strata-react 0.1.14 → 0.1.16
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 +4 -3
- package/dist/components/checkbox.d.ts +14 -1
- package/dist/components/data-table.d.ts +14 -0
- package/dist/components/data-view.d.ts +24 -2
- package/dist/components/disclosure.d.ts +47 -0
- package/dist/components/selectable-grid.d.ts +29 -0
- package/dist/components/selection.d.ts +39 -2
- package/dist/index.d.ts +7 -5
- package/dist/index.js +561 -139
- package/dist/index.js.map +1 -1
- package/dist/query/index.d.ts +12 -2
- package/dist/{query-CkOrBm3w.js → query-BlPgaCBG.js} +20 -3
- package/dist/{query-CkOrBm3w.js.map → query-BlPgaCBG.js.map} +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Fragment","_Fragment","defaultFormat","format","_Fragment","_Fragment"],"sources":["../src/lib/format.ts","../src/components/button.tsx","../src/components/checkbox.tsx","../src/components/async-button.tsx","../src/components/status.tsx","../src/components/metric.tsx","../src/components/meter.tsx","../src/components/composition.tsx","../src/components/link-card.tsx","../src/components/data-view.tsx","../src/lib/in-view.ts","../src/components/thumbnail.tsx","../src/components/data-table.tsx","../src/components/selection.tsx","../src/components/virtual-list.tsx","../src/components/infinite-list.tsx","../src/components/line-chart.tsx","../src/components/page-header.tsx","../src/components/undo.tsx","../src/components/done.tsx","../src/components/app-shell.tsx","../src/components/tabs.tsx","../src/components/hotkeys.tsx","../src/components/active-list.tsx","../src/query/infinite.ts"],"sourcesContent":["// Every number and date on screen goes through Intl, once, here. Units are joined with a\n// non-breaking space so \"212 °C\" never wraps between figure and unit. A product that is not\n// en-GB calls createFormat with its locale once and exports the result from its own lib.\n//\n// The number formatters are callable (`format.integer(n)`) because that is the form people reach\n// for (strata-react issue #12), and they keep Intl's methods (`format.integer.format(n)`,\n// `formatToParts`, `resolvedOptions`) so existing calls and Intl knowledge still work.\n//\n// Dates follow the same shape. Every date formatter is callable with a Date, an ISO string or\n// epoch milliseconds (`format.dateTime(row.at)`), because rows arrive from an API as ISO strings\n// and an app that has to wrap each one in `new Date(...)` soon builds its own Intl.DateTimeFormat\n// beside it instead (strata-react issue #31, from the Bright Horizons History screen). An invalid\n// date throws a RangeError naming the input rather than printing \"Invalid Date\" into a row.\n// `date` and `dateTime` use Intl's medium/short styles, so the locale decides the order\n// (\"8 Nov 2026, 06:05\" in en-GB, \"Nov 8, 2026, 6:05 AM\" in en-US) and nobody hand-writes a\n// pattern. `timeZone` is optional: left out, times are the viewer's; a product that shows a place's\n// times (a kiln in one room, a shop's opening hours) passes that place's zone once.\n//\n// Tests: the non-breaking space is a real character in the DOM. Testing Library's text matchers\n// (`getByText`, `toHaveTextContent`) collapse whitespace and match \"6 pieces\", but accessible-name\n// matching (`getByRole(\"heading\", { name: \"6 pieces\" })`) compares the name exactly and does not.\n// Build the expected string with the same formatter (`{ name: format.count(6, \"piece\") }`), or\n// use a regex with `\\s` (`/6\\spieces/`), which matches U+00A0.\n\nexport const NBSP = \" \";\n\n/** The decimal byte units `format.bytes` writes. */\nexport type ByteUnit = \"B\" | \"kB\" | \"MB\" | \"GB\" | \"TB\" | \"PB\";\nconst BYTE_UNITS: readonly ByteUnit[] = [\"B\", \"kB\", \"MB\", \"GB\", \"TB\", \"PB\"];\nconst BYTE_SIZE = Object.fromEntries(BYTE_UNITS.map((u, i) => [u, 1000 ** i])) as Record<ByteUnit, number>;\n\n/** An `Intl.NumberFormat` that can also be called directly: `f(n)` is `f.format(n)`. */\nexport type NumberFormatter = ((value: number | bigint) => string) & Pick<Intl.NumberFormat, \"format\" | \"formatToParts\" | \"resolvedOptions\">;\n\n/** What a date formatter accepts: a Date, an ISO 8601 string, or epoch milliseconds. */\nexport type DateInput = Date | string | number;\n\n/** An `Intl.DateTimeFormat` that can also be called directly, with a Date, an ISO string or epoch milliseconds. */\nexport type DateFormatter = ((value: DateInput) => string) & {\n format: (value: DateInput) => string;\n formatToParts: (value: DateInput) => Intl.DateTimeFormatPart[];\n formatRange: (start: DateInput, end: DateInput) => string;\n} & Pick<Intl.DateTimeFormat, \"resolvedOptions\">;\n\n/** Options shared by every date formatter one `createFormat` call makes. */\nexport interface FormatOptions {\n /** An IANA zone (\"Europe/London\", \"UTC\") to show times in. Left out, times are the viewer's own. */\n timeZone?: string;\n}\n\n/** A Date from a Date, an ISO string or epoch milliseconds; throws a RangeError naming the input when it is not a date. */\nexport function toDate(value: DateInput): Date {\n const date = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(date.getTime())) throw new RangeError(`Not a date: ${JSON.stringify(String(value))}`);\n return date;\n}\n\nfunction callableDate(df: Intl.DateTimeFormat): DateFormatter {\n const format = (value: DateInput) => df.format(toDate(value));\n return Object.assign(format, {\n format,\n formatToParts: (value: DateInput) => df.formatToParts(toDate(value)),\n formatRange: (start: DateInput, end: DateInput) => df.formatRange(toDate(start), toDate(end)),\n resolvedOptions: () => df.resolvedOptions(),\n });\n}\n\nfunction callable(nf: Intl.NumberFormat): NumberFormatter {\n const format = (value: number | bigint) => nf.format(value);\n return Object.assign(format, {\n format,\n formatToParts: (value: number | bigint) => nf.formatToParts(value),\n resolvedOptions: () => nf.resolvedOptions(),\n });\n}\n\n/** Intl formatters for one locale (and optionally one time zone): integers, decimals, percent, dates, times, units with a non-breaking space, byte sizes, and counted nouns. */\nexport function createFormat(locale: string, options: FormatOptions = {}) {\n const { timeZone } = options;\n const dates = (opts: Intl.DateTimeFormatOptions) => callableDate(new Intl.DateTimeFormat(locale, { ...opts, timeZone }));\n const integer = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }));\n const decimal = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }));\n const percent = callable(new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }));\n const clock = dates({ hour: \"2-digit\", minute: \"2-digit\" });\n const day = dates({ weekday: \"long\", day: \"numeric\", month: \"long\" });\n const shortDay = dates({ weekday: \"short\", hour: \"2-digit\", minute: \"2-digit\" });\n const date = dates({ dateStyle: \"medium\" });\n const dateTime = dates({ dateStyle: \"medium\", timeStyle: \"short\" });\n const withUnit = (value: number, unit: string, fmt: Pick<Intl.NumberFormat, \"format\"> = integer) =>\n `${fmt.format(value)}${NBSP}${unit}`;\n return {\n locale,\n /** The zone times are shown in, or `undefined` for the viewer's own. */\n timeZone,\n /** Whole numbers with grouping: `format.integer(1222)` is \"1,222\". */\n integer,\n /** One decimal place at most: `format.decimal(3.14)` is \"3.1\". */\n decimal,\n /** A ratio as a whole percent: `format.percent(0.42)` is \"42%\". */\n percent,\n /** A time of day: `format.clock(at)` is \"06:05\". */\n clock,\n /** A day without its year, for this week's things: `format.day(at)` is \"Sunday 8 November\". */\n day,\n /** A weekday and time, for chart axes and recent rows: `format.shortDay(at)` is \"Sun 06:05\". */\n shortDay,\n /** A date with its year, for a record or a deadline: `format.date(at)` is \"8 Nov 2026\". */\n date,\n /** A date and time, for a log or history row: `format.dateTime(at)` is \"8 Nov 2026, 06:05\". */\n dateTime,\n /** A figure and its unit joined by a non-breaking space (`NBSP`), so they never wrap apart. */\n withUnit,\n /** A temperature in °C, joined by a non-breaking space. */\n celsius: (value: number) => withUnit(value, \"°C\"),\n /**\n * A size in bytes in the largest decimal unit it reaches (kB, MB, GB, TB, as disks and\n * networks are sold): one decimal below 10 (\"5.2 GB\"), whole above (\"431 GB\"). Pass `unit`\n * to fix the unit, so figures compared side by side (\"431 of 466 GB\") share one.\n */\n bytes: (value: number, unit?: ByteUnit) => {\n const chosen = unit ?? [...BYTE_UNITS].reverse().find((u) => Math.abs(value) >= BYTE_SIZE[u]) ?? \"B\";\n const scaled = value / BYTE_SIZE[chosen];\n return withUnit(scaled, chosen, Math.abs(scaled) < 10 && chosen !== \"B\" ? decimal : integer);\n },\n /** The unit `bytes` would choose for a value, to share it across a set of figures. */\n byteUnit: (value: number): ByteUnit => [...BYTE_UNITS].reverse().find((u) => Math.abs(value) >= BYTE_SIZE[u]) ?? \"B\",\n /**\n * \"1 piece\", \"6 pieces\": the count and its noun, so copy never reads \"1 pieces\". They are\n * joined by a non-breaking space (`NBSP`), not a plain one: in a test, match with the same\n * call or a `\\s` regex, not a typed \"6 pieces\" string in a role's `name`.\n */\n count: (value: number, one: string, many = `${one}s`) =>\n `${integer.format(value)}${NBSP}${new Intl.PluralRules(locale).select(value) === \"one\" ? one : many}`,\n };\n}\n\nexport type Format = ReturnType<typeof createFormat>;\n\n/** The en-GB formatters. */\nexport const format = createFormat(\"en-GB\");\n","import * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\n\n// Variant names are shadcn's, so copied code and agents' prior knowledge still work. Two things\n// differ on purpose:\n// 1. The default variant is `outline`, not the filled accent. A bare <Button> is the restrained\n// one; the accent (`variant=\"default\"`) has to be asked for, once per view. Generated app screens\n// put the accent on every button; 12 of 23 real product screens had no filled primary at all.\n// 2. Heights come from --control-h, shared with Input and NativeSelect, so density changes move\n// every control together.\n// 3. `press`: the button gives 2% under a click or a finger, over 100ms. Buttons are used tens of\n// times a day, so that is all the motion they get (character.md, the frequency budget).\nexport const buttonVariants = cva(\n \"inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary-10\",\n outline: \"border border-input bg-background text-foreground hover:bg-muted\",\n secondary: \"bg-muted text-foreground hover:bg-neutral-4\",\n ghost: \"text-foreground hover:bg-muted\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-danger\",\n link: \"h-auto px-0 text-primary-11 underline underline-offset-4 hover:text-primary-12\",\n },\n size: {\n default: \"h-(--control-h) px-4\",\n sm: \"h-(--control-h-sm) px-3\",\n icon: \"size-(--control-h)\",\n },\n },\n defaultVariants: { variant: \"outline\", size: \"default\" },\n },\n);\n\nexport type ButtonProps = React.ComponentProps<\"button\"> &\n VariantProps<typeof buttonVariants> & { asChild?: boolean };\n\n/** A button with shadcn's variant names. The default variant is `outline`; ask for the filled accent (`variant=\"default\"`) once per view. `type` defaults to `button`. */\nexport function Button({ className, variant, size, asChild = false, type = \"button\", ...props }: ButtonProps) {\n const Comp = asChild ? Slot : \"button\";\n return <Comp type={asChild ? undefined : type} className={cn(buttonVariants({ variant, size }), className)} {...props} />;\n}\n\n// An icon-only button cannot be written without a name: `label` is required by the type, becomes\n// the accessible name, and doubles as the native tooltip. This makes the most common generated\n// accessibility defect (an unlabelled icon button) a compile error instead of an audit finding.\nexport type IconButtonProps = Omit<ButtonProps, \"size\" | \"children\" | \"aria-label\"> & {\n icon: IconComponent;\n label: string;\n};\n\n/** An icon-only button. `label` is required and becomes the accessible name and tooltip. */\nexport function IconButton({ icon: Icon, label, variant = \"ghost\", ...props }: IconButtonProps) {\n return (\n <Button size=\"icon\" variant={variant} aria-label={label} title={label} {...props}>\n <Icon aria-hidden />\n </Button>\n );\n}\n\n// A row action says what it does in the row (\"Withdraw\") and whom it does it to in its name\n// (\"Withdraw Tom Ellery\"): a table of eight \"Withdraw\" buttons is eight identical names in a\n// screen reader's list of controls. The name is an aria-label that starts with the visible verb,\n// so it meets WCAG 2.5.3 (label in name) and voice control still finds it by \"Withdraw\". Visually\n// hidden suffix text is not used: a hidden span joined to the verb did not form a name with its\n// space in dom-testing-library (strata-react issue #11). Ghost and small, one per row, shown only\n// on the rows where it applies; an icon-only row action is an `IconButton` whose `label` names the\n// row the same way. It keeps the row's pitch: rows with and without the action are the same height.\nexport type RowActionProps = Omit<ButtonProps, \"children\" | \"aria-label\" | \"asChild\"> & {\n /** The visible verb, sentence case: \"Withdraw\", \"Remove\". */\n label: string;\n /** What the row is, as a person would say it: \"Tom Ellery\", \"Moonbeam\". Completes the accessible name. */\n subject: string;\n icon?: IconComponent;\n};\n\n/** A small ghost action for one table row: shows `label`, and is named \"`label` `subject`\" so every row's action has its own name. */\nexport function RowAction({ label, subject, icon: Icon, variant = \"ghost\", size = \"sm\", className, ...props }: RowActionProps) {\n // -my-1.5 lets the 32px button sit in the 20px line of a table row, inside the row's padding, so\n // rows with an action keep the same pitch as rows without one.\n return (\n <Button variant={variant} size={size} aria-label={`${label} ${subject}`} className={cn(\"-my-1.5\", className)} {...props}>\n {Icon && <Icon aria-hidden />}\n {label}\n </Button>\n );\n}\n","import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// A checkbox cannot be written without a name: `label` is required, as `IconButton`'s is. Shown,\n// it sits beside the box inside one <label>, so the label and the control are a single target\n// with no dead zone between them (Vercel's interface guidelines; ux-design audit.md). Hidden\n// (`hideLabel`, for a table cell where the row already says what it is), it becomes the\n// accessible name through aria-label, never through visually hidden text: a hidden span inside a\n// label joined to a neighbour did not form a name with its space in dom-testing-library (strata-\n// react issue #11), and an aria-label leaves no room for that.\n//\n// It is the native control (an 18px box, `accent-primary`), so keyboard, forms and the platform's\n// own focus and checked rendering come free. `checked=\"mixed\"` is the indeterminate state a\n// select-all needs; React has no prop for it, so it is set on the element.\n\n/** A checkbox with its label as one target. `label` is required; `checked=\"mixed\"` is indeterminate. */\nexport type CheckboxProps = Omit<React.ComponentProps<\"input\">, \"type\" | \"checked\" | \"onChange\" | \"aria-label\" | \"children\"> & {\n /** Names the checkbox. Shown beside it unless `hideLabel`. */\n label: string;\n /** Keep the label as the accessible name only, for a cell or toolbar where the context shows what it is. */\n hideLabel?: boolean;\n /** A muted second line under a shown label. */\n detail?: string;\n checked: boolean | \"mixed\";\n onCheckedChange: (checked: boolean) => void;\n};\n\n/** A native checkbox and its label as one target. `label` is required; `hideLabel` keeps it as the accessible name only. */\nexport function Checkbox({ label, hideLabel = false, detail, checked, onCheckedChange, className, disabled, ...props }: CheckboxProps) {\n const ref = React.useRef<HTMLInputElement>(null);\n React.useEffect(() => {\n if (ref.current) ref.current.indeterminate = checked === \"mixed\";\n }, [checked]);\n return (\n <label\n className={cn(\n \"inline-flex min-h-6 min-w-6 items-start gap-3\",\n hideLabel && \"items-center justify-center\",\n disabled ? \"cursor-not-allowed opacity-50\" : \"cursor-pointer\",\n className,\n )}\n >\n <input\n ref={ref}\n type=\"checkbox\"\n checked={checked === true}\n aria-checked={checked === \"mixed\" ? \"mixed\" : undefined}\n aria-label={hideLabel ? label : undefined}\n disabled={disabled}\n onChange={(e) => onCheckedChange(e.target.checked)}\n className={cn(\"size-4.5 shrink-0 accent-primary\", !hideLabel && \"mt-0.5\", disabled ? \"cursor-not-allowed\" : \"cursor-pointer\")}\n {...props}\n />\n {!hideLabel && (\n <span className=\"grid\">\n <span className=\"type-body\">{label}</span>\n {detail && <span className=\"type-body-sm text-muted-foreground\">{detail}</span>}\n </span>\n )}\n </label>\n );\n}\n","import * as React from \"react\";\nimport { Check, CircleAlert, LoaderCircle } from \"lucide-react\";\nimport { Button, type ButtonProps } from \"./button\";\nimport { describeActionError } from \"../lib/errors\";\n\n// One object through its states: \"Book firing\" becomes \"Booking…\" becomes \"Booked\", in the same\n// button, rather than the button being swapped for a spinner. The labels are stacked in one grid\n// cell so the button is always as wide as its longest label and nothing around it shifts. The\n// button stays enabled until the request starts (so a person can always try), and the outcome is\n// announced politely for screen readers. When the action fails, the announcement carries what\n// went wrong in the product's words before the retry label (\"Kiln 2 is already booked. Try\n// again\"), because \"Try again\" alone does not say whether trying again can help.\n\nexport type Phase = \"idle\" | \"pending\" | \"done\" | \"error\";\n\nexport type AsyncLabels = {\n idle: string;\n /** Ends in an ellipsis: \"Saving…\", \"Booking…\". */\n pending: string;\n /** The same verb, finished: \"Saved\", \"Booked\". */\n done: string;\n error?: string;\n};\n\n/** One button through idle, pending, done and error, with the label changing in place and its width fixed by the longest label. The outcome is announced politely, with the error's own words when `error` is given. */\nexport function AsyncButton({\n phase,\n labels,\n error,\n disabled,\n ...props\n}: Omit<ButtonProps, \"children\"> & {\n phase: Phase;\n labels: AsyncLabels;\n /** What went wrong, in the product's words (`useAsyncAction`'s `error`). Announced with the error label when `phase` is `error`. */\n error?: string;\n}) {\n const errorLabel = labels.error ?? \"Try again\";\n const current = { idle: labels.idle, pending: labels.pending, done: labels.done, error: errorLabel }[phase];\n const Icon = { idle: null, pending: LoaderCircle, done: Check, error: CircleAlert }[phase];\n const announcement = phase === \"done\" ? labels.done : phase === \"error\" ? (error ? `${error} ${errorLabel}` : errorLabel) : \"\";\n\n return (\n <>\n <Button {...props} disabled={disabled || phase === \"pending\"} aria-disabled={phase === \"pending\" || undefined}>\n {Icon && <Icon aria-hidden className={phase === \"pending\" ? \"motion-safe:animate-spin\" : undefined} />}\n <span className=\"grid\">\n {[labels.idle, labels.pending, labels.done, errorLabel].map((l) => (\n <span key={l} aria-hidden={l !== current} className={l === current ? \"[grid-area:1/1]\" : \"invisible [grid-area:1/1]\"}>\n {l}\n </span>\n ))}\n </span>\n </Button>\n <span role=\"status\" className=\"sr-only\">\n {announcement}\n </span>\n </>\n );\n}\n\n/** Options for `useAsyncAction`. */\nexport type AsyncActionOptions = {\n /** How long `done` shows before returning to `idle`. Default 2000ms. */\n settleMs?: number;\n /** Called with whatever the action threw, once the `error` render has committed: for logging, or to move focus to the retry button or an error message. */\n onError?: (error: unknown) => void;\n /** Turns what was thrown into `error`'s sentence, in the product's words. Default `describeActionError`: HTTP status sentences for `fetchJson`'s `HttpError`, else the Error's message. */\n describeError?: (error: unknown) => string | undefined;\n};\n\n/** What `useAsyncAction` returns: the phase for `AsyncButton`, a stable `run`, and what went wrong while `phase` is `error`. */\nexport type AsyncAction<A extends unknown[]> = {\n phase: Phase;\n run: (...args: A) => Promise<void>;\n /** What went wrong, from `describeError`, while `phase` is `error`; otherwise undefined. Pass it to `AsyncButton`'s `error`. */\n error: string | undefined;\n};\n\n// The action and its options are read through a ref so `run` keeps one identity for the\n// component's life: a caller can pass an inline arrow without re-rendering every child that takes\n// `run`, and without the try/catch and error state each caller used to write to reach the phase.\n\n/** Runs an async action and reports its phase and error. `done` returns to `idle` after `settleMs`; `run` never changes identity. */\nexport function useAsyncAction<A extends unknown[]>(\n action: (...args: A) => Promise<unknown>,\n { settleMs = 2000, onError, describeError = describeActionError }: AsyncActionOptions = {},\n): AsyncAction<A> {\n const [state, setState] = React.useState<{ phase: Phase; error: string | undefined }>({ phase: \"idle\", error: undefined });\n const timer = React.useRef<number | undefined>(undefined);\n const unreported = React.useRef<{ thrown: unknown } | undefined>(undefined);\n const latest = React.useRef({ action, onError, settleMs, describeError });\n React.useLayoutEffect(() => {\n latest.current = { action, onError, settleMs, describeError };\n });\n React.useEffect(() => () => window.clearTimeout(timer.current), []);\n const run = React.useCallback(async (...args: A) => {\n window.clearTimeout(timer.current);\n setState({ phase: \"pending\", error: undefined });\n try {\n await latest.current.action(...args);\n setState({ phase: \"done\", error: undefined });\n timer.current = window.setTimeout(() => setState({ phase: \"idle\", error: undefined }), latest.current.settleMs);\n } catch (thrown) {\n unreported.current = { thrown };\n setState({ phase: \"error\", error: latest.current.describeError(thrown) });\n }\n }, []);\n // onError runs after the error render commits, not inside the catch: there the button is still\n // disabled from `pending` and an error message rendered on `error` does not exist yet, so a\n // callback that moves focus to either would find nothing to focus.\n React.useEffect(() => {\n if (state.phase !== \"error\" || !unreported.current) return;\n const { thrown } = unreported.current;\n unreported.current = undefined;\n latest.current.onError?.(thrown);\n }, [state]);\n return { phase: state.phase, run, error: state.error };\n}\n","import type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\n\n// Status is a word first. `children` is required and must be a string, so a status can never be a\n// bare coloured dot. The tint and ink come from the fixed status roles, which are kept apart from\n// the brand accent: pale tint, dark ink of the same hue, never a saturated chip with white text.\n// No pulsing variant exists; nothing on a status mark moves unless the data behind it is live.\n\nexport type Tone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst tones: Record<Tone, string> = {\n neutral: \"bg-muted text-muted-foreground\",\n info: \"bg-info-subtle text-info\",\n success: \"bg-success-subtle text-success\",\n warning: \"bg-warning-subtle text-warning\",\n danger: \"bg-danger-subtle text-danger\",\n};\n\n/** A status as a word on a pale tint of its tone, with an optional icon. Never colour alone. */\nexport function Status({\n tone,\n icon: Icon,\n children,\n className,\n}: {\n tone: Tone;\n icon?: IconComponent;\n children: string;\n className?: string;\n}) {\n return (\n <span\n className={cn(\n \"inline-flex items-center gap-1.5 whitespace-nowrap rounded-pill py-0.5 pr-2.5 pl-2 type-caption font-medium\",\n tones[tone],\n className,\n )}\n >\n {Icon && <Icon aria-hidden className=\"size-3.5 shrink-0\" />}\n {children}\n </span>\n );\n}\n","import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// Headline figures as one container split by hairlines, label over value: what real product screens\n// do, instead of four cards each with an icon in a tinted circle. There is deliberately no `icon`,\n// `sparkline` or `trend` prop. A change is written in words with its window (\"4 more than last\n// Thursday\"), because a green \"+12.5%\" pill says neither what changed nor since when, and the trend\n// gets its own chart.\n\n/** Headline figures as one description list split by hairlines. Holds `Metric`s. */\nexport function MetricStrip({ label, children, className }: { label: string; children: React.ReactNode; className?: string }) {\n return (\n <dl\n aria-label={label}\n className={cn(\n \"grid grid-cols-1 border-y border-border sm:auto-cols-fr sm:grid-flow-col sm:divide-x sm:divide-border\",\n className,\n )}\n >\n {children}\n </dl>\n );\n}\n\nexport type MetricProps = {\n label: string;\n /** Already formatted. Ink colour, 28px, tabular figures: never the brand colour, never 48px. */\n value: string;\n unit?: string;\n /** One sentence: the change in words with its window, or what the figure means right now. */\n note?: React.ReactNode;\n};\n\n/** One figure: label over value, an optional muted unit and a note that states any change in words with its window. */\nexport function Metric({ label, value, unit, note }: MetricProps) {\n return (\n <div className=\"grid content-start gap-0.5 border-border py-3 not-first:border-t sm:px-5 sm:not-first:border-t-0 sm:first:pl-0\">\n <dt className=\"type-label text-muted-foreground\">{label}</dt>\n <dd className=\"type-figure text-foreground\">\n {value}\n {unit && <span className=\"type-body text-muted-foreground\">{\" \" + unit}</span>}\n </dd>\n {note && <dd className=\"type-body-sm text-muted-foreground\">{note}</dd>}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { format } from \"../lib/format\";\nimport { cn } from \"../lib/utils\";\nimport { Status } from \"./status\";\n\n// A usage bar: how full one thing is (a disk, a quota, a kiln's shelves), for status dashboards\n// that otherwise hand-roll a div with a width (strata-react issue #25, from jburnhams/homepage).\n// The rules it encodes, from ux-research ui-library/components.md §3.8 and patterns.md §5:\n// - It is a `meter`, not a `progressbar`: a progress bar is a task moving to done, a meter is a\n// level that can go up or down. Its accessible name is what is measured (\"Disk /\") and its\n// value text says the reading in words (\"72% used\"), so a screen reader hears \"Disk /, meter,\n// 72% used\" rather than a bare 72.\n// - The figure is always printed beside the bar. A bar alone is read to ±10% at best.\n// - Thresholds are what the person compares against, so they are drawn on the track as notches,\n// like LineChart's `band`. Each threshold must name its state (\"Filling up\", \"Nearly full\"):\n// when the reading crosses one, the fill takes the status ink and the word is shown as a\n// `Status`, so colour is never the only cue. Thresholds are shares of `max` (0.8 is 80%),\n// because a dashboard of disks of different sizes shares one set of them.\n// - `worseWhen=\"lower\"` turns the thresholds round for levels where empty is the problem (a\n// battery, credit left): a threshold then applies at or below its share.\n// - Below every threshold the fill is one chart hue (`--chart-1` unless `colour` says otherwise),\n// the same default as LineChart, never the brand accent and never a status colour, since\n// \"fine\" needs no colour of its own.\n// - `hideLabel` is for a meter in a table row, where the row already says what it measures; the\n// label stays as the meter's accessible name.\n// - No animation on the fill: a dashboard re-renders readings, and a bar that slides on each one\n// draws the eye to nothing.\n\n/** A level on a `Meter` at which the reading changes state, with the word for that state. */\nexport type MeterThreshold = {\n /** A share of `max`, from 0 to 1: 0.8 is 80%. */\n at: number;\n tone: \"warning\" | \"danger\";\n /** What the state is called, in the product's words: \"Filling up\", \"Nearly full\". */\n label: string;\n};\n\nexport type MeterProps = {\n /** What is measured, such as \"Disk /\". The meter's accessible name. */\n label: string;\n value: number;\n /** The full scale, in the same units as `value`. Defaults to 1, so a share can be passed as is. */\n max?: number;\n /** The reading in words, shown beside the bar and used as `aria-valuetext`. Defaults to \"72% used\". */\n valueText?: string;\n /** A second line of fact, such as \"36 of 50 GB\". */\n detail?: React.ReactNode;\n thresholds?: MeterThreshold[];\n /** \"lower\" when an emptier reading is the worse one (a battery, credit left). */\n worseWhen?: \"higher\" | \"lower\";\n /** Keeps the label as the accessible name only, for a meter in a table row that names it. */\n hideLabel?: boolean;\n /** CSS colour for the fill below every threshold. Defaults to the first chart token. */\n colour?: string;\n className?: string;\n};\n\n/** The threshold a share has crossed, if any: the most severe one reached in the worse direction. */\nexport function crossedThreshold(\n share: number,\n thresholds: readonly MeterThreshold[] = [],\n worseWhen: \"higher\" | \"lower\" = \"higher\",\n): MeterThreshold | undefined {\n const reached = thresholds.filter((t) => (worseWhen === \"higher\" ? share >= t.at : share <= t.at));\n // The one furthest in the worse direction wins, so danger beats warning when both are reached.\n return reached.sort((a, b) => (worseWhen === \"higher\" ? b.at - a.at : a.at - b.at))[0];\n}\n\nconst fills = { warning: \"var(--warning)\", danger: \"var(--danger)\" } as const;\n\n/** How full one thing is: a labelled `meter` with its reading in words, threshold notches, and a status word once a threshold is crossed. */\nexport function Meter({\n label,\n value,\n max = 1,\n valueText,\n detail,\n thresholds,\n worseWhen = \"higher\",\n hideLabel = false,\n colour = \"var(--chart-1)\",\n className,\n}: MeterProps) {\n const labelId = React.useId();\n const statusId = React.useId();\n const detailId = React.useId();\n const share = max > 0 ? Math.min(1, Math.max(0, value / max)) : 0;\n const crossed = crossedThreshold(share, thresholds, worseWhen);\n const text = valueText ?? `${format.percent(share)} used`;\n const hasNote = Boolean(crossed || detail);\n // Two ids rather than one wrapper, so the description reads \"Nearly full, 431 GB of 466 GB\"\n // with a break between the parts instead of running them together.\n const describedBy = [crossed && statusId, detail && detailId].filter(Boolean).join(\" \") || undefined;\n\n const bar = (\n <div\n role=\"meter\"\n aria-labelledby={hideLabel ? undefined : labelId}\n aria-label={hideLabel ? label : undefined}\n aria-valuemin={0}\n aria-valuemax={max}\n aria-valuenow={Math.min(max, Math.max(0, value))}\n aria-valuetext={text}\n aria-describedby={describedBy}\n className=\"relative h-2 min-w-16 flex-1 overflow-hidden rounded-pill bg-muted\"\n >\n <div\n className=\"absolute inset-y-0 left-0\"\n style={{ width: `${share * 100}%`, background: crossed ? fills[crossed.tone] : colour }}\n />\n {/* Notches in the ground colour: the levels the reading is judged against. */}\n {thresholds?.map((t) => (\n <div\n key={t.at}\n className=\"absolute inset-y-0 w-0.5 -translate-x-1/2 bg-background\"\n style={{ left: `${Math.min(1, Math.max(0, t.at)) * 100}%` }}\n />\n ))}\n </div>\n );\n\n // The visible figure is the meter's value text, so it is hidden from the accessibility tree\n // rather than read twice.\n const figure = (\n <span aria-hidden className=\"shrink-0 type-body-sm tabular-nums text-foreground\">\n {text}\n </span>\n );\n\n const note = hasNote && (\n <div className=\"flex flex-wrap items-center gap-x-3 gap-y-1\">\n {crossed && (\n <span id={statusId} className=\"contents\">\n <Status tone={crossed.tone}>{crossed.label}</Status>\n </span>\n )}\n {detail && (\n <span id={detailId} className=\"type-body-sm text-muted-foreground tabular-nums\">\n {detail}\n </span>\n )}\n </div>\n );\n\n if (hideLabel) {\n return (\n <div className={cn(\"grid min-w-0 gap-1.5\", className)}>\n <div className=\"flex items-center gap-3\">\n {bar}\n {figure}\n </div>\n {note}\n </div>\n );\n }\n\n return (\n <div className={cn(\"grid min-w-0 gap-1.5\", className)}>\n <div className=\"flex items-baseline justify-between gap-3\">\n <span id={labelId} className=\"min-w-0 truncate type-label text-foreground\">\n {label}\n </span>\n {figure}\n </div>\n <div className=\"flex\">{bar}</div>\n {note}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { format } from \"../lib/format\";\nimport { cn } from \"../lib/utils\";\n\n// What a whole is made of (memory: used, cached, buffers, free; a kiln load: bisque, glaze, empty\n// shelves), as one stacked bar over a table. strata-react issue #25 asked for it after\n// jburnhams/homepage hand-rolled one. The rules, from ux-research ui-library/components.md §3.8\n// and patterns.md §5:\n// - Colour is never the only cue. The bar shows proportion at a glance; the table under it says\n// every part's name, amount and share in words, with a swatch that ties the row to its\n// segment. The bar is hidden from screen readers because the table already carries all of it.\n// - The parts stay in the order given, in the bar and the table, so the order is the caller's\n// meaning (used before cached before free), not sorted by size.\n// - Categorical colours come from `--chart-1…5` in order, which palette.mjs checks are told apart\n// by colour-blind readers. A sixth part has no token to take, so it must bring its own colour;\n// more than five parts usually means the small ones belong in an \"Other\" part.\n// - Segments are split by a 2px gap in the ground colour, so two neighbours of similar lightness\n// still read as two.\n// - When the parts do not fill the whole (`total` is larger than their sum), the remainder is the\n// empty track, and it must be named (`restLabel`, such as \"Free\"), so the table can say what the\n// gap is. Neither the remainder nor a part is ever left unlabelled.\n// - Values are formatted by the caller (`formatValue`), as LineChart's `formatY` is, so units stay\n// the product's; shares go through `format.percent` unless `formatShare` says otherwise.\n\n/** One part of a `CompositionBar`'s whole. */\nexport type CompositionPart = {\n /** Stable key for the part. */\n key: string;\n label: string;\n value: number;\n /** CSS colour for the segment and swatch. Defaults to the chart token for its position. */\n colour?: string;\n};\n\nexport type CompositionBarProps = {\n /** What the whole is, such as \"Memory\". Shown above the bar and names the table. */\n label: string;\n parts: CompositionPart[];\n formatValue: (value: number) => string;\n /** Formats a part's share of the whole (0 to 1). Defaults to `format.percent`. */\n formatShare?: (share: number) => string;\n /** Header of the parts column, for screen readers and over the table. Defaults to \"Part\". */\n partHeader?: string;\n /** Header of the amounts column. Defaults to \"Amount\". */\n valueHeader?: string;\n /** Header of the shares column. Defaults to \"Share\". */\n shareHeader?: string;\n className?: string;\n} & (\n | {\n /** The size of the whole, when the parts do not fill it. The remainder is the empty track. */\n total: number;\n /** What the remainder is called (\"Free\", \"Empty shelves\"). Required with `total`. */\n restLabel: string;\n }\n | { total?: undefined; restLabel?: undefined }\n);\n\nconst MAX_TOKENS = 5;\n\n/** A part's colour: its own, or the chart token for its position. Throws past the fifth token. */\nfunction colourFor(part: CompositionPart, index: number) {\n if (part.colour) return part.colour;\n if (index >= MAX_TOKENS) {\n throw new Error(\n `CompositionBar: part \"${part.label}\" is number ${index + 1}, and there are only ${MAX_TOKENS} chart colours. ` +\n `Combine the smallest parts into one \"Other\" part, or give this part a colour.`,\n );\n }\n return `var(--chart-${index + 1})`;\n}\n\n/** What a whole is made of: a stacked bar for proportion and a table that names every part, its amount and its share, so colour is never the only cue. */\nexport function CompositionBar({\n label,\n parts,\n formatValue,\n formatShare = format.percent,\n partHeader = \"Part\",\n valueHeader = \"Amount\",\n shareHeader = \"Share\",\n className,\n ...whole\n}: CompositionBarProps) {\n const captionId = React.useId();\n const sum = parts.reduce((n, p) => n + Math.max(0, p.value), 0);\n const total = Math.max(whole.total ?? sum, sum);\n const rest = whole.total !== undefined ? total - sum : 0;\n const shareOf = (value: number) => (total > 0 ? Math.max(0, value) / total : 0);\n const rows = parts.map((p, i) => ({ ...p, colour: colourFor(p, i), share: shareOf(p.value) }));\n\n return (\n <figure className={cn(\"grid min-w-0 gap-3\", className)}>\n <figcaption id={captionId} className=\"type-label text-foreground\">\n {label}\n </figcaption>\n <div aria-hidden className=\"flex h-3 gap-0.5 overflow-hidden rounded-pill bg-muted\">\n {rows\n .filter((r) => r.value > 0)\n .map((r) => (\n // Grow by share from a zero basis, so the gaps come out of every segment fairly and the\n // parts fill the track exactly. Shares, not raw values: flex-grow factors that sum to\n // less than 1 fill only that fraction of the track (found in review).\n <div key={r.key} className=\"h-full min-w-0\" style={{ flex: `${r.share} 1 0`, background: r.colour }} />\n ))}\n {rest > 0 && <div className=\"h-full min-w-0\" style={{ flex: `${shareOf(rest)} 1 0` }} />}\n </div>\n <table aria-labelledby={captionId} className=\"w-full border-collapse type-body-sm\">\n <thead className=\"sr-only\">\n <tr>\n <th scope=\"col\">{partHeader}</th>\n <th scope=\"col\">{valueHeader}</th>\n <th scope=\"col\">{shareHeader}</th>\n </tr>\n </thead>\n <tbody>\n {rows.map((r) => (\n <tr key={r.key} className=\"border-t border-border first:border-t-0\">\n <th scope=\"row\" className=\"py-1.5 pr-4 text-left font-normal\">\n <span className=\"inline-flex items-center gap-2\">\n <span aria-hidden className=\"size-3 shrink-0 rounded-control\" style={{ background: r.colour }} />\n {r.label}\n </span>\n </th>\n <td className=\"py-1.5 pr-4 text-right tabular-nums\">{formatValue(r.value)}</td>\n <td className=\"w-px py-1.5 text-right whitespace-nowrap text-muted-foreground tabular-nums\">\n {formatShare(r.share)}\n </td>\n </tr>\n ))}\n {whole.total !== undefined && (\n <tr className=\"border-t border-border\">\n <th scope=\"row\" className=\"py-1.5 pr-4 text-left font-normal\">\n <span className=\"inline-flex items-center gap-2\">\n {/* The empty track's colour with a hairline, so the swatch reads as \"nothing here\". */}\n <span aria-hidden className=\"size-3 shrink-0 rounded-control border border-border bg-muted\" />\n {whole.restLabel}\n </span>\n </th>\n <td className=\"py-1.5 pr-4 text-right tabular-nums\">{formatValue(rest)}</td>\n <td className=\"w-px py-1.5 text-right whitespace-nowrap text-muted-foreground tabular-nums\">\n {formatShare(shareOf(rest))}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </figure>\n );\n}\n","import * as React from \"react\";\nimport { Link, type To } from \"react-router\";\nimport { ArrowUpRight } from \"lucide-react\";\nimport { cn } from \"../lib/utils\";\n\n// A card that is a way to somewhere: an app on a homepage, a project in a list of projects.\n// strata-react issue #25 asked for it after jburnhams/homepage built `AppCard` by hand. A card is\n// right here because each destination *is* a separate object a person picks (ux-research\n// ui-library/patterns.md §3); a section of a screen is not, and gets space and hairlines instead.\n// - The whole card is the target, but it is one link with a short name. The link sits on the\n// title and its `::after` covers the card, so a pointer can press anywhere while a screen reader\n// hears \"Kiln log, link\" and then the description and status marks as its description, instead\n// of a link named with every word on the card. There is one tab stop per card.\n// - Because the whole card is one link, nothing else on it can be interactive (a button or a\n// second link inside a link is invalid and unreachable). `marks` is for `Status` words only.\n// - Status marks are words (`Status`), never a coloured dot in a corner.\n// - `to` is a route in this app (React Router's `Link`); `href` leaves it (a plain anchor) and is\n// marked with an arrow, so a person knows before pressing that they will leave.\n// - Hover and focus change the border and draw the ring around the card, not the title. There is\n// no lift, scale or shadow: elevation is for what floats above the page, and a card on a\n// homepage is pressed many times a day (ux-research ux-character.md, character by frequency).\n\n/** A destination card's props: `to` for a route in this app, or `href` for anywhere else, never both. */\nexport type LinkCardProps = (\n | {\n /** A route in this app, followed with React Router. */\n to: To;\n href?: undefined;\n }\n | {\n /** Somewhere outside this app; the card shows an arrow. */\n href: string;\n to?: undefined;\n }\n) & {\n /** The destination's name, and the link's accessible name. */\n title: string;\n /** One sentence on what is there. Read as the link's description. */\n description?: string;\n /** `Status` words about the destination (\"Running\", \"Updated today\"). Nothing interactive. */\n marks?: React.ReactNode;\n /** The title's element. h3 under a section heading; h2 when the cards are the page's sections. */\n as?: \"h2\" | \"h3\" | \"h4\";\n className?: string;\n};\n\n/** A destination as a card that is one link: its title is the link's name, the description and status marks are its description, and the whole card is the target. */\nexport function LinkCard({ title, description, marks, as: Heading = \"h3\", className, ...destination }: LinkCardProps) {\n const descriptionId = React.useId();\n const marksId = React.useId();\n const describedBy = [description && descriptionId, marks && marksId].filter(Boolean).join(\" \") || undefined;\n const linkClass =\n \"rounded-control outline-none after:absolute after:inset-0 after:rounded-surface\";\n\n return (\n <div\n className={cn(\n \"relative grid content-start gap-1.5 rounded-surface border border-border bg-background p-4 transition-state\",\n \"hover:border-muted-foreground has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ring\",\n className,\n )}\n >\n <Heading className=\"flex items-start justify-between gap-3 type-heading text-foreground\">\n {destination.href !== undefined ? (\n <>\n <a href={destination.href} aria-describedby={describedBy} className={linkClass}>\n {title}\n </a>\n <ArrowUpRight aria-hidden className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" />\n </>\n ) : (\n <Link to={destination.to} aria-describedby={describedBy} className={linkClass}>\n {title}\n </Link>\n )}\n </Heading>\n {description && (\n <p id={descriptionId} className=\"type-body-sm text-pretty text-muted-foreground\">\n {description}\n </p>\n )}\n {marks && (\n <div id={marksId} className=\"mt-1.5 flex flex-wrap gap-2\">\n {marks}\n </div>\n )}\n </div>\n );\n}\n\n/** A labelled list of `LinkCard`s in a grid: one column on a phone, up to three on a wide screen. */\nexport function LinkCardList({ label, children, className }: { label: string; children: React.ReactNode; className?: string }) {\n return (\n <ul aria-label={label} className={cn(\"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3\", className)}>\n {React.Children.toArray(children).map((child, i) => (\n <li key={React.isValidElement(child) && child.key != null ? child.key : i} className=\"grid\">\n {child}\n </li>\n ))}\n </ul>\n );\n}\n","import * as React from \"react\";\nimport { CircleAlert, RotateCcw } from \"lucide-react\";\nimport { Button } from \"./button\";\nimport { cn } from \"../lib/utils\";\n\n// Every view of remote data goes through DataView, and DataView will not type-check without a\n// skeleton and an empty state. Generated UI renders the happy path; this makes the other three\n// states part of the component's signature rather than a review comment.\n\nexport type Load<T> =\n | { status: \"loading\" }\n | { status: \"error\"; message: string; retry: () => void }\n | { status: \"ready\"; data: T };\n\n/** Every view of remote data: renders `skeleton` while loading, an alert with Try again on error, `empty` when `isEmpty`, else `children(data)`. The skeleton and empty state are required. */\nexport function DataView<T>({\n state,\n isEmpty,\n skeleton,\n empty,\n children,\n className,\n}: {\n state: Load<T>;\n /** When the loaded data counts as empty. For arrays, `(rows) => rows.length === 0`. */\n isEmpty: (data: T) => boolean;\n /** Mirrors the final layout, so nothing jumps when data arrives. Not a centred spinner. */\n skeleton: React.ReactNode;\n /** What goes here and how to add it. An `EmptyState`, not an illustration. */\n empty: React.ReactNode;\n children: (data: T) => React.ReactNode;\n className?: string;\n}) {\n return (\n <div className={cn(\"min-w-0\", className)} aria-busy={state.status === \"loading\" || undefined}>\n {state.status === \"loading\" && skeleton}\n {state.status === \"error\" && (\n <div role=\"alert\" className=\"flex flex-wrap items-start gap-3 rounded-surface bg-danger-subtle p-4 text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-5 shrink-0\" />\n <p className=\"min-w-0 flex-1 type-body\">{state.message}</p>\n <Button size=\"sm\" onClick={state.retry}>\n <RotateCcw aria-hidden />\n Try again\n </Button>\n </div>\n )}\n {state.status === \"ready\" && (isEmpty(state.data) ? empty : children(state.data))}\n </div>\n );\n}\n\n// An empty state teaches the next action. No illustration slot exists, on purpose.\n/** An empty state that teaches the next action: a title, a sentence and an action. No illustration slot, on purpose. */\nexport function EmptyState({ title, children, action }: { title: string; children?: React.ReactNode; action?: React.ReactNode }) {\n return (\n <div className=\"grid justify-items-start gap-2 border-y border-border py-6\">\n <p className=\"type-heading\">{title}</p>\n {children && <p className=\"max-w-prose type-body text-muted-foreground\">{children}</p>}\n {action && <div className=\"mt-2\">{action}</div>}\n </div>\n );\n}\n\n/** A placeholder block for a loading layout. Size it with layout classes so it mirrors the final content. */\nexport function Skeleton({ className }: { className?: string }) {\n return <div aria-hidden className={cn(\"rounded-control bg-muted motion-safe:animate-pulse\", className)} />;\n}\n","import * as React from \"react\";\n\n// One IntersectionObserver hook for everything that waits until it is near the screen: the\n// sentinel at the end of an InfiniteList and an image in a Thumbnail. Both watch from the nearest\n// `[data-strata-scroll]` region (a VirtualList's) or else the viewport, with a root\n// margin so the work starts before the element is reached. They differ in two ways, which are\n// options rather than two hooks:\n//\n// - `once`: an image, once asked for, stays asked for; scrolling it away again must not unload it.\n// A sentinel reports in and out of view every time.\n// - `unsupported`: where there is no IntersectionObserver (an old browser, a test without the\n// fake), an image loads at once, because a photo that never loads is worse than one loaded\n// early. A sentinel reports out of view, because InfiniteList's Show more button is the path\n// that always works.\n\n/** Options for {@link useInView}. */\nexport type InViewOptions = {\n /** Watch only while this is true. Default true. */\n active?: boolean;\n /** How far outside the scroll region still counts as in view (IntersectionObserver `rootMargin`). */\n rootMargin?: string;\n /** Stay in view after the first time, and stop watching. */\n once?: boolean;\n /** What to report where `IntersectionObserver` does not exist. Default false. */\n unsupported?: boolean;\n};\n\n/**\n * Whether an element is within `rootMargin` of its scroll region (the nearest\n * `[data-strata-scroll]` ancestor, else the viewport). Returns a callback ref, so it follows the\n * element as it mounts and unmounts.\n */\nexport function useInView({ active = true, rootMargin = \"0px\", once = false, unsupported = false }: InViewOptions = {}) {\n const [inView, setInView] = React.useState(false);\n const [el, setEl] = React.useState<Element | null>(null);\n const seen = once && inView;\n React.useEffect(() => {\n if (seen) return;\n if (!active || !el) {\n setInView(false);\n return;\n }\n if (typeof IntersectionObserver === \"undefined\") {\n setInView(unsupported);\n return;\n }\n const root = el.parentElement?.closest<HTMLElement>(\"[data-strata-scroll]\") ?? null;\n const observer = new IntersectionObserver((entries) => setInView(entries[entries.length - 1].isIntersecting), { root, rootMargin });\n observer.observe(el);\n return () => observer.disconnect();\n }, [active, el, rootMargin, seen, unsupported]);\n return { ref: setEl, inView };\n}\n","import * as React from \"react\";\nimport { ImageOff } from \"lucide-react\";\nimport { Skeleton } from \"./data-view\";\nimport { useInView } from \"../lib/in-view\";\nimport { cn } from \"../lib/utils\";\n\n// A photo or crop from an API, in a list, a table cell or a grid (strata-react issue #33, from\n// the Bright Horizons review app, where some crops 404 because the file is missing on disk). A\n// plain <img> gets three things wrong there, and each is a state generated UI leaves out:\n//\n// - it has no size until it loads, so the rows below jump as each one arrives. The box here has\n// its aspect ratio before anything is fetched, and the image is cropped (`cover`) or fitted\n// (`contain`) into it, so nothing moves.\n// - while it loads it is a blank, and on a slow connection a blank reads as \"no photo\". Here it\n// is a `Skeleton`, the same placeholder DataView's loading layouts are made of.\n// - when it fails it is the browser's broken-image icon and the alt text crammed into the box.\n// Here it says what happened in the product's words: `missing` is required (\"Photo not\n// found\"), for the same reason DataView requires `empty`. A record with no photo at all\n// (`src={null}`) shows the same words without a request.\n//\n// `alt` is required too; pass \"\" only when the name beside the thumbnail already says everything\n// it shows. The missing state is an `img` named \"<alt>: <missing>\", so a screen reader hears\n// which photo is gone. Thumbnails come in dozens, so the request waits until the box is near the\n// screen (`useInView`, the hook InfiniteList's sentinel uses, with the same scroll region and a\n// root margin), and once asked for it is not unloaded. `eager` is for the first few on screen.\n// There is no fade-in: a list of thumbnails is seen many times a day (ux-character.md, character\n// by frequency), so the photo simply replaces its skeleton.\n\n/** A width-over-height ratio: a number (`1.5`) or a fraction (`\"4/3\"`). */\nexport type AspectRatio = number | `${number}/${number}`;\n\n/** The thumbnail's props. */\nexport type ThumbnailProps = {\n /** The image URL. `null` when the record has no photo: the `missing` words show without a request. */\n src: string | null;\n /** What the photo shows (\"Celadon bowl, front\"). `\"\"` only when the text beside it already says it. */\n alt: string;\n /** What to show when there is no photo or it cannot be loaded, in the product's words: \"Photo not found\". */\n missing: string;\n /** Width over height. The box has this shape before the image loads. Default `1`. */\n aspect?: AspectRatio;\n /** `cover` crops to fill the box (default); `contain` fits the whole image in it. */\n fit?: \"cover\" | \"contain\";\n srcSet?: string;\n sizes?: string;\n /** Load at once rather than when near the screen: for the first few above the fold. */\n eager?: boolean;\n /** How far outside the scroll region the request starts (IntersectionObserver `rootMargin`). */\n rootMargin?: string;\n /** Layout at the call site: a width (`w-24`, `w-full`). The height follows from `aspect`. */\n className?: string;\n};\n\ntype Phase = \"loading\" | \"loaded\" | \"missing\";\n\nconst ratio = (aspect: AspectRatio) => (typeof aspect === \"number\" ? String(aspect) : aspect.replace(\"/\", \" / \"));\n\n/** A box of fixed aspect ratio for a remote image: a skeleton until it loads, the `missing` words if it cannot, and a request only when it nears the screen. `alt` and `missing` are required. */\nexport function Thumbnail({\n src,\n alt,\n missing,\n aspect = 1,\n fit = \"cover\",\n srcSet,\n sizes,\n eager = false,\n rootMargin = \"200px\",\n className,\n}: ThumbnailProps) {\n // The outcome is kept with the request it belongs to (`src` and `srcSet`, since the browser may\n // have loaded a candidate from either), so a new request starts loading again without an effect\n // to reset it, and a late event from the old image cannot mark the new one.\n const request = src ? `${src} ${srcSet ?? \"\"}` : null;\n const [result, setResult] = React.useState<{ request: string; ok: boolean } | null>(null);\n const phase: Phase = !request ? \"missing\" : result?.request === request ? (result.ok ? \"loaded\" : \"missing\") : \"loading\";\n const near = useInView({ active: !eager && !!src, rootMargin, once: true, unsupported: true });\n const requested = eager || near.inView;\n\n return (\n <div\n ref={near.ref}\n className={cn(\"relative overflow-hidden rounded-control bg-muted\", className)}\n style={{ aspectRatio: ratio(aspect) }}\n aria-busy={phase === \"loading\" || undefined}\n >\n {phase === \"loading\" && <Skeleton className=\"absolute inset-0\" />}\n {src && request && phase !== \"missing\" && requested && (\n <img\n key={request}\n src={src}\n srcSet={srcSet}\n sizes={sizes}\n alt={alt}\n decoding=\"async\"\n onLoad={() => setResult({ request, ok: true })}\n onError={() => setResult({ request, ok: false })}\n className={cn(\"absolute inset-0 size-full\", fit === \"cover\" ? \"object-cover\" : \"object-contain\", phase === \"loading\" && \"opacity-0\")}\n />\n )}\n {phase === \"missing\" && (\n <div\n role=\"img\"\n aria-label={alt ? `${alt}: ${missing}` : missing}\n className=\"absolute inset-0 grid content-center justify-items-center gap-0.5 p-1 text-center text-muted-foreground\"\n >\n <ImageOff aria-hidden className=\"size-4 shrink-0\" />\n <span className=\"type-caption text-balance\">{missing}</span>\n </div>\n )}\n </div>\n );\n}\n\n/** The loading shape of a `Thumbnail`, for a `DataView` skeleton: the same box and aspect ratio, so nothing moves when the list arrives. */\nexport function ThumbnailSkeleton({ aspect = 1, className }: { aspect?: AspectRatio; className?: string }) {\n return (\n <div aria-hidden className={cn(\"relative overflow-hidden rounded-control bg-muted\", className)} style={{ aspectRatio: ratio(aspect) }}>\n <Skeleton className=\"absolute inset-0\" />\n </div>\n );\n}\n","import * as React from \"react\";\nimport { ArrowDown, ArrowUp, ArrowUpDown } from \"lucide-react\";\nimport {\n flexRender,\n getCoreRowModel,\n getSortedRowModel,\n useReactTable,\n type ColumnDef,\n type SortingState,\n} from \"@tanstack/react-table\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport { useSearchParams } from \"react-router\";\nimport { cn } from \"../lib/utils\";\nimport { Checkbox } from \"./checkbox\";\n\n// The table real product screens use: 12px muted sentence-case headers, row rules (no zebra),\n// numbers right-aligned in tabular figures, one status mark and at most one action per row.\n// Sortable headers are buttons and look sortable; aria-sort says which way. The scroll container is\n// a labelled, focusable region so keyboard users can scroll a wide table.\n//\n// Underneath: TanStack Table for the row model and sorting, TanStack Virtual once a table passes\n// `virtualizeFrom` rows (only the visible rows are in the DOM; the header sticks). The column API\n// stays small on purpose (key, header, cell, numeric, sort), so a screen reads as a list of\n// decisions about columns, not as table plumbing. `sortParam` keeps the sort in the URL\n// (?sort=when.desc) so a sorted view can be linked and survives a reload.\n//\n// Selection is opt-in (`selection`), because checkboxes belong only where a bulk action exists\n// (one of 23 real product screens had them; a checkbox on every row is a generated-UI tell). When\n// it is on, the first column is a checkbox per row, named from the row (`rowLabel` is required),\n// disabled where `isSelectable` says no; the header's \"Select all shown\" covers the selectable rows\n// in `rows` (all of them, not only the rendered ones of a virtualised table) and is mixed when some\n// are chosen. Selected rows take the sunken fill, not a ring, so a selection never reads as focus.\n// The table only draws the selection; the state is the caller's, usually `useSelection`, and the\n// actions live in a `BulkBar`.\n\nexport type Column<T> = {\n key: string;\n header: string;\n cell: (row: T) => React.ReactNode;\n /** Right-aligns and sets tabular figures. Use for every quantity. */\n numeric?: boolean;\n sort?: (a: T, b: T) => number;\n /** Cells that may hold long text get truncated rather than stretching the table. */\n truncate?: boolean;\n /** Keep the header for screen readers only, as for a column of row actions. `header` still names it. */\n hideHeader?: boolean;\n className?: string;\n};\n\n/** Row selection for a `DataTable`: the chosen row keys, how to change them, and how to name each row's checkbox. */\nexport type RowSelection<T> = {\n /** Keys (from `rowKey`) of the chosen rows. */\n selected: ReadonlySet<string>;\n onChange: (next: Set<string>) => void;\n /** Names the row in its checkbox (\"Select <rowLabel>\"). Required: an unnamed checkbox is a column of \"checkbox, not checked\". */\n rowLabel: (row: T) => string;\n /** Rows that cannot be chosen get a disabled checkbox and are left out of select-all. Default: every row. */\n isSelectable?: (row: T) => boolean;\n};\n\nexport type Sort = { key: string; dir: \"ascending\" | \"descending\" };\n\nexport type DataTableProps<T> = {\n /** Names the table for screen readers and labels the scroll region. */\n caption: string;\n columns: Column<T>[];\n rows: T[];\n rowKey: (row: T) => string;\n initialSort?: Sort;\n /** Keep the sort in this URL search parameter. Needs a React Router context. */\n sortParam?: string;\n /** Row count from which only the visible rows render. Default 100. */\n virtualizeFrom?: number;\n /** Height of the scroll region once virtualised, in px. Default 480. */\n maxHeight?: number;\n /** Adds a checkbox column and \"Select all shown\". Use only where a `BulkBar` acts on the selection. */\n selection?: RowSelection<T>;\n className?: string;\n};\n\ntype SortState = [Sort | undefined, (next: Sort) => void];\n\nfunction useLocalSort(initial?: Sort): SortState {\n const [sort, setSort] = React.useState(initial);\n return [sort, setSort];\n}\n\n/** Reads a sort from its URL form (`pieces.desc`). */\nexport function parseSort(value: string | null): Sort | undefined {\n if (!value) return undefined;\n const [key, dir] = value.split(\".\");\n if (!key) return undefined;\n return { key, dir: dir === \"desc\" ? \"descending\" : \"ascending\" };\n}\n\n/** Writes a sort in its URL form (`pieces.desc`). */\nexport function serialiseSort(sort: Sort) {\n return `${sort.key}.${sort.dir === \"descending\" ? \"desc\" : \"asc\"}`;\n}\n\nfunction useUrlSort(param: string, initial?: Sort): SortState {\n const [params, setParams] = useSearchParams();\n const sort = parseSort(params.get(param)) ?? initial;\n const set = React.useCallback(\n (next: Sort) =>\n setParams(\n (p) => {\n const out = new URLSearchParams(p);\n out.set(param, serialiseSort(next));\n return out;\n },\n { replace: true },\n ),\n [param, setParams],\n );\n return [sort, set];\n}\n\n/** A table on TanStack Table: muted headers, row rules, right-aligned tabular numbers, sortable headers with `aria-sort`, virtualised from `virtualizeFrom` rows, sort optionally kept in the URL (`sortParam`). */\nexport function DataTable<T>(props: DataTableProps<T>) {\n // Two thin wrappers so each calls its hooks unconditionally.\n return props.sortParam ? <UrlSortedTable {...props} sortParam={props.sortParam} /> : <LocalSortedTable {...props} />;\n}\n\nfunction LocalSortedTable<T>(props: DataTableProps<T>) {\n return <Table {...props} sortState={useLocalSort(props.initialSort)} />;\n}\n\nfunction UrlSortedTable<T>(props: DataTableProps<T> & { sortParam: string }) {\n return <Table {...props} sortState={useUrlSort(props.sortParam, props.initialSort)} />;\n}\n\ntype Meta = { numeric?: boolean; truncate?: boolean; hideHeader?: boolean; className?: string };\n\nfunction useSelectAll<T>(rows: T[], rowKey: (row: T) => string, selection?: RowSelection<T>) {\n return React.useMemo(() => {\n if (!selection) return undefined;\n const keys = rows.filter((r) => selection.isSelectable?.(r) ?? true).map(rowKey);\n const chosen = keys.filter((k) => selection.selected.has(k)).length;\n const checked: boolean | \"mixed\" = chosen === 0 ? false : chosen === keys.length ? true : \"mixed\";\n const toggle = () => {\n const next = new Set(selection.selected);\n // A full or mixed box clears what is shown; an empty one selects every selectable row shown.\n // Keys outside `rows` (filtered away) are left as they are.\n if (checked === false) keys.forEach((k) => next.add(k));\n else keys.forEach((k) => next.delete(k));\n selection.onChange(next);\n };\n return { checked, toggle, disabled: keys.length === 0 };\n }, [rows, rowKey, selection]);\n}\n\nfunction Table<T>({\n caption,\n columns,\n rows,\n rowKey,\n sortState: [sort, setSort],\n virtualizeFrom = 100,\n maxHeight = 480,\n selection,\n className,\n}: DataTableProps<T> & { sortState: SortState }) {\n const selectAll = useSelectAll(rows, rowKey, selection);\n const defs = React.useMemo<ColumnDef<T>[]>(\n () =>\n columns.map((c) => ({\n id: c.key,\n // TanStack only sorts columns with an accessor; the row itself is enough, since the\n // column's own comparator does the work.\n accessorFn: (row) => row,\n header: c.header,\n cell: (info) => c.cell(info.row.original),\n enableSorting: Boolean(c.sort),\n sortingFn: c.sort ? (a, b) => c.sort!(a.original, b.original) : undefined,\n meta: { numeric: c.numeric, truncate: c.truncate, hideHeader: c.hideHeader, className: c.className } satisfies Meta,\n })),\n [columns],\n );\n\n const sorting: SortingState = sort && columns.some((c) => c.key === sort.key && c.sort)\n ? [{ id: sort.key, desc: sort.dir === \"descending\" }]\n : [];\n\n const table = useReactTable({\n data: rows,\n columns: defs,\n state: { sorting },\n getRowId: (row) => rowKey(row),\n getCoreRowModel: getCoreRowModel(),\n getSortedRowModel: getSortedRowModel(),\n // No pagination or expansion here, so nothing to reset. Left on, TanStack resets the page\n // index whenever `rows` is a new array; a screen that filters its rows on every render (the\n // kiln room after Withdraw) then re-renders forever and the tab freezes. Found by the\n // example app's visual suite, which jsdom did not show.\n autoResetAll: false,\n });\n\n const toggle = (key: string) =>\n setSort({ key, dir: sort?.key === key && sort.dir === \"ascending\" ? \"descending\" : \"ascending\" });\n\n const modelRows = table.getRowModel().rows;\n const virtual = modelRows.length >= virtualizeFrom;\n const scroller = React.useRef<HTMLDivElement>(null);\n const virtualizer = useVirtualizer({\n count: virtual ? modelRows.length : 0,\n getScrollElement: () => scroller.current,\n estimateSize: () => 41,\n overscan: 8,\n // Until the region is measured, assume it is full height: the first paint (and a test DOM\n // with no layout) shows the first page of rows instead of none.\n initialRect: { width: 0, height: maxHeight },\n });\n const items = virtual ? virtualizer.getVirtualItems() : [];\n const padTop = items.length ? items[0].start : 0;\n const padBottom = items.length ? virtualizer.getTotalSize() - items[items.length - 1].end : 0;\n const visible = virtual ? items.map((i) => modelRows[i.index]) : modelRows;\n\n return (\n <div\n ref={scroller}\n role=\"region\"\n aria-label={caption}\n tabIndex={0}\n className={cn(\"relative min-w-0 overflow-x-auto\", virtual && \"overflow-y-auto\", className)}\n style={virtual ? { maxHeight } : undefined}\n >\n <table className=\"w-full border-collapse type-body-sm\" aria-rowcount={virtual ? modelRows.length + 1 : undefined}>\n <caption className=\"sr-only\">{caption}</caption>\n <thead className={cn(virtual && \"sticky top-0 z-10 bg-background\")}>\n {table.getHeaderGroups().map((group) => (\n <tr key={group.id}>\n {selectAll && (\n <th scope=\"col\" className=\"w-8 py-2 pr-2 text-left align-bottom\">\n <Checkbox\n className=\"-my-1\"\n label=\"Select all shown\"\n hideLabel\n checked={selectAll.checked}\n disabled={selectAll.disabled}\n onCheckedChange={selectAll.toggle}\n />\n </th>\n )}\n {group.headers.map((header) => {\n const meta = header.column.columnDef.meta as Meta | undefined;\n const active = sort?.key === header.id && header.column.getCanSort() ? sort.dir : undefined;\n const Icon = active === \"ascending\" ? ArrowUp : active === \"descending\" ? ArrowDown : ArrowUpDown;\n const rendered = flexRender(header.column.columnDef.header, header.getContext());\n const label = meta?.hideHeader ? <span className=\"sr-only\">{rendered}</span> : rendered;\n return (\n <th\n key={header.id}\n scope=\"col\"\n aria-sort={active}\n className={cn(\n \"py-2 pr-4 text-left align-bottom type-caption text-muted-foreground last:pr-0\",\n meta?.numeric && \"text-right\",\n )}\n >\n {header.column.getCanSort() ? (\n <button\n type=\"button\"\n onClick={() => toggle(header.id)}\n className={cn(\n \"-mx-1 inline-flex cursor-pointer items-center gap-1 rounded-control px-1 transition-state hover:text-foreground\",\n meta?.numeric && \"flex-row-reverse\",\n active && \"text-foreground\",\n )}\n >\n {label}\n <Icon aria-hidden className={cn(\"size-3.5\", !active && \"opacity-50\")} />\n </button>\n ) : (\n label\n )}\n </th>\n );\n })}\n </tr>\n ))}\n </thead>\n <tbody>\n {padTop > 0 && <tr aria-hidden style={{ height: padTop }} />}\n {visible.map((row, i) => {\n const chosen = selection?.selected.has(row.id) ?? false;\n return (\n <tr\n key={row.id}\n className={cn(\"border-t border-border\", chosen && \"bg-surface-sunken\")}\n aria-rowindex={virtual ? (items[i]?.index ?? 0) + 2 : undefined}\n >\n {selection && (\n <td className=\"w-8 py-2.5 pr-2 align-middle\">\n <Checkbox\n className=\"-my-0.5\"\n label={`Select ${selection.rowLabel(row.original)}`}\n hideLabel\n checked={chosen}\n disabled={!(selection.isSelectable?.(row.original) ?? true)}\n onCheckedChange={(on) => {\n const next = new Set(selection.selected);\n if (on) next.add(row.id);\n else next.delete(row.id);\n selection.onChange(next);\n }}\n />\n </td>\n )}\n {row.getVisibleCells().map((cell) => {\n const meta = cell.column.columnDef.meta as Meta | undefined;\n return (\n <td\n key={cell.id}\n className={cn(\n \"py-2.5 pr-4 align-middle last:pr-0\",\n meta?.numeric && \"text-right tabular-nums\",\n meta?.truncate && \"max-w-48 truncate\",\n meta?.className,\n )}\n >\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </td>\n );\n })}\n </tr>\n );\n })}\n {padBottom > 0 && <tr aria-hidden style={{ height: padBottom }} />}\n </tbody>\n </table>\n </div>\n );\n}\n\n/** The loading placeholder for a `DataTable`, shaped like its rows. */\nexport function TableSkeleton({ rows = 4, columns = 5 }: { rows?: number; columns?: number }) {\n return (\n <div aria-hidden className=\"grid gap-0\">\n <div className=\"flex gap-4 py-2\">\n {Array.from({ length: columns }, (_, i) => (\n <div key={i} className=\"h-3 flex-1 rounded-control bg-muted\" />\n ))}\n </div>\n {Array.from({ length: rows }, (_, r) => (\n <div key={r} className=\"flex gap-4 border-t border-border py-3.5\">\n {Array.from({ length: columns }, (_, i) => (\n <div key={i} className=\"h-4 flex-1 rounded-control bg-muted motion-safe:animate-pulse\" />\n ))}\n </div>\n ))}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { X } from \"lucide-react\";\nimport { format as defaultFormat, type Format } from \"../lib/format\";\nimport { cn } from \"../lib/utils\";\nimport { Button } from \"./button\";\n\n// Select many, then act: the state (`useSelection`), and the bar that says how many are chosen and\n// holds what can be done to them (`BulkBar`). `DataTable`'s `selection` prop draws the checkboxes.\n//\n// The selection is pruned to the rows that exist. After a bulk removal, a refetch or a new filter,\n// a key whose row is gone is not counted and not acted on: the bar never says \"3 selected\" over\n// two visible rows, and an action never reaches a row the person cannot see. (Gmail and Linear\n// both drop a selection a filter hides; acting on hidden rows is how a bulk delete surprises.)\n//\n// The count is the bar's live region, and only the count: it is always mounted, so a screen reader\n// hears \"2 bookings selected\" on each change, and the buttons are outside it, so their names are\n// not read again with every tick. The actions are a labelled group. Per the research, at most one\n// of them is filled (`variant=\"default\"`), named with its verb and count (\"Withdraw 3\"), and a\n// reversible bulk removal goes through `useUndoable` like a single one, not through a confirm.\n\n/** Chosen row keys, pruned to the rows that exist, and the calls that change them. Spread into `DataTable`'s `selection` with a `rowLabel`. */\nexport function useSelection<T>(rows: readonly T[], rowKey: (row: T) => string, initial: Iterable<string> = []) {\n const [raw, setRaw] = React.useState<ReadonlySet<string>>(() => new Set(initial));\n const selected = React.useMemo<ReadonlySet<string>>(() => {\n const present = new Set(rows.map(rowKey));\n return new Set([...raw].filter((k) => present.has(k)));\n // rowKey is usually an inline arrow, so it is left out of the dependencies: the rows change.\n }, [raw, rows]);\n const selectedRows = React.useMemo(() => rows.filter((r) => selected.has(rowKey(r))), [rows, selected]);\n // Forget the dropped keys too, not only hide them: a row that comes back (a filter cleared, a\n // removal undone) returns unchosen, so a later bulk action never picks it up unasked.\n React.useEffect(() => {\n if (selected.size !== raw.size) setRaw(selected);\n }, [selected, raw]);\n const onChange = React.useCallback((next: Set<string>) => setRaw(next), []);\n const clear = React.useCallback(() => setRaw(new Set()), []);\n return { selected, selectedRows, count: selected.size, onChange, clear };\n}\n\n/** The bar for a selection: a polite live count (\"2 bookings selected\"), the bulk actions, and Clear selection. Renders only the live region while nothing is chosen. */\nexport function BulkBar({\n count,\n noun,\n onClear,\n children,\n format = defaultFormat,\n className,\n}: {\n count: number;\n /** What is chosen, singular, or singular and plural: `\"booking\"`, `[\"person\", \"people\"]`. */\n noun: string | [one: string, many: string];\n onClear: () => void;\n /** The actions. At most one filled button, named with its verb and count. */\n children: React.ReactNode;\n /** The product's formatters, for the count's figures and plural. Default en-GB. */\n format?: Format;\n className?: string;\n}) {\n const [one, many] = typeof noun === \"string\" ? [noun, `${noun}s`] : noun;\n const label = `${format.count(count, one, many)} selected`;\n return (\n <div\n className={cn(\n count > 0 && \"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-surface bg-surface-sunken py-1.5 pr-1.5 pl-3\",\n className,\n )}\n >\n <p aria-live=\"polite\" className={count > 0 ? \"type-label tabular-nums\" : \"sr-only\"}>\n {count > 0 ? label : `No ${many} selected`}\n </p>\n {count > 0 && (\n <div role=\"group\" aria-label={`Actions for the selected ${many}`} className=\"flex flex-1 flex-wrap items-center gap-2\">\n {children}\n <Button size=\"sm\" variant=\"ghost\" className=\"ml-auto\" onClick={onClear}>\n <X aria-hidden />\n Clear selection\n </Button>\n </div>\n )}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport { cn } from \"../lib/utils\";\n\n// A long list that keeps only its visible rows in the DOM (TanStack Virtual), for feeds, logs and\n// pickers with hundreds of items. Rows are measured after render, so variable heights work; the\n// estimate only sets the first paint. The list is a labelled, focusable region so it can be\n// scrolled from the keyboard, and keeps list semantics with aria-setsize/aria-posinset so screen\n// readers still hear \"12 of 480\". Under `virtualizeFrom` items it renders a plain list.\n//\n// `bounded` keeps a short list in the same scroll region (capped at `height`) that the virtual\n// one uses, so a list that grows past `virtualizeFrom` while someone scrolls it (InfiniteList)\n// does not jump from the page's flow into a box. `footer` renders after the last row, inside the\n// scroll region: where InfiniteList puts its next-page row. Rows carry `data-index` in both modes.\n\n/** A list that renders only its visible rows (TanStack Virtual) from `virtualizeFrom` items, keeping list semantics for screen readers. */\nexport function VirtualList<T>({\n label,\n items,\n itemKey,\n children,\n estimateSize = 48,\n height = 480,\n virtualizeFrom = 100,\n bounded = false,\n footer,\n className,\n}: {\n label: string;\n items: T[];\n itemKey: (item: T) => string;\n children: (item: T, index: number) => React.ReactNode;\n estimateSize?: number;\n height?: number;\n virtualizeFrom?: number;\n /** Scroll inside a region capped at `height` even below `virtualizeFrom`, so growing past it changes nothing on screen. */\n bounded?: boolean;\n /** After the last row, inside the scroll region (a next-page row, an end note). */\n footer?: React.ReactNode;\n className?: string;\n}) {\n const scroller = React.useRef<HTMLDivElement>(null);\n const virtual = items.length >= virtualizeFrom;\n const virtualizer = useVirtualizer({\n count: virtual ? items.length : 0,\n getScrollElement: () => scroller.current,\n estimateSize: () => estimateSize,\n overscan: 6,\n initialRect: { width: 0, height },\n });\n\n // Built only when it is shown: a virtual list must not render every row it keeps out of the DOM.\n const plain = () => (\n <ul aria-label={label} className={cn(\"grid min-w-0\", !bounded && !footer && className)}>\n {items.map((item, i) => (\n <li key={itemKey(item)} data-index={i} className=\"border-t border-border first:border-t-0\">\n {children(item, i)}\n </li>\n ))}\n </ul>\n );\n\n if (!virtual && !bounded) {\n return footer ? (\n <div className={cn(\"min-w-0\", className)}>\n {plain()}\n {footer}\n </div>\n ) : (\n plain()\n );\n }\n\n return (\n <div\n ref={scroller}\n role=\"region\"\n aria-label={label}\n tabIndex={0}\n data-strata-scroll=\"\"\n className={cn(\"min-w-0 overflow-y-auto\", className)}\n style={virtual ? { height } : { maxHeight: height }}\n >\n {virtual ? (\n <ul aria-label={label} className=\"relative w-full\" style={{ height: virtualizer.getTotalSize() }}>\n {virtualizer.getVirtualItems().map((v) => {\n const item = items[v.index];\n return (\n <li\n key={itemKey(item)}\n ref={virtualizer.measureElement}\n data-index={v.index}\n aria-setsize={items.length}\n aria-posinset={v.index + 1}\n className={cn(\"absolute inset-x-0 top-0\", v.index > 0 && \"border-t border-border\")}\n style={{ translate: `0 ${v.start}px` }}\n >\n {children(item, v.index)}\n </li>\n );\n })}\n </ul>\n ) : (\n plain()\n )}\n {footer}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { CircleAlert, RotateCcw } from \"lucide-react\";\nimport { Button } from \"./button\";\nimport { DataView } from \"./data-view\";\nimport { VirtualList } from \"./virtual-list\";\nimport type { InfiniteLoad } from \"../query/infinite\";\nimport { useInView } from \"../lib/in-view\";\n\n// A list that loads its next page as the person nears the end: the view for `useInfiniteLoad`.\n// It is DataView for the first page (skeleton, error with Try again, empty state, all required)\n// and VirtualList for the rows (virtualised from 100, so a long session stays fast), with one row\n// after the last item that is always in one of four states:\n//\n// - more to come: an IntersectionObserver sentinel with a root margin, so the next page is asked\n// for before the person reaches the end, and a real \"Show more\" button behind it. The button is\n// the keyboard and screen-reader path (an automatic load is invisible to them) and the fallback\n// where the observer never fires.\n// - loading: `moreSkeleton`, mirroring the rows that are coming, not a spinner, and a polite\n// status so a screen reader hears it.\n// - a later page failed: an alert row with the reason and Try again. The items already loaded\n// stay; a failed page 4 is not a failed list. The sentinel stops asking until Try again, so a\n// dead server is not called in a loop.\n// - the end: `end`, if given (\"That's every firing since March\"), so the person knows it is all.\n//\n// `keepAtLeast` loads more whenever fewer items than that are held: a queue people work through\n// (answered items `dismiss`ed) refills before it runs dry, even when nothing scrolls. Showing\n// more by button moves focus to the first new item, because the button the person pressed is\n// gone. The list scrolls in its own region (`height`) from the first page, so passing 100 items\n// and switching to virtual rows changes nothing on screen.\n\n/** The infinite list's props. */\nexport type InfiniteListProps<T> = {\n state: InfiniteLoad<T>;\n /** The list's accessible name, e.g. \"Firing log, newest first\". */\n label: string;\n children: (item: T, index: number) => React.ReactNode;\n /** The first load. Mirrors the final layout, so nothing jumps when data arrives. */\n skeleton: React.ReactNode;\n /** What goes here and how to add it, when the first page is empty and there are no more. */\n empty: React.ReactNode;\n /** The button behind the sentinel, in the product's words: \"Show older firings\". */\n moreLabel: string;\n /** The rows of a page on its way. Defaults to `skeleton`. */\n moreSkeleton?: React.ReactNode;\n /** After the last page: say that this is everything. */\n end?: React.ReactNode;\n /** How far before the end the next page is asked for (IntersectionObserver `rootMargin`). */\n rootMargin?: string;\n /** Load more whenever fewer than this many items are held. */\n keepAtLeast?: number;\n estimateSize?: number;\n height?: number;\n virtualizeFrom?: number;\n className?: string;\n};\n\n/** A cursor-paged list for `useInfiniteLoad`: DataView's first-page states, virtual rows, and a next-page row that loads on approach, shows a skeleton, or says why it failed with Try again. */\nexport function InfiniteList<T>({\n state,\n label,\n children,\n skeleton,\n empty,\n moreLabel,\n moreSkeleton = skeleton,\n end,\n rootMargin = \"400px\",\n keepAtLeast = 0,\n estimateSize,\n height = 480,\n virtualizeFrom,\n className,\n}: InfiniteListProps<T>) {\n const { more, itemKey } = state;\n const held = state.status === \"ready\" ? state.data.length : 0;\n const box = React.useRef<HTMLDivElement>(null);\n const near = useInView({ active: state.status === \"ready\" && more.hasMore, rootMargin });\n\n // Load on approach, and keep a worked-through queue topped up. Not after a failure: that waits\n // for Try again. Re-runs when a page lands, so a sentinel still in view asks for the next one.\n const { hasMore, loadingMore, error, loadMore } = more;\n React.useEffect(() => {\n if (state.status !== \"ready\" || !hasMore || loadingMore || error) return;\n if (near.inView || held < keepAtLeast) loadMore();\n }, [state.status, hasMore, loadingMore, error, near.inView, held, keepAtLeast, loadMore]);\n\n // After a click on Show more or Try again, focus the first new item: the button is gone.\n const focusFrom = React.useRef<number | null>(null);\n const loadByHand = () => {\n focusFrom.current = held;\n loadMore();\n };\n React.useEffect(() => {\n const from = focusFrom.current;\n if (from === null || loadingMore) return;\n if (held > from) {\n const row = box.current?.querySelector<HTMLElement>(`li[data-index=\"${from}\"]`);\n if (row) {\n row.tabIndex = -1;\n row.focus();\n }\n focusFrom.current = null;\n } else if (error || !hasMore) focusFrom.current = null;\n }, [held, loadingMore, error, hasMore]);\n\n const footer = (\n <div>\n {hasMore && !error && <div ref={near.ref} aria-hidden className=\"h-px\" />}\n {loadingMore ? (\n <div aria-hidden className=\"border-t border-border\">{moreSkeleton}</div>\n ) : error ? (\n <div role=\"alert\" className=\"flex flex-wrap items-start gap-3 border-t border-border bg-danger-subtle px-3 py-2 text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n <p className=\"min-w-0 flex-1 type-body-sm\">{error}</p>\n <Button size=\"sm\" onClick={loadByHand}>\n <RotateCcw aria-hidden />\n Try again\n </Button>\n </div>\n ) : hasMore ? (\n <div className=\"border-t border-border py-3\">\n <Button size=\"sm\" onClick={loadByHand}>\n {moreLabel}\n </Button>\n </div>\n ) : (\n end && <div className=\"border-t border-border py-3 type-body-sm text-muted-foreground\">{end}</div>\n )}\n <p role=\"status\" className=\"sr-only\">\n {loadingMore ? \"Loading more\" : \"\"}\n </p>\n </div>\n );\n\n return (\n <DataView\n state={state}\n isEmpty={(items) => items.length === 0 && !hasMore}\n skeleton={skeleton}\n empty={empty}\n className={className}\n >\n {(items) => (\n <div ref={box} aria-busy={loadingMore || undefined}>\n <VirtualList\n label={label}\n items={items}\n itemKey={itemKey}\n estimateSize={estimateSize}\n height={height}\n virtualizeFrom={virtualizeFrom}\n bounded\n footer={footer}\n >\n {children}\n </VirtualList>\n </div>\n )}\n </DataView>\n );\n}\n","import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// A line chart with the defaults real product screens use: one measured series in one hue, a 2px\n// straight line with no fill and no markers, 3 to 5 faint gridlines, no y-axis line, no legend for a\n// single series (the series is labelled where it ends). Values never live only in a hover tooltip:\n// the latest and peak readings are labelled on the chart and every reading is in a table for screen\n// readers. Optional extras exist only where they answer a question: a dashed `planned` series, a\n// horizontal `band` (a threshold that matters), and a `now` marker.\n//\n//\n// `colourScale` colours the measured line by its own value, for subjects where that colour is a\n// fact rather than decoration: a kiln's glow by temperature, water by depth. The y position still\n// carries the value, so the colour is never the only cue. Without a reason in DESIGN.md, use one\n// hue.\n//\n// It draws in real pixels (measured with ResizeObserver) rather than scaling a fixed viewBox, so\n// the 12px labels stay 12px on a phone. Because the labels keep their size, the chart thins the\n// x ticks itself when they would collide (every second, third… tick, so the rhythm stays even)\n// and keeps the first and last label inside the chart, rather than overlapping on a phone.\n//\n// The y-axis autoscales to four gridline steps of a size people write on a scale, from zero (or\n// below it, if a reading is negative). `yMin` and `yMax` pin either end for a quantity whose range\n// is a fact of the subject (a percentage is 0 to 100, a battery 0 to 1): autoscaling a machine at\n// 1% CPU gives a 0 to 8% axis that makes it look busy (strata-react issue #23). A pin is a floor on\n// the extent, never a crop: a reading outside it widens the axis, because a chart that hides a\n// reading is worse than one with an untidy scale.\n\nexport type Point = { x: number; y: number };\n\nexport type LineChartProps = {\n /** What the chart shows, as a sentence. Used as the accessible name and the table caption. */\n label: string;\n series: Point[];\n seriesLabel: string;\n planned?: Point[];\n plannedLabel?: string;\n band?: { below: number; label: string };\n formatX: (x: number) => string;\n formatY: (y: number) => string;\n /** Where to put x labels, in x units. The chart drops every other one (and so on) when they would overlap at its width. */\n xTicks: number[];\n /** Pin the bottom of the y-axis (default: 0, or lower if a reading is negative). A reading below it still shows. */\n yMin?: number;\n /** Pin the top of the y-axis, for a bounded quantity such as a percentage (`yMax={100}`), so a low reading looks low. Choose a range that divides into four steps. A reading above it still shows. */\n yMax?: number;\n /** CSS colour for the measured series. Defaults to the first chart token. */\n colour?: string;\n /** Colour the measured series by value: each stop applies from `at` upwards, blending to the\n * next. Only where the colour means something in the subject; record the reason in DESIGN.md. */\n colourScale?: { at: number; colour: string }[];\n /** Says what the colours mean, shown beside the legend swatch when `colourScale` is set. */\n colourScaleLabel?: string;\n height?: number;\n className?: string;\n};\n\nfunction useWidth<T extends HTMLElement>() {\n const ref = React.useRef<T>(null);\n const [width, setWidth] = React.useState(0);\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n setWidth(el.getBoundingClientRect().width);\n const ro = new ResizeObserver(([entry]) => setWidth(entry.contentRect.width));\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n return [ref, width] as const;\n}\n\n/** The smallest step of a size people write on a scale (1, 2, 2.5, 4 or 5 × 10ⁿ) at least `raw`. */\nfunction niceStep(raw: number) {\n const mag = 10 ** Math.floor(Math.log10(raw));\n return [1, 2, 2.5, 4, 5, 10].map((m) => m * mag).find((s) => s >= raw * (1 - 1e-9)) ?? 10 * mag;\n}\n\n/**\n * The y-axis: four equal gridline steps covering every value. With no pins the steps are a size\n * people write on a scale (1, 2, 2.5, 4 or 5 × 10ⁿ), from zero or a round number below the lowest\n * reading. A pinned end is used as given unless a value lies beyond it.\n */\nexport function yScale(values: number[], pin: { min?: number; max?: number } = {}) {\n const finite = values.filter(Number.isFinite);\n const dMin = finite.length ? Math.min(...finite) : 0;\n const dMax = finite.length ? Math.max(...finite) : 0;\n const pinMin = pin.min !== undefined && dMin >= pin.min ? pin.min : undefined;\n const pinMax = pin.max !== undefined && dMax <= pin.max ? pin.max : undefined;\n let lo = pinMin ?? Math.min(0, dMin);\n // Readings all at a pinned top (say all -10 under yMax={-10}) leave no span: open one below.\n if (pinMax !== undefined && pinMin === undefined && !(pinMax > lo)) lo = pinMax - (Math.abs(pinMax) || 4);\n let min: number;\n let max: number;\n if (pinMax !== undefined) {\n max = pinMax;\n // Only the bottom is free: round it down to a step of the span, so 0 stays 0.\n min = pinMin ?? (lo < 0 ? Math.floor(lo / niceStep((max - lo) / 4)) * niceStep((max - lo) / 4) : 0);\n } else {\n const hi = Math.max(dMax, pin.max ?? -Infinity);\n // All-zero (or empty) data still needs a positive extent, or every coordinate divides by zero.\n let step = hi > lo ? niceStep((hi - lo) / 4) : 1;\n let base = pinMin ?? Math.floor(lo / step) * step;\n while (base + 4 * step < hi) {\n step = niceStep(step * 1.01);\n base = pinMin ?? Math.floor(lo / step) * step;\n }\n min = base;\n max = base + 4 * step;\n }\n if (!(max > min)) max = min + 4;\n return { min, max, ticks: [0, 1, 2, 3, 4].map((i) => min + ((max - min) * i) / 4) };\n}\n\n/** Roughly how wide a 12px caption label is, in px. jsdom cannot measure text, so the chart estimates. */\nconst labelWidth = (text: string) => text.length * 7;\n\n/**\n * The x ticks that fit at this width: every k-th tick, the smallest k for which neighbouring labels\n * leave a gap, so the spacing stays even. `scale` maps an x value to a pixel.\n */\nexport function fitTicks(ticks: number[], scale: (x: number) => number, widthOf: (t: number) => number, gap = 12) {\n if (ticks.length < 3) return ticks;\n const sorted = [...ticks].sort((a, b) => a - b);\n for (let k = 1; k < sorted.length; k++) {\n const kept = sorted.filter((_, i) => i % k === 0);\n const fits = kept.every((t, i) => i === 0 || scale(t) - scale(kept[i - 1]) >= (widthOf(t) + widthOf(kept[i - 1])) / 2 + gap);\n if (fits) return kept;\n }\n return sorted.slice(0, 1);\n}\n\n/** One measured series, drawn in real pixels, with the peak and current readings labelled on the chart and every reading in a screen-reader table. Optional plan, threshold band and `colourScale`. */\nexport function LineChart({\n label,\n series,\n seriesLabel,\n planned,\n plannedLabel,\n band,\n formatX,\n formatY,\n xTicks,\n yMin,\n yMax,\n colour = \"var(--chart-1)\",\n colourScale,\n colourScaleLabel,\n height = 280,\n className,\n}: LineChartProps) {\n const [ref, width] = useWidth<HTMLDivElement>();\n const gradientId = `heat-${React.useId().replace(/[^\\w-]/g, \"\")}`;\n const all = [...series, ...(planned ?? [])];\n const xMin = Math.min(...all.map((p) => p.x));\n const xMax = Math.max(...all.map((p) => p.x));\n const y = yScale(\n all.map((p) => p.y),\n { min: yMin, max: yMax },\n );\n\n const pad = { top: 16, right: 16, bottom: 28, left: 56 };\n const w = Math.max(0, width - pad.left - pad.right);\n const h = height - pad.top - pad.bottom;\n const sx = (x: number) => pad.left + ((x - xMin) / (xMax - xMin || 1)) * w;\n const sy = (v: number) => pad.top + h - ((v - y.min) / (y.max - y.min)) * h;\n const xLabelWidth = (t: number) => labelWidth(formatX(t));\n // Keep the first and last labels inside the chart instead of centring them past its edge.\n const xLabelAt = (t: number) => {\n const half = xLabelWidth(t) / 2;\n return Math.min(Math.max(sx(t), half), Math.max(half, width - half));\n };\n // Fit against where the labels are drawn, so pulling an end label in cannot make it collide.\n const shownXTicks = fitTicks(xTicks, xLabelAt, xLabelWidth);\n const path = (pts: Point[]) => pts.map((p, i) => `${i ? \"L\" : \"M\"}${sx(p.x).toFixed(1)},${sy(p.y).toFixed(1)}`).join(\"\");\n\n const last = series[series.length - 1];\n const peak = series.reduce((a, b) => (b.y > a.y ? b : a), series[0]);\n const stops = colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : [];\n /** The colour a value lands on: the highest stop at or below it. Used for the labelled points. */\n const colourAt = (y: number) => (stops.length ? [...stops].reverse().find((s) => s.at <= y)?.colour ?? stops[0].colour : colour);\n const stroke = stops.length ? `url(#${gradientId})` : colour;\n\n return (\n <figure className={cn(\"grid min-w-0 gap-2\", className)}>\n <div ref={ref} className=\"min-w-0\">\n {width > 0 && (\n <svg width={width} height={height} role=\"img\" aria-label={label} className=\"block overflow-visible\">\n {stops.length > 0 && (\n // A vertical gradient in chart space, so a colour sits at a temperature, not at a\n // point along the line: the line is the same red wherever it crosses 600 °C.\n <defs>\n <linearGradient id={gradientId} gradientUnits=\"userSpaceOnUse\" x1={0} x2={0} y1={sy(y.min)} y2={sy(y.max)}>\n {stops.map((s) => (\n <stop key={s.at} offset={Math.min(1, Math.max(0, (s.at - y.min) / (y.max - y.min)))} stopColor={s.colour} />\n ))}\n </linearGradient>\n </defs>\n )}\n {band && band.below > y.min && (\n <g>\n <rect x={pad.left} y={sy(Math.min(band.below, y.max))} width={w} height={sy(y.min) - sy(Math.min(band.below, y.max))} fill=\"var(--success-subtle)\" />\n <text x={pad.left + 8} y={sy(Math.min(band.below, y.max)) + 16} className=\"fill-success type-caption\">\n {band.label}\n </text>\n </g>\n )}\n {y.ticks.map((t) => (\n <g key={t}>\n <line x1={pad.left} x2={pad.left + w} y1={sy(t)} y2={sy(t)} stroke=\"var(--border)\" strokeWidth={1} />\n <text x={pad.left - 8} y={sy(t)} dy=\"0.32em\" textAnchor=\"end\" className=\"fill-muted-foreground type-caption tabular-nums\">\n {formatY(t)}\n </text>\n </g>\n ))}\n {shownXTicks.map((t) => (\n <text key={t} x={xLabelAt(t)} y={height - 8} textAnchor=\"middle\" className=\"fill-muted-foreground type-caption tabular-nums\">\n {formatX(t)}\n </text>\n ))}\n {planned && (\n <path d={path(planned)} fill=\"none\" stroke=\"var(--muted-foreground)\" strokeWidth={1.5} strokeDasharray=\"4 4\" />\n )}\n <path d={path(series)} fill=\"none\" stroke={stroke} strokeWidth={stops.length ? 2.5 : 2} strokeLinejoin=\"round\" strokeLinecap=\"round\" />\n {/* Direct labels instead of a legend and a tooltip. */}\n <circle cx={sx(peak.x)} cy={sy(peak.y)} r={3} fill={colourAt(peak.y)} />\n <text x={sx(peak.x) + 8} y={sy(peak.y) - 8} className=\"fill-foreground type-caption tabular-nums\">\n {formatY(peak.y)} peak\n </text>\n <line x1={sx(last.x)} x2={sx(last.x)} y1={pad.top} y2={pad.top + h} stroke=\"var(--foreground)\" strokeWidth={1} />\n <circle cx={sx(last.x)} cy={sy(last.y)} r={3.5} fill={colourAt(last.y)} />\n <text\n x={sx(last.x) - 8}\n y={sy(last.y) - 10}\n textAnchor=\"end\"\n className=\"fill-foreground type-label tabular-nums\"\n >\n {formatY(last.y)} now\n </text>\n </svg>\n )}\n </div>\n <figcaption className=\"flex flex-wrap gap-x-5 gap-y-1 type-caption text-muted-foreground\">\n <span className=\"inline-flex items-center gap-2\">\n {stops.length ? (\n <svg width={stops.length * 8} height=\"3\" aria-hidden>\n {stops.map((s, i) => (\n <line key={s.at} x1={i * 8} x2={i * 8 + 8} y1=\"1.5\" y2=\"1.5\" stroke={s.colour} strokeWidth={3} />\n ))}\n </svg>\n ) : (\n <svg width=\"16\" height=\"2\" aria-hidden>\n <line x1=\"0\" x2=\"16\" y1=\"1\" y2=\"1\" stroke={colour} strokeWidth={2} />\n </svg>\n )}\n {seriesLabel}\n {stops.length > 0 && colourScaleLabel && <span>({colourScaleLabel})</span>}\n </span>\n {planned && plannedLabel && (\n <span className=\"inline-flex items-center gap-2\">\n <svg width=\"16\" height=\"2\" aria-hidden>\n <line x1=\"0\" x2=\"16\" y1=\"1\" y2=\"1\" stroke=\"var(--muted-foreground)\" strokeWidth={1.5} strokeDasharray=\"4 4\" />\n </svg>\n {plannedLabel}\n </span>\n )}\n </figcaption>\n {/* sr-only on a wrapper: a table ignores width: 1px and would widen the page. */}\n <div className=\"sr-only\">\n <table>\n <caption>{label}</caption>\n <thead>\n <tr>\n <th scope=\"col\">Time</th>\n <th scope=\"col\">{seriesLabel}</th>\n </tr>\n </thead>\n <tbody>\n {series.map((p) => (\n <tr key={p.x}>\n <td>{formatX(p.x)}</td>\n <td>{formatY(p.y)}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </figure>\n );\n}\n","import * as React from \"react\";\n\n// The top of every Operate screen: a noun title at 24px (never \"Welcome back\"), its scope, the\n// screen's main action, and the finding. The finding is the one fact in today's data that most\n// needs attention; it sits where it is read first, beside the action it drives.\n\n/** The top of an Operate screen: a noun title, its scope, the main action, and the finding (the one fact in today's data that most needs attention). */\nexport function PageHeader({\n title,\n scope,\n actions,\n finding,\n as: Heading = \"h1\",\n}: {\n title: string;\n /** The title's element: h1 on a screen, h2 where the header is shown inside another page. */\n as?: \"h1\" | \"h2\";\n /** What the screen covers: a date, a range, a filter. */\n scope?: React.ReactNode;\n actions?: React.ReactNode;\n finding?: { text: React.ReactNode; action?: React.ReactNode };\n}) {\n return (\n <header className=\"grid gap-4\">\n <div className=\"flex flex-wrap items-end justify-between gap-x-6 gap-y-3\">\n <div className=\"grid min-w-0 gap-0.5\">\n <Heading className=\"type-title text-balance\">{title}</Heading>\n {scope && <p className=\"type-body-sm text-muted-foreground\">{scope}</p>}\n </div>\n {actions && <div className=\"flex flex-wrap gap-2\">{actions}</div>}\n </div>\n {finding && (\n <div className=\"flex flex-wrap items-center justify-between gap-x-6 gap-y-3 border-y border-border py-3\">\n <p className=\"max-w-prose min-w-0 type-body text-pretty\">{finding.text}</p>\n {finding.action}\n </div>\n )}\n </header>\n );\n}\n","import * as React from \"react\";\nimport { Button } from \"./button\";\nimport { describeActionError } from \"../lib/errors\";\n\n// Destructive actions take effect visibly at once and commit after a window, with Undo in reach.\n// For reversible removals this beats a confirm dialog: the dialog interrupts every time to protect\n// against the rare mistake, and people learn to click through it. Keep a confirm dialog for\n// actions that cannot be undone (deleting an account, firing a kiln).\n\n// A bulk removal is one removal with `ids`: the selected rows go, come back on Undo, and fail\n// together, under one message and one commit, because the person did one thing.\n//\n// One removal is pending at a time. Scheduling a second commits the first at once: in rapid-fire\n// triage (withdraw, withdraw, withdraw) Undo reaches back one step, and the bar never stacks up a\n// queue of messages nobody reads. Undo is for the slip just made, not for an audit trail.\n//\n// The hook owns which items are out of view (`isRemoved`), so a screen filters its rows by it and\n// never keeps a second \"hidden\" set that can drift from the pending one. An item stays removed\n// from when it is scheduled; Undo brings it back; a commit that fails brings it back and puts the\n// failure in the same bar, with \"Try again\", because the screen told the person it was done and a\n// silent failure would leave the screen lying. A committed item stays removed until the screen's\n// data drops it (the commit should invalidate the query it came from), so it never flickers back.\n//\n// `flush()` exists for the action that depends on the removal having happened (retrain on the\n// answers, export the list): commit now and await it, rather than racing the window.\n//\n// Failures are described like any other failed action (`describeActionError`, as AsyncButton uses,\n// unless the product passes its own): the same HTTP sentences as reads, without promising that\n// nothing changed, since a write that failed may still have reached the server.\n\n/** A removal waiting out its undo window: what to say, what to do when the window closes, and what to say if that fails. */\nexport type PendingRemoval = {\n /** Identifies the removed item: `isRemoved(id)` is true from `schedule` until Undo or a failed commit. */\n id: string;\n /** A bulk removal's items, all removed, undone, committed and restored together (one `commit` for the batch). `isRemoved` is true for each. Default `[id]`. */\n ids?: readonly string[];\n /** What happened, in the product's words: \"Withdrew Tom Ellery's 3 pieces from kiln 2.\" */\n message: string;\n /** What the person reads if the commit fails, saying the item is back: \"Tom Ellery's 3 pieces are back in kiln 2: the withdrawal did not go through.\" */\n failure: string;\n /** Makes the removal real (usually a request, then invalidating the query the item came from). Runs once per attempt: when the window closes, on `flush()`, when a second removal is scheduled, or when the owner unmounts. */\n commit: () => void | Promise<unknown>;\n /** Called after a failed commit, for anything beyond restoring the item and showing the failure (which the hook does). The only failure path once the owner has unmounted. */\n onError?: (error: unknown) => void;\n};\n\n/** A removal whose commit failed: the removal, and the error described for a person. */\nexport type FailedRemoval = { removal: PendingRemoval; message?: string };\n\n/** Options for `useUndoable`. */\nexport type UndoableOptions = {\n /** How long Undo stays in reach, in milliseconds. Default 8000. */\n windowMs?: number;\n /** Describes a failed commit for a person, or returns undefined to show the removal's `failure` alone. Default `describeActionError`, as for `useAsyncAction`. */\n describeError?: (error: unknown) => string | undefined;\n};\n\n/** What `useUndoable` returns. Pass it whole to `UndoBar`. */\nexport type Undoable = {\n /** The removal inside its window, or null. */\n pending: PendingRemoval | null;\n /** The last removal whose commit failed, until it is retried, dismissed or another removal is scheduled. */\n failed: FailedRemoval | null;\n /** Whether an item is out of view: scheduled, committing or committed, and not undone or failed. Filter rows with it. */\n isRemoved: (id: string) => boolean;\n /** Removes an item and starts its window. Commits any removal already pending first: only one is pending at a time. */\n schedule: (next: PendingRemoval) => void;\n /** Cancels the pending removal and brings the item back; its `commit` never runs. */\n undo: () => void;\n /** Commits the pending removal now and resolves when it and every earlier commit still in flight have settled; rejects if any failed, so a dependent action does not run. Resolves at once when nothing is pending or running. */\n flush: () => Promise<void>;\n /** Removes the failed item again and commits it now (the person already waited out the window); settles like `flush`. */\n retry: () => Promise<void>;\n /** Clears the failure from the bar; the item stays back. */\n dismiss: () => void;\n};\n\n/**\n * Schedules a reversible removal to commit after a window unless undone, and owns which items\n * are out of view meanwhile.\n *\n * Only one removal is pending at a time: scheduling a second commits the first immediately.\n * Unmounting inside the window commits the pending removal (leaving is not Undo), so a navigation\n * or a test that unmounts still sends the commit's request: await `flush()` before a dependent\n * action, and in tests let MSW answer the request or flush before unmounting.\n */\nexport function useUndoable(options: number | UndoableOptions = {}): Undoable {\n const { windowMs = 8000, describeError = describeActionError } =\n typeof options === \"number\" ? { windowMs: options } : options;\n const [pending, setPending] = React.useState<PendingRemoval | null>(null);\n const [failed, setFailed] = React.useState<FailedRemoval | null>(null);\n const [removed, setRemoved] = React.useState<ReadonlySet<string>>(() => new Set());\n const current = React.useRef<PendingRemoval | null>(null);\n const timer = React.useRef<number | undefined>(undefined);\n const mounted = React.useRef(true);\n // Every commit still running, whoever started it: flush() waits for all of them, not only the\n // pending one, because an earlier removal's request may still be in flight (its window closed,\n // or a second removal committed it) and a dependent action must not overtake it.\n const inFlight = React.useRef(new Set<Promise<void>>());\n const describe = React.useRef(describeError);\n describe.current = describeError;\n\n const hide = React.useCallback((p: PendingRemoval, out: boolean) => {\n const ids = p.ids ?? [p.id];\n setRemoved((s) => {\n if (ids.every((id) => s.has(id) === out)) return s;\n const n = new Set(s);\n for (const id of ids) {\n if (out) n.add(id);\n else n.delete(id);\n }\n return n;\n });\n }, []);\n\n // Runs one attempt at a removal's commit. A synchronous throw is treated like a rejection, so\n // there is one failure path: bring the item back, show the failure, tell onError, reject.\n const attempt = React.useCallback(\n (p: PendingRemoval): Promise<void> => {\n let result: void | Promise<unknown>;\n try {\n result = p.commit();\n } catch (error) {\n result = Promise.reject(error);\n }\n const done = Promise.resolve(result).then(\n () => undefined,\n (error: unknown) => {\n if (mounted.current) {\n hide(p, false);\n setFailed({ removal: p, message: describe.current(error) });\n }\n p.onError?.(error);\n throw error;\n },\n );\n inFlight.current.add(done);\n const settle = () => void inFlight.current.delete(done);\n done.then(settle, settle);\n return done;\n },\n [hide],\n );\n\n // Takes the pending removal out (so it commits only once) and attempts it.\n const take = React.useCallback((): { removal: PendingRemoval; done: Promise<void> } | null => {\n window.clearTimeout(timer.current);\n const p = current.current;\n if (!p) return null;\n current.current = null;\n if (mounted.current) setPending(null);\n return { removal: p, done: attempt(p) };\n }, [attempt]);\n\n // Commits the hook starts itself (window closed, second removal, unmount) have no caller to\n // await them. A failure is handled once it is in the bar or onError has it; only a failure\n // nobody can see (unmounted, no onError) is left to surface as an unhandled rejection.\n const commitDetached = React.useCallback(() => {\n const t = take();\n t?.done.catch((error: unknown) => {\n if (!mounted.current && !t.removal.onError) throw error;\n });\n }, [take]);\n\n const schedule = React.useCallback(\n (next: PendingRemoval) => {\n commitDetached(); // a second removal commits the first\n setFailed(null);\n hide(next, true);\n current.current = next;\n setPending(next);\n timer.current = window.setTimeout(commitDetached, windowMs);\n },\n [commitDetached, hide, windowMs],\n );\n\n const undo = React.useCallback(() => {\n window.clearTimeout(timer.current);\n const p = current.current;\n current.current = null;\n setPending(null);\n if (p) hide(p, false);\n }, [hide]);\n\n const flush = React.useCallback(async () => {\n take();\n const results = await Promise.allSettled([...inFlight.current]);\n const failure = results.find((r): r is PromiseRejectedResult => r.status === \"rejected\");\n if (failure) throw failure.reason;\n }, [take]);\n\n const retry = React.useCallback(() => {\n if (!failed) return Promise.resolve();\n setFailed(null);\n hide(failed.removal, true);\n return attempt(failed.removal);\n }, [attempt, failed, hide]);\n\n const dismiss = React.useCallback(() => setFailed(null), []);\n\n const isRemoved = React.useCallback((id: string) => removed.has(id), [removed]);\n\n // Leaving the screen is not Undo: if the owner unmounts inside the window (the person navigated\n // away), commit what was scheduled rather than silently dropping it.\n React.useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n commitDetached();\n };\n }, [commitDetached]);\n\n return { pending, failed, isRemoved, schedule, undo, flush, retry, dismiss };\n}\n\n// The bar lives in a polite live region that is always mounted, so screen readers hear the message\n// when it appears, and a failure replaces the message in the same place the person was looking.\n// It is fixed to the bottom of the viewport; a page that uses it keeps that much bottom padding so\n// the bar never covers the focused row. A failure stays until it is retried or dismissed: an error\n// that times out is one a person can miss.\n/** The polite live region that shows a pending removal with Undo, or a failed one with Try again. Pass it the whole `useUndoable()` result. */\nexport function UndoBar({\n undoable,\n inline = false,\n}: {\n undoable: Pick<Undoable, \"pending\" | \"failed\" | \"undo\" | \"retry\" | \"dismiss\">;\n /** Render in the flow instead of fixed to the viewport; for the state-matrix page. */\n inline?: boolean;\n}) {\n const { pending, failed, undo, retry, dismiss } = undoable;\n const ghost = \"text-background hover:bg-neutral-11\";\n return (\n <div\n aria-live=\"polite\"\n className={\n inline ? \"flex\" : \"pointer-events-none fixed inset-x-0 bottom-4 z-50 flex justify-center px-4\"\n }\n >\n {(pending || failed) && (\n <div className=\"pointer-events-auto flex max-w-lg items-center gap-4 rounded-overlay bg-foreground py-2 pr-2 pl-4 text-background shadow-overlay\">\n {pending ? (\n <>\n <p className=\"min-w-0 type-body-sm\">{pending.message}</p>\n <Button size=\"sm\" variant=\"ghost\" className={ghost} onClick={undo}>\n Undo\n </Button>\n </>\n ) : (\n failed && (\n <>\n <p className=\"min-w-0 type-body-sm\">\n {failed.message ? `${failed.removal.failure} ${failed.message}` : failed.removal.failure}\n </p>\n <div className=\"flex shrink-0 gap-1\">\n <Button size=\"sm\" variant=\"ghost\" className={ghost} onClick={() => void retry().catch(() => undefined)}>\n Try again\n </Button>\n <Button size=\"sm\" variant=\"ghost\" className={ghost} onClick={dismiss}>\n Dismiss\n </Button>\n </div>\n </>\n )\n )}\n </div>\n )}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { Check } from \"lucide-react\";\nimport { cn } from \"../lib/utils\";\n\n// The completion moment: what a person sees after finishing something that took effort (a\n// booking, a submission, an import). It is the one place on an Operate product where the library\n// spends its delight budget (character.md §3), so it is a component with rules rather than a\n// confetti call:\n// - `title` says what happened, in the past tense, with the object: \"Booked: 6 pieces in kiln 2\".\n// - `next` is required. A finish that does not say what happens now is a dead end, however\n// pleasant.\n// - `figure` is optional and must be drawn from the person's own data in the subject's terms\n// (their pieces on a shelf, their route on a map), never a stock illustration.\n// - The part of the figure that is the person's result enters once, with the `enter-moment`\n// utility (500ms, hard ease-out, no overshoot): their pieces set down on the shelf. Reduced\n// motion makes it instant. Nothing loops and nothing plays a sound.\n// - Focus moves to the heading on mount, so keyboard and screen-reader users land on the result.\n\n/** The completion moment for a rare, earned finish: what happened (past tense, with its object), what happens next, and optionally a figure drawn from the person's own data. Focus moves to the heading. */\nexport function Done({\n title,\n next,\n figure,\n actions,\n focusOnMount = true,\n className,\n}: {\n /** What happened, past tense, with its object. */\n title: string;\n /** What the person does now, or what happens next and when. */\n next: React.ReactNode;\n /** A drawing of the result made from the person's data in the subject's own terms. */\n figure?: React.ReactNode;\n actions?: React.ReactNode;\n /** Off only where the result is not the page's subject (the state-matrix page). */\n focusOnMount?: boolean;\n className?: string;\n}) {\n const heading = React.useRef<HTMLHeadingElement>(null);\n const titleId = React.useId();\n React.useEffect(() => {\n if (focusOnMount) heading.current?.focus();\n }, [focusOnMount]);\n return (\n <section aria-labelledby={titleId} className={cn(\"grid gap-5\", className)}>\n <div className=\"grid gap-2\">\n <h1 id={titleId} ref={heading} tabIndex={-1} className=\"flex items-start gap-2 type-title\">\n <Check aria-hidden className=\"mt-1 size-6 shrink-0 text-success\" />\n {title}\n </h1>\n <div className=\"max-w-prose type-body text-muted-foreground\">{next}</div>\n </div>\n {figure}\n {actions && <div className=\"flex flex-wrap items-center gap-3\">{actions}</div>}\n </section>\n );\n}\n","import * as React from \"react\";\nimport { Link, NavLink } from \"react-router\";\nimport { cn } from \"../lib/utils\";\nimport type { IconComponent } from \"../lib/icon\";\n\n// The frame of an app: a side nav on the page ground (not a navy or tinted sidebar), the current\n// item as a neutral pill (no left bar, no accent), and the page beside it. A top bar exists only\n// when it holds something used on every screen, so it is a slot, not a default. Built on React\n// Router's NavLink, so \"current\" is the router's answer and aria-current is set for free. On\n// phones the nav becomes a horizontal, scrollable row above the page rather than a hamburger, so\n// every destination stays one tap away.\n\nexport type NavItem = {\n to: string;\n label: string;\n icon?: IconComponent;\n /** Match only this exact path, for an index route such as \"/\". */\n end?: boolean;\n};\n\n/** The app frame: product name, side nav on the page ground (a scrollable row on phones), optional top bar, and the main region. */\nexport function AppShell({\n product,\n nav,\n navLabel = \"Main\",\n topBar,\n children,\n className,\n}: {\n /** The product's name or mark, linking home. */\n product: React.ReactNode;\n nav: NavItem[];\n navLabel?: string;\n topBar?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n}) {\n return (\n <div className={cn(\"min-h-dvh md:grid md:grid-cols-[14rem_minmax(0,1fr)]\", className)}>\n <aside className=\"border-b border-border md:border-r md:border-b-0\">\n <div className=\"flex items-center gap-4 px-4 py-3 md:block md:px-3 md:py-4\">\n <Link to=\"/\" className=\"shrink-0 rounded-control px-2 type-heading text-foreground no-underline\">\n {product}\n </Link>\n <SideNav items={nav} label={navLabel} className=\"min-w-0 flex-1 md:mt-4\" />\n </div>\n </aside>\n <div className=\"min-w-0\">\n {topBar && <div className=\"flex items-center gap-3 border-b border-border px-4 py-2 md:px-8\">{topBar}</div>}\n <main className=\"px-4 py-6 md:px-8 md:py-8\">{children}</main>\n </div>\n </div>\n );\n}\n\n/** Navigation links (React Router `NavLink`); the current route is a neutral pill with `aria-current`. */\nexport function SideNav({ items, label, className }: { items: NavItem[]; label: string; className?: string }) {\n return (\n <nav aria-label={label} className={cn(\"min-w-0\", className)}>\n <ul className=\"flex gap-1 overflow-x-auto md:grid md:overflow-visible\">\n {items.map(({ to, label, icon: Icon, end }) => (\n <li key={to} className=\"shrink-0\">\n <NavLink\n to={to}\n end={end}\n className={({ isActive }) =>\n cn(\n \"flex h-(--control-h-sm) items-center gap-2 rounded-control px-2 type-label whitespace-nowrap no-underline transition-state\",\n isActive ? \"bg-muted text-foreground\" : \"text-muted-foreground hover:bg-muted hover:text-foreground\",\n )\n }\n >\n {Icon && <Icon aria-hidden className=\"size-4 shrink-0\" />}\n {label}\n </NavLink>\n </li>\n ))}\n </ul>\n </nav>\n );\n}\n\n// Plain links with a \"/\" separator in muted ink. The last crumb is the current page: text, not a\n// link, with aria-current.\n/** Plain links separated by `/`; the last crumb is the current page. */\nexport function Breadcrumb({ items }: { items: { label: string; to?: string }[] }) {\n return (\n <nav aria-label=\"Breadcrumb\">\n <ol className=\"flex flex-wrap items-center gap-x-2 type-body-sm text-muted-foreground\">\n {items.map((item, i) => {\n const last = i === items.length - 1;\n return (\n <li key={`${item.label}-${i}`} className=\"flex items-center gap-2\">\n {item.to && !last ? (\n <Link to={item.to} className=\"text-muted-foreground underline hover:text-foreground\">\n {item.label}\n </Link>\n ) : (\n <span aria-current={last ? \"page\" : undefined} className={cn(last && \"text-foreground\")}>\n {item.label}\n </span>\n )}\n {!last && <span aria-hidden>/</span>}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n}\n","import * as React from \"react\";\nimport { useSearchParams } from \"react-router\";\nimport { cn } from \"../lib/utils\";\n\n// Tabs whose state lives in the URL (?view=readings), so a tab can be linked, survives reload and\n// works with Back. ARIA tabs pattern: arrow keys move between tabs and select them, Home and End\n// jump, only the selected tab is in the tab order. The selected tab is marked by weight and a\n// 2px rule in ink, not by colour alone. The first tab is the default and is not written to the URL.\n\nexport type TabItem = { value: string; label: string };\n\n/** Tabs whose selection lives in a URL search parameter (React Router), with the ARIA tabs keyboard model. */\nexport function Tabs({\n param,\n items,\n label,\n children,\n className,\n}: {\n /** The search parameter that holds the selected tab. */\n param: string;\n items: TabItem[];\n /** Names the tab list for screen readers. */\n label: string;\n /** Renders the selected panel. */\n children: (value: string) => React.ReactNode;\n className?: string;\n}) {\n const [params, setParams] = useSearchParams();\n const fallback = items[0]?.value ?? \"\";\n const raw = params.get(param);\n const value = items.some((i) => i.value === raw) ? raw! : fallback;\n const baseId = React.useId();\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n\n const select = (next: string, focus = false) => {\n setParams(\n (p) => {\n const out = new URLSearchParams(p);\n if (next === fallback) out.delete(param);\n else out.set(param, next);\n return out;\n },\n { replace: true },\n );\n if (focus) refs.current[items.findIndex((i) => i.value === next)]?.focus();\n };\n\n const onKeyDown = (e: React.KeyboardEvent, index: number) => {\n const last = items.length - 1;\n const to =\n e.key === \"ArrowRight\" ? (index === last ? 0 : index + 1)\n : e.key === \"ArrowLeft\" ? (index === 0 ? last : index - 1)\n : e.key === \"Home\" ? 0\n : e.key === \"End\" ? last\n : undefined;\n if (to === undefined) return;\n e.preventDefault();\n select(items[to].value, true);\n };\n\n return (\n <div className={cn(\"grid gap-4\", className)}>\n <div role=\"tablist\" aria-label={label} className=\"flex gap-4 overflow-x-auto border-b border-border\">\n {items.map((item, i) => {\n const selected = item.value === value;\n return (\n <button\n key={item.value}\n ref={(el) => {\n refs.current[i] = el;\n }}\n type=\"button\"\n role=\"tab\"\n id={`${baseId}-tab-${item.value}`}\n aria-selected={selected}\n aria-controls={`${baseId}-panel`}\n tabIndex={selected ? 0 : -1}\n onClick={() => select(item.value)}\n onKeyDown={(e) => onKeyDown(e, i)}\n className={cn(\n \"-mb-px cursor-pointer border-b-2 py-2 type-label whitespace-nowrap transition-state\",\n selected\n ? \"border-foreground font-semibold text-foreground\"\n : \"border-transparent text-muted-foreground hover:text-foreground\",\n )}\n >\n {item.label}\n </button>\n );\n })}\n </div>\n <div role=\"tabpanel\" id={`${baseId}-panel`} aria-labelledby={`${baseId}-tab-${value}`} tabIndex={0}>\n {children(value)}\n </div>\n </div>\n );\n}\n","import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// Single-key shortcuts for Operate screens that clear a queue (accept, reject, next). A person\n// doing the same answer a hundred times a day wants one key, no pointer and no motion\n// (ux-research `ux-character.md`: 100+ a day gets nothing but an instant change). Three rules\n// keep single keys from hurting anyone:\n// 1. They never fire while the person is typing: not in an input, textarea, select or\n// contenteditable (WCAG 2.1.4 Character Key Shortcuts), and not mid-composition (IME).\n// 2. They never take a chord: with Ctrl, Meta or Alt held the browser and the OS keep the key.\n// Shift is part of the key itself, so \"?\" works and \"A\" is not \"a\".\n// 3. Holding a key does not repeat an answer; only shortcuts marked `repeat` (moving) repeat.\n// The same list drives the handler and the legend, so a shortcut cannot exist without being\n// shown, and the legend cannot advertise a key that does nothing.\n\n/** One shortcut: the keys that run it (as `KeyboardEvent.key`), what it does in the product's words, and the action. */\nexport type Shortcut = {\n /** `KeyboardEvent.key` values, e.g. `[\"j\", \"ArrowDown\"]`. The first is the one the legend leads with. */\n keys: string[];\n /** What it does, in the product's words: \"Accept booking\", not \"Action 1\". */\n label: string;\n run: () => void;\n /** Fire again while the key is held. On for moving through a list, off (the default) for answers. */\n repeat?: boolean;\n /** Ignore the key for now, and show it muted in the legend (nothing is active, say). */\n disabled?: boolean;\n};\n\nconst TEXT_INPUTS_EXEMPT = new Set([\"checkbox\", \"radio\", \"button\", \"submit\", \"reset\", \"range\", \"color\", \"file\"]);\n\n/** True when a key pressed on this element is the person typing, so single-key shortcuts must leave it alone. */\nexport function isTypingTarget(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) return false;\n if (target.isContentEditable || target.closest(\"[contenteditable=''],[contenteditable='true']\")) return true;\n if (target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement) return true;\n if (target instanceof HTMLInputElement) return !TEXT_INPUTS_EXEMPT.has(target.type);\n return false;\n}\n\nfunction toShortcuts(input: Shortcut[] | Record<string, () => void>): Shortcut[] {\n return Array.isArray(input) ? input : Object.entries(input).map(([key, run]) => ({ keys: [key], label: key, run }));\n}\n\n/**\n * Binds single-key shortcuts on the window, ignoring keys typed into fields, chords with Ctrl, Meta\n * or Alt, IME composition and (unless `repeat`) held keys. Pass the same list to `KeysLegend`.\n */\nexport function useHotkeys(shortcuts: Shortcut[] | Record<string, () => void>, { enabled = true }: { enabled?: boolean } = {}) {\n // The listener is bound once; it reads the latest list, so handlers can close over fresh state.\n const latest = React.useRef<Shortcut[]>([]);\n latest.current = toShortcuts(shortcuts);\n\n React.useEffect(() => {\n if (!enabled) return;\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.defaultPrevented || e.isComposing || e.ctrlKey || e.metaKey || e.altKey) return;\n if (isTypingTarget(e.target)) return;\n const hit = latest.current.find((s) => !s.disabled && s.keys.includes(e.key));\n if (!hit || (e.repeat && !hit.repeat)) return;\n e.preventDefault();\n hit.run();\n };\n window.addEventListener(\"keydown\", onKeyDown);\n return () => window.removeEventListener(\"keydown\", onKeyDown);\n }, [enabled]);\n}\n\nconst KEY_NAMES: Record<string, string> = {\n ArrowDown: \"↓\",\n ArrowUp: \"↑\",\n ArrowLeft: \"←\",\n ArrowRight: \"→\",\n Escape: \"Esc\",\n Enter: \"Enter\",\n Backspace: \"Backspace\",\n Delete: \"Delete\",\n \" \": \"Space\",\n};\n\n// The legend is quiet, caption-sized and muted: it is there to be found, not read every time.\n// It hides on coarse pointers (phones, tablets without a keyboard), where the keys do not exist.\n// Each key is a <kbd>; alternatives are read as \"j or down arrow\".\n/** A quiet legend of the screen's shortcuts, from the same list `useHotkeys` binds. Hidden on touch screens. */\nexport function KeysLegend({\n shortcuts,\n label = \"Keyboard shortcuts\",\n className,\n}: {\n shortcuts: Pick<Shortcut, \"keys\" | \"label\" | \"disabled\">[];\n /** Names the legend for screen readers. */\n label?: string;\n className?: string;\n}) {\n return (\n <dl aria-label={label} className={cn(\"flex flex-wrap gap-x-4 gap-y-1 type-caption text-muted-foreground pointer-coarse:hidden\", className)}>\n {shortcuts.map((s) => (\n <div key={s.keys.join(\" \")} className={cn(\"flex items-center gap-1.5\", s.disabled && \"opacity-50\")}>\n <dt className=\"flex items-center gap-1\">\n {s.keys.map((k, i) => (\n <React.Fragment key={k}>\n {i > 0 && <span className=\"sr-only\"> or </span>}\n <kbd className=\"min-w-5 rounded-control border border-border bg-surface-sunken px-1 text-center font-mono text-foreground\">\n {KEY_NAMES[k] ?? k}\n </kbd>\n </React.Fragment>\n ))}\n </dt>\n <dd>{s.label}</dd>\n </div>\n ))}\n </dl>\n );\n}\n","import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { isTypingTarget, type Shortcut } from \"./hotkeys\";\n\n// A queue someone works through from the keyboard: one item is active, j/k (or the arrow keys\n// inside the list) move it, and answering an item moves straight on to the next one. Three\n// decisions shape it:\n// 1. The active item is the one with focus. It is a roving tab stop (only it is in the tab order)\n// and carries aria-current, so a screen reader hears which item an answer applies to. It is\n// marked by a 2px rule in ink as well as a tint, not by colour alone.\n// 2. When the active item leaves the list (accepted, rejected, removed), the item that took its\n// place becomes active, or the one before it at the end of the list, and focus follows if it\n// was in the list. Otherwise focus would fall to <body> and the next key would do nothing.\n// 3. The hook remembers which item the person chose, not just a position. If an Undo puts the\n// item back, it is active again (pairs with `useUndoable`).\n// Moving is instant: no transition on the highlight (ux-research `ux-character.md`, 100+ a day).\n\n/** What `useActiveItem` returns: the active item, ways to move it, and the props each item element needs. */\nexport type ActiveItem<T> = {\n items: readonly T[];\n getKey: (item: T) => string;\n activeKey: string | null;\n activeItem: T | null;\n /** Position of the active item, or -1 when the list is empty. */\n index: number;\n next: () => void;\n prev: () => void;\n first: () => void;\n last: () => void;\n setActive: (key: string) => void;\n /** The j/k shortcuts for `useHotkeys` and `KeysLegend`. */\n shortcuts: Shortcut[];\n /** Props for the element that represents an item: ref, tabIndex, aria-current and focus tracking. */\n itemProps: (key: string) => {\n ref: (el: HTMLElement | null) => void;\n tabIndex: number;\n \"aria-current\": \"true\" | undefined;\n \"data-active\": \"\" | undefined;\n onFocus: () => void;\n onBlur: (e: React.FocusEvent) => void;\n };\n};\n\n/** Tracks the active item in a list worked through from the keyboard: moving, roving focus, and moving on when the active item is removed. */\nexport function useActiveItem<T>(\n items: readonly T[],\n getKey: (item: T) => string,\n {\n initial,\n noun,\n }: {\n /** Key of the item active at first; the first item otherwise. */\n initial?: string;\n /** Names an item in the shortcut labels: \"Next booking\". */\n noun?: string;\n } = {},\n): ActiveItem<T> {\n const [chosen, setChosen] = React.useState<string | null>(initial ?? null);\n const lastIndex = React.useRef(0);\n const elements = React.useRef(new Map<string, HTMLElement>());\n const navigated = React.useRef(false);\n const focusWithin = React.useRef(false);\n\n const keys = items.map(getKey);\n let index = chosen === null ? -1 : keys.indexOf(chosen);\n if (index === -1 && keys.length > 0) index = Math.min(lastIndex.current, keys.length - 1);\n const activeKey = index >= 0 ? keys[index] : null;\n\n // Remember the position, and the last item that left the list while active. Answering two in a\n // row (at the end of the queue, say) must make the second the one an Undo brings back as\n // active, not the first.\n const prevActive = React.useRef<string | null>(activeKey);\n React.useLayoutEffect(() => {\n if (index >= 0) lastIndex.current = index;\n const gone = prevActive.current;\n prevActive.current = activeKey;\n if (gone !== null && gone !== chosen && !keys.includes(gone)) setChosen(gone);\n });\n\n // Move focus to the active item when the person moved it, when the focused item was removed\n // (focus has fallen to <body>), or when focus is on another item in the list (an Undo made the\n // restored item active again). Never take focus from somewhere else on the page.\n React.useLayoutEffect(() => {\n const el = activeKey === null ? undefined : elements.current.get(activeKey);\n const focused = document.activeElement;\n const lost = focusWithin.current && (focused === null || focused === document.body);\n const elsewhereInList =\n focused !== null && !el?.contains(focused) && [...elements.current.values()].some((item) => item.contains(focused));\n if (el && (navigated.current || lost || elsewhereInList)) {\n el.focus({ preventScroll: true });\n el.scrollIntoView?.({ block: \"nearest\" });\n }\n navigated.current = false;\n }, [activeKey]);\n\n const moveTo = (i: number) => {\n if (keys.length === 0) return;\n const to = Math.max(0, Math.min(keys.length - 1, i));\n navigated.current = true;\n if (to === index) {\n // Already there: still bring focus back to it, as the person asked to move.\n const el = elements.current.get(keys[to]);\n el?.focus({ preventScroll: true });\n el?.scrollIntoView?.({ block: \"nearest\" });\n navigated.current = false;\n }\n setChosen(keys[to]);\n };\n\n const next = () => moveTo(index + 1);\n const prev = () => moveTo(index - 1);\n const first = () => moveTo(0);\n const last = () => moveTo(keys.length - 1);\n const setActive = (key: string) => {\n const i = keys.indexOf(key);\n if (i >= 0) moveTo(i);\n };\n\n const name = noun ? ` ${noun}` : \"\";\n const shortcuts: Shortcut[] = [\n { keys: [\"j\"], label: `Next${name}`, run: next, repeat: true, disabled: keys.length === 0 },\n { keys: [\"k\"], label: `Previous${name}`, run: prev, repeat: true, disabled: keys.length === 0 },\n ];\n\n const itemProps: ActiveItem<T>[\"itemProps\"] = (key) => ({\n ref: (el) => {\n if (el) elements.current.set(key, el);\n else elements.current.delete(key);\n },\n tabIndex: key === activeKey ? 0 : -1,\n \"aria-current\": key === activeKey ? \"true\" : undefined,\n \"data-active\": key === activeKey ? \"\" : undefined,\n onFocus: () => {\n focusWithin.current = true;\n // Clicking or tabbing into an item makes it active. If it already is (it took a removed\n // item's place), keep remembering the removed one so an Undo makes that active again.\n if (key !== activeKey) setChosen(key);\n },\n onBlur: (e) => {\n // Focus going nowhere (null) is what removal looks like, so only a move to a real element\n // outside the list counts as leaving it.\n const to = e.relatedTarget;\n if (to instanceof Node && ![...elements.current.values()].some((el) => el.contains(to))) focusWithin.current = false;\n },\n });\n\n return {\n items,\n getKey,\n activeKey,\n activeItem: index >= 0 ? items[index] : null,\n index,\n next,\n prev,\n first,\n last,\n setActive,\n shortcuts,\n itemProps,\n };\n}\n\n// The list renders the queue from `useActiveItem`. The arrow keys, Home and End move the active\n// item while focus is in the list (the window-wide j/k come from `active.shortcuts` via\n// `useHotkeys`, because only the screen knows whether it has one queue or two). An empty queue\n// is a state the list cannot be written without: say what clearing it means and what is next.\n/** A keyboard-worked queue: the active item is a roving tab stop with aria-current, and the arrow keys, Home and End move it. */\nexport function ActiveList<T>({\n label,\n active,\n empty,\n children,\n className,\n}: {\n /** Names the list for screen readers. */\n label: string;\n active: ActiveItem<T>;\n /** Shown when the queue is clear: what that means and what to do next. */\n empty: React.ReactNode;\n children: (item: T, state: { active: boolean }) => React.ReactNode;\n className?: string;\n}) {\n if (active.items.length === 0) return <>{empty}</>;\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.ctrlKey || e.metaKey || e.altKey || isTypingTarget(e.target)) return;\n const move =\n e.key === \"ArrowDown\" ? active.next\n : e.key === \"ArrowUp\" ? active.prev\n : e.key === \"Home\" ? active.first\n : e.key === \"End\" ? active.last\n : undefined;\n if (!move) return;\n e.preventDefault();\n move();\n };\n\n return (\n <ul aria-label={label} onKeyDown={onKeyDown} className={cn(\"grid gap-px\", className)}>\n {active.items.map((item) => {\n const key = active.getKey(item);\n const isActive = key === active.activeKey;\n return (\n <li\n key={key}\n {...active.itemProps(key)}\n className={cn(\n \"rounded-control border-l-2 px-3 py-2 -outline-offset-2\",\n isActive ? \"border-foreground bg-accent text-accent-foreground\" : \"border-transparent\",\n )}\n >\n {children(item, { active: isActive })}\n </li>\n );\n })}\n </ul>\n );\n}\n","import * as React from \"react\";\nimport { hashKey, useInfiniteQuery, type QueryKey } from \"@tanstack/react-query\";\nimport type { Load } from \"../components/data-view\";\nimport { describeHttpError, type DescribeError } from \"./index\";\n\n// Cursor-paged reads, the Strata way. `useLoad` covers a read that arrives whole; a feed, a log or\n// a triage queue arrives a page at a time. This is the same bridge for those: TanStack's\n// useInfiniteQuery underneath, a `Load<T[]>` on top (so `DataView` takes it unchanged for the\n// first page's loading, error and empty states), and a `more` object for everything after it.\n//\n// Three opinions:\n// 1. The cursor is \"after the last item held\", never an offset, and the hook works it out: the\n// app says how to make a cursor from an item (`cursorAfter`) and whether a page says there are\n// more (`hasMore`). In a queue people work through (answered reviews, archived firings), items\n// leave the server's list between pages, and an offset would skip the ones that moved up to\n// fill the gap. Two cases fall back to the last item *seen*, dismissed or not: when everything\n// held has been dismissed (there is no held item to go after, and starting again from the top\n// could fetch the same dismissed page forever), and when the last page brought nothing new\n// (only items already held or dismissed came back, so going after the last held item again\n// would ask for the same page in a loop).\n// 2. Items have keys. Pages are merged by key, so an item that shifts across a page boundary is\n// shown once, and `dismiss(key)` hides one at once (an optimistic remove, paired with\n// useUndoable) without the app rewriting TanStack's page cache by hand. Dismissals belong to\n// one query: a new `queryKey` (another filter) starts with none. A screen that removes items\n// with `useUndoable` passes its `isRemoved` instead, so the undo hook stays the one owner of\n// what is out of view (Undo, a failed commit and Try again all show through) and the cursor\n// still skips past what it hides.\n// 3. A later page failing is not the list failing. The held items stay; `more.error` says what\n// happened and `more.loadMore` is the Try again. Only a failed first page is a `Load` error.\n\n/** The state of the pages after the first: whether there are more, whether one is on its way, and why the last one failed. */\nexport type More = {\n /** The server has said there is another page. */\n hasMore: boolean;\n /** A page after the first is being fetched. */\n loadingMore: boolean;\n /** Why the last page after the first failed, for a person. Cleared when a retry succeeds. */\n error?: string;\n /** Fetch the next page; also the Try again after `error`. Does nothing while one is loading or when there are no more. */\n loadMore: () => void;\n};\n\n/** A cursor-paged read: a `Load<T[]>` of the items held (so `DataView` takes it), plus the next page's state and keyed removal. */\nexport type InfiniteLoad<T> = Load<T[]> & {\n more: More;\n itemKey: (item: T) => string;\n /** Hide an item at once (an optimistic removal). The next cursor goes after the last item still held. */\n dismiss: (key: string) => void;\n /** Show a dismissed item again: the Undo of `dismiss`. */\n restore: (key: string) => void;\n};\n\n/** Options for `useInfiniteLoad`. */\nexport type InfiniteLoadOptions<T, Page, Cursor, K extends QueryKey> = {\n queryKey: K;\n /** Fetch one page. `cursor` is undefined for the first page, else `cursorAfter` of the last item held. */\n queryFn: (context: { cursor: Cursor | undefined; signal: AbortSignal }) => Promise<Page>;\n /** The items in a page. For an API that returns a bare array, `(page) => page`. */\n items: (page: Page) => T[];\n /** A stable key per item: merges pages, and is what `dismiss` takes. */\n itemKey: (item: T) => string;\n /** Whether the server says there is a page after this one. */\n hasMore: (lastPage: Page) => boolean;\n /** The cursor that asks for the items after this one; usually its id. Defaults to `itemKey`. */\n cursorAfter?: (item: T) => Cursor;\n /** Items hidden by someone else, usually `useUndoable().isRemoved`: treated like dismissed ones. */\n isRemoved?: (key: string) => boolean;\n describeError?: DescribeError;\n enabled?: boolean;\n staleTime?: number;\n};\n\ntype Dismissed = { query: string; keys: ReadonlySet<string> };\ntype PageParam<Cursor> = { cursor: Cursor | undefined };\n\n/** `useInfiniteQuery` for cursor-paged data, returned as an `InfiniteLoad<T>` for `InfiniteList` (or `DataView`). */\nexport function useInfiniteLoad<T, Page, Cursor = string, K extends QueryKey = QueryKey>({\n queryKey,\n queryFn,\n items,\n itemKey,\n hasMore,\n cursorAfter = itemKey as unknown as (item: T) => Cursor,\n isRemoved,\n describeError = describeHttpError,\n enabled,\n staleTime,\n}: InfiniteLoadOptions<T, Page, Cursor, K>): InfiniteLoad<T> {\n const queryHash = hashKey(queryKey);\n const [stored, setStored] = React.useState<Dismissed>(() => ({ query: queryHash, keys: new Set() }));\n const dismissed = stored.query === queryHash ? stored.keys : none;\n const hidden = React.useCallback((key: string) => dismissed.has(key) || (isRemoved?.(key) ?? false), [dismissed, isRemoved]);\n // TanStack calls getNextPageParam outside render; it reads the latest hidden set and accessors.\n const latest = React.useRef({ hidden, items, itemKey, hasMore, cursorAfter });\n latest.current = { hidden, items, itemKey, hasMore, cursorAfter };\n\n const query = useInfiniteQuery({\n queryKey,\n queryFn: ({ pageParam, signal }) => queryFn({ cursor: pageParam.cursor, signal }),\n initialPageParam: { cursor: undefined } as PageParam<Cursor>,\n getNextPageParam: (lastPage, pages): PageParam<Cursor> | null => {\n const l = latest.current;\n if (!l.hasMore(lastPage)) return null;\n const after = nextAfter(pages, l.items, l.itemKey, l.hidden);\n return { cursor: after === undefined ? undefined : l.cursorAfter(after) };\n },\n enabled,\n staleTime,\n });\n\n const pages = query.data?.pages;\n // Keyed on the pages and dismissals only, so inline `items`/`itemKey` arrows do not hand the\n // list a new array every render.\n const list = React.useMemo(\n () => (pages ? merge(pages, latest.current.items, latest.current.itemKey, hidden).held : undefined),\n [pages, hidden],\n );\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage, refetch } = query;\n const loadMore = React.useCallback(() => {\n if (hasNextPage && !isFetchingNextPage) void fetchNextPage();\n }, [hasNextPage, isFetchingNextPage, fetchNextPage]);\n const change = React.useCallback(\n (edit: (keys: Set<string>) => void) =>\n setStored((s) => {\n const keys = new Set(s.query === queryHash ? s.keys : none);\n edit(keys);\n return { query: queryHash, keys };\n }),\n [queryHash],\n );\n const dismiss = React.useCallback((key: string) => change((keys) => keys.add(key)), [change]);\n const restore = React.useCallback((key: string) => change((keys) => keys.delete(key)), [change]);\n\n const more: More = {\n hasMore: Boolean(hasNextPage),\n loadingMore: isFetchingNextPage,\n error: query.isFetchNextPageError ? describeError(query.error) : undefined,\n loadMore,\n };\n const extra = { more, itemKey, dismiss, restore };\n if (list) return { status: \"ready\", data: list, ...extra };\n if (query.status === \"error\") return { status: \"error\", message: describeError(query.error), retry: () => void refetch(), ...extra };\n return { status: \"loading\", ...extra };\n}\n\nconst none: ReadonlySet<string> = new Set();\n\n/** Every page's items, in order, once each by key: the ones held (not dismissed) and the last one seen. */\nfunction merge<T, Page>(pages: Page[], items: (page: Page) => T[], itemKey: (item: T) => string, hidden: (key: string) => boolean) {\n const seen = new Set<string>();\n const held: T[] = [];\n let last: T | undefined;\n let lastPageAddedAny = false;\n pages.forEach((page, p) => {\n for (const item of items(page)) {\n const key = itemKey(item);\n if (seen.has(key)) continue;\n seen.add(key);\n last = item;\n if (p === pages.length - 1) lastPageAddedAny = true;\n if (!hidden(key)) held.push(item);\n }\n });\n return { held, last, lastPageAddedAny };\n}\n\n/** The item the next page goes after: the last held, or the last seen when nothing is held or the last page brought nothing new. */\nfunction nextAfter<T, Page>(pages: Page[], items: (page: Page) => T[], itemKey: (item: T) => string, hidden: (key: string) => boolean) {\n const { held, last, lastPageAddedAny } = merge(pages, items, itemKey, hidden);\n if (held.length === 0 || (pages.length > 1 && !lastPageAddedAny)) return last;\n return held[held.length - 1];\n}\n"],"mappings":";;;;;;;;;;;AAwBA,IAAa,OAAO;AAIpB,IAAM,aAAkC;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;AAAI;AAC1E,IAAM,YAAY,OAAO,YAAY,WAAW,KAAK,GAAG,MAAM,CAAC,GAAG,OAAQ,CAAC,CAAC,CAAC;;AAsB7E,SAAgB,OAAO,OAAwB;CAC7C,MAAM,OAAO,iBAAiB,OAAO,QAAQ,IAAI,KAAK,KAAK;CAC3D,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,GAAG,MAAM,IAAI,WAAW,eAAe,KAAK,UAAU,OAAO,KAAK,CAAC,GAAG;CACrG,OAAO;AACT;AAEA,SAAS,aAAa,IAAwC;CAC5D,MAAM,UAAU,UAAqB,GAAG,OAAO,OAAO,KAAK,CAAC;CAC5D,OAAO,OAAO,OAAO,QAAQ;EAC3B;EACA,gBAAgB,UAAqB,GAAG,cAAc,OAAO,KAAK,CAAC;EACnE,cAAc,OAAkB,QAAmB,GAAG,YAAY,OAAO,KAAK,GAAG,OAAO,GAAG,CAAC;EAC5F,uBAAuB,GAAG,gBAAgB;CAC5C,CAAC;AACH;AAEA,SAAS,SAAS,IAAwC;CACxD,MAAM,UAAU,UAA2B,GAAG,OAAO,KAAK;CAC1D,OAAO,OAAO,OAAO,QAAQ;EAC3B;EACA,gBAAgB,UAA2B,GAAG,cAAc,KAAK;EACjE,uBAAuB,GAAG,gBAAgB;CAC5C,CAAC;AACH;;AAGA,SAAgB,aAAa,QAAgB,UAAyB,CAAC,GAAG;CACxE,MAAM,EAAE,aAAa;CACrB,MAAM,SAAS,SAAqC,aAAa,IAAI,KAAK,eAAe,QAAQ;EAAE,GAAG;EAAM;CAAS,CAAC,CAA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KAAA;GACjE;EAEc;EAAM;EAAS;EAAS;CAAQ;CAChD,IAAI,MAAM,OAAO;EAAE,QAAQ;EAAS,MAAM;EAAM,GAAG;CAAM;CACzD,IAAI,MAAM,WAAW,SAAS,OAAO;EAAE,QAAQ;EAAS,SAAS,cAAc,MAAM,KAAK;EAAG,aAAa,KAAK,QAAQ;EAAG,GAAG;CAAM;CACnI,OAAO;EAAE,QAAQ;EAAW,GAAG;CAAM;AACvC;AAEA,IAAM,uBAA4B,IAAI,IAAI;;AAG1C,SAAS,MAAe,OAAe,OAA4B,SAA8B,QAAkC;CACjI,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,OAAY,CAAC;CACnB,IAAI;CACJ,IAAI,mBAAmB;CACvB,MAAM,SAAS,MAAM,MAAM;EACzB,KAAK,MAAM,QAAQ,MAAM,IAAI,GAAG;GAC9B,MAAM,MAAM,QAAQ,IAAI;GACxB,IAAI,KAAK,IAAI,GAAG,GAAG;GACnB,KAAK,IAAI,GAAG;GACZ,OAAO;GACP,IAAI,MAAM,MAAM,SAAS,GAAG,mBAAmB;GAC/C,IAAI,CAAC,OAAO,GAAG,GAAG,KAAK,KAAK,IAAI;EAClC;CACF,CAAC;CACD,OAAO;EAAE;EAAM;EAAM;CAAiB;AACxC;;AAGA,SAAS,UAAmB,OAAe,OAA4B,SAA8B,QAAkC;CACrI,MAAM,EAAE,MAAM,MAAM,qBAAqB,MAAM,OAAO,OAAO,SAAS,MAAM;CAC5E,IAAI,KAAK,WAAW,KAAM,MAAM,SAAS,KAAK,CAAC,kBAAmB,OAAO;CACzE,OAAO,KAAK,KAAK,SAAS;AAC5B"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","_Fragment","_Fragment","defaultFormat","format","_Fragment","_Fragment"],"sources":["../src/lib/format.ts","../src/components/button.tsx","../src/components/checkbox.tsx","../src/components/async-button.tsx","../src/components/status.tsx","../src/components/metric.tsx","../src/components/meter.tsx","../src/components/composition.tsx","../src/components/link-card.tsx","../src/components/data-view.tsx","../src/lib/in-view.ts","../src/components/thumbnail.tsx","../src/components/disclosure.tsx","../src/components/selection.tsx","../src/components/data-table.tsx","../src/components/selectable-grid.tsx","../src/components/virtual-list.tsx","../src/components/infinite-list.tsx","../src/components/line-chart.tsx","../src/components/page-header.tsx","../src/components/undo.tsx","../src/components/done.tsx","../src/components/app-shell.tsx","../src/components/tabs.tsx","../src/components/hotkeys.tsx","../src/components/active-list.tsx","../src/query/infinite.ts"],"sourcesContent":["// Every number and date on screen goes through Intl, once, here. Units are joined with a\n// non-breaking space so \"212 °C\" never wraps between figure and unit. A product that is not\n// en-GB calls createFormat with its locale once and exports the result from its own lib.\n//\n// The number formatters are callable (`format.integer(n)`) because that is the form people reach\n// for (strata-react issue #12), and they keep Intl's methods (`format.integer.format(n)`,\n// `formatToParts`, `resolvedOptions`) so existing calls and Intl knowledge still work.\n//\n// Dates follow the same shape. Every date formatter is callable with a Date, an ISO string or\n// epoch milliseconds (`format.dateTime(row.at)`), because rows arrive from an API as ISO strings\n// and an app that has to wrap each one in `new Date(...)` soon builds its own Intl.DateTimeFormat\n// beside it instead (strata-react issue #31, from the Bright Horizons History screen). An invalid\n// date throws a RangeError naming the input rather than printing \"Invalid Date\" into a row.\n// `date` and `dateTime` use Intl's medium/short styles, so the locale decides the order\n// (\"8 Nov 2026, 06:05\" in en-GB, \"Nov 8, 2026, 6:05 AM\" in en-US) and nobody hand-writes a\n// pattern. `timeZone` is optional: left out, times are the viewer's; a product that shows a place's\n// times (a kiln in one room, a shop's opening hours) passes that place's zone once.\n//\n// Tests: the non-breaking space is a real character in the DOM. Testing Library's text matchers\n// (`getByText`, `toHaveTextContent`) collapse whitespace and match \"6 pieces\", but accessible-name\n// matching (`getByRole(\"heading\", { name: \"6 pieces\" })`) compares the name exactly and does not.\n// Build the expected string with the same formatter (`{ name: format.count(6, \"piece\") }`), or\n// use a regex with `\\s` (`/6\\spieces/`), which matches U+00A0.\n\nexport const NBSP = \" \";\n\n/** The decimal byte units `format.bytes` writes. */\nexport type ByteUnit = \"B\" | \"kB\" | \"MB\" | \"GB\" | \"TB\" | \"PB\";\nconst BYTE_UNITS: readonly ByteUnit[] = [\"B\", \"kB\", \"MB\", \"GB\", \"TB\", \"PB\"];\nconst BYTE_SIZE = Object.fromEntries(BYTE_UNITS.map((u, i) => [u, 1000 ** i])) as Record<ByteUnit, number>;\n\n/** An `Intl.NumberFormat` that can also be called directly: `f(n)` is `f.format(n)`. */\nexport type NumberFormatter = ((value: number | bigint) => string) & Pick<Intl.NumberFormat, \"format\" | \"formatToParts\" | \"resolvedOptions\">;\n\n/** What a date formatter accepts: a Date, an ISO 8601 string, or epoch milliseconds. */\nexport type DateInput = Date | string | number;\n\n/** An `Intl.DateTimeFormat` that can also be called directly, with a Date, an ISO string or epoch milliseconds. */\nexport type DateFormatter = ((value: DateInput) => string) & {\n format: (value: DateInput) => string;\n formatToParts: (value: DateInput) => Intl.DateTimeFormatPart[];\n formatRange: (start: DateInput, end: DateInput) => string;\n} & Pick<Intl.DateTimeFormat, \"resolvedOptions\">;\n\n/** Options shared by every date formatter one `createFormat` call makes. */\nexport interface FormatOptions {\n /** An IANA zone (\"Europe/London\", \"UTC\") to show times in. Left out, times are the viewer's own. */\n timeZone?: string;\n}\n\n/** A Date from a Date, an ISO string or epoch milliseconds; throws a RangeError naming the input when it is not a date. */\nexport function toDate(value: DateInput): Date {\n const date = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(date.getTime())) throw new RangeError(`Not a date: ${JSON.stringify(String(value))}`);\n return date;\n}\n\nfunction callableDate(df: Intl.DateTimeFormat): DateFormatter {\n const format = (value: DateInput) => df.format(toDate(value));\n return Object.assign(format, {\n format,\n formatToParts: (value: DateInput) => df.formatToParts(toDate(value)),\n formatRange: (start: DateInput, end: DateInput) => df.formatRange(toDate(start), toDate(end)),\n resolvedOptions: () => df.resolvedOptions(),\n });\n}\n\nfunction callable(nf: Intl.NumberFormat): NumberFormatter {\n const format = (value: number | bigint) => nf.format(value);\n return Object.assign(format, {\n format,\n formatToParts: (value: number | bigint) => nf.formatToParts(value),\n resolvedOptions: () => nf.resolvedOptions(),\n });\n}\n\n/** Intl formatters for one locale (and optionally one time zone): integers, decimals, percent, dates, times, units with a non-breaking space, byte sizes, and counted nouns. */\nexport function createFormat(locale: string, options: FormatOptions = {}) {\n const { timeZone } = options;\n const dates = (opts: Intl.DateTimeFormatOptions) => callableDate(new Intl.DateTimeFormat(locale, { ...opts, timeZone }));\n const integer = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }));\n const decimal = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }));\n const percent = callable(new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }));\n const clock = dates({ hour: \"2-digit\", minute: \"2-digit\" });\n const day = dates({ weekday: \"long\", day: \"numeric\", month: \"long\" });\n const shortDay = dates({ weekday: \"short\", hour: \"2-digit\", minute: \"2-digit\" });\n const date = dates({ dateStyle: \"medium\" });\n const dateTime = dates({ dateStyle: \"medium\", timeStyle: \"short\" });\n const withUnit = (value: number, unit: string, fmt: Pick<Intl.NumberFormat, \"format\"> = integer) =>\n `${fmt.format(value)}${NBSP}${unit}`;\n return {\n locale,\n /** The zone times are shown in, or `undefined` for the viewer's own. */\n timeZone,\n /** Whole numbers with grouping: `format.integer(1222)` is \"1,222\". */\n integer,\n /** One decimal place at most: `format.decimal(3.14)` is \"3.1\". */\n decimal,\n /** A ratio as a whole percent: `format.percent(0.42)` is \"42%\". */\n percent,\n /** A time of day: `format.clock(at)` is \"06:05\". */\n clock,\n /** A day without its year, for this week's things: `format.day(at)` is \"Sunday 8 November\". */\n day,\n /** A weekday and time, for chart axes and recent rows: `format.shortDay(at)` is \"Sun 06:05\". */\n shortDay,\n /** A date with its year, for a record or a deadline: `format.date(at)` is \"8 Nov 2026\". */\n date,\n /** A date and time, for a log or history row: `format.dateTime(at)` is \"8 Nov 2026, 06:05\". */\n dateTime,\n /** A figure and its unit joined by a non-breaking space (`NBSP`), so they never wrap apart. */\n withUnit,\n /** A temperature in °C, joined by a non-breaking space. */\n celsius: (value: number) => withUnit(value, \"°C\"),\n /**\n * A size in bytes in the largest decimal unit it reaches (kB, MB, GB, TB, as disks and\n * networks are sold): one decimal below 10 (\"5.2 GB\"), whole above (\"431 GB\"). Pass `unit`\n * to fix the unit, so figures compared side by side (\"431 of 466 GB\") share one.\n */\n bytes: (value: number, unit?: ByteUnit) => {\n const chosen = unit ?? [...BYTE_UNITS].reverse().find((u) => Math.abs(value) >= BYTE_SIZE[u]) ?? \"B\";\n const scaled = value / BYTE_SIZE[chosen];\n return withUnit(scaled, chosen, Math.abs(scaled) < 10 && chosen !== \"B\" ? decimal : integer);\n },\n /** The unit `bytes` would choose for a value, to share it across a set of figures. */\n byteUnit: (value: number): ByteUnit => [...BYTE_UNITS].reverse().find((u) => Math.abs(value) >= BYTE_SIZE[u]) ?? \"B\",\n /**\n * \"1 piece\", \"6 pieces\": the count and its noun, so copy never reads \"1 pieces\". They are\n * joined by a non-breaking space (`NBSP`), not a plain one: in a test, match with the same\n * call or a `\\s` regex, not a typed \"6 pieces\" string in a role's `name`.\n */\n count: (value: number, one: string, many = `${one}s`) =>\n `${integer.format(value)}${NBSP}${new Intl.PluralRules(locale).select(value) === \"one\" ? one : many}`,\n };\n}\n\nexport type Format = ReturnType<typeof createFormat>;\n\n/** The en-GB formatters. */\nexport const format = createFormat(\"en-GB\");\n","import * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\n\n// Variant names are shadcn's, so copied code and agents' prior knowledge still work. Two things\n// differ on purpose:\n// 1. The default variant is `outline`, not the filled accent. A bare <Button> is the restrained\n// one; the accent (`variant=\"default\"`) has to be asked for, once per view. Generated app screens\n// put the accent on every button; 12 of 23 real product screens had no filled primary at all.\n// 2. Heights come from --control-h, shared with Input and NativeSelect, so density changes move\n// every control together.\n// 3. `press`: the button gives 2% under a click or a finger, over 100ms. Buttons are used tens of\n// times a day, so that is all the motion they get (character.md, the frequency budget).\nexport const buttonVariants = cva(\n \"inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary-10\",\n outline: \"border border-input bg-background text-foreground hover:bg-muted\",\n secondary: \"bg-muted text-foreground hover:bg-neutral-4\",\n ghost: \"text-foreground hover:bg-muted\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-danger\",\n link: \"h-auto px-0 text-primary-11 underline underline-offset-4 hover:text-primary-12\",\n },\n size: {\n default: \"h-(--control-h) px-4\",\n sm: \"h-(--control-h-sm) px-3\",\n icon: \"size-(--control-h)\",\n },\n },\n defaultVariants: { variant: \"outline\", size: \"default\" },\n },\n);\n\nexport type ButtonProps = React.ComponentProps<\"button\"> &\n VariantProps<typeof buttonVariants> & { asChild?: boolean };\n\n/** A button with shadcn's variant names. The default variant is `outline`; ask for the filled accent (`variant=\"default\"`) once per view. `type` defaults to `button`. */\nexport function Button({ className, variant, size, asChild = false, type = \"button\", ...props }: ButtonProps) {\n const Comp = asChild ? Slot : \"button\";\n return <Comp type={asChild ? undefined : type} className={cn(buttonVariants({ variant, size }), className)} {...props} />;\n}\n\n// An icon-only button cannot be written without a name: `label` is required by the type, becomes\n// the accessible name, and doubles as the native tooltip. This makes the most common generated\n// accessibility defect (an unlabelled icon button) a compile error instead of an audit finding.\nexport type IconButtonProps = Omit<ButtonProps, \"size\" | \"children\" | \"aria-label\"> & {\n icon: IconComponent;\n label: string;\n};\n\n/** An icon-only button. `label` is required and becomes the accessible name and tooltip. */\nexport function IconButton({ icon: Icon, label, variant = \"ghost\", ...props }: IconButtonProps) {\n return (\n <Button size=\"icon\" variant={variant} aria-label={label} title={label} {...props}>\n <Icon aria-hidden />\n </Button>\n );\n}\n\n// A row action says what it does in the row (\"Withdraw\") and whom it does it to in its name\n// (\"Withdraw Tom Ellery\"): a table of eight \"Withdraw\" buttons is eight identical names in a\n// screen reader's list of controls. The name is an aria-label that starts with the visible verb,\n// so it meets WCAG 2.5.3 (label in name) and voice control still finds it by \"Withdraw\". Visually\n// hidden suffix text is not used: a hidden span joined to the verb did not form a name with its\n// space in dom-testing-library (strata-react issue #11). Ghost and small, one per row, shown only\n// on the rows where it applies; an icon-only row action is an `IconButton` whose `label` names the\n// row the same way. It keeps the row's pitch: rows with and without the action are the same height.\nexport type RowActionProps = Omit<ButtonProps, \"children\" | \"aria-label\" | \"asChild\"> & {\n /** The visible verb, sentence case: \"Withdraw\", \"Remove\". */\n label: string;\n /** What the row is, as a person would say it: \"Tom Ellery\", \"Moonbeam\". Completes the accessible name. */\n subject: string;\n icon?: IconComponent;\n};\n\n/** A small ghost action for one table row: shows `label`, and is named \"`label` `subject`\" so every row's action has its own name. */\nexport function RowAction({ label, subject, icon: Icon, variant = \"ghost\", size = \"sm\", className, ...props }: RowActionProps) {\n // -my-1.5 lets the 32px button sit in the 20px line of a table row, inside the row's padding, so\n // rows with an action keep the same pitch as rows without one.\n return (\n <Button variant={variant} size={size} aria-label={`${label} ${subject}`} className={cn(\"-my-1.5\", className)} {...props}>\n {Icon && <Icon aria-hidden />}\n {label}\n </Button>\n );\n}\n","import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// A checkbox cannot be written without a name: `label` is required, as `IconButton`'s is. Shown,\n// it sits beside the box inside one <label>, so the label and the control are a single target\n// with no dead zone between them (Vercel's interface guidelines; ux-design audit.md). Hidden\n// (`hideLabel`, for a table cell where the row already says what it is), it becomes the\n// accessible name through aria-label, never through visually hidden text: a hidden span inside a\n// label joined to a neighbour did not form a name with its space in dom-testing-library (strata-\n// react issue #11), and an aria-label leaves no room for that.\n//\n// It is the native control (an 18px box, `accent-primary`), so keyboard, forms and the platform's\n// own focus and checked rendering come free. `checked=\"mixed\"` is the indeterminate state a\n// select-all needs; React has no prop for it, so it is set on the element.\n//\n// `onCheckedChange` also says whether Shift was held, which is how a list of checkboxes extends a\n// range (strata-react issue #32). A change event carries no modifier keys, so the label notes Shift\n// on the press that leads to it: a mouse press anywhere on the target, or Space on the box.\n\n/** A checkbox with its label as one target. `label` is required; `checked=\"mixed\"` is indeterminate. */\nexport type CheckboxProps = Omit<React.ComponentProps<\"input\">, \"type\" | \"checked\" | \"onChange\" | \"aria-label\" | \"children\"> & {\n /** Names the checkbox. Shown beside it unless `hideLabel`. */\n label: string;\n /** Keep the label as the accessible name only, for a cell or toolbar where the context shows what it is. */\n hideLabel?: boolean;\n /** A muted second line under a shown label. */\n detail?: string;\n checked: boolean | \"mixed\";\n /** Called with the new state, and whether Shift was held (a range click or Shift+Space). */\n onCheckedChange: (checked: boolean, gesture: CheckboxGesture) => void;\n};\n\n/** How a checkbox was changed: `shiftKey` is true for Shift+click and Shift+Space, which extend a range in a list. */\nexport type CheckboxGesture = { shiftKey: boolean };\n\n/** A native checkbox and its label as one target. `label` is required; `hideLabel` keeps it as the accessible name only. */\nexport function Checkbox({ label, hideLabel = false, detail, checked, onCheckedChange, className, disabled, ...props }: CheckboxProps) {\n const ref = React.useRef<HTMLInputElement>(null);\n const shift = useShiftNote();\n React.useEffect(() => {\n if (ref.current) ref.current.indeterminate = checked === \"mixed\";\n }, [checked]);\n return (\n <label\n {...shift.handlers}\n className={cn(\n \"inline-flex min-h-6 min-w-6 items-start gap-3\",\n hideLabel && \"items-center justify-center\",\n disabled ? \"cursor-not-allowed opacity-50\" : \"cursor-pointer\",\n className,\n )}\n >\n <input\n ref={ref}\n type=\"checkbox\"\n checked={checked === true}\n aria-checked={checked === \"mixed\" ? \"mixed\" : undefined}\n aria-label={hideLabel ? label : undefined}\n disabled={disabled}\n onChange={(e) => onCheckedChange(e.target.checked, shift.take())}\n className={cn(\"size-4.5 shrink-0 accent-primary\", !hideLabel && \"mt-0.5\", disabled ? \"cursor-not-allowed\" : \"cursor-pointer\")}\n {...props}\n />\n {!hideLabel && (\n <span className=\"grid\">\n <span className=\"type-body\">{label}</span>\n {detail && <span className=\"type-body-sm text-muted-foreground\">{detail}</span>}\n </span>\n )}\n </label>\n );\n}\n\n/** Notes Shift on the press that leads to a checkbox's change event, which has no modifier keys of its own. */\nexport function useShiftNote() {\n const held = React.useRef(false);\n return React.useMemo(\n () => ({\n handlers: {\n onMouseDown: (e: React.MouseEvent) => void (held.current = e.shiftKey),\n onKeyDown: (e: React.KeyboardEvent) => void (held.current = e.shiftKey),\n },\n take: (): CheckboxGesture => {\n const shiftKey = held.current;\n held.current = false;\n return { shiftKey };\n },\n }),\n [],\n );\n}\n","import * as React from \"react\";\nimport { Check, CircleAlert, LoaderCircle } from \"lucide-react\";\nimport { Button, type ButtonProps } from \"./button\";\nimport { describeActionError } from \"../lib/errors\";\n\n// One object through its states: \"Book firing\" becomes \"Booking…\" becomes \"Booked\", in the same\n// button, rather than the button being swapped for a spinner. The labels are stacked in one grid\n// cell so the button is always as wide as its longest label and nothing around it shifts. The\n// button stays enabled until the request starts (so a person can always try), and the outcome is\n// announced politely for screen readers. When the action fails, the announcement carries what\n// went wrong in the product's words before the retry label (\"Kiln 2 is already booked. Try\n// again\"), because \"Try again\" alone does not say whether trying again can help.\n\nexport type Phase = \"idle\" | \"pending\" | \"done\" | \"error\";\n\nexport type AsyncLabels = {\n idle: string;\n /** Ends in an ellipsis: \"Saving…\", \"Booking…\". */\n pending: string;\n /** The same verb, finished: \"Saved\", \"Booked\". */\n done: string;\n error?: string;\n};\n\n/** One button through idle, pending, done and error, with the label changing in place and its width fixed by the longest label. The outcome is announced politely, with the error's own words when `error` is given. */\nexport function AsyncButton({\n phase,\n labels,\n error,\n disabled,\n ...props\n}: Omit<ButtonProps, \"children\"> & {\n phase: Phase;\n labels: AsyncLabels;\n /** What went wrong, in the product's words (`useAsyncAction`'s `error`). Announced with the error label when `phase` is `error`. */\n error?: string;\n}) {\n const errorLabel = labels.error ?? \"Try again\";\n const current = { idle: labels.idle, pending: labels.pending, done: labels.done, error: errorLabel }[phase];\n const Icon = { idle: null, pending: LoaderCircle, done: Check, error: CircleAlert }[phase];\n const announcement = phase === \"done\" ? labels.done : phase === \"error\" ? (error ? `${error} ${errorLabel}` : errorLabel) : \"\";\n\n return (\n <>\n <Button {...props} disabled={disabled || phase === \"pending\"} aria-disabled={phase === \"pending\" || undefined}>\n {Icon && <Icon aria-hidden className={phase === \"pending\" ? \"motion-safe:animate-spin\" : undefined} />}\n <span className=\"grid\">\n {[labels.idle, labels.pending, labels.done, errorLabel].map((l) => (\n <span key={l} aria-hidden={l !== current} className={l === current ? \"[grid-area:1/1]\" : \"invisible [grid-area:1/1]\"}>\n {l}\n </span>\n ))}\n </span>\n </Button>\n <span role=\"status\" className=\"sr-only\">\n {announcement}\n </span>\n </>\n );\n}\n\n/** Options for `useAsyncAction`. */\nexport type AsyncActionOptions = {\n /** How long `done` shows before returning to `idle`. Default 2000ms. */\n settleMs?: number;\n /** Called with whatever the action threw, once the `error` render has committed: for logging, or to move focus to the retry button or an error message. */\n onError?: (error: unknown) => void;\n /** Turns what was thrown into `error`'s sentence, in the product's words. Default `describeActionError`: HTTP status sentences for `fetchJson`'s `HttpError`, else the Error's message. */\n describeError?: (error: unknown) => string | undefined;\n};\n\n/** What `useAsyncAction` returns: the phase for `AsyncButton`, a stable `run`, and what went wrong while `phase` is `error`. */\nexport type AsyncAction<A extends unknown[]> = {\n phase: Phase;\n run: (...args: A) => Promise<void>;\n /** What went wrong, from `describeError`, while `phase` is `error`; otherwise undefined. Pass it to `AsyncButton`'s `error`. */\n error: string | undefined;\n};\n\n// The action and its options are read through a ref so `run` keeps one identity for the\n// component's life: a caller can pass an inline arrow without re-rendering every child that takes\n// `run`, and without the try/catch and error state each caller used to write to reach the phase.\n\n/** Runs an async action and reports its phase and error. `done` returns to `idle` after `settleMs`; `run` never changes identity. */\nexport function useAsyncAction<A extends unknown[]>(\n action: (...args: A) => Promise<unknown>,\n { settleMs = 2000, onError, describeError = describeActionError }: AsyncActionOptions = {},\n): AsyncAction<A> {\n const [state, setState] = React.useState<{ phase: Phase; error: string | undefined }>({ phase: \"idle\", error: undefined });\n const timer = React.useRef<number | undefined>(undefined);\n const unreported = React.useRef<{ thrown: unknown } | undefined>(undefined);\n const latest = React.useRef({ action, onError, settleMs, describeError });\n React.useLayoutEffect(() => {\n latest.current = { action, onError, settleMs, describeError };\n });\n React.useEffect(() => () => window.clearTimeout(timer.current), []);\n const run = React.useCallback(async (...args: A) => {\n window.clearTimeout(timer.current);\n setState({ phase: \"pending\", error: undefined });\n try {\n await latest.current.action(...args);\n setState({ phase: \"done\", error: undefined });\n timer.current = window.setTimeout(() => setState({ phase: \"idle\", error: undefined }), latest.current.settleMs);\n } catch (thrown) {\n unreported.current = { thrown };\n setState({ phase: \"error\", error: latest.current.describeError(thrown) });\n }\n }, []);\n // onError runs after the error render commits, not inside the catch: there the button is still\n // disabled from `pending` and an error message rendered on `error` does not exist yet, so a\n // callback that moves focus to either would find nothing to focus.\n React.useEffect(() => {\n if (state.phase !== \"error\" || !unreported.current) return;\n const { thrown } = unreported.current;\n unreported.current = undefined;\n latest.current.onError?.(thrown);\n }, [state]);\n return { phase: state.phase, run, error: state.error };\n}\n","import type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\n\n// Status is a word first. `children` is required and must be a string, so a status can never be a\n// bare coloured dot. The tint and ink come from the fixed status roles, which are kept apart from\n// the brand accent: pale tint, dark ink of the same hue, never a saturated chip with white text.\n// No pulsing variant exists; nothing on a status mark moves unless the data behind it is live.\n\nexport type Tone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst tones: Record<Tone, string> = {\n neutral: \"bg-muted text-muted-foreground\",\n info: \"bg-info-subtle text-info\",\n success: \"bg-success-subtle text-success\",\n warning: \"bg-warning-subtle text-warning\",\n danger: \"bg-danger-subtle text-danger\",\n};\n\n/** A status as a word on a pale tint of its tone, with an optional icon. Never colour alone. */\nexport function Status({\n tone,\n icon: Icon,\n children,\n className,\n}: {\n tone: Tone;\n icon?: IconComponent;\n children: string;\n className?: string;\n}) {\n return (\n <span\n className={cn(\n \"inline-flex items-center gap-1.5 whitespace-nowrap rounded-pill py-0.5 pr-2.5 pl-2 type-caption font-medium\",\n tones[tone],\n className,\n )}\n >\n {Icon && <Icon aria-hidden className=\"size-3.5 shrink-0\" />}\n {children}\n </span>\n );\n}\n","import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// Headline figures as one container split by hairlines, label over value: what real product screens\n// do, instead of four cards each with an icon in a tinted circle. There is deliberately no `icon`,\n// `sparkline` or `trend` prop. A change is written in words with its window (\"4 more than last\n// Thursday\"), because a green \"+12.5%\" pill says neither what changed nor since when, and the trend\n// gets its own chart.\n\n/** Headline figures as one description list split by hairlines. Holds `Metric`s. */\nexport function MetricStrip({ label, children, className }: { label: string; children: React.ReactNode; className?: string }) {\n return (\n <dl\n aria-label={label}\n className={cn(\n \"grid grid-cols-1 border-y border-border sm:auto-cols-fr sm:grid-flow-col sm:divide-x sm:divide-border\",\n className,\n )}\n >\n {children}\n </dl>\n );\n}\n\nexport type MetricProps = {\n label: string;\n /** Already formatted. Ink colour, 28px, tabular figures: never the brand colour, never 48px. */\n value: string;\n unit?: string;\n /** One sentence: the change in words with its window, or what the figure means right now. */\n note?: React.ReactNode;\n};\n\n/** One figure: label over value, an optional muted unit and a note that states any change in words with its window. */\nexport function Metric({ label, value, unit, note }: MetricProps) {\n return (\n <div className=\"grid content-start gap-0.5 border-border py-3 not-first:border-t sm:px-5 sm:not-first:border-t-0 sm:first:pl-0\">\n <dt className=\"type-label text-muted-foreground\">{label}</dt>\n <dd className=\"type-figure text-foreground\">\n {value}\n {unit && <span className=\"type-body text-muted-foreground\">{\" \" + unit}</span>}\n </dd>\n {note && <dd className=\"type-body-sm text-muted-foreground\">{note}</dd>}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { format } from \"../lib/format\";\nimport { cn } from \"../lib/utils\";\nimport { Status } from \"./status\";\n\n// A usage bar: how full one thing is (a disk, a quota, a kiln's shelves), for status dashboards\n// that otherwise hand-roll a div with a width (strata-react issue #25, from jburnhams/homepage).\n// The rules it encodes, from ux-research ui-library/components.md §3.8 and patterns.md §5:\n// - It is a `meter`, not a `progressbar`: a progress bar is a task moving to done, a meter is a\n// level that can go up or down. Its accessible name is what is measured (\"Disk /\") and its\n// value text says the reading in words (\"72% used\"), so a screen reader hears \"Disk /, meter,\n// 72% used\" rather than a bare 72.\n// - The figure is always printed beside the bar. A bar alone is read to ±10% at best.\n// - Thresholds are what the person compares against, so they are drawn on the track as notches,\n// like LineChart's `band`. Each threshold must name its state (\"Filling up\", \"Nearly full\"):\n// when the reading crosses one, the fill takes the status ink and the word is shown as a\n// `Status`, so colour is never the only cue. Thresholds are shares of `max` (0.8 is 80%),\n// because a dashboard of disks of different sizes shares one set of them.\n// - `worseWhen=\"lower\"` turns the thresholds round for levels where empty is the problem (a\n// battery, credit left): a threshold then applies at or below its share.\n// - Below every threshold the fill is one chart hue (`--chart-1` unless `colour` says otherwise),\n// the same default as LineChart, never the brand accent and never a status colour, since\n// \"fine\" needs no colour of its own.\n// - `hideLabel` is for a meter in a table row, where the row already says what it measures; the\n// label stays as the meter's accessible name.\n// - No animation on the fill: a dashboard re-renders readings, and a bar that slides on each one\n// draws the eye to nothing.\n\n/** A level on a `Meter` at which the reading changes state, with the word for that state. */\nexport type MeterThreshold = {\n /** A share of `max`, from 0 to 1: 0.8 is 80%. */\n at: number;\n tone: \"warning\" | \"danger\";\n /** What the state is called, in the product's words: \"Filling up\", \"Nearly full\". */\n label: string;\n};\n\nexport type MeterProps = {\n /** What is measured, such as \"Disk /\". The meter's accessible name. */\n label: string;\n value: number;\n /** The full scale, in the same units as `value`. Defaults to 1, so a share can be passed as is. */\n max?: number;\n /** The reading in words, shown beside the bar and used as `aria-valuetext`. Defaults to \"72% used\". */\n valueText?: string;\n /** A second line of fact, such as \"36 of 50 GB\". */\n detail?: React.ReactNode;\n thresholds?: MeterThreshold[];\n /** \"lower\" when an emptier reading is the worse one (a battery, credit left). */\n worseWhen?: \"higher\" | \"lower\";\n /** Keeps the label as the accessible name only, for a meter in a table row that names it. */\n hideLabel?: boolean;\n /** CSS colour for the fill below every threshold. Defaults to the first chart token. */\n colour?: string;\n className?: string;\n};\n\n/** The threshold a share has crossed, if any: the most severe one reached in the worse direction. */\nexport function crossedThreshold(\n share: number,\n thresholds: readonly MeterThreshold[] = [],\n worseWhen: \"higher\" | \"lower\" = \"higher\",\n): MeterThreshold | undefined {\n const reached = thresholds.filter((t) => (worseWhen === \"higher\" ? share >= t.at : share <= t.at));\n // The one furthest in the worse direction wins, so danger beats warning when both are reached.\n return reached.sort((a, b) => (worseWhen === \"higher\" ? b.at - a.at : a.at - b.at))[0];\n}\n\nconst fills = { warning: \"var(--warning)\", danger: \"var(--danger)\" } as const;\n\n/** How full one thing is: a labelled `meter` with its reading in words, threshold notches, and a status word once a threshold is crossed. */\nexport function Meter({\n label,\n value,\n max = 1,\n valueText,\n detail,\n thresholds,\n worseWhen = \"higher\",\n hideLabel = false,\n colour = \"var(--chart-1)\",\n className,\n}: MeterProps) {\n const labelId = React.useId();\n const statusId = React.useId();\n const detailId = React.useId();\n const share = max > 0 ? Math.min(1, Math.max(0, value / max)) : 0;\n const crossed = crossedThreshold(share, thresholds, worseWhen);\n const text = valueText ?? `${format.percent(share)} used`;\n const hasNote = Boolean(crossed || detail);\n // Two ids rather than one wrapper, so the description reads \"Nearly full, 431 GB of 466 GB\"\n // with a break between the parts instead of running them together.\n const describedBy = [crossed && statusId, detail && detailId].filter(Boolean).join(\" \") || undefined;\n\n const bar = (\n <div\n role=\"meter\"\n aria-labelledby={hideLabel ? undefined : labelId}\n aria-label={hideLabel ? label : undefined}\n aria-valuemin={0}\n aria-valuemax={max}\n aria-valuenow={Math.min(max, Math.max(0, value))}\n aria-valuetext={text}\n aria-describedby={describedBy}\n className=\"relative h-2 min-w-16 flex-1 overflow-hidden rounded-pill bg-muted\"\n >\n <div\n className=\"absolute inset-y-0 left-0\"\n style={{ width: `${share * 100}%`, background: crossed ? fills[crossed.tone] : colour }}\n />\n {/* Notches in the ground colour: the levels the reading is judged against. */}\n {thresholds?.map((t) => (\n <div\n key={t.at}\n className=\"absolute inset-y-0 w-0.5 -translate-x-1/2 bg-background\"\n style={{ left: `${Math.min(1, Math.max(0, t.at)) * 100}%` }}\n />\n ))}\n </div>\n );\n\n // The visible figure is the meter's value text, so it is hidden from the accessibility tree\n // rather than read twice.\n const figure = (\n <span aria-hidden className=\"shrink-0 type-body-sm tabular-nums text-foreground\">\n {text}\n </span>\n );\n\n const note = hasNote && (\n <div className=\"flex flex-wrap items-center gap-x-3 gap-y-1\">\n {crossed && (\n <span id={statusId} className=\"contents\">\n <Status tone={crossed.tone}>{crossed.label}</Status>\n </span>\n )}\n {detail && (\n <span id={detailId} className=\"type-body-sm text-muted-foreground tabular-nums\">\n {detail}\n </span>\n )}\n </div>\n );\n\n if (hideLabel) {\n return (\n <div className={cn(\"grid min-w-0 gap-1.5\", className)}>\n <div className=\"flex items-center gap-3\">\n {bar}\n {figure}\n </div>\n {note}\n </div>\n );\n }\n\n return (\n <div className={cn(\"grid min-w-0 gap-1.5\", className)}>\n <div className=\"flex items-baseline justify-between gap-3\">\n <span id={labelId} className=\"min-w-0 truncate type-label text-foreground\">\n {label}\n </span>\n {figure}\n </div>\n <div className=\"flex\">{bar}</div>\n {note}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { format } from \"../lib/format\";\nimport { cn } from \"../lib/utils\";\n\n// What a whole is made of (memory: used, cached, buffers, free; a kiln load: bisque, glaze, empty\n// shelves), as one stacked bar over a table. strata-react issue #25 asked for it after\n// jburnhams/homepage hand-rolled one. The rules, from ux-research ui-library/components.md §3.8\n// and patterns.md §5:\n// - Colour is never the only cue. The bar shows proportion at a glance; the table under it says\n// every part's name, amount and share in words, with a swatch that ties the row to its\n// segment. The bar is hidden from screen readers because the table already carries all of it.\n// - The parts stay in the order given, in the bar and the table, so the order is the caller's\n// meaning (used before cached before free), not sorted by size.\n// - Categorical colours come from `--chart-1…5` in order, which palette.mjs checks are told apart\n// by colour-blind readers. A sixth part has no token to take, so it must bring its own colour;\n// more than five parts usually means the small ones belong in an \"Other\" part.\n// - Segments are split by a 2px gap in the ground colour, so two neighbours of similar lightness\n// still read as two.\n// - When the parts do not fill the whole (`total` is larger than their sum), the remainder is the\n// empty track, and it must be named (`restLabel`, such as \"Free\"), so the table can say what the\n// gap is. Neither the remainder nor a part is ever left unlabelled.\n// - Values are formatted by the caller (`formatValue`), as LineChart's `formatY` is, so units stay\n// the product's; shares go through `format.percent` unless `formatShare` says otherwise.\n\n/** One part of a `CompositionBar`'s whole. */\nexport type CompositionPart = {\n /** Stable key for the part. */\n key: string;\n label: string;\n value: number;\n /** CSS colour for the segment and swatch. Defaults to the chart token for its position. */\n colour?: string;\n};\n\nexport type CompositionBarProps = {\n /** What the whole is, such as \"Memory\". Shown above the bar and names the table. */\n label: string;\n parts: CompositionPart[];\n formatValue: (value: number) => string;\n /** Formats a part's share of the whole (0 to 1). Defaults to `format.percent`. */\n formatShare?: (share: number) => string;\n /** Header of the parts column, for screen readers and over the table. Defaults to \"Part\". */\n partHeader?: string;\n /** Header of the amounts column. Defaults to \"Amount\". */\n valueHeader?: string;\n /** Header of the shares column. Defaults to \"Share\". */\n shareHeader?: string;\n className?: string;\n} & (\n | {\n /** The size of the whole, when the parts do not fill it. The remainder is the empty track. */\n total: number;\n /** What the remainder is called (\"Free\", \"Empty shelves\"). Required with `total`. */\n restLabel: string;\n }\n | { total?: undefined; restLabel?: undefined }\n);\n\nconst MAX_TOKENS = 5;\n\n/** A part's colour: its own, or the chart token for its position. Throws past the fifth token. */\nfunction colourFor(part: CompositionPart, index: number) {\n if (part.colour) return part.colour;\n if (index >= MAX_TOKENS) {\n throw new Error(\n `CompositionBar: part \"${part.label}\" is number ${index + 1}, and there are only ${MAX_TOKENS} chart colours. ` +\n `Combine the smallest parts into one \"Other\" part, or give this part a colour.`,\n );\n }\n return `var(--chart-${index + 1})`;\n}\n\n/** What a whole is made of: a stacked bar for proportion and a table that names every part, its amount and its share, so colour is never the only cue. */\nexport function CompositionBar({\n label,\n parts,\n formatValue,\n formatShare = format.percent,\n partHeader = \"Part\",\n valueHeader = \"Amount\",\n shareHeader = \"Share\",\n className,\n ...whole\n}: CompositionBarProps) {\n const captionId = React.useId();\n const sum = parts.reduce((n, p) => n + Math.max(0, p.value), 0);\n const total = Math.max(whole.total ?? sum, sum);\n const rest = whole.total !== undefined ? total - sum : 0;\n const shareOf = (value: number) => (total > 0 ? Math.max(0, value) / total : 0);\n const rows = parts.map((p, i) => ({ ...p, colour: colourFor(p, i), share: shareOf(p.value) }));\n\n return (\n <figure className={cn(\"grid min-w-0 gap-3\", className)}>\n <figcaption id={captionId} className=\"type-label text-foreground\">\n {label}\n </figcaption>\n <div aria-hidden className=\"flex h-3 gap-0.5 overflow-hidden rounded-pill bg-muted\">\n {rows\n .filter((r) => r.value > 0)\n .map((r) => (\n // Grow by share from a zero basis, so the gaps come out of every segment fairly and the\n // parts fill the track exactly. Shares, not raw values: flex-grow factors that sum to\n // less than 1 fill only that fraction of the track (found in review).\n <div key={r.key} className=\"h-full min-w-0\" style={{ flex: `${r.share} 1 0`, background: r.colour }} />\n ))}\n {rest > 0 && <div className=\"h-full min-w-0\" style={{ flex: `${shareOf(rest)} 1 0` }} />}\n </div>\n <table aria-labelledby={captionId} className=\"w-full border-collapse type-body-sm\">\n <thead className=\"sr-only\">\n <tr>\n <th scope=\"col\">{partHeader}</th>\n <th scope=\"col\">{valueHeader}</th>\n <th scope=\"col\">{shareHeader}</th>\n </tr>\n </thead>\n <tbody>\n {rows.map((r) => (\n <tr key={r.key} className=\"border-t border-border first:border-t-0\">\n <th scope=\"row\" className=\"py-1.5 pr-4 text-left font-normal\">\n <span className=\"inline-flex items-center gap-2\">\n <span aria-hidden className=\"size-3 shrink-0 rounded-control\" style={{ background: r.colour }} />\n {r.label}\n </span>\n </th>\n <td className=\"py-1.5 pr-4 text-right tabular-nums\">{formatValue(r.value)}</td>\n <td className=\"w-px py-1.5 text-right whitespace-nowrap text-muted-foreground tabular-nums\">\n {formatShare(r.share)}\n </td>\n </tr>\n ))}\n {whole.total !== undefined && (\n <tr className=\"border-t border-border\">\n <th scope=\"row\" className=\"py-1.5 pr-4 text-left font-normal\">\n <span className=\"inline-flex items-center gap-2\">\n {/* The empty track's colour with a hairline, so the swatch reads as \"nothing here\". */}\n <span aria-hidden className=\"size-3 shrink-0 rounded-control border border-border bg-muted\" />\n {whole.restLabel}\n </span>\n </th>\n <td className=\"py-1.5 pr-4 text-right tabular-nums\">{formatValue(rest)}</td>\n <td className=\"w-px py-1.5 text-right whitespace-nowrap text-muted-foreground tabular-nums\">\n {formatShare(shareOf(rest))}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </figure>\n );\n}\n","import * as React from \"react\";\nimport { Link, type To } from \"react-router\";\nimport { ArrowUpRight } from \"lucide-react\";\nimport { cn } from \"../lib/utils\";\n\n// A card that is a way to somewhere: an app on a homepage, a project in a list of projects.\n// strata-react issue #25 asked for it after jburnhams/homepage built `AppCard` by hand. A card is\n// right here because each destination *is* a separate object a person picks (ux-research\n// ui-library/patterns.md §3); a section of a screen is not, and gets space and hairlines instead.\n// - The whole card is the target, but it is one link with a short name. The link sits on the\n// title and its `::after` covers the card, so a pointer can press anywhere while a screen reader\n// hears \"Kiln log, link\" and then the description and status marks as its description, instead\n// of a link named with every word on the card. There is one tab stop per card.\n// - Because the whole card is one link, nothing else on it can be interactive (a button or a\n// second link inside a link is invalid and unreachable). `marks` is for `Status` words only.\n// - Status marks are words (`Status`), never a coloured dot in a corner.\n// - `to` is a route in this app (React Router's `Link`); `href` leaves it (a plain anchor) and is\n// marked with an arrow, so a person knows before pressing that they will leave.\n// - Hover and focus change the border and draw the ring around the card, not the title. There is\n// no lift, scale or shadow: elevation is for what floats above the page, and a card on a\n// homepage is pressed many times a day (ux-research ux-character.md, character by frequency).\n\n/** A destination card's props: `to` for a route in this app, or `href` for anywhere else, never both. */\nexport type LinkCardProps = (\n | {\n /** A route in this app, followed with React Router. */\n to: To;\n href?: undefined;\n }\n | {\n /** Somewhere outside this app; the card shows an arrow. */\n href: string;\n to?: undefined;\n }\n) & {\n /** The destination's name, and the link's accessible name. */\n title: string;\n /** One sentence on what is there. Read as the link's description. */\n description?: string;\n /** `Status` words about the destination (\"Running\", \"Updated today\"). Nothing interactive. */\n marks?: React.ReactNode;\n /** The title's element. h3 under a section heading; h2 when the cards are the page's sections. */\n as?: \"h2\" | \"h3\" | \"h4\";\n className?: string;\n};\n\n/** A destination as a card that is one link: its title is the link's name, the description and status marks are its description, and the whole card is the target. */\nexport function LinkCard({ title, description, marks, as: Heading = \"h3\", className, ...destination }: LinkCardProps) {\n const descriptionId = React.useId();\n const marksId = React.useId();\n const describedBy = [description && descriptionId, marks && marksId].filter(Boolean).join(\" \") || undefined;\n const linkClass =\n \"rounded-control outline-none after:absolute after:inset-0 after:rounded-surface\";\n\n return (\n <div\n className={cn(\n \"relative grid content-start gap-1.5 rounded-surface border border-border bg-background p-4 transition-state\",\n \"hover:border-muted-foreground has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ring\",\n className,\n )}\n >\n <Heading className=\"flex items-start justify-between gap-3 type-heading text-foreground\">\n {destination.href !== undefined ? (\n <>\n <a href={destination.href} aria-describedby={describedBy} className={linkClass}>\n {title}\n </a>\n <ArrowUpRight aria-hidden className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" />\n </>\n ) : (\n <Link to={destination.to} aria-describedby={describedBy} className={linkClass}>\n {title}\n </Link>\n )}\n </Heading>\n {description && (\n <p id={descriptionId} className=\"type-body-sm text-pretty text-muted-foreground\">\n {description}\n </p>\n )}\n {marks && (\n <div id={marksId} className=\"mt-1.5 flex flex-wrap gap-2\">\n {marks}\n </div>\n )}\n </div>\n );\n}\n\n/** A labelled list of `LinkCard`s in a grid: one column on a phone, up to three on a wide screen. */\nexport function LinkCardList({ label, children, className }: { label: string; children: React.ReactNode; className?: string }) {\n return (\n <ul aria-label={label} className={cn(\"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3\", className)}>\n {React.Children.toArray(children).map((child, i) => (\n <li key={React.isValidElement(child) && child.key != null ? child.key : i} className=\"grid\">\n {child}\n </li>\n ))}\n </ul>\n );\n}\n","import * as React from \"react\";\nimport { CircleAlert, History, RotateCcw } from \"lucide-react\";\nimport { Button } from \"./button\";\nimport { format } from \"../lib/format\";\nimport { cn } from \"../lib/utils\";\n\n// Every view of remote data goes through DataView, and DataView will not type-check without a\n// skeleton and an empty state. Generated UI renders the happy path; this makes the other three\n// states part of the component's signature rather than a review comment.\n//\n// A failed refresh is not a failed read (strata-react issue #26). Once data has arrived, a later\n// refetch that fails (a poll while the server restarts, a Try again on a flaky link) leaves the\n// data on screen with `stale` set: a polite notice above it says what happened, when the data\n// shown was read, and offers Try again. Swapping a whole dashboard for an error panel throws away\n// readings the person was using, and a silent failure lets them act on old numbers as if live, so\n// the data stays and its age is said in words. Only a read that never produced data is an error.\n\n/** Data still shown after a refresh failed: why the refresh failed, when the data was read, and the Try again. */\nexport type Stale = {\n /** Why the refresh failed, for a person: the sentence an error panel would have shown. */\n message: string;\n /** When the data on screen was read. */\n readAt: Date;\n /** Fetch again. */\n retry: () => void;\n /** A fetch is on its way (a Try again or the next poll). */\n retrying?: boolean;\n};\n\n/** The state of one remote read, for `DataView`: loading, failed with no data, or ready (and `stale` when a later refresh failed). */\nexport type Load<T> =\n | { status: \"loading\" }\n | { status: \"error\"; message: string; retry: () => void }\n | { status: \"ready\"; data: T; stale?: Stale };\n\n/** Every view of remote data: renders `skeleton` while loading, an alert with Try again on error, `empty` when `isEmpty`, else `children(data)`, under a `StaleNotice` when a refresh failed. The skeleton and empty state are required. */\nexport function DataView<T>({\n state,\n isEmpty,\n skeleton,\n empty,\n children,\n staleNotice = (stale) => <StaleNotice stale={stale} />,\n className,\n}: {\n state: Load<T>;\n /** When the loaded data counts as empty. For arrays, `(rows) => rows.length === 0`. */\n isEmpty: (data: T) => boolean;\n /** Mirrors the final layout, so nothing jumps when data arrives. Not a centred spinner. */\n skeleton: React.ReactNode;\n /** What goes here and how to add it. An `EmptyState`, not an illustration. */\n empty: React.ReactNode;\n children: (data: T) => React.ReactNode;\n /** Shown above the data when a refresh failed. Defaults to a `StaleNotice`; pass one with the product's words for what is old (\"Readings from 13:50\"). */\n staleNotice?: (stale: Stale) => React.ReactNode;\n className?: string;\n}) {\n return (\n <div className={cn(\"min-w-0\", className)} aria-busy={state.status === \"loading\" || undefined}>\n {state.status === \"loading\" && skeleton}\n {state.status === \"error\" && (\n <div role=\"alert\" className=\"flex flex-wrap items-start gap-3 rounded-surface bg-danger-subtle p-4 text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-5 shrink-0\" />\n <p className=\"min-w-0 flex-1 type-body\">{state.message}</p>\n <Button size=\"sm\" onClick={state.retry}>\n <RotateCcw aria-hidden />\n Try again\n </Button>\n </div>\n )}\n {state.status === \"ready\" && (\n <>\n {state.stale && staleNotice(state.stale)}\n {isEmpty(state.data) ? empty : children(state.data)}\n </>\n )}\n </div>\n );\n}\n\n/** When `readAt` was, for a person: the clock time today, else the weekday and time. */\nfunction readTime(readAt: Date, now = new Date()) {\n return readAt.toDateString() === now.toDateString() ? format.clock.format(readAt) : format.shortDay.format(readAt);\n}\n\n/** The notice over data whose refresh failed: what happened, how old the data shown is, and Try again. A polite status, not an alert: nothing was lost. */\nexport function StaleNotice({\n stale,\n shown,\n className,\n}: {\n stale: Stale;\n /** What is old, in the product's words, given when it was read (\"13:50\", or \"Sat 13:50\" before today). Defaults to \"Showing data from 13:50.\" */\n shown?: (when: string) => React.ReactNode;\n className?: string;\n}) {\n return (\n <div role=\"status\" className={cn(\"mb-4 flex flex-wrap items-start gap-3 rounded-surface bg-warning-subtle p-3 text-warning\", className)}>\n <History aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n <p className=\"min-w-0 flex-1 type-body-sm\">\n {stale.message} {shown ? shown(readTime(stale.readAt)) : `Showing data from ${readTime(stale.readAt)}.`}\n </p>\n <Button size=\"sm\" onClick={stale.retry} disabled={stale.retrying}>\n <RotateCcw aria-hidden />\n {stale.retrying ? \"Trying again…\" : \"Try again\"}\n </Button>\n </div>\n );\n}\n\n// An empty state teaches the next action. No illustration slot exists, on purpose.\n/** An empty state that teaches the next action: a title, a sentence and an action. No illustration slot, on purpose. */\nexport function EmptyState({ title, children, action }: { title: string; children?: React.ReactNode; action?: React.ReactNode }) {\n return (\n <div className=\"grid justify-items-start gap-2 border-y border-border py-6\">\n <p className=\"type-heading\">{title}</p>\n {children && <p className=\"max-w-prose type-body text-muted-foreground\">{children}</p>}\n {action && <div className=\"mt-2\">{action}</div>}\n </div>\n );\n}\n\n/** A placeholder block for a loading layout. Size it with layout classes so it mirrors the final content. */\nexport function Skeleton({ className }: { className?: string }) {\n return <div aria-hidden className={cn(\"rounded-control bg-muted motion-safe:animate-pulse\", className)} />;\n}\n","import * as React from \"react\";\n\n// One IntersectionObserver hook for everything that waits until it is near the screen: the\n// sentinel at the end of an InfiniteList and an image in a Thumbnail. Both watch from the nearest\n// `[data-strata-scroll]` region (a VirtualList's) or else the viewport, with a root\n// margin so the work starts before the element is reached. They differ in two ways, which are\n// options rather than two hooks:\n//\n// - `once`: an image, once asked for, stays asked for; scrolling it away again must not unload it.\n// A sentinel reports in and out of view every time.\n// - `unsupported`: where there is no IntersectionObserver (an old browser, a test without the\n// fake), an image loads at once, because a photo that never loads is worse than one loaded\n// early. A sentinel reports out of view, because InfiniteList's Show more button is the path\n// that always works.\n\n/** Options for {@link useInView}. */\nexport type InViewOptions = {\n /** Watch only while this is true. Default true. */\n active?: boolean;\n /** How far outside the scroll region still counts as in view (IntersectionObserver `rootMargin`). */\n rootMargin?: string;\n /** Stay in view after the first time, and stop watching. */\n once?: boolean;\n /** What to report where `IntersectionObserver` does not exist. Default false. */\n unsupported?: boolean;\n};\n\n/**\n * Whether an element is within `rootMargin` of its scroll region (the nearest\n * `[data-strata-scroll]` ancestor, else the viewport). Returns a callback ref, so it follows the\n * element as it mounts and unmounts.\n */\nexport function useInView({ active = true, rootMargin = \"0px\", once = false, unsupported = false }: InViewOptions = {}) {\n const [inView, setInView] = React.useState(false);\n const [el, setEl] = React.useState<Element | null>(null);\n const seen = once && inView;\n React.useEffect(() => {\n if (seen) return;\n if (!active || !el) {\n setInView(false);\n return;\n }\n if (typeof IntersectionObserver === \"undefined\") {\n setInView(unsupported);\n return;\n }\n const root = el.parentElement?.closest<HTMLElement>(\"[data-strata-scroll]\") ?? null;\n const observer = new IntersectionObserver((entries) => setInView(entries[entries.length - 1].isIntersecting), { root, rootMargin });\n observer.observe(el);\n return () => observer.disconnect();\n }, [active, el, rootMargin, seen, unsupported]);\n return { ref: setEl, inView };\n}\n","import * as React from \"react\";\nimport { ImageOff } from \"lucide-react\";\nimport { Skeleton } from \"./data-view\";\nimport { useInView } from \"../lib/in-view\";\nimport { cn } from \"../lib/utils\";\n\n// A photo or crop from an API, in a list, a table cell or a grid (strata-react issue #33, from\n// the Bright Horizons review app, where some crops 404 because the file is missing on disk). A\n// plain <img> gets three things wrong there, and each is a state generated UI leaves out:\n//\n// - it has no size until it loads, so the rows below jump as each one arrives. The box here has\n// its aspect ratio before anything is fetched, and the image is cropped (`cover`) or fitted\n// (`contain`) into it, so nothing moves.\n// - while it loads it is a blank, and on a slow connection a blank reads as \"no photo\". Here it\n// is a `Skeleton`, the same placeholder DataView's loading layouts are made of.\n// - when it fails it is the browser's broken-image icon and the alt text crammed into the box.\n// Here it says what happened in the product's words: `missing` is required (\"Photo not\n// found\"), for the same reason DataView requires `empty`. A record with no photo at all\n// (`src={null}`) shows the same words without a request.\n//\n// `alt` is required too; pass \"\" only when the name beside the thumbnail already says everything\n// it shows. The missing state is an `img` named \"<alt>: <missing>\", so a screen reader hears\n// which photo is gone. Thumbnails come in dozens, so the request waits until the box is near the\n// screen (`useInView`, the hook InfiniteList's sentinel uses, with the same scroll region and a\n// root margin), and once asked for it is not unloaded. `eager` is for the first few on screen.\n// There is no fade-in: a list of thumbnails is seen many times a day (ux-character.md, character\n// by frequency), so the photo simply replaces its skeleton.\n\n/** A width-over-height ratio: a number (`1.5`) or a fraction (`\"4/3\"`). */\nexport type AspectRatio = number | `${number}/${number}`;\n\n/** The thumbnail's props. */\nexport type ThumbnailProps = {\n /** The image URL. `null` when the record has no photo: the `missing` words show without a request. */\n src: string | null;\n /** What the photo shows (\"Celadon bowl, front\"). `\"\"` only when the text beside it already says it. */\n alt: string;\n /** What to show when there is no photo or it cannot be loaded, in the product's words: \"Photo not found\". */\n missing: string;\n /** Width over height. The box has this shape before the image loads. Default `1`. */\n aspect?: AspectRatio;\n /** `cover` crops to fill the box (default); `contain` fits the whole image in it. */\n fit?: \"cover\" | \"contain\";\n srcSet?: string;\n sizes?: string;\n /** Load at once rather than when near the screen: for the first few above the fold. */\n eager?: boolean;\n /** How far outside the scroll region the request starts (IntersectionObserver `rootMargin`). */\n rootMargin?: string;\n /** Layout at the call site: a width (`w-24`, `w-full`). The height follows from `aspect`. */\n className?: string;\n};\n\ntype Phase = \"loading\" | \"loaded\" | \"missing\";\n\nconst ratio = (aspect: AspectRatio) => (typeof aspect === \"number\" ? String(aspect) : aspect.replace(\"/\", \" / \"));\n\n/** A box of fixed aspect ratio for a remote image: a skeleton until it loads, the `missing` words if it cannot, and a request only when it nears the screen. `alt` and `missing` are required. */\nexport function Thumbnail({\n src,\n alt,\n missing,\n aspect = 1,\n fit = \"cover\",\n srcSet,\n sizes,\n eager = false,\n rootMargin = \"200px\",\n className,\n}: ThumbnailProps) {\n // The outcome is kept with the request it belongs to (`src` and `srcSet`, since the browser may\n // have loaded a candidate from either), so a new request starts loading again without an effect\n // to reset it, and a late event from the old image cannot mark the new one.\n const request = src ? `${src} ${srcSet ?? \"\"}` : null;\n const [result, setResult] = React.useState<{ request: string; ok: boolean } | null>(null);\n const phase: Phase = !request ? \"missing\" : result?.request === request ? (result.ok ? \"loaded\" : \"missing\") : \"loading\";\n const near = useInView({ active: !eager && !!src, rootMargin, once: true, unsupported: true });\n const requested = eager || near.inView;\n\n return (\n <div\n ref={near.ref}\n className={cn(\"relative overflow-hidden rounded-control bg-muted\", className)}\n style={{ aspectRatio: ratio(aspect) }}\n aria-busy={phase === \"loading\" || undefined}\n >\n {phase === \"loading\" && <Skeleton className=\"absolute inset-0\" />}\n {src && request && phase !== \"missing\" && requested && (\n <img\n key={request}\n src={src}\n srcSet={srcSet}\n sizes={sizes}\n alt={alt}\n decoding=\"async\"\n onLoad={() => setResult({ request, ok: true })}\n onError={() => setResult({ request, ok: false })}\n className={cn(\"absolute inset-0 size-full\", fit === \"cover\" ? \"object-cover\" : \"object-contain\", phase === \"loading\" && \"opacity-0\")}\n />\n )}\n {phase === \"missing\" && (\n <div\n role=\"img\"\n aria-label={alt ? `${alt}: ${missing}` : missing}\n className=\"absolute inset-0 grid content-center justify-items-center gap-0.5 p-1 text-center text-muted-foreground\"\n >\n <ImageOff aria-hidden className=\"size-4 shrink-0\" />\n <span className=\"type-caption text-balance\">{missing}</span>\n </div>\n )}\n </div>\n );\n}\n\n/** The loading shape of a `Thumbnail`, for a `DataView` skeleton: the same box and aspect ratio, so nothing moves when the list arrives. */\nexport function ThumbnailSkeleton({ aspect = 1, className }: { aspect?: AspectRatio; className?: string }) {\n return (\n <div aria-hidden className={cn(\"relative overflow-hidden rounded-control bg-muted\", className)} style={{ aspectRatio: ratio(aspect) }}>\n <Skeleton className=\"absolute inset-0\" />\n </div>\n );\n}\n","import * as React from \"react\";\nimport { ChevronRight } from \"lucide-react\";\nimport { useSearchParams } from \"react-router\";\nimport { cn } from \"../lib/utils\";\n\n// Show more of one thing in place: a batch's faces under its row in a history list, a firing's\n// pieces under its line in the log. Strata issue #34, from an app that wrote its own <details>.\n//\n// Not <details>. A closed <details> still mounts its content, so every row's detail component\n// runs, and a list of forty batches makes forty requests on load for bodies nobody opened. Here\n// the body is mounted only while it is open: a `useLoad` inside it runs on the first open, and on\n// a later open the query cache answers at once. Closed, nothing of the body is in the DOM.\n//\n// The trigger is a native button (Enter and Space, focus outline from the base layer) with\n// `aria-expanded`, and `aria-controls` naming the body while it exists (the WAI-ARIA disclosure\n// pattern). Focus stays on the button through open and close, so a keyboard user walks a list of\n// rows with Tab and opens each in place. The summary is the button's name, so it holds text and\n// marks (a Status, a count), never controls; actions for the row go in `actions`, beside it.\n//\n// No height animation: people open rows in a list many times a session, and character by\n// frequency (ux-research ux-character.md) gives frequent actions no motion. The chevron turns\n// with the state, which is the only signal besides the body itself.\n//\n// Many disclosures over one list share their state through `useExpanded`, which can keep it in\n// the URL (`?open=f-0412`), so an opened row survives a reload and can be linked. `DataTable`'s\n// `expansion` prop draws the same thing as a detail row under a table row.\n\n/** Open and closed disclosure state: controlled with `open` and `onOpenChange`, or uncontrolled from `defaultOpen`. */\nexport type DisclosureOpenProps =\n | { open: boolean; onOpenChange: (open: boolean) => void; defaultOpen?: never }\n | { open?: never; onOpenChange?: (open: boolean) => void; defaultOpen?: boolean };\n\nexport type DisclosureProps = DisclosureOpenProps & {\n /** The always-visible line, and the button's accessible name: text and marks, no controls. */\n summary: React.ReactNode;\n /** Mounted only while open, so a request inside runs when the person opens it. */\n children: React.ReactNode;\n /** Controls for the row (a `RowAction`), beside the summary and outside its button. */\n actions?: React.ReactNode;\n className?: string;\n};\n\n/** Shows more of one thing in place: a button with `aria-expanded` around `summary`, and a body mounted only while open (so a request inside it runs on first open). Controlled with `open`/`onOpenChange` or `useExpanded`, or uncontrolled with `defaultOpen`. */\nexport function Disclosure({ summary, children, actions, open, defaultOpen = false, onOpenChange, className }: DisclosureProps) {\n const [own, setOwn] = React.useState(defaultOpen);\n const isOpen = open ?? own;\n const bodyId = React.useId();\n const toggle = () => {\n if (open === undefined) setOwn(!isOpen);\n onOpenChange?.(!isOpen);\n };\n return (\n <div className={cn(\"min-w-0\", className)}>\n <div className=\"flex items-center gap-3\">\n <button\n type=\"button\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? bodyId : undefined}\n onClick={toggle}\n className=\"-mx-1 flex min-h-(--control-h-sm) min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-control px-1 text-left hover:bg-muted\"\n >\n <Chevron open={isOpen} />\n <span className=\"min-w-0 flex-1\">{summary}</span>\n </button>\n {actions && <div className=\"flex shrink-0 items-center gap-2\">{actions}</div>}\n </div>\n {isOpen && (\n <div id={bodyId} className=\"pt-2 pb-3 pl-6\">\n {children}\n </div>\n )}\n </div>\n );\n}\n\n/** The disclosure chevron: points right when closed, down when open. Shared with `DataTable`'s row toggle. */\nexport function Chevron({ open, className }: { open: boolean; className?: string }) {\n return <ChevronRight aria-hidden className={cn(\"size-4 shrink-0 text-muted-foreground\", open && \"rotate-90\", className)} />;\n}\n\n/** Which of many disclosures are open, by key: spread into `DataTable`'s `expansion`, or read with `isOpen`/`setOpen` for a list of `Disclosure`s. */\nexport type Expanded = {\n /** Keys of the open items. */\n expanded: ReadonlySet<string>;\n /** Replaces the open set. `DataTable` calls this. */\n onChange: (next: Set<string>) => void;\n isOpen: (key: string) => boolean;\n setOpen: (key: string, open: boolean) => void;\n collapseAll: () => void;\n};\n\nexport type ExpandedOptions = {\n /** Keep the open keys in this URL search parameter (`?open=a&open=b`), so an opened row can be linked and survives a reload. Needs a React Router context. */\n param?: string;\n /** Keys open at first. Ignored with `param`: there the URL says what is open, so a link that opens a row carries it. */\n initial?: Iterable<string>;\n /** Opening one closes the others (an accordion). Default false: people compare two rows. */\n single?: boolean;\n};\n\n/** Shared open state for the disclosures of one list or table, optionally kept in the URL (`param`). */\nexport function useExpanded(options: ExpandedOptions = {}): Expanded {\n // One of two hooks, chosen by whether `param` is given; a screen does not switch between the two\n // while mounted (as with DataTable's `sortParam`), so the hook order is stable.\n return options.param ? useUrlExpanded(options.param, options) : useLocalExpanded(options);\n}\n\nfunction api(expanded: ReadonlySet<string>, set: (next: Set<string>) => void, single?: boolean): Expanded {\n return {\n expanded,\n // With `single`, a change that opens a key keeps only that key, so `DataTable` (which calls\n // onChange with the whole set) gets the accordion too, not only `setOpen`.\n onChange: (next) => {\n const opened = single ? [...next].filter((k) => !expanded.has(k)) : [];\n set(opened.length ? new Set([opened[opened.length - 1]]) : next);\n },\n isOpen: (key) => expanded.has(key),\n setOpen: (key, open) => {\n const next = single ? new Set<string>() : new Set(expanded);\n if (open) next.add(key);\n else next.delete(key);\n set(next);\n },\n collapseAll: () => set(new Set()),\n };\n}\n\nfunction useLocalExpanded({ initial = [], single }: ExpandedOptions): Expanded {\n const [expanded, setExpanded] = React.useState<ReadonlySet<string>>(() => new Set(initial));\n return React.useMemo(() => api(expanded, setExpanded, single), [expanded, single]);\n}\n\nfunction useUrlExpanded(param: string, { single }: ExpandedOptions): Expanded {\n const [params, setParams] = useSearchParams();\n const fromUrl = params.getAll(param);\n const joined = fromUrl.join(\"\\u0000\");\n // `fromUrl` is a new array each render; its joined form is the dependency.\n const expanded = React.useMemo<ReadonlySet<string>>(() => new Set(fromUrl), [joined]);\n const set = React.useCallback(\n (next: Set<string>) =>\n setParams(\n (p) => {\n const out = new URLSearchParams(p);\n out.delete(param);\n for (const k of next) out.append(param, k);\n return out;\n },\n { replace: true },\n ),\n [param, setParams],\n );\n return React.useMemo(() => api(expanded, set, single), [expanded, set, single]);\n}\n","import * as React from \"react\";\nimport { X } from \"lucide-react\";\nimport { format as defaultFormat, type Format } from \"../lib/format\";\nimport { cn } from \"../lib/utils\";\nimport { Button } from \"./button\";\n\n// Select many, then act: the state (`useSelection`), and the bar that says how many are chosen and\n// holds what can be done to them (`BulkBar`). `DataTable`'s `selection` prop draws the checkboxes.\n//\n// The selection is pruned to the rows that exist. After a bulk removal, a refetch or a new filter,\n// a key whose row is gone is not counted and not acted on: the bar never says \"3 selected\" over\n// two visible rows, and an action never reaches a row the person cannot see. (Gmail and Linear\n// both drop a selection a filter hides; acting on hidden rows is how a bulk delete surprises.)\n//\n// Shift extends a range from the last row clicked, on every surface (`useSelectRows`), and\n// `initial` chooses a row when it first appears rather than only on mount, so a selection seeded\n// from data still applies once the data arrives (both from strata-react issue #32, a review screen\n// of face crops with the likely matches pre-chosen).\n//\n// The count is the bar's live region, and only the count: it is always mounted, so a screen reader\n// hears \"2 bookings selected\" on each change, and the buttons are outside it, so their names are\n// not read again with every tick. The actions are a labelled group. Per the research, at most one\n// of them is filled (`variant=\"default\"`), named with its verb and count (\"Withdraw 3\"), and a\n// reversible bulk removal goes through `useUndoable` like a single one, not through a confirm.\n\n/** Which rows start chosen: their keys, or a test on each row. Either applies to a row the first time it appears. */\nexport type InitialSelection<T> = Iterable<string> | ((row: T) => boolean);\n\ntype SelectionState = { keys: readonly string[]; seen: ReadonlySet<string>; raw: ReadonlySet<string> };\n\n// Bring the state up to the rows now shown: drop keys whose row has gone, and choose the rows seen\n// for the first time that `initial` names. A row seen before keeps the person's choice, even if it\n// left and came back (it returns unchosen, as it was forgotten when it left).\nfunction reconcile<T>(prev: SelectionState, rows: readonly T[], keys: readonly string[], initial: (row: T, key: string) => boolean): SelectionState {\n const present = new Set(keys);\n const raw = new Set([...prev.raw].filter((k) => present.has(k)));\n const seen = new Set(prev.seen);\n rows.forEach((row, i) => {\n const key = keys[i];\n if (seen.has(key)) return;\n seen.add(key);\n if (initial(row, key)) raw.add(key);\n });\n return { keys, seen, raw };\n}\n\nconst sameKeys = (a: readonly string[], b: readonly string[]) => a.length === b.length && a.every((k, i) => k === b[i]);\n\n/**\n * Chosen row keys, pruned to the rows that exist, and the calls that change them. Spread into\n * `DataTable`'s or `SelectableGrid`'s `selection` with a `rowLabel`. `initial` (keys, or a test on\n * the row) chooses each row the first time it appears, so a selection seeded from data that loads\n * later, or a next page, still starts right.\n */\nexport function useSelection<T>(rows: readonly T[], rowKey: (row: T) => string, initial: InitialSelection<T> = []) {\n // `initial` is read when a row first appears, so a new function each render is fine.\n const initialRef = React.useRef(initial);\n initialRef.current = initial;\n // Keys are read into a set once per `initial` value, not once per row: a single-use iterable (a\n // generator, `set.values()`) would otherwise be used up by the first row, and an array rebuilt\n // for every row. The set is kept for rows that arrive later.\n const initialKeys = React.useRef<{ source: InitialSelection<T>; keys: ReadonlySet<string> } | undefined>(undefined);\n const test = (row: T, key: string) => {\n const init = initialRef.current;\n if (typeof init === \"function\") return init(row);\n if (initialKeys.current?.source !== init) initialKeys.current = { source: init, keys: new Set(init) };\n return initialKeys.current.keys.has(key);\n };\n const keys = rows.map(rowKey);\n const [state, setState] = React.useState<SelectionState>(() =>\n reconcile({ keys: [], seen: new Set(), raw: new Set() }, rows, keys, test),\n );\n // Adjusted while rendering (React's pattern for state derived from props), not in an effect, so\n // the first paint of new rows already shows them chosen. Compared by key, not by array identity,\n // so `rows={data ?? []}` does not loop.\n let current = state;\n if (!sameKeys(state.keys, keys)) {\n current = reconcile(state, rows, keys, test);\n setState(current);\n }\n const selected = current.raw;\n // rowKey is usually an inline arrow, so it is left out of the dependencies: the rows change.\n const selectedRows = React.useMemo(() => rows.filter((r) => selected.has(rowKey(r))), [rows, selected]);\n // A key with no row is never kept, so an action never reaches a row the person cannot see.\n const onChange = React.useCallback(\n (next: Set<string>) =>\n setState((s) => {\n const present = new Set(s.keys);\n return { ...s, raw: new Set([...next].filter((k) => present.has(k))) };\n }),\n [],\n );\n const clear = React.useCallback(() => setState((s) => ({ ...s, raw: new Set() })), []);\n return { selected, selectedRows, count: selected.size, onChange, clear };\n}\n\n/** The part of a selection the surfaces drawing it (`DataTable`, `SelectableGrid`) need. */\ntype SelectionLike<T> = {\n selected: ReadonlySet<string>;\n onChange: (next: Set<string>) => void;\n isSelectable?: (row: T) => boolean;\n};\n\n/**\n * Selecting rows of a surface in the order it shows them: one row, a range with Shift, and all\n * shown. Shared by `DataTable` and `SelectableGrid`, so a range and select-all behave the same on\n * both. `rows` are in display order (after sorting) and include rows a virtualised surface has not\n * rendered.\n *\n * A range runs from the last row clicked (the anchor) to this one, over the selectable rows\n * between, and sets them all to this row's new state, as Gmail and Finder do: Shift-clicking an\n * unchosen row chooses the run, Shift-clicking a chosen one clears it. Every click moves the\n * anchor. An anchor that has left the rows (filtered, removed) makes the next Shift-click a plain\n * one.\n * @internal\n */\nexport function useSelectRows<T>(rows: readonly T[], rowKey: (row: T) => string, selection?: SelectionLike<T>) {\n const anchor = React.useRef<string | undefined>(undefined);\n const keys = selection ? rows.filter((r) => selection.isSelectable?.(r) ?? true).map(rowKey) : [];\n const chosen = selection ? keys.filter((k) => selection.selected.has(k)).length : 0;\n const allChecked: boolean | \"mixed\" = chosen === 0 ? false : chosen === keys.length ? true : \"mixed\";\n\n const toggle = (key: string, on: boolean, { shiftKey }: { shiftKey: boolean }) => {\n if (!selection) return;\n const next = new Set(selection.selected);\n const from = shiftKey && anchor.current !== undefined ? keys.indexOf(anchor.current) : -1;\n const to = keys.indexOf(key);\n if (from >= 0 && to >= 0) {\n const [a, b] = from < to ? [from, to] : [to, from];\n for (const k of keys.slice(a, b + 1)) {\n if (on) next.add(k);\n else next.delete(k);\n }\n } else if (on) next.add(key);\n else next.delete(key);\n anchor.current = key;\n selection.onChange(next);\n };\n\n // A full or mixed box clears what is shown; an empty one selects every selectable row shown.\n // Keys outside `rows` (filtered away) are left as they are.\n const toggleAll = () => {\n if (!selection) return;\n const next = new Set(selection.selected);\n if (allChecked === false) keys.forEach((k) => next.add(k));\n else keys.forEach((k) => next.delete(k));\n selection.onChange(next);\n };\n\n return { toggle, all: { checked: allChecked, toggle: toggleAll, disabled: keys.length === 0 } };\n}\n\n/** The bar for a selection: a polite live count (\"2 bookings selected\"), the bulk actions, and Clear selection. Renders only the live region while nothing is chosen. */\nexport function BulkBar({\n count,\n noun,\n onClear,\n children,\n format = defaultFormat,\n className,\n}: {\n count: number;\n /** What is chosen, singular, or singular and plural: `\"booking\"`, `[\"person\", \"people\"]`. */\n noun: string | [one: string, many: string];\n onClear: () => void;\n /** The actions. At most one filled button, named with its verb and count. */\n children: React.ReactNode;\n /** The product's formatters, for the count's figures and plural. Default en-GB. */\n format?: Format;\n className?: string;\n}) {\n const [one, many] = typeof noun === \"string\" ? [noun, `${noun}s`] : noun;\n const label = `${format.count(count, one, many)} selected`;\n return (\n <div\n className={cn(\n count > 0 && \"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-surface bg-surface-sunken py-1.5 pr-1.5 pl-3\",\n className,\n )}\n >\n <p aria-live=\"polite\" className={count > 0 ? \"type-label tabular-nums\" : \"sr-only\"}>\n {count > 0 ? label : `No ${many} selected`}\n </p>\n {count > 0 && (\n <div role=\"group\" aria-label={`Actions for the selected ${many}`} className=\"flex flex-1 flex-wrap items-center gap-2\">\n {children}\n <Button size=\"sm\" variant=\"ghost\" className=\"ml-auto\" onClick={onClear}>\n <X aria-hidden />\n Clear selection\n </Button>\n </div>\n )}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { ArrowDown, ArrowUp, ArrowUpDown } from \"lucide-react\";\nimport {\n flexRender,\n getCoreRowModel,\n getSortedRowModel,\n useReactTable,\n type ColumnDef,\n type SortingState,\n} from \"@tanstack/react-table\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport { useSearchParams } from \"react-router\";\nimport { cn } from \"../lib/utils\";\nimport { Checkbox } from \"./checkbox\";\nimport { Chevron } from \"./disclosure\";\nimport { useSelectRows } from \"./selection\";\n\n// The table real product screens use: 12px muted sentence-case headers, row rules (no zebra),\n// numbers right-aligned in tabular figures, one status mark and at most one action per row.\n// Sortable headers are buttons and look sortable; aria-sort says which way. The scroll container is\n// a labelled, focusable region so keyboard users can scroll a wide table.\n//\n// Underneath: TanStack Table for the row model and sorting, TanStack Virtual once a table passes\n// `virtualizeFrom` rows (only the visible rows are in the DOM; the header sticks). The column API\n// stays small on purpose (key, header, cell, numeric, sort), so a screen reads as a list of\n// decisions about columns, not as table plumbing. `sortParam` keeps the sort in the URL\n// (?sort=when.desc) so a sorted view can be linked and survives a reload.\n//\n// Selection is opt-in (`selection`), because checkboxes belong only where a bulk action exists\n// (one of 23 real product screens had them; a checkbox on every row is a generated-UI tell). When\n// it is on, the first column is a checkbox per row, named from the row (`rowLabel` is required),\n// disabled where `isSelectable` says no; the header's \"Select all shown\" covers the selectable rows\n// in `rows` (all of them, not only the rendered ones of a virtualised table) and is mixed when some\n// are chosen. Shift-click (or Shift+Space) chooses or clears the run from the last row clicked, in\n// the sorted order shown (`useSelectRows`, shared with `SelectableGrid`). Selected rows take the sunken fill, not a ring, so a selection never reads as focus.\n// The table only draws the selection; the state is the caller's, usually `useSelection`, and the\n// actions live in a `BulkBar`.\n//\n// Expansion is opt-in too (`expansion`): a row opens a detail row under it, for what belongs to\n// the row but would crowd the table (a firing's pieces, a batch's faces). It follows `Disclosure`:\n// the toggle is a button with `aria-expanded`, named for what it shows (`rowLabel`, \"Pieces in\n// firing 412\"), and the detail is mounted only while open, so a `useLoad` inside it runs on the\n// first open and not for every row on load. The detail row spans the data columns, starts under\n// the first of them, and has no rule between it and its row, so the two read as one. State is the\n// caller's, usually `useExpanded` (which can keep it in the URL). A virtualised table measures\n// each detail row, so details of any height scroll correctly.\n\nexport type Column<T> = {\n key: string;\n header: string;\n cell: (row: T) => React.ReactNode;\n /** Right-aligns and sets tabular figures. Use for every quantity. */\n numeric?: boolean;\n sort?: (a: T, b: T) => number;\n /** Cells that may hold long text get truncated rather than stretching the table. */\n truncate?: boolean;\n /** Keep the header for screen readers only, as for a column of row actions. `header` still names it. */\n hideHeader?: boolean;\n className?: string;\n};\n\n/** Row selection for a `DataTable`: the chosen row keys, how to change them, and how to name each row's checkbox. */\nexport type RowSelection<T> = {\n /** Keys (from `rowKey`) of the chosen rows. */\n selected: ReadonlySet<string>;\n onChange: (next: Set<string>) => void;\n /** Names the row in its checkbox (\"Select <rowLabel>\"). Required: an unnamed checkbox is a column of \"checkbox, not checked\". */\n rowLabel: (row: T) => string;\n /** Rows that cannot be chosen get a disabled checkbox and are left out of select-all. Default: every row. */\n isSelectable?: (row: T) => boolean;\n};\n\n/** Row expansion for a `DataTable`: the open row keys, how to change them, how to name each toggle, and the detail to show. */\nexport type RowExpansion<T> = {\n /** Keys (from `rowKey`) of the open rows. */\n expanded: ReadonlySet<string>;\n onChange: (next: Set<string>) => void;\n /** Names the row's toggle by what it shows: \"Pieces in firing 412\". Its state is `aria-expanded`, so the name stays the same open or closed. */\n rowLabel: (row: T) => string;\n /** The row's detail, mounted only while it is open. Return an element whose component makes any request, so the request runs on open. */\n detail: (row: T) => React.ReactNode;\n /** Rows with nothing to show get no toggle. Default: every row. */\n isExpandable?: (row: T) => boolean;\n};\n\nexport type Sort = { key: string; dir: \"ascending\" | \"descending\" };\n\nexport type DataTableProps<T> = {\n /** Names the table for screen readers and labels the scroll region. */\n caption: string;\n columns: Column<T>[];\n rows: T[];\n rowKey: (row: T) => string;\n initialSort?: Sort;\n /** Keep the sort in this URL search parameter. Needs a React Router context. */\n sortParam?: string;\n /** Row count from which only the visible rows render. Default 100. */\n virtualizeFrom?: number;\n /** Height of the scroll region once virtualised, in px. Default 480. */\n maxHeight?: number;\n /** Adds a checkbox column and \"Select all shown\". Use only where a `BulkBar` acts on the selection. */\n selection?: RowSelection<T>;\n /** Adds a toggle per row that opens a detail row under it. Spread `useExpanded()` in with a `rowLabel` and `detail`. */\n expansion?: RowExpansion<T>;\n className?: string;\n};\n\ntype SortState = [Sort | undefined, (next: Sort) => void];\n\nfunction useLocalSort(initial?: Sort): SortState {\n const [sort, setSort] = React.useState(initial);\n return [sort, setSort];\n}\n\n/** Reads a sort from its URL form (`pieces.desc`). */\nexport function parseSort(value: string | null): Sort | undefined {\n if (!value) return undefined;\n const [key, dir] = value.split(\".\");\n if (!key) return undefined;\n return { key, dir: dir === \"desc\" ? \"descending\" : \"ascending\" };\n}\n\n/** Writes a sort in its URL form (`pieces.desc`). */\nexport function serialiseSort(sort: Sort) {\n return `${sort.key}.${sort.dir === \"descending\" ? \"desc\" : \"asc\"}`;\n}\n\nfunction useUrlSort(param: string, initial?: Sort): SortState {\n const [params, setParams] = useSearchParams();\n const sort = parseSort(params.get(param)) ?? initial;\n const set = React.useCallback(\n (next: Sort) =>\n setParams(\n (p) => {\n const out = new URLSearchParams(p);\n out.set(param, serialiseSort(next));\n return out;\n },\n { replace: true },\n ),\n [param, setParams],\n );\n return [sort, set];\n}\n\n/** A table on TanStack Table: muted headers, row rules, right-aligned tabular numbers, sortable headers with `aria-sort`, virtualised from `virtualizeFrom` rows, sort optionally kept in the URL (`sortParam`). */\nexport function DataTable<T>(props: DataTableProps<T>) {\n // Two thin wrappers so each calls its hooks unconditionally.\n return props.sortParam ? <UrlSortedTable {...props} sortParam={props.sortParam} /> : <LocalSortedTable {...props} />;\n}\n\nfunction LocalSortedTable<T>(props: DataTableProps<T>) {\n return <Table {...props} sortState={useLocalSort(props.initialSort)} />;\n}\n\nfunction UrlSortedTable<T>(props: DataTableProps<T> & { sortParam: string }) {\n return <Table {...props} sortState={useUrlSort(props.sortParam, props.initialSort)} />;\n}\n\ntype Meta = { numeric?: boolean; truncate?: boolean; hideHeader?: boolean; className?: string };\n\nfunction Table<T>({\n caption,\n columns,\n rows,\n rowKey,\n sortState: [sort, setSort],\n virtualizeFrom = 100,\n maxHeight = 480,\n selection,\n expansion,\n className,\n}: DataTableProps<T> & { sortState: SortState }) {\n const baseId = React.useId();\n const defs = React.useMemo<ColumnDef<T>[]>(\n () =>\n columns.map((c) => ({\n id: c.key,\n // TanStack only sorts columns with an accessor; the row itself is enough, since the\n // column's own comparator does the work.\n accessorFn: (row) => row,\n header: c.header,\n cell: (info) => c.cell(info.row.original),\n enableSorting: Boolean(c.sort),\n sortingFn: c.sort ? (a, b) => c.sort!(a.original, b.original) : undefined,\n meta: { numeric: c.numeric, truncate: c.truncate, hideHeader: c.hideHeader, className: c.className } satisfies Meta,\n })),\n [columns],\n );\n\n const sorting: SortingState = sort && columns.some((c) => c.key === sort.key && c.sort)\n ? [{ id: sort.key, desc: sort.dir === \"descending\" }]\n : [];\n\n const table = useReactTable({\n data: rows,\n columns: defs,\n state: { sorting },\n getRowId: (row) => rowKey(row),\n getCoreRowModel: getCoreRowModel(),\n getSortedRowModel: getSortedRowModel(),\n // No pagination here, and expansion is the caller's state, not TanStack's: nothing to reset. Left on, TanStack resets the page\n // index whenever `rows` is a new array; a screen that filters its rows on every render (the\n // kiln room after Withdraw) then re-renders forever and the tab freezes. Found by the\n // example app's visual suite, which jsdom did not show.\n autoResetAll: false,\n });\n\n const toggle = (key: string) =>\n setSort({ key, dir: sort?.key === key && sort.dir === \"ascending\" ? \"descending\" : \"ascending\" });\n\n const modelRows = table.getRowModel().rows;\n const canExpand = (row: T) => expansion?.isExpandable?.(row) ?? true;\n // What the body draws, in order: every row, and a detail line after each open one. The\n // virtualiser counts these lines, so an open detail takes its own measured slot.\n const lines = React.useMemo(\n () =>\n expansion\n ? modelRows.flatMap((row) =>\n expansion.expanded.has(row.id) && canExpand(row.original)\n ? [{ row, detail: false }, { row, detail: true }]\n : [{ row, detail: false }],\n )\n : modelRows.map((row) => ({ row, detail: false })),\n // canExpand reads `expansion`, which is a dependency.\n [modelRows, expansion],\n );\n // In the order shown, so a Shift-click range runs down the sorted table, not the data's order.\n const sortedRows = React.useMemo(() => modelRows.map((r) => r.original), [modelRows]);\n const select = useSelectRows(sortedRows, rowKey, selection);\n const selectAll = selection ? select.all : undefined;\n const virtual = modelRows.length >= virtualizeFrom;\n const scroller = React.useRef<HTMLDivElement>(null);\n const virtualizer = useVirtualizer({\n count: virtual ? lines.length : 0,\n getScrollElement: () => scroller.current,\n estimateSize: (i) => (lines[i]?.detail ? 160 : 41),\n // Keyed by row and line kind, not by position: opening or closing a detail shifts every line\n // after it, and a measured detail height must stay with its detail, not pass to the row that\n // takes its index (rows are not measured, so a wrong height would never be corrected).\n getItemKey: (i) => (lines[i] ? `${lines[i].row.id}${lines[i].detail ? \"\\u0000detail\" : \"\"}` : i),\n overscan: 8,\n // Until the region is measured, assume it is full height: the first paint (and a test DOM\n // with no layout) shows the first page of rows instead of none.\n initialRect: { width: 0, height: maxHeight },\n });\n const items = virtual ? virtualizer.getVirtualItems() : [];\n const padTop = items.length ? items[0].start : 0;\n const padBottom = items.length ? virtualizer.getTotalSize() - items[items.length - 1].end : 0;\n const visible = virtual ? items.map((i) => ({ ...lines[i.index], index: i.index })) : lines.map((l, index) => ({ ...l, index }));\n const lead = (selection ? 1 : 0) + (expansion ? 1 : 0);\n\n return (\n <div\n ref={scroller}\n role=\"region\"\n aria-label={caption}\n tabIndex={0}\n className={cn(\"relative min-w-0 overflow-x-auto\", virtual && \"overflow-y-auto\", className)}\n style={virtual ? { maxHeight } : undefined}\n >\n <table className=\"w-full border-collapse type-body-sm\" aria-rowcount={virtual ? lines.length + 1 : undefined}>\n <caption className=\"sr-only\">{caption}</caption>\n <thead className={cn(virtual && \"sticky top-0 z-10 bg-background\")}>\n {table.getHeaderGroups().map((group) => (\n <tr key={group.id}>\n {selectAll && (\n <th scope=\"col\" className=\"w-8 py-2 pr-2 text-left align-bottom\">\n <Checkbox\n className=\"-my-1\"\n label=\"Select all shown\"\n hideLabel\n checked={selectAll.checked}\n disabled={selectAll.disabled}\n onCheckedChange={selectAll.toggle}\n />\n </th>\n )}\n {expansion && (\n <th scope=\"col\" className=\"w-10 py-2 pr-2\">\n <span className=\"sr-only\">Details</span>\n </th>\n )}\n {group.headers.map((header) => {\n const meta = header.column.columnDef.meta as Meta | undefined;\n const active = sort?.key === header.id && header.column.getCanSort() ? sort.dir : undefined;\n const Icon = active === \"ascending\" ? ArrowUp : active === \"descending\" ? ArrowDown : ArrowUpDown;\n const rendered = flexRender(header.column.columnDef.header, header.getContext());\n const label = meta?.hideHeader ? <span className=\"sr-only\">{rendered}</span> : rendered;\n return (\n <th\n key={header.id}\n scope=\"col\"\n aria-sort={active}\n className={cn(\n \"py-2 pr-4 text-left align-bottom type-caption text-muted-foreground last:pr-0\",\n meta?.numeric && \"text-right\",\n )}\n >\n {header.column.getCanSort() ? (\n <button\n type=\"button\"\n onClick={() => toggle(header.id)}\n className={cn(\n \"-mx-1 inline-flex cursor-pointer items-center gap-1 rounded-control px-1 transition-state hover:text-foreground\",\n meta?.numeric && \"flex-row-reverse\",\n active && \"text-foreground\",\n )}\n >\n {label}\n <Icon aria-hidden className={cn(\"size-3.5\", !active && \"opacity-50\")} />\n </button>\n ) : (\n label\n )}\n </th>\n );\n })}\n </tr>\n ))}\n </thead>\n <tbody>\n {padTop > 0 && <tr aria-hidden style={{ height: padTop }} />}\n {visible.map(({ row, detail, index }) => {\n const chosen = selection?.selected.has(row.id) ?? false;\n const detailId = `${baseId}-detail-${row.id}`;\n if (detail && expansion)\n return (\n <tr\n key={`${row.id}-detail`}\n ref={virtual ? virtualizer.measureElement : undefined}\n data-index={index}\n className={cn(chosen && \"bg-surface-sunken\")}\n aria-rowindex={virtual ? index + 2 : undefined}\n >\n {lead > 0 && <td colSpan={lead} />}\n <td id={detailId} colSpan={columns.length} className=\"pt-0.5 pb-4 align-top\">\n {expansion.detail(row.original)}\n </td>\n </tr>\n );\n const open = expansion?.expanded.has(row.id) ?? false;\n return (\n <tr\n key={row.id}\n className={cn(\"border-t border-border\", chosen && \"bg-surface-sunken\")}\n aria-rowindex={virtual ? index + 2 : undefined}\n >\n {selection && (\n <td className=\"w-8 py-2.5 pr-2 align-middle\">\n <Checkbox\n className=\"-my-0.5\"\n label={`Select ${selection.rowLabel(row.original)}`}\n hideLabel\n checked={chosen}\n disabled={!(selection.isSelectable?.(row.original) ?? true)}\n onCheckedChange={(on, gesture) => select.toggle(row.id, on, gesture)}\n />\n </td>\n )}\n {expansion && (\n <td className=\"w-10 py-2.5 pr-2 align-middle\">\n {canExpand(row.original) && (\n <button\n type=\"button\"\n aria-expanded={open}\n aria-controls={open ? detailId : undefined}\n aria-label={expansion.rowLabel(row.original)}\n title={expansion.rowLabel(row.original)}\n onClick={() => {\n const next = new Set(expansion.expanded);\n if (open) next.delete(row.id);\n else next.add(row.id);\n expansion.onChange(next);\n }}\n className=\"-my-1.5 grid size-(--control-h-sm) cursor-pointer place-items-center rounded-control hover:bg-muted\"\n >\n <Chevron open={open} />\n </button>\n )}\n </td>\n )}\n {row.getVisibleCells().map((cell) => {\n const meta = cell.column.columnDef.meta as Meta | undefined;\n return (\n <td\n key={cell.id}\n className={cn(\n \"py-2.5 pr-4 align-middle last:pr-0\",\n meta?.numeric && \"text-right tabular-nums\",\n meta?.truncate && \"max-w-48 truncate\",\n meta?.className,\n )}\n >\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </td>\n );\n })}\n </tr>\n );\n })}\n {padBottom > 0 && <tr aria-hidden style={{ height: padBottom }} />}\n </tbody>\n </table>\n </div>\n );\n}\n\n/** The loading placeholder for a `DataTable`, shaped like its rows. */\nexport function TableSkeleton({ rows = 4, columns = 5 }: { rows?: number; columns?: number }) {\n return (\n <div aria-hidden className=\"grid gap-0\">\n <div className=\"flex gap-4 py-2\">\n {Array.from({ length: columns }, (_, i) => (\n <div key={i} className=\"h-3 flex-1 rounded-control bg-muted\" />\n ))}\n </div>\n {Array.from({ length: rows }, (_, r) => (\n <div key={r} className=\"flex gap-4 border-t border-border py-3.5\">\n {Array.from({ length: columns }, (_, i) => (\n <div key={i} className=\"h-4 flex-1 rounded-control bg-muted motion-safe:animate-pulse\" />\n ))}\n </div>\n ))}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport { cn } from \"../lib/utils\";\nimport { Checkbox, useShiftNote, type CheckboxGesture } from \"./checkbox\";\nimport type { RowSelection } from \"./data-table\";\nimport { useSelectRows } from \"./selection\";\n\n// Choosing from pictures: a review screen of face crops, a set of glaze test tiles, photos to\n// archive. It is `DataTable`'s selection drawn as a grid (strata-react issue #32, from the Bright\n// Horizons port, where the Groups screen had to be built by hand from `Checkbox` and\n// `useSelection`), and it shares the state and the rules: `useSelection` holds the keys, a\n// `BulkBar` holds the actions, select-all covers the selectable tiles shown (all of them, rendered\n// or not) and is mixed when some are chosen, and Shift-click or Shift+Space chooses or clears the\n// run from the last tile clicked (`useSelectRows`, the same code the table uses).\n//\n// Each tile is one target: the picture, the box and the detail line sit in one <label>, so a click\n// anywhere on the picture toggles it (Google Photos and Apple Photos select from the picture, not\n// only from the box). The box is named from the row (`rowLabel` is required, as the table's is),\n// so a screen reader hears \"Select Ada Lovelace, crop 3\", not twelve \"checkbox, not checked\". The\n// box sits on a chip of the page's ground in the picture's corner, so it stays visible on any\n// photo. A chosen tile takes the sunken fill and a primary border, not a ring: the focus outline is\n// the only ring, so a selection never reads as focus.\n//\n// The picture is the caller's (`renderImage`), in a frame of fixed aspect (`aspect`, square by\n// default) so tiles line up and nothing shifts as images load; an <img> or Strata's `Thumbnail`\n// fills it. Tiles are sized by a minimum width (`tileSize`) and fill the row. From\n// `virtualizeFrom` tiles (100, as the table and list) the grid renders only the visible rows of\n// tiles in a labelled, focusable scroll region, measuring its width to know how many fit a row.\n\n/** The frame each picture is drawn in. */\nexport type TileAspect = \"square\" | \"portrait\" | \"landscape\";\n\n/** Smallest tile width: `sm` 96px (dense crops), `md` 144px, `lg` 192px. Tiles grow to fill the row. */\nexport type TileSize = \"sm\" | \"md\" | \"lg\";\n\nexport type SelectableGridProps<T> = {\n /** Names the list of tiles (and its scroll region once virtualised). */\n label: string;\n rows: T[];\n rowKey: (row: T) => string;\n /** The picture, drawn to fill a frame of `aspect`. An `<img className=\"size-full object-cover\">` or a `Thumbnail`. */\n renderImage: (row: T) => React.ReactNode;\n /** A short line under the picture (a name, a date, a score). Truncated to one line. */\n detail?: (row: T) => React.ReactNode;\n /** The chosen keys and how to change them, as `DataTable` takes them; `rowLabel` names each tile's box. */\n selection: RowSelection<T>;\n /** Default `square`. `portrait` is 3:4, `landscape` 4:3. */\n aspect?: TileAspect;\n /** Default `md`. */\n tileSize?: TileSize;\n /** Tile count from which only the visible rows of tiles render. Default 100. */\n virtualizeFrom?: number;\n /** Height of the scroll region once virtualised, in px. Default 480. */\n maxHeight?: number;\n className?: string;\n};\n\nconst minWidth: Record<TileSize, number> = { sm: 96, md: 144, lg: 192 };\nconst aspectClass: Record<TileAspect, string> = { square: \"aspect-square\", portrait: \"aspect-3/4\", landscape: \"aspect-4/3\" };\nconst aspectRatio: Record<TileAspect, number> = { square: 1, portrait: 4 / 3, landscape: 3 / 4 };\n// gap-3, in px, for the column count of a virtualised grid.\nconst GAP = 12;\n// The detail line and the tile's padding, for the first estimate of a row's height.\nconst TILE_CHROME = 40;\n\n/** A grid of pictures to choose from: each tile one labelled target, \"Select all shown\", Shift-click ranges, virtualised from `virtualizeFrom` tiles. Pair with `useSelection` and a `BulkBar`. */\nexport function SelectableGrid<T>({\n label,\n rows,\n rowKey,\n renderImage,\n detail,\n selection,\n aspect = \"square\",\n tileSize = \"md\",\n virtualizeFrom = 100,\n maxHeight = 480,\n className,\n}: SelectableGridProps<T>) {\n const select = useSelectRows(rows, rowKey, selection);\n const virtual = rows.length >= virtualizeFrom;\n\n const tile = (row: T, index: number) => {\n const key = rowKey(row);\n return (\n <Tile\n name={`Select ${selection.rowLabel(row)}`}\n chosen={selection.selected.has(key)}\n disabled={!(selection.isSelectable?.(row) ?? true)}\n onChange={(on, gesture) => select.toggle(key, on, gesture)}\n aspect={aspect}\n image={renderImage(row)}\n detail={detail?.(row)}\n index={index}\n />\n );\n };\n\n return (\n <div className={cn(\"grid min-w-0 gap-3\", className)}>\n <Checkbox\n className=\"justify-self-start\"\n label=\"Select all shown\"\n checked={select.all.checked}\n disabled={select.all.disabled}\n onCheckedChange={select.all.toggle}\n />\n {virtual ? (\n <VirtualTiles label={label} rows={rows} rowKey={rowKey} tile={tile} aspect={aspect} tileSize={tileSize} maxHeight={maxHeight} />\n ) : (\n <ul\n aria-label={label}\n className=\"grid gap-3\"\n style={{ gridTemplateColumns: `repeat(auto-fill, minmax(min(${minWidth[tileSize]}px, 100%), 1fr))` }}\n >\n {rows.map((row, i) => (\n <li key={rowKey(row)}>{tile(row, i)}</li>\n ))}\n </ul>\n )}\n </div>\n );\n}\n\nfunction VirtualTiles<T>({\n label,\n rows,\n rowKey,\n tile,\n aspect,\n tileSize,\n maxHeight,\n}: {\n label: string;\n rows: T[];\n rowKey: (row: T) => string;\n tile: (row: T, index: number) => React.ReactNode;\n aspect: TileAspect;\n tileSize: TileSize;\n maxHeight: number;\n}) {\n const scroller = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n React.useLayoutEffect(() => {\n const el = scroller.current;\n if (!el || typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(([entry]) => setWidth(entry.contentRect.width));\n observer.observe(el);\n return () => observer.disconnect();\n }, []);\n const min = minWidth[tileSize];\n const columns = Math.max(1, Math.floor((width + GAP) / (min + GAP)));\n const tileWidth = width > 0 ? (width - GAP * (columns - 1)) / columns : min;\n const lines = Math.ceil(rows.length / columns);\n const virtualizer = useVirtualizer({\n count: lines,\n getScrollElement: () => scroller.current,\n estimateSize: () => Math.round(tileWidth * aspectRatio[aspect]) + TILE_CHROME + GAP,\n overscan: 3,\n // Keyed by the column count as well as the row: a new count moves every tile to another row,\n // so each row of tiles is a new element, measured afresh, not an old height reused.\n getItemKey: (i) => `${columns}:${i}`,\n // Until the region is measured, assume it is full height, so the first paint shows tiles.\n initialRect: { width: 0, height: maxHeight },\n });\n const items = virtualizer.getVirtualItems();\n\n return (\n <div\n ref={scroller}\n role=\"region\"\n aria-label={label}\n tabIndex={0}\n data-strata-scroll=\"\"\n className=\"min-w-0 overflow-y-auto\"\n style={{ height: maxHeight }}\n >\n {/* role=\"list\" over plain rows of tiles: each row is laid out on its own, and the rows add nothing for a screen reader. */}\n <div role=\"list\" aria-label={label} className=\"relative w-full\" style={{ height: virtualizer.getTotalSize() }}>\n {items.map((v) => {\n const start = v.index * columns;\n return (\n <div\n key={v.key}\n ref={virtualizer.measureElement}\n data-index={v.index}\n role=\"none\"\n className=\"absolute inset-x-0 top-0 grid gap-3 pb-3\"\n style={{ translate: `0 ${v.start}px`, gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` }}\n >\n {rows.slice(start, start + columns).map((row, i) => (\n <div key={rowKey(row)} role=\"listitem\" aria-setsize={rows.length} aria-posinset={start + i + 1}>\n {tile(row, start + i)}\n </div>\n ))}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\nfunction Tile({\n name,\n chosen,\n disabled,\n onChange,\n aspect,\n image,\n detail,\n index,\n}: {\n name: string;\n chosen: boolean;\n disabled: boolean;\n onChange: (on: boolean, gesture: CheckboxGesture) => void;\n aspect: TileAspect;\n image: React.ReactNode;\n detail?: React.ReactNode;\n index: number;\n}) {\n const shift = useShiftNote();\n return (\n <label\n {...shift.handlers}\n data-index={index}\n className={cn(\n // select-none: a Shift-click range would otherwise also select the text between the tiles.\n \"relative grid min-w-0 gap-1.5 rounded-surface border border-transparent p-1.5 select-none transition-state\",\n chosen && \"border-primary bg-surface-sunken\",\n disabled ? \"cursor-not-allowed opacity-50\" : \"cursor-pointer hover:bg-surface-sunken\",\n )}\n >\n <span className={cn(\"block overflow-hidden rounded-control bg-muted *:size-full *:object-cover\", aspectClass[aspect])}>\n {image}\n </span>\n <span className=\"absolute top-3 left-3 grid size-7 place-items-center rounded-control bg-background\">\n <input\n type=\"checkbox\"\n aria-label={name}\n checked={chosen}\n disabled={disabled}\n onChange={(e) => onChange(e.target.checked, shift.take())}\n className={cn(\"size-4.5 accent-primary\", disabled ? \"cursor-not-allowed\" : \"cursor-pointer\")}\n />\n </span>\n {detail != null && <span className=\"truncate type-body-sm text-muted-foreground\">{detail}</span>}\n </label>\n );\n}\n","import * as React from \"react\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport { cn } from \"../lib/utils\";\n\n// A long list that keeps only its visible rows in the DOM (TanStack Virtual), for feeds, logs and\n// pickers with hundreds of items. Rows are measured after render, so variable heights work; the\n// estimate only sets the first paint. The list is a labelled, focusable region so it can be\n// scrolled from the keyboard, and keeps list semantics with aria-setsize/aria-posinset so screen\n// readers still hear \"12 of 480\". Under `virtualizeFrom` items it renders a plain list.\n//\n// `bounded` keeps a short list in the same scroll region (capped at `height`) that the virtual\n// one uses, so a list that grows past `virtualizeFrom` while someone scrolls it (InfiniteList)\n// does not jump from the page's flow into a box. `footer` renders after the last row, inside the\n// scroll region: where InfiniteList puts its next-page row. Rows carry `data-index` in both modes.\n\n/** A list that renders only its visible rows (TanStack Virtual) from `virtualizeFrom` items, keeping list semantics for screen readers. */\nexport function VirtualList<T>({\n label,\n items,\n itemKey,\n children,\n estimateSize = 48,\n height = 480,\n virtualizeFrom = 100,\n bounded = false,\n footer,\n className,\n}: {\n label: string;\n items: T[];\n itemKey: (item: T) => string;\n children: (item: T, index: number) => React.ReactNode;\n estimateSize?: number;\n height?: number;\n virtualizeFrom?: number;\n /** Scroll inside a region capped at `height` even below `virtualizeFrom`, so growing past it changes nothing on screen. */\n bounded?: boolean;\n /** After the last row, inside the scroll region (a next-page row, an end note). */\n footer?: React.ReactNode;\n className?: string;\n}) {\n const scroller = React.useRef<HTMLDivElement>(null);\n const virtual = items.length >= virtualizeFrom;\n const virtualizer = useVirtualizer({\n count: virtual ? items.length : 0,\n getScrollElement: () => scroller.current,\n estimateSize: () => estimateSize,\n overscan: 6,\n initialRect: { width: 0, height },\n });\n\n // Built only when it is shown: a virtual list must not render every row it keeps out of the DOM.\n const plain = () => (\n <ul aria-label={label} className={cn(\"grid min-w-0\", !bounded && !footer && className)}>\n {items.map((item, i) => (\n <li key={itemKey(item)} data-index={i} className=\"border-t border-border first:border-t-0\">\n {children(item, i)}\n </li>\n ))}\n </ul>\n );\n\n if (!virtual && !bounded) {\n return footer ? (\n <div className={cn(\"min-w-0\", className)}>\n {plain()}\n {footer}\n </div>\n ) : (\n plain()\n );\n }\n\n return (\n <div\n ref={scroller}\n role=\"region\"\n aria-label={label}\n tabIndex={0}\n data-strata-scroll=\"\"\n className={cn(\"min-w-0 overflow-y-auto\", className)}\n style={virtual ? { height } : { maxHeight: height }}\n >\n {virtual ? (\n <ul aria-label={label} className=\"relative w-full\" style={{ height: virtualizer.getTotalSize() }}>\n {virtualizer.getVirtualItems().map((v) => {\n const item = items[v.index];\n return (\n <li\n key={itemKey(item)}\n ref={virtualizer.measureElement}\n data-index={v.index}\n aria-setsize={items.length}\n aria-posinset={v.index + 1}\n className={cn(\"absolute inset-x-0 top-0\", v.index > 0 && \"border-t border-border\")}\n style={{ translate: `0 ${v.start}px` }}\n >\n {children(item, v.index)}\n </li>\n );\n })}\n </ul>\n ) : (\n plain()\n )}\n {footer}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { CircleAlert, RotateCcw } from \"lucide-react\";\nimport { Button } from \"./button\";\nimport { DataView } from \"./data-view\";\nimport { VirtualList } from \"./virtual-list\";\nimport type { InfiniteLoad } from \"../query/infinite\";\nimport { useInView } from \"../lib/in-view\";\n\n// A list that loads its next page as the person nears the end: the view for `useInfiniteLoad`.\n// It is DataView for the first page (skeleton, error with Try again, empty state, all required)\n// and VirtualList for the rows (virtualised from 100, so a long session stays fast), with one row\n// after the last item that is always in one of four states:\n//\n// - more to come: an IntersectionObserver sentinel with a root margin, so the next page is asked\n// for before the person reaches the end, and a real \"Show more\" button behind it. The button is\n// the keyboard and screen-reader path (an automatic load is invisible to them) and the fallback\n// where the observer never fires.\n// - loading: `moreSkeleton`, mirroring the rows that are coming, not a spinner, and a polite\n// status so a screen reader hears it.\n// - a later page failed: an alert row with the reason and Try again. The items already loaded\n// stay; a failed page 4 is not a failed list. The sentinel stops asking until Try again, so a\n// dead server is not called in a loop.\n// - the end: `end`, if given (\"That's every firing since March\"), so the person knows it is all.\n//\n// `keepAtLeast` loads more whenever fewer items than that are held: a queue people work through\n// (answered items `dismiss`ed) refills before it runs dry, even when nothing scrolls. Showing\n// more by button moves focus to the first new item, because the button the person pressed is\n// gone. The list scrolls in its own region (`height`) from the first page, so passing 100 items\n// and switching to virtual rows changes nothing on screen.\n\n/** The infinite list's props. */\nexport type InfiniteListProps<T> = {\n state: InfiniteLoad<T>;\n /** The list's accessible name, e.g. \"Firing log, newest first\". */\n label: string;\n children: (item: T, index: number) => React.ReactNode;\n /** The first load. Mirrors the final layout, so nothing jumps when data arrives. */\n skeleton: React.ReactNode;\n /** What goes here and how to add it, when the first page is empty and there are no more. */\n empty: React.ReactNode;\n /** The button behind the sentinel, in the product's words: \"Show older firings\". */\n moreLabel: string;\n /** The rows of a page on its way. Defaults to `skeleton`. */\n moreSkeleton?: React.ReactNode;\n /** After the last page: say that this is everything. */\n end?: React.ReactNode;\n /** How far before the end the next page is asked for (IntersectionObserver `rootMargin`). */\n rootMargin?: string;\n /** Load more whenever fewer than this many items are held. */\n keepAtLeast?: number;\n estimateSize?: number;\n height?: number;\n virtualizeFrom?: number;\n className?: string;\n};\n\n/** A cursor-paged list for `useInfiniteLoad`: DataView's first-page states, virtual rows, and a next-page row that loads on approach, shows a skeleton, or says why it failed with Try again. */\nexport function InfiniteList<T>({\n state,\n label,\n children,\n skeleton,\n empty,\n moreLabel,\n moreSkeleton = skeleton,\n end,\n rootMargin = \"400px\",\n keepAtLeast = 0,\n estimateSize,\n height = 480,\n virtualizeFrom,\n className,\n}: InfiniteListProps<T>) {\n const { more, itemKey } = state;\n const held = state.status === \"ready\" ? state.data.length : 0;\n const box = React.useRef<HTMLDivElement>(null);\n const near = useInView({ active: state.status === \"ready\" && more.hasMore, rootMargin });\n\n // Load on approach, and keep a worked-through queue topped up. Not after a failure: that waits\n // for Try again. Re-runs when a page lands, so a sentinel still in view asks for the next one.\n const { hasMore, loadingMore, error, loadMore } = more;\n React.useEffect(() => {\n if (state.status !== \"ready\" || !hasMore || loadingMore || error) return;\n if (near.inView || held < keepAtLeast) loadMore();\n }, [state.status, hasMore, loadingMore, error, near.inView, held, keepAtLeast, loadMore]);\n\n // After a click on Show more or Try again, focus the first new item: the button is gone.\n const focusFrom = React.useRef<number | null>(null);\n const loadByHand = () => {\n focusFrom.current = held;\n loadMore();\n };\n React.useEffect(() => {\n const from = focusFrom.current;\n if (from === null || loadingMore) return;\n if (held > from) {\n const row = box.current?.querySelector<HTMLElement>(`li[data-index=\"${from}\"]`);\n if (row) {\n row.tabIndex = -1;\n row.focus();\n }\n focusFrom.current = null;\n } else if (error || !hasMore) focusFrom.current = null;\n }, [held, loadingMore, error, hasMore]);\n\n const footer = (\n <div>\n {hasMore && !error && <div ref={near.ref} aria-hidden className=\"h-px\" />}\n {loadingMore ? (\n <div aria-hidden className=\"border-t border-border\">{moreSkeleton}</div>\n ) : error ? (\n <div role=\"alert\" className=\"flex flex-wrap items-start gap-3 border-t border-border bg-danger-subtle px-3 py-2 text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n <p className=\"min-w-0 flex-1 type-body-sm\">{error}</p>\n <Button size=\"sm\" onClick={loadByHand}>\n <RotateCcw aria-hidden />\n Try again\n </Button>\n </div>\n ) : hasMore ? (\n <div className=\"border-t border-border py-3\">\n <Button size=\"sm\" onClick={loadByHand}>\n {moreLabel}\n </Button>\n </div>\n ) : (\n end && <div className=\"border-t border-border py-3 type-body-sm text-muted-foreground\">{end}</div>\n )}\n <p role=\"status\" className=\"sr-only\">\n {loadingMore ? \"Loading more\" : \"\"}\n </p>\n </div>\n );\n\n return (\n <DataView\n state={state}\n isEmpty={(items) => items.length === 0 && !hasMore}\n skeleton={skeleton}\n empty={empty}\n className={className}\n >\n {(items) => (\n <div ref={box} aria-busy={loadingMore || undefined}>\n <VirtualList\n label={label}\n items={items}\n itemKey={itemKey}\n estimateSize={estimateSize}\n height={height}\n virtualizeFrom={virtualizeFrom}\n bounded\n footer={footer}\n >\n {children}\n </VirtualList>\n </div>\n )}\n </DataView>\n );\n}\n","import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// A line chart with the defaults real product screens use: one measured series in one hue, a 2px\n// straight line with no fill and no markers, 3 to 5 faint gridlines, no y-axis line, no legend for a\n// single series (the series is labelled where it ends). Values never live only in a hover tooltip:\n// the latest and peak readings are labelled on the chart and every reading is in a table for screen\n// readers. Optional extras exist only where they answer a question: a dashed `planned` series, a\n// horizontal `band` (a threshold that matters), and a `now` marker.\n//\n//\n// `colourScale` colours the measured line by its own value, for subjects where that colour is a\n// fact rather than decoration: a kiln's glow by temperature, water by depth. The y position still\n// carries the value, so the colour is never the only cue. Without a reason in DESIGN.md, use one\n// hue.\n//\n// It draws in real pixels (measured with ResizeObserver) rather than scaling a fixed viewBox, so\n// the 12px labels stay 12px on a phone. Because the labels keep their size, the chart thins the\n// x ticks itself when they would collide (every second, third… tick, so the rhythm stays even)\n// and keeps the first and last label inside the chart, rather than overlapping on a phone.\n//\n// The y-axis autoscales to four gridline steps of a size people write on a scale, from zero (or\n// below it, if a reading is negative). `yMin` and `yMax` pin either end for a quantity whose range\n// is a fact of the subject (a percentage is 0 to 100, a battery 0 to 1): autoscaling a machine at\n// 1% CPU gives a 0 to 8% axis that makes it look busy (strata-react issue #23). A pin is a floor on\n// the extent, never a crop: a reading outside it widens the axis, because a chart that hides a\n// reading is worse than one with an untidy scale.\n\nexport type Point = { x: number; y: number };\n\nexport type LineChartProps = {\n /** What the chart shows, as a sentence. Used as the accessible name and the table caption. */\n label: string;\n series: Point[];\n seriesLabel: string;\n planned?: Point[];\n plannedLabel?: string;\n band?: { below: number; label: string };\n formatX: (x: number) => string;\n formatY: (y: number) => string;\n /** Where to put x labels, in x units. The chart drops every other one (and so on) when they would overlap at its width. */\n xTicks: number[];\n /** Pin the bottom of the y-axis (default: 0, or lower if a reading is negative). A reading below it still shows. */\n yMin?: number;\n /** Pin the top of the y-axis, for a bounded quantity such as a percentage (`yMax={100}`), so a low reading looks low. Choose a range that divides into four steps. A reading above it still shows. */\n yMax?: number;\n /** CSS colour for the measured series. Defaults to the first chart token. */\n colour?: string;\n /** Colour the measured series by value: each stop applies from `at` upwards, blending to the\n * next. Only where the colour means something in the subject; record the reason in DESIGN.md. */\n colourScale?: { at: number; colour: string }[];\n /** Says what the colours mean, shown beside the legend swatch when `colourScale` is set. */\n colourScaleLabel?: string;\n height?: number;\n className?: string;\n};\n\nfunction useWidth<T extends HTMLElement>() {\n const ref = React.useRef<T>(null);\n const [width, setWidth] = React.useState(0);\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n setWidth(el.getBoundingClientRect().width);\n const ro = new ResizeObserver(([entry]) => setWidth(entry.contentRect.width));\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n return [ref, width] as const;\n}\n\n/** The smallest step of a size people write on a scale (1, 2, 2.5, 4 or 5 × 10ⁿ) at least `raw`. */\nfunction niceStep(raw: number) {\n const mag = 10 ** Math.floor(Math.log10(raw));\n return [1, 2, 2.5, 4, 5, 10].map((m) => m * mag).find((s) => s >= raw * (1 - 1e-9)) ?? 10 * mag;\n}\n\n/**\n * The y-axis: four equal gridline steps covering every value. With no pins the steps are a size\n * people write on a scale (1, 2, 2.5, 4 or 5 × 10ⁿ), from zero or a round number below the lowest\n * reading. A pinned end is used as given unless a value lies beyond it.\n */\nexport function yScale(values: number[], pin: { min?: number; max?: number } = {}) {\n const finite = values.filter(Number.isFinite);\n const dMin = finite.length ? Math.min(...finite) : 0;\n const dMax = finite.length ? Math.max(...finite) : 0;\n const pinMin = pin.min !== undefined && dMin >= pin.min ? pin.min : undefined;\n const pinMax = pin.max !== undefined && dMax <= pin.max ? pin.max : undefined;\n let lo = pinMin ?? Math.min(0, dMin);\n // Readings all at a pinned top (say all -10 under yMax={-10}) leave no span: open one below.\n if (pinMax !== undefined && pinMin === undefined && !(pinMax > lo)) lo = pinMax - (Math.abs(pinMax) || 4);\n let min: number;\n let max: number;\n if (pinMax !== undefined) {\n max = pinMax;\n // Only the bottom is free: round it down to a step of the span, so 0 stays 0.\n min = pinMin ?? (lo < 0 ? Math.floor(lo / niceStep((max - lo) / 4)) * niceStep((max - lo) / 4) : 0);\n } else {\n const hi = Math.max(dMax, pin.max ?? -Infinity);\n // All-zero (or empty) data still needs a positive extent, or every coordinate divides by zero.\n let step = hi > lo ? niceStep((hi - lo) / 4) : 1;\n let base = pinMin ?? Math.floor(lo / step) * step;\n while (base + 4 * step < hi) {\n step = niceStep(step * 1.01);\n base = pinMin ?? Math.floor(lo / step) * step;\n }\n min = base;\n max = base + 4 * step;\n }\n if (!(max > min)) max = min + 4;\n return { min, max, ticks: [0, 1, 2, 3, 4].map((i) => min + ((max - min) * i) / 4) };\n}\n\n/** Roughly how wide a 12px caption label is, in px. jsdom cannot measure text, so the chart estimates. */\nconst labelWidth = (text: string) => text.length * 7;\n\n/**\n * The x ticks that fit at this width: every k-th tick, the smallest k for which neighbouring labels\n * leave a gap, so the spacing stays even. `scale` maps an x value to a pixel.\n */\nexport function fitTicks(ticks: number[], scale: (x: number) => number, widthOf: (t: number) => number, gap = 12) {\n if (ticks.length < 3) return ticks;\n const sorted = [...ticks].sort((a, b) => a - b);\n for (let k = 1; k < sorted.length; k++) {\n const kept = sorted.filter((_, i) => i % k === 0);\n const fits = kept.every((t, i) => i === 0 || scale(t) - scale(kept[i - 1]) >= (widthOf(t) + widthOf(kept[i - 1])) / 2 + gap);\n if (fits) return kept;\n }\n return sorted.slice(0, 1);\n}\n\n/** One measured series, drawn in real pixels, with the peak and current readings labelled on the chart and every reading in a screen-reader table. Optional plan, threshold band and `colourScale`. */\nexport function LineChart({\n label,\n series,\n seriesLabel,\n planned,\n plannedLabel,\n band,\n formatX,\n formatY,\n xTicks,\n yMin,\n yMax,\n colour = \"var(--chart-1)\",\n colourScale,\n colourScaleLabel,\n height = 280,\n className,\n}: LineChartProps) {\n const [ref, width] = useWidth<HTMLDivElement>();\n const gradientId = `heat-${React.useId().replace(/[^\\w-]/g, \"\")}`;\n const all = [...series, ...(planned ?? [])];\n const xMin = Math.min(...all.map((p) => p.x));\n const xMax = Math.max(...all.map((p) => p.x));\n const y = yScale(\n all.map((p) => p.y),\n { min: yMin, max: yMax },\n );\n\n const pad = { top: 16, right: 16, bottom: 28, left: 56 };\n const w = Math.max(0, width - pad.left - pad.right);\n const h = height - pad.top - pad.bottom;\n const sx = (x: number) => pad.left + ((x - xMin) / (xMax - xMin || 1)) * w;\n const sy = (v: number) => pad.top + h - ((v - y.min) / (y.max - y.min)) * h;\n const xLabelWidth = (t: number) => labelWidth(formatX(t));\n // Keep the first and last labels inside the chart instead of centring them past its edge.\n const xLabelAt = (t: number) => {\n const half = xLabelWidth(t) / 2;\n return Math.min(Math.max(sx(t), half), Math.max(half, width - half));\n };\n // Fit against where the labels are drawn, so pulling an end label in cannot make it collide.\n const shownXTicks = fitTicks(xTicks, xLabelAt, xLabelWidth);\n const path = (pts: Point[]) => pts.map((p, i) => `${i ? \"L\" : \"M\"}${sx(p.x).toFixed(1)},${sy(p.y).toFixed(1)}`).join(\"\");\n\n const last = series[series.length - 1];\n const peak = series.reduce((a, b) => (b.y > a.y ? b : a), series[0]);\n const stops = colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : [];\n /** The colour a value lands on: the highest stop at or below it. Used for the labelled points. */\n const colourAt = (y: number) => (stops.length ? [...stops].reverse().find((s) => s.at <= y)?.colour ?? stops[0].colour : colour);\n const stroke = stops.length ? `url(#${gradientId})` : colour;\n\n return (\n <figure className={cn(\"grid min-w-0 gap-2\", className)}>\n <div ref={ref} className=\"min-w-0\">\n {width > 0 && (\n <svg width={width} height={height} role=\"img\" aria-label={label} className=\"block overflow-visible\">\n {stops.length > 0 && (\n // A vertical gradient in chart space, so a colour sits at a temperature, not at a\n // point along the line: the line is the same red wherever it crosses 600 °C.\n <defs>\n <linearGradient id={gradientId} gradientUnits=\"userSpaceOnUse\" x1={0} x2={0} y1={sy(y.min)} y2={sy(y.max)}>\n {stops.map((s) => (\n <stop key={s.at} offset={Math.min(1, Math.max(0, (s.at - y.min) / (y.max - y.min)))} stopColor={s.colour} />\n ))}\n </linearGradient>\n </defs>\n )}\n {band && band.below > y.min && (\n <g>\n <rect x={pad.left} y={sy(Math.min(band.below, y.max))} width={w} height={sy(y.min) - sy(Math.min(band.below, y.max))} fill=\"var(--success-subtle)\" />\n <text x={pad.left + 8} y={sy(Math.min(band.below, y.max)) + 16} className=\"fill-success type-caption\">\n {band.label}\n </text>\n </g>\n )}\n {y.ticks.map((t) => (\n <g key={t}>\n <line x1={pad.left} x2={pad.left + w} y1={sy(t)} y2={sy(t)} stroke=\"var(--border)\" strokeWidth={1} />\n <text x={pad.left - 8} y={sy(t)} dy=\"0.32em\" textAnchor=\"end\" className=\"fill-muted-foreground type-caption tabular-nums\">\n {formatY(t)}\n </text>\n </g>\n ))}\n {shownXTicks.map((t) => (\n <text key={t} x={xLabelAt(t)} y={height - 8} textAnchor=\"middle\" className=\"fill-muted-foreground type-caption tabular-nums\">\n {formatX(t)}\n </text>\n ))}\n {planned && (\n <path d={path(planned)} fill=\"none\" stroke=\"var(--muted-foreground)\" strokeWidth={1.5} strokeDasharray=\"4 4\" />\n )}\n <path d={path(series)} fill=\"none\" stroke={stroke} strokeWidth={stops.length ? 2.5 : 2} strokeLinejoin=\"round\" strokeLinecap=\"round\" />\n {/* Direct labels instead of a legend and a tooltip. */}\n <circle cx={sx(peak.x)} cy={sy(peak.y)} r={3} fill={colourAt(peak.y)} />\n <text x={sx(peak.x) + 8} y={sy(peak.y) - 8} className=\"fill-foreground type-caption tabular-nums\">\n {formatY(peak.y)} peak\n </text>\n <line x1={sx(last.x)} x2={sx(last.x)} y1={pad.top} y2={pad.top + h} stroke=\"var(--foreground)\" strokeWidth={1} />\n <circle cx={sx(last.x)} cy={sy(last.y)} r={3.5} fill={colourAt(last.y)} />\n <text\n x={sx(last.x) - 8}\n y={sy(last.y) - 10}\n textAnchor=\"end\"\n className=\"fill-foreground type-label tabular-nums\"\n >\n {formatY(last.y)} now\n </text>\n </svg>\n )}\n </div>\n <figcaption className=\"flex flex-wrap gap-x-5 gap-y-1 type-caption text-muted-foreground\">\n <span className=\"inline-flex items-center gap-2\">\n {stops.length ? (\n <svg width={stops.length * 8} height=\"3\" aria-hidden>\n {stops.map((s, i) => (\n <line key={s.at} x1={i * 8} x2={i * 8 + 8} y1=\"1.5\" y2=\"1.5\" stroke={s.colour} strokeWidth={3} />\n ))}\n </svg>\n ) : (\n <svg width=\"16\" height=\"2\" aria-hidden>\n <line x1=\"0\" x2=\"16\" y1=\"1\" y2=\"1\" stroke={colour} strokeWidth={2} />\n </svg>\n )}\n {seriesLabel}\n {stops.length > 0 && colourScaleLabel && <span>({colourScaleLabel})</span>}\n </span>\n {planned && plannedLabel && (\n <span className=\"inline-flex items-center gap-2\">\n <svg width=\"16\" height=\"2\" aria-hidden>\n <line x1=\"0\" x2=\"16\" y1=\"1\" y2=\"1\" stroke=\"var(--muted-foreground)\" strokeWidth={1.5} strokeDasharray=\"4 4\" />\n </svg>\n {plannedLabel}\n </span>\n )}\n </figcaption>\n {/* sr-only on a wrapper: a table ignores width: 1px and would widen the page. */}\n <div className=\"sr-only\">\n <table>\n <caption>{label}</caption>\n <thead>\n <tr>\n <th scope=\"col\">Time</th>\n <th scope=\"col\">{seriesLabel}</th>\n </tr>\n </thead>\n <tbody>\n {series.map((p) => (\n <tr key={p.x}>\n <td>{formatX(p.x)}</td>\n <td>{formatY(p.y)}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </figure>\n );\n}\n","import * as React from \"react\";\n\n// The top of every Operate screen: a noun title at 24px (never \"Welcome back\"), its scope, the\n// screen's main action, and the finding. The finding is the one fact in today's data that most\n// needs attention; it sits where it is read first, beside the action it drives.\n\n/** The top of an Operate screen: a noun title, its scope, the main action, and the finding (the one fact in today's data that most needs attention). */\nexport function PageHeader({\n title,\n scope,\n actions,\n finding,\n as: Heading = \"h1\",\n}: {\n title: string;\n /** The title's element: h1 on a screen, h2 where the header is shown inside another page. */\n as?: \"h1\" | \"h2\";\n /** What the screen covers: a date, a range, a filter. */\n scope?: React.ReactNode;\n actions?: React.ReactNode;\n finding?: { text: React.ReactNode; action?: React.ReactNode };\n}) {\n return (\n <header className=\"grid gap-4\">\n <div className=\"flex flex-wrap items-end justify-between gap-x-6 gap-y-3\">\n <div className=\"grid min-w-0 gap-0.5\">\n <Heading className=\"type-title text-balance\">{title}</Heading>\n {scope && <p className=\"type-body-sm text-muted-foreground\">{scope}</p>}\n </div>\n {actions && <div className=\"flex flex-wrap gap-2\">{actions}</div>}\n </div>\n {finding && (\n <div className=\"flex flex-wrap items-center justify-between gap-x-6 gap-y-3 border-y border-border py-3\">\n <p className=\"max-w-prose min-w-0 type-body text-pretty\">{finding.text}</p>\n {finding.action}\n </div>\n )}\n </header>\n );\n}\n","import * as React from \"react\";\nimport { Button } from \"./button\";\nimport { describeActionError } from \"../lib/errors\";\n\n// Destructive actions take effect visibly at once and commit after a window, with Undo in reach.\n// For reversible removals this beats a confirm dialog: the dialog interrupts every time to protect\n// against the rare mistake, and people learn to click through it. Keep a confirm dialog for\n// actions that cannot be undone (deleting an account, firing a kiln).\n\n// A bulk removal is one removal with `ids`: the selected rows go, come back on Undo, and fail\n// together, under one message and one commit, because the person did one thing.\n//\n// One removal is pending at a time. Scheduling a second commits the first at once: in rapid-fire\n// triage (withdraw, withdraw, withdraw) Undo reaches back one step, and the bar never stacks up a\n// queue of messages nobody reads. Undo is for the slip just made, not for an audit trail.\n//\n// The hook owns which items are out of view (`isRemoved`), so a screen filters its rows by it and\n// never keeps a second \"hidden\" set that can drift from the pending one. An item stays removed\n// from when it is scheduled; Undo brings it back; a commit that fails brings it back and puts the\n// failure in the same bar, with \"Try again\", because the screen told the person it was done and a\n// silent failure would leave the screen lying. A committed item stays removed until the screen's\n// data drops it (the commit should invalidate the query it came from), so it never flickers back.\n//\n// `flush()` exists for the action that depends on the removal having happened (retrain on the\n// answers, export the list): commit now and await it, rather than racing the window.\n//\n// Failures are described like any other failed action (`describeActionError`, as AsyncButton uses,\n// unless the product passes its own): the same HTTP sentences as reads, without promising that\n// nothing changed, since a write that failed may still have reached the server.\n\n/** A removal waiting out its undo window: what to say, what to do when the window closes, and what to say if that fails. */\nexport type PendingRemoval = {\n /** Identifies the removed item: `isRemoved(id)` is true from `schedule` until Undo or a failed commit. */\n id: string;\n /** A bulk removal's items, all removed, undone, committed and restored together (one `commit` for the batch). `isRemoved` is true for each. Default `[id]`. */\n ids?: readonly string[];\n /** What happened, in the product's words: \"Withdrew Tom Ellery's 3 pieces from kiln 2.\" */\n message: string;\n /** What the person reads if the commit fails, saying the item is back: \"Tom Ellery's 3 pieces are back in kiln 2: the withdrawal did not go through.\" */\n failure: string;\n /** Makes the removal real (usually a request, then invalidating the query the item came from). Runs once per attempt: when the window closes, on `flush()`, when a second removal is scheduled, or when the owner unmounts. */\n commit: () => void | Promise<unknown>;\n /** Called after a failed commit, for anything beyond restoring the item and showing the failure (which the hook does). The only failure path once the owner has unmounted. */\n onError?: (error: unknown) => void;\n};\n\n/** A removal whose commit failed: the removal, and the error described for a person. */\nexport type FailedRemoval = { removal: PendingRemoval; message?: string };\n\n/** Options for `useUndoable`. */\nexport type UndoableOptions = {\n /** How long Undo stays in reach, in milliseconds. Default 8000. */\n windowMs?: number;\n /** Describes a failed commit for a person, or returns undefined to show the removal's `failure` alone. Default `describeActionError`, as for `useAsyncAction`. */\n describeError?: (error: unknown) => string | undefined;\n};\n\n/** What `useUndoable` returns. Pass it whole to `UndoBar`. */\nexport type Undoable = {\n /** The removal inside its window, or null. */\n pending: PendingRemoval | null;\n /** The last removal whose commit failed, until it is retried, dismissed or another removal is scheduled. */\n failed: FailedRemoval | null;\n /** Whether an item is out of view: scheduled, committing or committed, and not undone or failed. Filter rows with it. */\n isRemoved: (id: string) => boolean;\n /** Removes an item and starts its window. Commits any removal already pending first: only one is pending at a time. */\n schedule: (next: PendingRemoval) => void;\n /** Cancels the pending removal and brings the item back; its `commit` never runs. */\n undo: () => void;\n /** Commits the pending removal now and resolves when it and every earlier commit still in flight have settled; rejects if any failed, so a dependent action does not run. Resolves at once when nothing is pending or running. */\n flush: () => Promise<void>;\n /** Removes the failed item again and commits it now (the person already waited out the window); settles like `flush`. */\n retry: () => Promise<void>;\n /** Clears the failure from the bar; the item stays back. */\n dismiss: () => void;\n};\n\n/**\n * Schedules a reversible removal to commit after a window unless undone, and owns which items\n * are out of view meanwhile.\n *\n * Only one removal is pending at a time: scheduling a second commits the first immediately.\n * Unmounting inside the window commits the pending removal (leaving is not Undo), so a navigation\n * or a test that unmounts still sends the commit's request: await `flush()` before a dependent\n * action, and in tests let MSW answer the request or flush before unmounting.\n */\nexport function useUndoable(options: number | UndoableOptions = {}): Undoable {\n const { windowMs = 8000, describeError = describeActionError } =\n typeof options === \"number\" ? { windowMs: options } : options;\n const [pending, setPending] = React.useState<PendingRemoval | null>(null);\n const [failed, setFailed] = React.useState<FailedRemoval | null>(null);\n const [removed, setRemoved] = React.useState<ReadonlySet<string>>(() => new Set());\n const current = React.useRef<PendingRemoval | null>(null);\n const timer = React.useRef<number | undefined>(undefined);\n const mounted = React.useRef(true);\n // Every commit still running, whoever started it: flush() waits for all of them, not only the\n // pending one, because an earlier removal's request may still be in flight (its window closed,\n // or a second removal committed it) and a dependent action must not overtake it.\n const inFlight = React.useRef(new Set<Promise<void>>());\n const describe = React.useRef(describeError);\n describe.current = describeError;\n\n const hide = React.useCallback((p: PendingRemoval, out: boolean) => {\n const ids = p.ids ?? [p.id];\n setRemoved((s) => {\n if (ids.every((id) => s.has(id) === out)) return s;\n const n = new Set(s);\n for (const id of ids) {\n if (out) n.add(id);\n else n.delete(id);\n }\n return n;\n });\n }, []);\n\n // Runs one attempt at a removal's commit. A synchronous throw is treated like a rejection, so\n // there is one failure path: bring the item back, show the failure, tell onError, reject.\n const attempt = React.useCallback(\n (p: PendingRemoval): Promise<void> => {\n let result: void | Promise<unknown>;\n try {\n result = p.commit();\n } catch (error) {\n result = Promise.reject(error);\n }\n const done = Promise.resolve(result).then(\n () => undefined,\n (error: unknown) => {\n if (mounted.current) {\n hide(p, false);\n setFailed({ removal: p, message: describe.current(error) });\n }\n p.onError?.(error);\n throw error;\n },\n );\n inFlight.current.add(done);\n const settle = () => void inFlight.current.delete(done);\n done.then(settle, settle);\n return done;\n },\n [hide],\n );\n\n // Takes the pending removal out (so it commits only once) and attempts it.\n const take = React.useCallback((): { removal: PendingRemoval; done: Promise<void> } | null => {\n window.clearTimeout(timer.current);\n const p = current.current;\n if (!p) return null;\n current.current = null;\n if (mounted.current) setPending(null);\n return { removal: p, done: attempt(p) };\n }, [attempt]);\n\n // Commits the hook starts itself (window closed, second removal, unmount) have no caller to\n // await them. A failure is handled once it is in the bar or onError has it; only a failure\n // nobody can see (unmounted, no onError) is left to surface as an unhandled rejection.\n const commitDetached = React.useCallback(() => {\n const t = take();\n t?.done.catch((error: unknown) => {\n if (!mounted.current && !t.removal.onError) throw error;\n });\n }, [take]);\n\n const schedule = React.useCallback(\n (next: PendingRemoval) => {\n commitDetached(); // a second removal commits the first\n setFailed(null);\n hide(next, true);\n current.current = next;\n setPending(next);\n timer.current = window.setTimeout(commitDetached, windowMs);\n },\n [commitDetached, hide, windowMs],\n );\n\n const undo = React.useCallback(() => {\n window.clearTimeout(timer.current);\n const p = current.current;\n current.current = null;\n setPending(null);\n if (p) hide(p, false);\n }, [hide]);\n\n const flush = React.useCallback(async () => {\n take();\n const results = await Promise.allSettled([...inFlight.current]);\n const failure = results.find((r): r is PromiseRejectedResult => r.status === \"rejected\");\n if (failure) throw failure.reason;\n }, [take]);\n\n const retry = React.useCallback(() => {\n if (!failed) return Promise.resolve();\n setFailed(null);\n hide(failed.removal, true);\n return attempt(failed.removal);\n }, [attempt, failed, hide]);\n\n const dismiss = React.useCallback(() => setFailed(null), []);\n\n const isRemoved = React.useCallback((id: string) => removed.has(id), [removed]);\n\n // Leaving the screen is not Undo: if the owner unmounts inside the window (the person navigated\n // away), commit what was scheduled rather than silently dropping it.\n React.useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n commitDetached();\n };\n }, [commitDetached]);\n\n return { pending, failed, isRemoved, schedule, undo, flush, retry, dismiss };\n}\n\n// The bar lives in a polite live region that is always mounted, so screen readers hear the message\n// when it appears, and a failure replaces the message in the same place the person was looking.\n// It is fixed to the bottom of the viewport; a page that uses it keeps that much bottom padding so\n// the bar never covers the focused row. A failure stays until it is retried or dismissed: an error\n// that times out is one a person can miss.\n/** The polite live region that shows a pending removal with Undo, or a failed one with Try again. Pass it the whole `useUndoable()` result. */\nexport function UndoBar({\n undoable,\n inline = false,\n}: {\n undoable: Pick<Undoable, \"pending\" | \"failed\" | \"undo\" | \"retry\" | \"dismiss\">;\n /** Render in the flow instead of fixed to the viewport; for the state-matrix page. */\n inline?: boolean;\n}) {\n const { pending, failed, undo, retry, dismiss } = undoable;\n const ghost = \"text-background hover:bg-neutral-11\";\n return (\n <div\n aria-live=\"polite\"\n className={\n inline ? \"flex\" : \"pointer-events-none fixed inset-x-0 bottom-4 z-50 flex justify-center px-4\"\n }\n >\n {(pending || failed) && (\n <div className=\"pointer-events-auto flex max-w-lg items-center gap-4 rounded-overlay bg-foreground py-2 pr-2 pl-4 text-background shadow-overlay\">\n {pending ? (\n <>\n <p className=\"min-w-0 type-body-sm\">{pending.message}</p>\n <Button size=\"sm\" variant=\"ghost\" className={ghost} onClick={undo}>\n Undo\n </Button>\n </>\n ) : (\n failed && (\n <>\n <p className=\"min-w-0 type-body-sm\">\n {failed.message ? `${failed.removal.failure} ${failed.message}` : failed.removal.failure}\n </p>\n <div className=\"flex shrink-0 gap-1\">\n <Button size=\"sm\" variant=\"ghost\" className={ghost} onClick={() => void retry().catch(() => undefined)}>\n Try again\n </Button>\n <Button size=\"sm\" variant=\"ghost\" className={ghost} onClick={dismiss}>\n Dismiss\n </Button>\n </div>\n </>\n )\n )}\n </div>\n )}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { Check } from \"lucide-react\";\nimport { cn } from \"../lib/utils\";\n\n// The completion moment: what a person sees after finishing something that took effort (a\n// booking, a submission, an import). It is the one place on an Operate product where the library\n// spends its delight budget (character.md §3), so it is a component with rules rather than a\n// confetti call:\n// - `title` says what happened, in the past tense, with the object: \"Booked: 6 pieces in kiln 2\".\n// - `next` is required. A finish that does not say what happens now is a dead end, however\n// pleasant.\n// - `figure` is optional and must be drawn from the person's own data in the subject's terms\n// (their pieces on a shelf, their route on a map), never a stock illustration.\n// - The part of the figure that is the person's result enters once, with the `enter-moment`\n// utility (500ms, hard ease-out, no overshoot): their pieces set down on the shelf. Reduced\n// motion makes it instant. Nothing loops and nothing plays a sound.\n// - Focus moves to the heading on mount, so keyboard and screen-reader users land on the result.\n\n/** The completion moment for a rare, earned finish: what happened (past tense, with its object), what happens next, and optionally a figure drawn from the person's own data. Focus moves to the heading. */\nexport function Done({\n title,\n next,\n figure,\n actions,\n focusOnMount = true,\n className,\n}: {\n /** What happened, past tense, with its object. */\n title: string;\n /** What the person does now, or what happens next and when. */\n next: React.ReactNode;\n /** A drawing of the result made from the person's data in the subject's own terms. */\n figure?: React.ReactNode;\n actions?: React.ReactNode;\n /** Off only where the result is not the page's subject (the state-matrix page). */\n focusOnMount?: boolean;\n className?: string;\n}) {\n const heading = React.useRef<HTMLHeadingElement>(null);\n const titleId = React.useId();\n React.useEffect(() => {\n if (focusOnMount) heading.current?.focus();\n }, [focusOnMount]);\n return (\n <section aria-labelledby={titleId} className={cn(\"grid gap-5\", className)}>\n <div className=\"grid gap-2\">\n <h1 id={titleId} ref={heading} tabIndex={-1} className=\"flex items-start gap-2 type-title\">\n <Check aria-hidden className=\"mt-1 size-6 shrink-0 text-success\" />\n {title}\n </h1>\n <div className=\"max-w-prose type-body text-muted-foreground\">{next}</div>\n </div>\n {figure}\n {actions && <div className=\"flex flex-wrap items-center gap-3\">{actions}</div>}\n </section>\n );\n}\n","import * as React from \"react\";\nimport { Link, NavLink } from \"react-router\";\nimport { cn } from \"../lib/utils\";\nimport type { IconComponent } from \"../lib/icon\";\n\n// The frame of an app: a side nav on the page ground (not a navy or tinted sidebar), the current\n// item as a neutral pill (no left bar, no accent), and the page beside it. A top bar exists only\n// when it holds something used on every screen, so it is a slot, not a default. Built on React\n// Router's NavLink, so \"current\" is the router's answer and aria-current is set for free. On\n// phones the nav becomes a horizontal, scrollable row above the page rather than a hamburger, so\n// every destination stays one tap away.\n\nexport type NavItem = {\n to: string;\n label: string;\n icon?: IconComponent;\n /** Match only this exact path, for an index route such as \"/\". */\n end?: boolean;\n};\n\n/** The app frame: product name, side nav on the page ground (a scrollable row on phones), optional top bar, and the main region. */\nexport function AppShell({\n product,\n nav,\n navLabel = \"Main\",\n topBar,\n children,\n className,\n}: {\n /** The product's name or mark, linking home. */\n product: React.ReactNode;\n nav: NavItem[];\n navLabel?: string;\n topBar?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n}) {\n return (\n <div className={cn(\"min-h-dvh md:grid md:grid-cols-[14rem_minmax(0,1fr)]\", className)}>\n <aside className=\"border-b border-border md:border-r md:border-b-0\">\n <div className=\"flex items-center gap-4 px-4 py-3 md:block md:px-3 md:py-4\">\n <Link to=\"/\" className=\"shrink-0 rounded-control px-2 type-heading text-foreground no-underline\">\n {product}\n </Link>\n <SideNav items={nav} label={navLabel} className=\"min-w-0 flex-1 md:mt-4\" />\n </div>\n </aside>\n <div className=\"min-w-0\">\n {topBar && <div className=\"flex items-center gap-3 border-b border-border px-4 py-2 md:px-8\">{topBar}</div>}\n <main className=\"px-4 py-6 md:px-8 md:py-8\">{children}</main>\n </div>\n </div>\n );\n}\n\n/** Navigation links (React Router `NavLink`); the current route is a neutral pill with `aria-current`. */\nexport function SideNav({ items, label, className }: { items: NavItem[]; label: string; className?: string }) {\n return (\n <nav aria-label={label} className={cn(\"min-w-0\", className)}>\n <ul className=\"flex gap-1 overflow-x-auto md:grid md:overflow-visible\">\n {items.map(({ to, label, icon: Icon, end }) => (\n <li key={to} className=\"shrink-0\">\n <NavLink\n to={to}\n end={end}\n className={({ isActive }) =>\n cn(\n \"flex h-(--control-h-sm) items-center gap-2 rounded-control px-2 type-label whitespace-nowrap no-underline transition-state\",\n isActive ? \"bg-muted text-foreground\" : \"text-muted-foreground hover:bg-muted hover:text-foreground\",\n )\n }\n >\n {Icon && <Icon aria-hidden className=\"size-4 shrink-0\" />}\n {label}\n </NavLink>\n </li>\n ))}\n </ul>\n </nav>\n );\n}\n\n// Plain links with a \"/\" separator in muted ink. The last crumb is the current page: text, not a\n// link, with aria-current.\n/** Plain links separated by `/`; the last crumb is the current page. */\nexport function Breadcrumb({ items }: { items: { label: string; to?: string }[] }) {\n return (\n <nav aria-label=\"Breadcrumb\">\n <ol className=\"flex flex-wrap items-center gap-x-2 type-body-sm text-muted-foreground\">\n {items.map((item, i) => {\n const last = i === items.length - 1;\n return (\n <li key={`${item.label}-${i}`} className=\"flex items-center gap-2\">\n {item.to && !last ? (\n <Link to={item.to} className=\"text-muted-foreground underline hover:text-foreground\">\n {item.label}\n </Link>\n ) : (\n <span aria-current={last ? \"page\" : undefined} className={cn(last && \"text-foreground\")}>\n {item.label}\n </span>\n )}\n {!last && <span aria-hidden>/</span>}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n}\n","import * as React from \"react\";\nimport { useSearchParams } from \"react-router\";\nimport { cn } from \"../lib/utils\";\n\n// Tabs whose state lives in the URL (?view=readings), so a tab can be linked, survives reload and\n// works with Back. ARIA tabs pattern: arrow keys move between tabs and select them, Home and End\n// jump, only the selected tab is in the tab order. The selected tab is marked by weight and a\n// 2px rule in ink, not by colour alone. The first tab is the default and is not written to the URL.\n\nexport type TabItem = { value: string; label: string };\n\n/** Tabs whose selection lives in a URL search parameter (React Router), with the ARIA tabs keyboard model. */\nexport function Tabs({\n param,\n items,\n label,\n children,\n className,\n}: {\n /** The search parameter that holds the selected tab. */\n param: string;\n items: TabItem[];\n /** Names the tab list for screen readers. */\n label: string;\n /** Renders the selected panel. */\n children: (value: string) => React.ReactNode;\n className?: string;\n}) {\n const [params, setParams] = useSearchParams();\n const fallback = items[0]?.value ?? \"\";\n const raw = params.get(param);\n const value = items.some((i) => i.value === raw) ? raw! : fallback;\n const baseId = React.useId();\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n\n const select = (next: string, focus = false) => {\n setParams(\n (p) => {\n const out = new URLSearchParams(p);\n if (next === fallback) out.delete(param);\n else out.set(param, next);\n return out;\n },\n { replace: true },\n );\n if (focus) refs.current[items.findIndex((i) => i.value === next)]?.focus();\n };\n\n const onKeyDown = (e: React.KeyboardEvent, index: number) => {\n const last = items.length - 1;\n const to =\n e.key === \"ArrowRight\" ? (index === last ? 0 : index + 1)\n : e.key === \"ArrowLeft\" ? (index === 0 ? last : index - 1)\n : e.key === \"Home\" ? 0\n : e.key === \"End\" ? last\n : undefined;\n if (to === undefined) return;\n e.preventDefault();\n select(items[to].value, true);\n };\n\n return (\n <div className={cn(\"grid gap-4\", className)}>\n <div role=\"tablist\" aria-label={label} className=\"flex gap-4 overflow-x-auto border-b border-border\">\n {items.map((item, i) => {\n const selected = item.value === value;\n return (\n <button\n key={item.value}\n ref={(el) => {\n refs.current[i] = el;\n }}\n type=\"button\"\n role=\"tab\"\n id={`${baseId}-tab-${item.value}`}\n aria-selected={selected}\n aria-controls={`${baseId}-panel`}\n tabIndex={selected ? 0 : -1}\n onClick={() => select(item.value)}\n onKeyDown={(e) => onKeyDown(e, i)}\n className={cn(\n \"-mb-px cursor-pointer border-b-2 py-2 type-label whitespace-nowrap transition-state\",\n selected\n ? \"border-foreground font-semibold text-foreground\"\n : \"border-transparent text-muted-foreground hover:text-foreground\",\n )}\n >\n {item.label}\n </button>\n );\n })}\n </div>\n <div role=\"tabpanel\" id={`${baseId}-panel`} aria-labelledby={`${baseId}-tab-${value}`} tabIndex={0}>\n {children(value)}\n </div>\n </div>\n );\n}\n","import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// Single-key shortcuts for Operate screens that clear a queue (accept, reject, next). A person\n// doing the same answer a hundred times a day wants one key, no pointer and no motion\n// (ux-research `ux-character.md`: 100+ a day gets nothing but an instant change). Three rules\n// keep single keys from hurting anyone:\n// 1. They never fire while the person is typing: not in an input, textarea, select or\n// contenteditable (WCAG 2.1.4 Character Key Shortcuts), and not mid-composition (IME).\n// 2. They never take a chord: with Ctrl, Meta or Alt held the browser and the OS keep the key.\n// Shift is part of the key itself, so \"?\" works and \"A\" is not \"a\".\n// 3. Holding a key does not repeat an answer; only shortcuts marked `repeat` (moving) repeat.\n// The same list drives the handler and the legend, so a shortcut cannot exist without being\n// shown, and the legend cannot advertise a key that does nothing.\n\n/** One shortcut: the keys that run it (as `KeyboardEvent.key`), what it does in the product's words, and the action. */\nexport type Shortcut = {\n /** `KeyboardEvent.key` values, e.g. `[\"j\", \"ArrowDown\"]`. The first is the one the legend leads with. */\n keys: string[];\n /** What it does, in the product's words: \"Accept booking\", not \"Action 1\". */\n label: string;\n run: () => void;\n /** Fire again while the key is held. On for moving through a list, off (the default) for answers. */\n repeat?: boolean;\n /** Ignore the key for now, and show it muted in the legend (nothing is active, say). */\n disabled?: boolean;\n};\n\nconst TEXT_INPUTS_EXEMPT = new Set([\"checkbox\", \"radio\", \"button\", \"submit\", \"reset\", \"range\", \"color\", \"file\"]);\n\n/** True when a key pressed on this element is the person typing, so single-key shortcuts must leave it alone. */\nexport function isTypingTarget(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) return false;\n if (target.isContentEditable || target.closest(\"[contenteditable=''],[contenteditable='true']\")) return true;\n if (target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement) return true;\n if (target instanceof HTMLInputElement) return !TEXT_INPUTS_EXEMPT.has(target.type);\n return false;\n}\n\nfunction toShortcuts(input: Shortcut[] | Record<string, () => void>): Shortcut[] {\n return Array.isArray(input) ? input : Object.entries(input).map(([key, run]) => ({ keys: [key], label: key, run }));\n}\n\n/**\n * Binds single-key shortcuts on the window, ignoring keys typed into fields, chords with Ctrl, Meta\n * or Alt, IME composition and (unless `repeat`) held keys. Pass the same list to `KeysLegend`.\n */\nexport function useHotkeys(shortcuts: Shortcut[] | Record<string, () => void>, { enabled = true }: { enabled?: boolean } = {}) {\n // The listener is bound once; it reads the latest list, so handlers can close over fresh state.\n const latest = React.useRef<Shortcut[]>([]);\n latest.current = toShortcuts(shortcuts);\n\n React.useEffect(() => {\n if (!enabled) return;\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.defaultPrevented || e.isComposing || e.ctrlKey || e.metaKey || e.altKey) return;\n if (isTypingTarget(e.target)) return;\n const hit = latest.current.find((s) => !s.disabled && s.keys.includes(e.key));\n if (!hit || (e.repeat && !hit.repeat)) return;\n e.preventDefault();\n hit.run();\n };\n window.addEventListener(\"keydown\", onKeyDown);\n return () => window.removeEventListener(\"keydown\", onKeyDown);\n }, [enabled]);\n}\n\nconst KEY_NAMES: Record<string, string> = {\n ArrowDown: \"↓\",\n ArrowUp: \"↑\",\n ArrowLeft: \"←\",\n ArrowRight: \"→\",\n Escape: \"Esc\",\n Enter: \"Enter\",\n Backspace: \"Backspace\",\n Delete: \"Delete\",\n \" \": \"Space\",\n};\n\n// The legend is quiet, caption-sized and muted: it is there to be found, not read every time.\n// It hides on coarse pointers (phones, tablets without a keyboard), where the keys do not exist.\n// Each key is a <kbd>; alternatives are read as \"j or down arrow\".\n/** A quiet legend of the screen's shortcuts, from the same list `useHotkeys` binds. Hidden on touch screens. */\nexport function KeysLegend({\n shortcuts,\n label = \"Keyboard shortcuts\",\n className,\n}: {\n shortcuts: Pick<Shortcut, \"keys\" | \"label\" | \"disabled\">[];\n /** Names the legend for screen readers. */\n label?: string;\n className?: string;\n}) {\n return (\n <dl aria-label={label} className={cn(\"flex flex-wrap gap-x-4 gap-y-1 type-caption text-muted-foreground pointer-coarse:hidden\", className)}>\n {shortcuts.map((s) => (\n <div key={s.keys.join(\" \")} className={cn(\"flex items-center gap-1.5\", s.disabled && \"opacity-50\")}>\n <dt className=\"flex items-center gap-1\">\n {s.keys.map((k, i) => (\n <React.Fragment key={k}>\n {i > 0 && <span className=\"sr-only\"> or </span>}\n <kbd className=\"min-w-5 rounded-control border border-border bg-surface-sunken px-1 text-center font-mono text-foreground\">\n {KEY_NAMES[k] ?? k}\n </kbd>\n </React.Fragment>\n ))}\n </dt>\n <dd>{s.label}</dd>\n </div>\n ))}\n </dl>\n );\n}\n","import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { isTypingTarget, type Shortcut } from \"./hotkeys\";\n\n// A queue someone works through from the keyboard: one item is active, j/k (or the arrow keys\n// inside the list) move it, and answering an item moves straight on to the next one. Three\n// decisions shape it:\n// 1. The active item is the one with focus. It is a roving tab stop (only it is in the tab order)\n// and carries aria-current, so a screen reader hears which item an answer applies to. It is\n// marked by a 2px rule in ink as well as a tint, not by colour alone.\n// 2. When the active item leaves the list (accepted, rejected, removed), the item that took its\n// place becomes active, or the one before it at the end of the list, and focus follows if it\n// was in the list. Otherwise focus would fall to <body> and the next key would do nothing.\n// 3. The hook remembers which item the person chose, not just a position. If an Undo puts the\n// item back, it is active again (pairs with `useUndoable`).\n// Moving is instant: no transition on the highlight (ux-research `ux-character.md`, 100+ a day).\n\n/** What `useActiveItem` returns: the active item, ways to move it, and the props each item element needs. */\nexport type ActiveItem<T> = {\n items: readonly T[];\n getKey: (item: T) => string;\n activeKey: string | null;\n activeItem: T | null;\n /** Position of the active item, or -1 when the list is empty. */\n index: number;\n next: () => void;\n prev: () => void;\n first: () => void;\n last: () => void;\n setActive: (key: string) => void;\n /** The j/k shortcuts for `useHotkeys` and `KeysLegend`. */\n shortcuts: Shortcut[];\n /** Props for the element that represents an item: ref, tabIndex, aria-current and focus tracking. */\n itemProps: (key: string) => {\n ref: (el: HTMLElement | null) => void;\n tabIndex: number;\n \"aria-current\": \"true\" | undefined;\n \"data-active\": \"\" | undefined;\n onFocus: () => void;\n onBlur: (e: React.FocusEvent) => void;\n };\n};\n\n/** Tracks the active item in a list worked through from the keyboard: moving, roving focus, and moving on when the active item is removed. */\nexport function useActiveItem<T>(\n items: readonly T[],\n getKey: (item: T) => string,\n {\n initial,\n noun,\n }: {\n /** Key of the item active at first; the first item otherwise. */\n initial?: string;\n /** Names an item in the shortcut labels: \"Next booking\". */\n noun?: string;\n } = {},\n): ActiveItem<T> {\n const [chosen, setChosen] = React.useState<string | null>(initial ?? null);\n const lastIndex = React.useRef(0);\n const elements = React.useRef(new Map<string, HTMLElement>());\n const navigated = React.useRef(false);\n const focusWithin = React.useRef(false);\n\n const keys = items.map(getKey);\n let index = chosen === null ? -1 : keys.indexOf(chosen);\n if (index === -1 && keys.length > 0) index = Math.min(lastIndex.current, keys.length - 1);\n const activeKey = index >= 0 ? keys[index] : null;\n\n // Remember the position, and the last item that left the list while active. Answering two in a\n // row (at the end of the queue, say) must make the second the one an Undo brings back as\n // active, not the first.\n const prevActive = React.useRef<string | null>(activeKey);\n React.useLayoutEffect(() => {\n if (index >= 0) lastIndex.current = index;\n const gone = prevActive.current;\n prevActive.current = activeKey;\n if (gone !== null && gone !== chosen && !keys.includes(gone)) setChosen(gone);\n });\n\n // Move focus to the active item when the person moved it, when the focused item was removed\n // (focus has fallen to <body>), or when focus is on another item in the list (an Undo made the\n // restored item active again). Never take focus from somewhere else on the page.\n React.useLayoutEffect(() => {\n const el = activeKey === null ? undefined : elements.current.get(activeKey);\n const focused = document.activeElement;\n const lost = focusWithin.current && (focused === null || focused === document.body);\n const elsewhereInList =\n focused !== null && !el?.contains(focused) && [...elements.current.values()].some((item) => item.contains(focused));\n if (el && (navigated.current || lost || elsewhereInList)) {\n el.focus({ preventScroll: true });\n el.scrollIntoView?.({ block: \"nearest\" });\n }\n navigated.current = false;\n }, [activeKey]);\n\n const moveTo = (i: number) => {\n if (keys.length === 0) return;\n const to = Math.max(0, Math.min(keys.length - 1, i));\n navigated.current = true;\n if (to === index) {\n // Already there: still bring focus back to it, as the person asked to move.\n const el = elements.current.get(keys[to]);\n el?.focus({ preventScroll: true });\n el?.scrollIntoView?.({ block: \"nearest\" });\n navigated.current = false;\n }\n setChosen(keys[to]);\n };\n\n const next = () => moveTo(index + 1);\n const prev = () => moveTo(index - 1);\n const first = () => moveTo(0);\n const last = () => moveTo(keys.length - 1);\n const setActive = (key: string) => {\n const i = keys.indexOf(key);\n if (i >= 0) moveTo(i);\n };\n\n const name = noun ? ` ${noun}` : \"\";\n const shortcuts: Shortcut[] = [\n { keys: [\"j\"], label: `Next${name}`, run: next, repeat: true, disabled: keys.length === 0 },\n { keys: [\"k\"], label: `Previous${name}`, run: prev, repeat: true, disabled: keys.length === 0 },\n ];\n\n const itemProps: ActiveItem<T>[\"itemProps\"] = (key) => ({\n ref: (el) => {\n if (el) elements.current.set(key, el);\n else elements.current.delete(key);\n },\n tabIndex: key === activeKey ? 0 : -1,\n \"aria-current\": key === activeKey ? \"true\" : undefined,\n \"data-active\": key === activeKey ? \"\" : undefined,\n onFocus: () => {\n focusWithin.current = true;\n // Clicking or tabbing into an item makes it active. If it already is (it took a removed\n // item's place), keep remembering the removed one so an Undo makes that active again.\n if (key !== activeKey) setChosen(key);\n },\n onBlur: (e) => {\n // Focus going nowhere (null) is what removal looks like, so only a move to a real element\n // outside the list counts as leaving it.\n const to = e.relatedTarget;\n if (to instanceof Node && ![...elements.current.values()].some((el) => el.contains(to))) focusWithin.current = false;\n },\n });\n\n return {\n items,\n getKey,\n activeKey,\n activeItem: index >= 0 ? items[index] : null,\n index,\n next,\n prev,\n first,\n last,\n setActive,\n shortcuts,\n itemProps,\n };\n}\n\n// The list renders the queue from `useActiveItem`. The arrow keys, Home and End move the active\n// item while focus is in the list (the window-wide j/k come from `active.shortcuts` via\n// `useHotkeys`, because only the screen knows whether it has one queue or two). An empty queue\n// is a state the list cannot be written without: say what clearing it means and what is next.\n/** A keyboard-worked queue: the active item is a roving tab stop with aria-current, and the arrow keys, Home and End move it. */\nexport function ActiveList<T>({\n label,\n active,\n empty,\n children,\n className,\n}: {\n /** Names the list for screen readers. */\n label: string;\n active: ActiveItem<T>;\n /** Shown when the queue is clear: what that means and what to do next. */\n empty: React.ReactNode;\n children: (item: T, state: { active: boolean }) => React.ReactNode;\n className?: string;\n}) {\n if (active.items.length === 0) return <>{empty}</>;\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.ctrlKey || e.metaKey || e.altKey || isTypingTarget(e.target)) return;\n const move =\n e.key === \"ArrowDown\" ? active.next\n : e.key === \"ArrowUp\" ? active.prev\n : e.key === \"Home\" ? active.first\n : e.key === \"End\" ? active.last\n : undefined;\n if (!move) return;\n e.preventDefault();\n move();\n };\n\n return (\n <ul aria-label={label} onKeyDown={onKeyDown} className={cn(\"grid gap-px\", className)}>\n {active.items.map((item) => {\n const key = active.getKey(item);\n const isActive = key === active.activeKey;\n return (\n <li\n key={key}\n {...active.itemProps(key)}\n className={cn(\n \"rounded-control border-l-2 px-3 py-2 -outline-offset-2\",\n isActive ? \"border-foreground bg-accent text-accent-foreground\" : \"border-transparent\",\n )}\n >\n {children(item, { active: isActive })}\n </li>\n );\n })}\n </ul>\n );\n}\n","import * as React from \"react\";\nimport { hashKey, useInfiniteQuery, type QueryKey } from \"@tanstack/react-query\";\nimport type { Load } from \"../components/data-view\";\nimport { describeHttpError, staleOf, type DescribeError } from \"./index\";\n\n// Cursor-paged reads, the Strata way. `useLoad` covers a read that arrives whole; a feed, a log or\n// a triage queue arrives a page at a time. This is the same bridge for those: TanStack's\n// useInfiniteQuery underneath, a `Load<T[]>` on top (so `DataView` takes it unchanged for the\n// first page's loading, error and empty states), and a `more` object for everything after it.\n//\n// Three opinions:\n// 1. The cursor is \"after the last item held\", never an offset, and the hook works it out: the\n// app says how to make a cursor from an item (`cursorAfter`) and whether a page says there are\n// more (`hasMore`). In a queue people work through (answered reviews, archived firings), items\n// leave the server's list between pages, and an offset would skip the ones that moved up to\n// fill the gap. Two cases fall back to the last item *seen*, dismissed or not: when everything\n// held has been dismissed (there is no held item to go after, and starting again from the top\n// could fetch the same dismissed page forever), and when the last page brought nothing new\n// (only items already held or dismissed came back, so going after the last held item again\n// would ask for the same page in a loop).\n// 2. Items have keys. Pages are merged by key, so an item that shifts across a page boundary is\n// shown once, and `dismiss(key)` hides one at once (an optimistic remove, paired with\n// useUndoable) without the app rewriting TanStack's page cache by hand. Dismissals belong to\n// one query: a new `queryKey` (another filter) starts with none. A screen that removes items\n// with `useUndoable` passes its `isRemoved` instead, so the undo hook stays the one owner of\n// what is out of view (Undo, a failed commit and Try again all show through) and the cursor\n// still skips past what it hides.\n// 3. A later page failing is not the list failing. The held items stay; `more.error` says what\n// happened and `more.loadMore` is the Try again. A refetch of the held pages failing is not the\n// list failing either: the items stay and `stale` says how old they are, as with `useLoad`.\n// Only a failed first page is a `Load` error.\n\n/** The state of the pages after the first: whether there are more, whether one is on its way, and why the last one failed. */\nexport type More = {\n /** The server has said there is another page. */\n hasMore: boolean;\n /** A page after the first is being fetched. */\n loadingMore: boolean;\n /** Why the last page after the first failed, for a person. Cleared when a retry succeeds. */\n error?: string;\n /** Fetch the next page; also the Try again after `error`. Does nothing while one is loading or when there are no more. */\n loadMore: () => void;\n};\n\n/** A cursor-paged read: a `Load<T[]>` of the items held (so `DataView` takes it), plus the next page's state and keyed removal. */\nexport type InfiniteLoad<T> = Load<T[]> & {\n more: More;\n itemKey: (item: T) => string;\n /** Hide an item at once (an optimistic removal). The next cursor goes after the last item still held. */\n dismiss: (key: string) => void;\n /** Show a dismissed item again: the Undo of `dismiss`. */\n restore: (key: string) => void;\n};\n\n/** Options for `useInfiniteLoad`. */\nexport type InfiniteLoadOptions<T, Page, Cursor, K extends QueryKey> = {\n queryKey: K;\n /** Fetch one page. `cursor` is undefined for the first page, else `cursorAfter` of the last item held. */\n queryFn: (context: { cursor: Cursor | undefined; signal: AbortSignal }) => Promise<Page>;\n /** The items in a page. For an API that returns a bare array, `(page) => page`. */\n items: (page: Page) => T[];\n /** A stable key per item: merges pages, and is what `dismiss` takes. */\n itemKey: (item: T) => string;\n /** Whether the server says there is a page after this one. */\n hasMore: (lastPage: Page) => boolean;\n /** The cursor that asks for the items after this one; usually its id. Defaults to `itemKey`. */\n cursorAfter?: (item: T) => Cursor;\n /** Items hidden by someone else, usually `useUndoable().isRemoved`: treated like dismissed ones. */\n isRemoved?: (key: string) => boolean;\n describeError?: DescribeError;\n enabled?: boolean;\n staleTime?: number;\n};\n\ntype Dismissed = { query: string; keys: ReadonlySet<string> };\ntype PageParam<Cursor> = { cursor: Cursor | undefined };\n\n/** `useInfiniteQuery` for cursor-paged data, returned as an `InfiniteLoad<T>` for `InfiniteList` (or `DataView`). */\nexport function useInfiniteLoad<T, Page, Cursor = string, K extends QueryKey = QueryKey>({\n queryKey,\n queryFn,\n items,\n itemKey,\n hasMore,\n cursorAfter = itemKey as unknown as (item: T) => Cursor,\n isRemoved,\n describeError = describeHttpError,\n enabled,\n staleTime,\n}: InfiniteLoadOptions<T, Page, Cursor, K>): InfiniteLoad<T> {\n const queryHash = hashKey(queryKey);\n const [stored, setStored] = React.useState<Dismissed>(() => ({ query: queryHash, keys: new Set() }));\n const dismissed = stored.query === queryHash ? stored.keys : none;\n const hidden = React.useCallback((key: string) => dismissed.has(key) || (isRemoved?.(key) ?? false), [dismissed, isRemoved]);\n // TanStack calls getNextPageParam outside render; it reads the latest hidden set and accessors.\n const latest = React.useRef({ hidden, items, itemKey, hasMore, cursorAfter });\n latest.current = { hidden, items, itemKey, hasMore, cursorAfter };\n\n const query = useInfiniteQuery({\n queryKey,\n queryFn: ({ pageParam, signal }) => queryFn({ cursor: pageParam.cursor, signal }),\n initialPageParam: { cursor: undefined } as PageParam<Cursor>,\n getNextPageParam: (lastPage, pages): PageParam<Cursor> | null => {\n const l = latest.current;\n if (!l.hasMore(lastPage)) return null;\n const after = nextAfter(pages, l.items, l.itemKey, l.hidden);\n return { cursor: after === undefined ? undefined : l.cursorAfter(after) };\n },\n enabled,\n staleTime,\n });\n\n const pages = query.data?.pages;\n // Keyed on the pages and dismissals only, so inline `items`/`itemKey` arrows do not hand the\n // list a new array every render.\n const list = React.useMemo(\n () => (pages ? merge(pages, latest.current.items, latest.current.itemKey, hidden).held : undefined),\n [pages, hidden],\n );\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage, refetch } = query;\n const loadMore = React.useCallback(() => {\n if (hasNextPage && !isFetchingNextPage) void fetchNextPage();\n }, [hasNextPage, isFetchingNextPage, fetchNextPage]);\n const change = React.useCallback(\n (edit: (keys: Set<string>) => void) =>\n setStored((s) => {\n const keys = new Set(s.query === queryHash ? s.keys : none);\n edit(keys);\n return { query: queryHash, keys };\n }),\n [queryHash],\n );\n const dismiss = React.useCallback((key: string) => change((keys) => keys.add(key)), [change]);\n const restore = React.useCallback((key: string) => change((keys) => keys.delete(key)), [change]);\n\n const more: More = {\n hasMore: Boolean(hasNextPage),\n loadingMore: isFetchingNextPage,\n error: query.isFetchNextPageError ? describeError(query.error) : undefined,\n loadMore,\n };\n const extra = { more, itemKey, dismiss, restore };\n if (list) {\n // isRefetchError excludes a failed next page, which is `more.error`'s to report.\n const stale = query.isRefetchError ? staleOf(query, describeError) : undefined;\n return { status: \"ready\", data: list, ...(stale && { stale }), ...extra };\n }\n if (query.status === \"error\") return { status: \"error\", message: describeError(query.error), retry: () => void refetch(), ...extra };\n return { status: \"loading\", ...extra };\n}\n\nconst none: ReadonlySet<string> = new Set();\n\n/** Every page's items, in order, once each by key: the ones held (not dismissed) and the last one seen. */\nfunction merge<T, Page>(pages: Page[], items: (page: Page) => T[], itemKey: (item: T) => string, hidden: (key: string) => boolean) {\n const seen = new Set<string>();\n const held: T[] = [];\n let last: T | undefined;\n let lastPageAddedAny = false;\n pages.forEach((page, p) => {\n for (const item of items(page)) {\n const key = itemKey(item);\n if (seen.has(key)) continue;\n seen.add(key);\n last = item;\n if (p === pages.length - 1) lastPageAddedAny = true;\n if (!hidden(key)) held.push(item);\n }\n });\n return { held, last, lastPageAddedAny };\n}\n\n/** The item the next page goes after: the last held, or the last seen when nothing is held or the last page brought nothing new. */\nfunction nextAfter<T, Page>(pages: Page[], items: (page: Page) => T[], itemKey: (item: T) => string, hidden: (key: string) => boolean) {\n const { held, last, lastPageAddedAny } = merge(pages, items, itemKey, hidden);\n if (held.length === 0 || (pages.length > 1 && !lastPageAddedAny)) return last;\n return held[held.length - 1];\n}\n"],"mappings":";;;;;;;;;;;AAwBA,IAAa,OAAO;AAIpB,IAAM,aAAkC;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;AAAI;AAC1E,IAAM,YA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