strata-react 1.3.2 → 1.3.4
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 +20 -2
- package/UPGRADING.md +4 -0
- package/dist/api-types/generate.d.ts +2 -0
- package/dist/api-types-cli.js +1 -1
- package/dist/api-types.js +1 -1
- package/dist/components/field.d.ts +28 -5
- package/dist/components/link.d.ts +43 -0
- package/dist/components/recorder.d.ts +73 -0
- package/dist/components/say-again.d.ts +11 -0
- package/dist/components/toggle.d.ts +12 -4
- package/dist/{errors-DqezYZgy.js → errors-D99YX4XL.js} +2 -2
- package/dist/{errors-DqezYZgy.js.map → errors-D99YX4XL.js.map} +1 -1
- package/dist/{field-CTd1l3md.js → field-QCCmWTuY.js} +77 -4
- package/dist/field-QCCmWTuY.js.map +1 -0
- package/dist/{generate-DCRYZPJs.js → generate-CjTHKJ39.js} +21 -3
- package/dist/generate-CjTHKJ39.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +447 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/base.d.ts +10 -0
- package/dist/lib/microphone.d.ts +24 -0
- package/dist/lib/recording.d.ts +16 -0
- package/dist/lib/search-param.d.ts +16 -0
- package/dist/lib/speech.d.ts +37 -0
- package/dist/map.js +2 -2
- package/dist/{query-CgoGqE0T.js → microphone-BZXMKTCM.js} +84 -7
- package/dist/microphone-BZXMKTCM.js.map +1 -0
- package/dist/panorama.js +2 -2
- package/dist/query/api.d.ts +23 -0
- package/dist/query/index.d.ts +12 -2
- package/dist/query/typed-api.d.ts +78 -0
- package/dist/testing/index.d.ts +10 -8
- package/dist/testing/layout.d.ts +1 -1
- package/dist/testing/microphone.d.ts +20 -0
- package/dist/testing/speech.d.ts +32 -0
- package/dist/testing/storage.d.ts +7 -0
- package/dist/testing.js +175 -8
- package/dist/testing.js.map +1 -1
- package/dist/{theme-DB0Km2m2.js → theme-By3DSUTs.js} +2 -2
- package/dist/{theme-DB0Km2m2.js.map → theme-By3DSUTs.js.map} +1 -1
- package/dist/{value-controls-CiwdvJeH.js → value-controls-B7iNh4WO.js} +3 -3
- package/dist/{value-controls-CiwdvJeH.js.map → value-controls-B7iNh4WO.js.map} +1 -1
- package/package.json +1 -1
- package/dist/field-CTd1l3md.js.map +0 -1
- package/dist/generate-DCRYZPJs.js.map +0 -1
- package/dist/query-CgoGqE0T.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value-controls-CiwdvJeH.js","names":["Toolbar","AriaToolbar","_Fragment","Button","NumberField","AriaNumberField","AriaInput","Toolbar","Button","Slider","AriaSlider","_Fragment"],"sources":["../src/lib/in-view.ts","../src/components/hotkeys.tsx","../src/components/toolbar.tsx","../src/components/async-button.tsx","../src/lib/number-input.ts","../src/components/value-controls.tsx"],"sourcesContent":["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 { KeyText } from \"./key-glyphs\";\nimport * 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 <KeyText>{KEY_NAMES[k] ?? k}</KeyText>\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 { Toolbar as AriaToolbar, Separator } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\nimport { isTypingTarget } from \"./hotkeys\";\n\n// A toolbar groups controls that act on what is shown (a preview's grid and quality, a timeline's\n// snap, a table's density). React Aria gives it the WAI-ARIA toolbar keyboard model: one tab stop,\n// arrow keys (and Home and End) move inside it, Tab leaves it. It needs a `label`, as an unnamed\n// toolbar is announced as nothing. Groups inside it are separated by a hairline (`ToolbarSeparator`)\n// rather than by space alone, so a row of eight small controls reads as three groups. It lays out\n// as one wrapping row: when it runs out of width, controls wrap to the next line instead of being\n// hidden behind an overflow menu, which keeps every control reachable with no extra state\n// (an overflow menu is the later step, once the Menu exists).\n\n// A slider keeps its own Home and End (to its ends), as a typing target keeps its own: a size slider\n// in a toolbar (`ViewOptions`) would otherwise lose them to \"first control\".\nconst isRange = (t: EventTarget | null) => t instanceof HTMLInputElement && t.type === \"range\";\n\n/** Props for `Toolbar`. */\nexport type ToolbarProps = {\n /** Names the toolbar for screen readers: \"Preview options\". Required. */\n label: string;\n orientation?: \"horizontal\" | \"vertical\";\n children: React.ReactNode;\n className?: string;\n};\n\n/** A group of controls with one tab stop and arrow-key movement (the WAI-ARIA toolbar pattern). Needs a `label`. */\nexport function Toolbar({ label, orientation = \"horizontal\", children, className }: ToolbarProps) {\n // React Aria's toolbar moves with the arrow keys; Home and End (to the first and last control) are\n // added here, as the WAI-ARIA toolbar pattern lists them. The capture phase runs before React\n // Aria's own handler, and a typing target (a number field inside the toolbar) keeps its Home and End.\n const jump = (e: React.KeyboardEvent<HTMLElement>) => {\n // Only events from inside the toolbar's own DOM: a Popover opened from a control here renders in\n // a portal, and its events still reach this handler through React's tree.\n if ((e.key !== \"Home\" && e.key !== \"End\") || isTypingTarget(e.target) || isRange(e.target) || !e.currentTarget.contains(e.target as Node)) return;\n const items = [...e.currentTarget.querySelectorAll<HTMLElement>(\"button, input, select, textarea, a[href], [tabindex]\")].filter(\n (el) => !el.hasAttribute(\"disabled\") && el.getAttribute(\"aria-disabled\") !== \"true\" && el.tabIndex >= -1 && el.getAttribute(\"role\") !== \"separator\",\n );\n const target = e.key === \"Home\" ? items[0] : items[items.length - 1];\n if (!target) return;\n e.preventDefault();\n e.stopPropagation();\n target.focus();\n };\n return (\n <div className=\"contents\" onKeyDownCapture={jump}>\n <AriaToolbar\n aria-label={label}\n orientation={orientation}\n className={cn(\"flex flex-wrap items-center gap-1\", orientation === \"vertical\" && \"flex-col items-stretch\", className)}\n >\n {children}\n </AriaToolbar>\n </div>\n );\n}\n\n/** A hairline between groups of controls inside a `Toolbar`. */\nexport function ToolbarSeparator({ className }: { className?: string }) {\n return <Separator className={cn(\"mx-1 h-5 w-px self-center border-0 bg-border\", className)} />;\n}\n","import * as React from \"react\";\nimport { Check, CircleAlert, LoaderCircle } from \"lucide-react\";\nimport { Button, type ButtonProps } from \"./button\";\nimport { describeActionError, fieldErrorsOf } 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//\n// The button carries `data-phase` (and Button's `data-variant`), so a test reads which phase it is\n// in without matching four stacked labels in its text (strata-react issue #48); `asyncButtonPhase`\n// in strata-react/testing reads it.\n//\n// `useAsyncAction` also owns a form's field messages (strata-react issues #42 and #46). `validate`\n// runs before the action, and messages it returns stop the run and land on `fieldErrors`, keyed by\n// field; a server's per-field messages (an HttpError's `fieldErrors`, from a 422) land there too.\n// A screen passes `fieldErrors.link` to `Field error=` and keeps no `problem` state of its own.\n// Failing validation leaves the button idle, not \"Try again\": nothing was tried. `onInvalid` runs\n// once the messages are on screen, to move focus to the first field named.\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} data-phase={phase} disabled={disabled || phase === \"pending\"} aria-disabled={phase === \"pending\" || undefined} aria-busy={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/** Messages for a form's fields, keyed by field name. */\nexport type FieldErrors = Readonly<Record<string, string>>;\n\n/** Options for `useAsyncAction`. */\nexport type AsyncActionOptions<A extends unknown[] = unknown[]> = {\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 /** Checks the arguments before the action runs. A message for any field stops the run and is put on `fieldErrors`; the button stays idle. */\n validate?: (...args: A) => Record<string, string | undefined> | undefined;\n /** Called once validation's messages are on screen: to move focus to the first field named. */\n onInvalid?: (fieldErrors: FieldErrors) => void;\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 /** What the action threw, while `phase` is `error`: to read more than the sentence (an HttpError's `status` or `body`). */\n thrown: unknown;\n /** Messages per field, from `validate` or from the server (an HttpError's `fieldErrors`). Pass each to its `Field`'s `error`. Cleared by the next run. */\n fieldErrors: FieldErrors;\n /** Clears one field's message (as the person edits it), or all of them. */\n clearFieldError: (field?: string) => void;\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, its error and any field messages. `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, validate, onInvalid }: AsyncActionOptions<A> = {},\n): AsyncAction<A> {\n const [state, setState] = React.useState<ActionState>(idle);\n const timer = React.useRef<number | undefined>(undefined);\n const unreported = React.useRef<{ thrown: unknown } | { invalid: FieldErrors } | undefined>(undefined);\n const latest = React.useRef({ action, onError, settleMs, describeError, validate, onInvalid });\n React.useLayoutEffect(() => {\n latest.current = { action, onError, settleMs, describeError, validate, onInvalid };\n });\n // An action that settles after the component has gone (a test's teardown, a route change) must not set state or start the settle timer: after jsdom is torn down React reads `window` and throws (issue #267).\n const mounted = React.useRef(true);\n React.useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n window.clearTimeout(timer.current);\n };\n }, []);\n const run = React.useCallback(async (...args: A) => {\n window.clearTimeout(timer.current);\n const invalid = messages(latest.current.validate?.(...args));\n if (invalid) {\n unreported.current = { invalid };\n setState({ ...idle, fieldErrors: invalid });\n return;\n }\n setState({ ...idle, phase: \"pending\" });\n try {\n await latest.current.action(...args);\n if (!mounted.current) return;\n setState({ ...idle, phase: \"done\" });\n timer.current = window.setTimeout(() => setState(idle), latest.current.settleMs);\n } catch (thrown) {\n if (!mounted.current) return;\n unreported.current = { thrown };\n setState({ phase: \"error\", error: latest.current.describeError(thrown), thrown, fieldErrors: fieldErrorsOf(thrown) });\n }\n }, []);\n // onError and onInvalid run after their render commits, not inside run: there the button is\n // still disabled from `pending` and a 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 const note = unreported.current;\n if (!note) return;\n if (\"thrown\" in note && state.phase === \"error\") latest.current.onError?.(note.thrown);\n else if (\"invalid\" in note) latest.current.onInvalid?.(note.invalid);\n else return;\n unreported.current = undefined;\n }, [state]);\n const clearFieldError = React.useCallback(\n (field?: string) =>\n setState((s) => {\n if (field === undefined) return Object.keys(s.fieldErrors).length ? { ...s, fieldErrors: {} } : s;\n if (!(field in s.fieldErrors)) return s;\n const { [field]: _gone, ...rest } = s.fieldErrors;\n return { ...s, fieldErrors: rest };\n }),\n [],\n );\n return { phase: state.phase, run, error: state.error, thrown: state.thrown, fieldErrors: state.fieldErrors, clearFieldError };\n}\n\ntype ActionState = { phase: Phase; error: string | undefined; thrown: unknown; fieldErrors: FieldErrors };\nconst idle: ActionState = { phase: \"idle\", error: undefined, thrown: undefined, fieldErrors: {} };\n\n/** The messages `validate` returned, without the empty ones; undefined when there are none. */\nfunction messages(found: Record<string, string | undefined> | undefined): FieldErrors | undefined {\n if (!found) return undefined;\n const kept = Object.fromEntries(Object.entries(found).filter((e): e is [string, string] => Boolean(e[1])));\n return Object.keys(kept).length ? kept : undefined;\n}\n","// Colour rules for `ColorField` (issue #73): reading a typed hex, and the WCAG contrast ratio\n// against what the colour is drawn on, which a user-chosen colour (content, not theme) is checked\n// with. Number parsing and stepping are React Aria's.\n\n/** Reads `#rgb`, `#rrggbb` (with or without the #) as lower-case `#rrggbb`, or null. */\nexport function parseHex(text: string): string | null {\n const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(text.trim());\n if (!m) return null;\n const h = m[1].toLowerCase();\n return \"#\" + (h.length === 3 ? [...h].map((c) => c + c).join(\"\") : h);\n}\n\nfunction luminance(hex: string): number {\n const v = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255).map((c) => (c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));\n return 0.2126 * v[0] + 0.7152 * v[1] + 0.0722 * v[2];\n}\n\n/** WCAG contrast ratio between two `#rrggbb` colours, 1 to 21. */\nexport function contrastRatio(a: string, b: string): number {\n const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);\n return (hi + 0.05) / (lo + 0.05);\n}\n","import * as React from \"react\";\nimport {\n I18nProvider,\n Input as AriaInput,\n NumberField as AriaNumberField,\n Slider as AriaSlider,\n SliderOutput,\n SliderThumb,\n SliderTrack,\n} from \"react-aria-components\";\nimport { useFieldControl } from \"./field\";\nimport { AsyncButton, useAsyncAction } from \"./async-button\";\nimport { Button } from \"./button\";\nimport { Toolbar } from \"./toolbar\";\nimport { NBSP, format } from \"../lib/format\";\nimport { contrastRatio, parseHex } from \"../lib/number-input\";\nimport { cn } from \"../lib/utils\";\nimport { controlHeight, type ControlSize } from \"../lib/control\";\n\n// Controls for setting a number or a colour precisely (strata-react issue #73, from moving\n// strata-vid onto Strata: opacity, rotation, volume, bitrate, a line colour). The native ones fail\n// in the same few ways, and each rule below answers one:\n//\n// - `parseFloat(e.target.value)` turns an empty field into NaN. Here a value that is not known is\n// `null`, stays `null`, and prints `format.missing`; a typed value outside the limits is NOT\n// clamped and NOT passed on: React Aria's field runs with `commitBehavior=\"validate\"` (it keeps\n// what was typed instead of snapping 600 to 500), and the control tells the surrounding `Field`\n// what is wrong (\"Enter a value from 0% to 500%.\"), the same place a server's 422 appears. The\n// callback only ever receives a number inside the limits, or null.\n// - The unit lives inside the control, muted. A slider's spoken value carries it (\"40%\", \"90°\")\n// when `Intl` knows the unit (percent, degree, millisecond, megabit-per-second and the like):\n// React Aria builds `aria-valuetext` from an `Intl.NumberFormat`, so \"px\" or \"steps\" are in the\n// printed value and the label but cannot be in the spoken one.\n// - Digits are the locale's: what is printed and what is read back go through `Intl` (React Aria's\n// `NumberParser`), so 12,5 works in a de-DE app, and the message is in the same digits.\n// - Behaviour is React Aria's: arrows step, PageUp/PageDown take ten steps, Home/End jump to the\n// limits, a field commits on Enter and blur. Nothing animates when a value changes: these are\n// dragged and stepped dozens of times a minute (character.md, the frequency budget).\n// - A colour a person picks for their own content (a route's line) is content, not theme, so it is\n// the one place a raw colour value is right; `against` checks it against what it is drawn on.\n// The colour field's text box is ours: React Aria's colour field puts the old colour back when\n// the text is not a colour, where this one says so under the control; the swatch opens the\n// platform picker.\n//\n// A value that is set a little at a time, or that costs work to change (strata-react issue #224,\n// from strata-360's camera clock offset, which re-times everything) gets three options on\n// `NumberField`, each an extension of React Aria's field, not a new control:\n// - `nudge={[0.1, 1, 10]}`: a `Toolbar` of \"−10 −1 −0.1 +0.1 +1 +10\" beside the field, each named\n// (\"Subtract 1 s\"). A press steps once at once; held, the first repeat comes after 400 ms and then\n// every 60 ms (React Aria's own stepper buttons repeat too, but it exposes no hook to put that\n// on buttons of ours, checked in `useNumberField`/`useSpinButton`; the timer here is the same\n// idea). The result is rounded to the field's places (0.1 + 0.2 is 0.3) and held at `min`/`max`;\n// a button that would go past a limit is disabled.\n// - `suggestion={{ value, label, reason }}`: a row under the field that says what the app suggests\n// and why, in text, with \"Use this value\". It never changes the field by itself, and it goes\n// away once the field holds the suggestion.\n// - `preview`: the field stops committing as it goes. `value` is the saved one, an entry or nudge\n// is only pending, and while it differs the preview (a node, or a function of the pending value)\n// is shown with Apply, the view's one filled button, and Revert. `onChange` is called once, by\n// Apply, and may return a promise, which Apply shows through `AsyncButton`.\n\nconst box =\n \"flex w-full min-w-0 items-center rounded-control border border-input bg-background px-3 type-body text-foreground transition-state disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-70 has-[input:disabled]:cursor-not-allowed has-[input:disabled]:bg-muted has-[input:disabled]:opacity-70 aria-invalid:border-danger has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-offset-2 has-[input:focus-visible]:outline-ring\";\n\n/** A number with its unit joined by a non-breaking space; `%` and `°` stay attached. */\nfunction withUnit(text: string, unit?: string) {\n if (!unit) return text;\n return unit === \"%\" || unit === \"°\" ? text + unit : text + NBSP + unit;\n}\n\n// Units `Intl` can speak, by the symbol an app prints. Anything else is printed but not spoken.\nconst intlUnits: Record<string, string> = {\n \"%\": \"percent\",\n \"°\": \"degree\",\n ms: \"millisecond\",\n s: \"second\",\n kB: \"kilobyte\",\n MB: \"megabyte\",\n GB: \"gigabyte\",\n kbps: \"kilobit-per-second\",\n Mbps: \"megabit-per-second\",\n};\n\nfunction decimalsOf(n: number): number {\n const s = String(n);\n if (s.includes(\"e-\")) return Number(s.split(\"e-\")[1]) + (s.split(\"e-\")[0].split(\".\")[1]?.length ?? 0);\n return s.split(\".\")[1]?.length ?? 0;\n}\n\nfunction useNumberText(locale: string, places: number) {\n return React.useMemo(() => {\n const f = new Intl.NumberFormat(locale, { maximumFractionDigits: places, minimumFractionDigits: 0 });\n return (n: number) => f.format(n);\n }, [locale, places]);\n}\n\nfunction formatOptionsFor(places: number, unit?: string): Intl.NumberFormatOptions {\n const base: Intl.NumberFormatOptions = { maximumFractionDigits: places, minimumFractionDigits: 0 };\n const known = unit ? intlUnits[unit] : undefined;\n return known ? { ...base, style: \"unit\", unit: known, unitDisplay: \"narrow\" } : base;\n}\n\n/** Props shared by the number field and the slider. */\nexport type RangeProps = {\n min?: number;\n max?: number;\n /** The size of one arrow-key step. Default 1. */\n step?: number;\n /** The unit shown with the value: \"%\", \"°\", \"Mbps\", \"px\". Spoken too when `Intl` has it (%, °, ms, s, kB, MB, GB, kbps, Mbps). */\n unit?: string;\n /** The locale for digits and the decimal mark. Default the app's `format` locale. */\n locale?: string;\n};\n\n/** Props for `NumberField`. */\nexport type NumberFieldProps = RangeProps & {\n /** The current value; `null` when it is not known (shown as an en dash, not 0). */\n value: number | null;\n /** Receives a number inside the limits, or `null` when the field is cleared. Never NaN, never out of range. With `preview`, only Apply calls it, and it may return a promise. */\n onChange: (value: number | null) => void | Promise<unknown>;\n /** Decimal places to show and keep. Default the places in `step` (and `min`). */\n places?: number;\n /** An empty field is an error (\"Enter a value.\") rather than `null`. */\n required?: boolean;\n disabled?: boolean;\n /** Names the control when it is used without a `Field`. */\n \"aria-label\"?: string;\n id?: string;\n name?: string;\n /** `sm` is --control-h-sm, the height of a small `Toggle` or `IconButton` beside it. Default --control-h. */\n size?: ControlSize;\n /** Step buttons beside the field, each a size in the field's unit: `[0.1, 1, 10]` draws \"−10 −1 −0.1 +0.1 +1 +10\". Held, they repeat. They honour `min` and `max`. */\n nudge?: readonly number[];\n /** What the app suggests, drawn as a row under the field with \"Use this value\". `label` is the value as the person reads it (\"+2.4 s\"); `reason` says why, in words. Choosing it sets the field's value, which `preview` still holds back until Apply. */\n suggestion?: { value: number; label?: string; reason: string };\n /** Hold changes back until the person applies them: shown while the value differs from `value` (the saved one), as a node or a function of the pending value. `onChange` is then called by Apply only. */\n preview?: React.ReactNode | ((pending: number | null) => React.ReactNode);\n /** Apply's words in preview mode, the same verb through its states. Default \"Apply\" → \"Applying…\" → \"Applied\". */\n applyLabels?: { idle: string; pending: string; done: string };\n className?: string;\n};\n\nfunction describeRange(min: number | undefined, max: number | undefined, show: (n: number) => string, unit?: string) {\n const a = min === undefined ? \"\" : withUnit(show(min), unit);\n const b = max === undefined ? \"\" : withUnit(show(max), unit);\n if (min !== undefined && max !== undefined) return `Enter a value from ${a} to ${b}.`;\n if (min !== undefined) return `Enter ${a} or more.`;\n if (max !== undefined) return `Enter ${b} or less.`;\n return \"Enter a number.\";\n}\n\nconst REPEAT_AFTER_MS = 400;\nconst REPEAT_EVERY_MS = 60;\n\nconst round = (n: number, places: number) => Number(n.toFixed(places));\nconst signed = (n: number) => (n < 0 ? \"\\u2212\" : \"+\") + String(Math.abs(n));\n\n/** A number with a unit on React Aria's number field: typed input is validated, not clamped, so an out-of-range value is explained in the surrounding `Field` and never passed on; empty stays `null`. `nudge` adds step buttons that repeat when held, `suggestion` a value the app proposes with its reason, and `preview` holds changes back behind Apply and Revert. */\nexport function NumberField({\n value,\n onChange,\n min,\n max,\n step = 1,\n places,\n unit,\n locale = format.locale,\n required = false,\n disabled,\n id: idProp,\n name,\n size = \"default\",\n nudge,\n suggestion,\n preview,\n applyLabels = { idle: \"Apply\", pending: \"Applying…\", done: \"Applied\" },\n className,\n \"aria-label\": ariaLabel,\n}: NumberFieldProps) {\n const { field, report } = useFieldControl();\n const digits = places ?? Math.max(decimalsOf(step), min === undefined ? 0 : decimalsOf(min), ...(nudge ?? []).map(decimalsOf));\n const show = useNumberText(locale, digits);\n const [own, setOwn] = React.useState(false); // invalid, when there is no Field to say so\n const unitId = React.useId();\n // What the field shows. It follows `value`, but also holds an entry we refused, so the person sees\n // (and can correct) what they typed instead of the field snapping back to the old value.\n const [local, setLocal] = React.useState<number>(value ?? Number.NaN);\n const [seen, setSeen] = React.useState(value);\n // With `preview`: the accepted entry that is not applied yet. `undefined` is none; `null` is \"cleared\".\n const [pending, setPending] = React.useState<number | null | undefined>(undefined);\n if (seen !== value) {\n setSeen(value);\n setLocal(value ?? Number.NaN);\n setPending(undefined);\n }\n const held = preview !== undefined;\n const latest = React.useRef(local);\n latest.current = local;\n\n const fail = (message: string) => {\n setOwn(true);\n report(message);\n };\n const ok = () => {\n setOwn(false);\n report(undefined);\n };\n\n const accept = (n: number | null) => {\n if (held) setPending(n === value ? undefined : n);\n else if (n !== value) void onChange(n);\n };\n const handle = (n: number) => {\n latest.current = n;\n setLocal(n);\n if (Number.isNaN(n)) {\n if (required) return fail(\"Enter a value.\");\n ok();\n accept(null);\n return;\n }\n if ((min !== undefined && n < min) || (max !== undefined && n > max)) return fail(describeRange(min, max, show, unit));\n ok();\n accept(n);\n };\n\n const apply = useAsyncAction(async () => {\n if (pending === undefined) return;\n await onChange(pending);\n });\n const revert = () => {\n setLocal(value ?? Number.NaN);\n setPending(undefined);\n ok();\n };\n\n // Nudging: from what the field shows (a refused entry counts), held at the limits.\n const timers = React.useRef<{ first?: number; every?: number }>({});\n const stopNudge = React.useCallback(() => {\n window.clearTimeout(timers.current.first);\n window.clearInterval(timers.current.every);\n }, []);\n React.useEffect(() => stopNudge, [stopNudge]);\n const stepBy = (delta: number) => {\n const base = Number.isNaN(latest.current) ? 0 : latest.current;\n let next = round(base + delta, digits);\n if (min !== undefined) next = Math.max(next, min);\n if (max !== undefined) next = Math.min(next, max);\n if (next === base) return stopNudge();\n handle(next);\n };\n const startNudge = (delta: number) => {\n stopNudge();\n stepBy(delta);\n timers.current.first = window.setTimeout(() => {\n timers.current.every = window.setInterval(() => stepBy(delta), REPEAT_EVERY_MS);\n }, REPEAT_AFTER_MS);\n };\n\n const invalid = field?.invalid || own;\n const name_ = ariaLabel ?? field?.label ?? \"value\";\n const current = Number.isNaN(local) ? null : local;\n const field_ = (\n <I18nProvider locale={locale}>\n <AriaNumberField\n value={local}\n onChange={handle}\n minValue={min}\n maxValue={max}\n step={step}\n formatOptions={{ maximumFractionDigits: digits, minimumFractionDigits: 0 }}\n commitBehavior=\"validate\"\n isDisabled={disabled}\n isInvalid={invalid || undefined}\n name={name}\n aria-label={ariaLabel ?? field?.label}\n className={cn(box, controlHeight[size], nudge ? \"min-w-32 flex-1\" : undefined, !nudge && !suggestion && !held && className)}\n >\n <AriaInput\n id={idProp ?? field?.id}\n placeholder={format.missing}\n aria-describedby={[field?.describedBy, unit ? unitId : undefined].filter(Boolean).join(\" \") || undefined}\n className=\"min-w-0 flex-1 bg-transparent tabular-nums outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed\"\n />\n {unit && (\n <span id={unitId} className=\"ml-2 shrink-0 type-body-sm text-muted-foreground\">\n <span aria-hidden>{unit}</span>\n <span className=\"sr-only\">{intlUnits[unit] ? intlUnits[unit].replace(/-/g, \" \") : unit}</span>\n </span>\n )}\n </AriaNumberField>\n </I18nProvider>\n );\n if (!nudge && !suggestion && !held) return field_;\n\n const sizes = [...new Set(nudge ?? [])].filter((n) => n > 0).sort((a, b) => a - b);\n const steps = [...sizes.slice().reverse().map((n) => -n), ...sizes];\n const row = (\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n {field_}\n {steps.length > 0 && (\n <Toolbar label={`Nudge ${name_}`} className=\"gap-1\">\n {steps.map((delta) => {\n const base = current ?? 0;\n const atLimit = delta < 0 ? min !== undefined && base <= min : max !== undefined && base >= max;\n return (\n <Button\n key={delta}\n size={size === \"sm\" ? \"sm\" : \"default\"}\n className=\"tabular-nums\"\n disabled={disabled || atLimit}\n aria-label={`${delta < 0 ? \"Subtract\" : \"Add\"} ${withUnit(show(Math.abs(delta)), unit)}`}\n onPressStart={() => startNudge(delta)}\n onPressEnd={stopNudge}\n >\n {signed(delta)}\n </Button>\n );\n })}\n </Toolbar>\n )}\n </div>\n );\n const shown = suggestion && current !== suggestion.value ? suggestion : undefined;\n const suggestionId = `${unitId}-suggestion`;\n const label = shown && (shown.label ?? withUnit(show(shown.value), unit));\n return (\n <div className={cn(\"grid min-w-0 gap-2\", className)}>\n {row}\n {shown && (\n <div className=\"flex flex-wrap items-center gap-x-3 gap-y-1\">\n <p id={suggestionId} className=\"min-w-0 flex-1 type-body-sm text-muted-foreground\">\n <span className=\"text-foreground\">Suggested {label}:</span> {shown.reason}\n </p>\n <Button size=\"sm\" disabled={disabled} aria-describedby={suggestionId} onPress={() => handle(shown.value)}>\n Use this value\n </Button>\n </div>\n )}\n {held && pending !== undefined && (\n <div role=\"group\" aria-label=\"Change not applied yet\" className=\"grid gap-3 rounded-surface bg-surface-sunken p-3\">\n {typeof preview === \"function\" ? preview(pending) : preview}\n <div className=\"flex flex-wrap items-center gap-2\">\n <AsyncButton\n variant=\"default\"\n size=\"sm\"\n phase={apply.phase}\n error={apply.error}\n labels={applyLabels}\n disabled={disabled || invalid}\n onPress={() => void apply.run()}\n />\n <Button size=\"sm\" variant=\"ghost\" disabled={apply.phase === \"pending\"} onPress={revert}>\n Revert\n </Button>\n </div>\n </div>\n )}\n </div>\n );\n}\n\n/** Props for `Slider`. */\nexport type SliderProps = RangeProps & {\n value: number;\n onChange: (value: number) => void;\n /** Both limits are required: a slider with no ends is not a slider. */\n min: number;\n max: number;\n /** Replace the printed value with a `NumberField` beside the track, so an exact value can be typed. */\n editable?: boolean;\n /** Hide the printed value (when something else beside it already shows it). */\n hideValue?: boolean;\n /** Decimal places in the printed and spoken value. Default the places in `step`. */\n places?: number;\n disabled?: boolean;\n /** Names the slider when it is used without a `Field`. */\n \"aria-label\"?: string;\n className?: string;\n};\n\n/** A slider on React Aria with its current value always printed beside the track (and spoken with the unit when `Intl` knows it); `editable` adds a number field to type an exact value. */\nexport function Slider({\n value,\n onChange,\n min,\n max,\n step = 1,\n unit,\n locale = format.locale,\n editable = false,\n hideValue = false,\n places,\n disabled,\n className,\n \"aria-label\": ariaLabel,\n}: SliderProps) {\n const { field } = useFieldControl();\n const digits = places ?? Math.max(decimalsOf(step), decimalsOf(min));\n const show = useNumberText(locale, digits);\n const name = ariaLabel ?? field?.label ?? \"Value\";\n const text = withUnit(show(value), unit);\n return (\n <I18nProvider locale={locale}>\n <AriaSlider\n value={value}\n onChange={(v) => onChange(v as number)}\n minValue={min}\n maxValue={max}\n step={step}\n formatOptions={formatOptionsFor(digits, unit)}\n isDisabled={disabled}\n aria-label={name}\n aria-describedby={field?.describedBy}\n className={cn(\"flex min-w-0 items-center gap-3\", className)}\n >\n <SliderTrack className=\"relative flex h-(--control-h) min-w-0 flex-1 cursor-pointer items-center disabled:cursor-not-allowed disabled:opacity-50\">\n {({ state }) => (\n <>\n <span aria-hidden className=\"absolute inset-x-0 h-1.5 rounded-pill bg-muted\" />\n <span aria-hidden className=\"absolute left-0 h-1.5 rounded-pill bg-primary\" style={{ width: `${state.getThumbPercent(0) * 100}%` }} />\n <SliderThumb className=\"top-1/2 size-5 rounded-pill border-2 border-primary bg-background focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\" />\n </>\n )}\n </SliderTrack>\n {editable ? (\n <NumberField className=\"w-28 shrink-0\" aria-label={`${name}, exact value`} value={value} onChange={(v) => { if (v !== null) onChange(v); }} min={min} max={max} step={step} unit={unit} locale={locale} places={digits} required disabled={disabled} />\n ) : (\n !hideValue && (\n <SliderOutput aria-hidden className=\"w-16 shrink-0 text-right type-body-sm tabular-nums text-foreground\">\n {text}\n </SliderOutput>\n )\n )}\n </AriaSlider>\n </I18nProvider>\n );\n}\n\n/** Props for `ColorField`. */\nexport type ColorFieldProps = {\n /** `#rrggbb`, or `null` when no colour is set. */\n value: string | null;\n /** Receives a valid `#rrggbb` (lower case) or `null` when cleared; never a half-typed value. */\n onChange: (value: string | null) => void;\n /** A short list the app suggests, as `#rrggbb`. Pressing one chooses it. */\n suggestions?: readonly string[];\n /** The colour this will be drawn on, `#rrggbb`: a note appears when the contrast would be low. */\n against?: string;\n /** What it is drawn on, in words: \"the map\". Completes the note. */\n againstLabel?: string;\n /** The lowest contrast ratio accepted before the note shows. Default 3, the WCAG minimum for graphics. */\n minContrast?: number;\n disabled?: boolean;\n \"aria-label\"?: string;\n id?: string;\n className?: string;\n};\n\n/** Choose a colour with the platform picker, see and type its hex value, pick from the app's suggestions, and get a note when it would be hard to see on `against`. A half-typed value is never passed on. */\nexport function ColorField({ value, onChange, suggestions, against, againstLabel = \"the background\", minContrast = 3, disabled, id: idProp, className, \"aria-label\": ariaLabel }: ColorFieldProps) {\n const { field, report } = useFieldControl();\n // Named for the `aria-label` or, failing that, the surrounding Field's label, so two colour fields in one panel never share a name (issue #116).\n const label = ariaLabel ?? field?.label;\n const pickerName = label ? `${label}, picker` : \"Colour picker\";\n const [draft, setDraft] = React.useState<string | null>(null);\n const [own, setOwn] = React.useState(false);\n const text = draft ?? value ?? \"\";\n const ratio = value && against ? contrastRatio(value, against) : null;\n\n const commitText = (t: string): boolean => {\n if (t.trim() === \"\") {\n setOwn(false);\n report(undefined);\n if (value !== null) onChange(null);\n return true;\n }\n const hex = parseHex(t);\n if (!hex) {\n setOwn(true);\n report(\"Enter a colour like #1a7f64.\");\n return false;\n }\n setOwn(false);\n report(undefined);\n if (hex !== value) onChange(hex);\n return true;\n };\n\n const pick = (hex: string) => {\n setDraft(null);\n setOwn(false);\n report(undefined);\n if (hex !== value) onChange(hex);\n };\n\n const invalid = field?.invalid || own;\n return (\n <div className={cn(\"grid min-w-0 gap-2\", className)}>\n <div className={cn(box, controlHeight.default, \"gap-2 px-2\")} aria-invalid={invalid || undefined}>\n <span className=\"relative size-6 shrink-0 overflow-hidden rounded-control border border-input\">\n {/* The swatch is the chosen colour itself: user content, not a theme role. */}\n <span aria-hidden className={cn(\"absolute inset-0\", value === null && \"bg-muted\")} style={value ? { background: value } : undefined} />\n <input\n type=\"color\"\n aria-label={pickerName}\n value={value ?? \"#000000\"}\n disabled={disabled}\n onChange={(e) => pick(e.target.value)}\n className=\"absolute inset-0 size-full cursor-pointer opacity-0 disabled:cursor-not-allowed\"\n />\n </span>\n <input\n id={idProp ?? field?.id}\n type=\"text\"\n autoComplete=\"off\"\n spellCheck={false}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-describedby={field?.describedBy}\n aria-invalid={invalid || undefined}\n placeholder={format.missing}\n value={text}\n onChange={(e) => setDraft(e.target.value)}\n onBlur={() => {\n if (draft !== null && commitText(draft)) setDraft(null);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && draft !== null && commitText(draft)) setDraft(null);\n if (e.key === \"Escape\" && draft !== null) {\n setDraft(null);\n setOwn(false);\n report(undefined);\n }\n }}\n className=\"min-w-0 flex-1 bg-transparent tabular-nums outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed\"\n />\n </div>\n {suggestions && suggestions.length > 0 && (\n <div role=\"group\" aria-label=\"Suggested colours\" className=\"flex flex-wrap gap-1.5\">\n {suggestions.map((hex) => (\n <button\n key={hex}\n type=\"button\"\n disabled={disabled}\n aria-label={hex}\n aria-pressed={value === hex}\n onClick={() => pick(hex)}\n className=\"size-6 cursor-pointer rounded-control border border-input transition-state aria-pressed:outline-2 aria-pressed:outline-offset-2 aria-pressed:outline-foreground disabled:cursor-not-allowed disabled:opacity-50\"\n style={{ background: hex }}\n />\n ))}\n </div>\n )}\n {ratio !== null && ratio < minContrast && (\n <p className=\"type-body-sm text-warning\">\n Hard to see on {againstLabel}: contrast {format.decimal(ratio)}:1, aim for {format.decimal(minContrast)}:1 or more.\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,SAAgB,UAAU,EAAE,SAAS,MAAM,aAAa,OAAO,OAAO,OAAO,cAAc,UAAyB,CAAC,GAAG;CACtH,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAS,KAAK;CAChD,MAAM,CAAC,IAAI,SAAS,MAAM,SAAyB,IAAI;CACvD,MAAM,OAAO,QAAQ;CACrB,MAAM,gBAAgB;EACpB,IAAI,MAAM;EACV,IAAI,CAAC,UAAU,CAAC,IAAI;GAClB,UAAU,KAAK;GACf;EACF;EACA,IAAI,OAAO,yBAAyB,aAAa;GAC/C,UAAU,WAAW;GACrB;EACF;EACA,MAAM,OAAO,GAAG,eAAe,QAAqB,sBAAsB,KAAK;EAC/E,MAAM,WAAW,IAAI,sBAAsB,YAAY,UAAU,QAAQ,QAAQ,SAAS,EAAE,CAAC,cAAc,GAAG;GAAE;GAAM;EAAW,CAAC;EAClI,SAAS,QAAQ,EAAE;EACnB,aAAa,SAAS,WAAW;CACnC,GAAG;EAAC;EAAQ;EAAI;EAAY;EAAM;CAAW,CAAC;CAC9C,OAAO;EAAE,KAAK;EAAO;CAAO;AAC9B;;ACvBA,IAAM,qCAAqB,IAAI,IAAI;CAAC;CAAY;CAAS;CAAU;CAAU;CAAS;CAAS;CAAS;AAAM,CAAC;;AAG/G,SAAgB,eAAe,QAAqC;CAClE,IAAI,EAAE,kBAAkB,cAAc,OAAO;CAC7C,IAAI,OAAO,qBAAqB,OAAO,QAAQ,+CAA+C,GAAG,OAAO;CACxG,IAAI,kBAAkB,uBAAuB,kBAAkB,mBAAmB,OAAO;CACzF,IAAI,kBAAkB,kBAAkB,OAAO,CAAC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CACG;IACN,CAAA,GAAA,oBAAC,SAAD;KACE,IAAI,UAAU,OAAO;KACrB,MAAK;KACL,cAAa;KACb,YAAY;KACF;KACV,cAAY;KACZ,oBAAkB,OAAO;KACzB,gBAAc,WAAW,KAAA;KACzB,aAAa,OAAO;KACpB,OAAO;KACP,WAAW,MAAM,SAAS,EAAE,OAAO,KAAK;KACxC,cAAc;MACZ,IAAI,UAAU,QAAQ,WAAW,KAAK,GAAG,SAAS,IAAI;KACxD;KACA,YAAY,MAAM;MAChB,IAAI,EAAE,QAAQ,WAAW,UAAU,QAAQ,WAAW,KAAK,GAAG,SAAS,IAAI;MAC3E,IAAI,EAAE,QAAQ,YAAY,UAAU,MAAM;OACxC,SAAS,IAAI;OACb,OAAO,KAAK;OACZ,OAAO,KAAA,CAAS;MAClB;KACF;KACA,WAAU;IACX,CAAA,CACE;;GACJ,eAAe,YAAY,SAAS,KACnC,oBAAC,OAAD;IAAK,MAAK;IAAQ,cAAW;IAAoB,WAAU;IACxD,UAAA,YAAY,KAAK,QAChB,oBAAC,UAAD;KAEE,MAAK;KACK;KACV,cAAY;KACZ,gBAAc,UAAU;KACxB,eAAe,KAAK,GAAG;KACvB,WAAU;KACV,OAAO,EAAE,YAAY,IAAI;IAC1B,GARM,GAQN,CACF;GACE,CAAA;GAEN,UAAU,QAAQ,QAAQ,eACzB,qBAAC,KAAD;IAAG,WAAU;IAAb,UAAA;KAAyC;KACvB;KAAa;KAAY,OAAO,QAAQ,KAAK;KAAE;KAAa,OAAO,QAAQ,WAAW;KAAE;IACvG;;EAEF;;AAET"}
|
|
1
|
+
{"version":3,"file":"value-controls-B7iNh4WO.js","names":["Toolbar","AriaToolbar","_Fragment","Button","NumberField","AriaNumberField","AriaInput","Toolbar","Button","Slider","AriaSlider","_Fragment"],"sources":["../src/lib/in-view.ts","../src/components/hotkeys.tsx","../src/components/toolbar.tsx","../src/components/async-button.tsx","../src/lib/number-input.ts","../src/components/value-controls.tsx"],"sourcesContent":["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 { KeyText } from \"./key-glyphs\";\nimport * 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 <KeyText>{KEY_NAMES[k] ?? k}</KeyText>\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 { Toolbar as AriaToolbar, Separator } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\nimport { isTypingTarget } from \"./hotkeys\";\n\n// A toolbar groups controls that act on what is shown (a preview's grid and quality, a timeline's\n// snap, a table's density). React Aria gives it the WAI-ARIA toolbar keyboard model: one tab stop,\n// arrow keys (and Home and End) move inside it, Tab leaves it. It needs a `label`, as an unnamed\n// toolbar is announced as nothing. Groups inside it are separated by a hairline (`ToolbarSeparator`)\n// rather than by space alone, so a row of eight small controls reads as three groups. It lays out\n// as one wrapping row: when it runs out of width, controls wrap to the next line instead of being\n// hidden behind an overflow menu, which keeps every control reachable with no extra state\n// (an overflow menu is the later step, once the Menu exists).\n\n// A slider keeps its own Home and End (to its ends), as a typing target keeps its own: a size slider\n// in a toolbar (`ViewOptions`) would otherwise lose them to \"first control\".\nconst isRange = (t: EventTarget | null) => t instanceof HTMLInputElement && t.type === \"range\";\n\n/** Props for `Toolbar`. */\nexport type ToolbarProps = {\n /** Names the toolbar for screen readers: \"Preview options\". Required. */\n label: string;\n orientation?: \"horizontal\" | \"vertical\";\n children: React.ReactNode;\n className?: string;\n};\n\n/** A group of controls with one tab stop and arrow-key movement (the WAI-ARIA toolbar pattern). Needs a `label`. */\nexport function Toolbar({ label, orientation = \"horizontal\", children, className }: ToolbarProps) {\n // React Aria's toolbar moves with the arrow keys; Home and End (to the first and last control) are\n // added here, as the WAI-ARIA toolbar pattern lists them. The capture phase runs before React\n // Aria's own handler, and a typing target (a number field inside the toolbar) keeps its Home and End.\n const jump = (e: React.KeyboardEvent<HTMLElement>) => {\n // Only events from inside the toolbar's own DOM: a Popover opened from a control here renders in\n // a portal, and its events still reach this handler through React's tree.\n if ((e.key !== \"Home\" && e.key !== \"End\") || isTypingTarget(e.target) || isRange(e.target) || !e.currentTarget.contains(e.target as Node)) return;\n const items = [...e.currentTarget.querySelectorAll<HTMLElement>(\"button, input, select, textarea, a[href], [tabindex]\")].filter(\n (el) => !el.hasAttribute(\"disabled\") && el.getAttribute(\"aria-disabled\") !== \"true\" && el.tabIndex >= -1 && el.getAttribute(\"role\") !== \"separator\",\n );\n const target = e.key === \"Home\" ? items[0] : items[items.length - 1];\n if (!target) return;\n e.preventDefault();\n e.stopPropagation();\n target.focus();\n };\n return (\n <div className=\"contents\" onKeyDownCapture={jump}>\n <AriaToolbar\n aria-label={label}\n orientation={orientation}\n className={cn(\"flex flex-wrap items-center gap-1\", orientation === \"vertical\" && \"flex-col items-stretch\", className)}\n >\n {children}\n </AriaToolbar>\n </div>\n );\n}\n\n/** A hairline between groups of controls inside a `Toolbar`. */\nexport function ToolbarSeparator({ className }: { className?: string }) {\n return <Separator className={cn(\"mx-1 h-5 w-px self-center border-0 bg-border\", className)} />;\n}\n","import * as React from \"react\";\nimport { Check, CircleAlert, LoaderCircle } from \"lucide-react\";\nimport { Button, type ButtonProps } from \"./button\";\nimport { describeActionError, fieldErrorsOf } 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//\n// The button carries `data-phase` (and Button's `data-variant`), so a test reads which phase it is\n// in without matching four stacked labels in its text (strata-react issue #48); `asyncButtonPhase`\n// in strata-react/testing reads it.\n//\n// `useAsyncAction` also owns a form's field messages (strata-react issues #42 and #46). `validate`\n// runs before the action, and messages it returns stop the run and land on `fieldErrors`, keyed by\n// field; a server's per-field messages (an HttpError's `fieldErrors`, from a 422) land there too.\n// A screen passes `fieldErrors.link` to `Field error=` and keeps no `problem` state of its own.\n// Failing validation leaves the button idle, not \"Try again\": nothing was tried. `onInvalid` runs\n// once the messages are on screen, to move focus to the first field named.\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} data-phase={phase} disabled={disabled || phase === \"pending\"} aria-disabled={phase === \"pending\" || undefined} aria-busy={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/** Messages for a form's fields, keyed by field name. */\nexport type FieldErrors = Readonly<Record<string, string>>;\n\n/** Options for `useAsyncAction`. */\nexport type AsyncActionOptions<A extends unknown[] = unknown[]> = {\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 /** Checks the arguments before the action runs. A message for any field stops the run and is put on `fieldErrors`; the button stays idle. */\n validate?: (...args: A) => Record<string, string | undefined> | undefined;\n /** Called once validation's messages are on screen: to move focus to the first field named. */\n onInvalid?: (fieldErrors: FieldErrors) => void;\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 /** What the action threw, while `phase` is `error`: to read more than the sentence (an HttpError's `status` or `body`). */\n thrown: unknown;\n /** Messages per field, from `validate` or from the server (an HttpError's `fieldErrors`). Pass each to its `Field`'s `error`. Cleared by the next run. */\n fieldErrors: FieldErrors;\n /** Clears one field's message (as the person edits it), or all of them. */\n clearFieldError: (field?: string) => void;\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, its error and any field messages. `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, validate, onInvalid }: AsyncActionOptions<A> = {},\n): AsyncAction<A> {\n const [state, setState] = React.useState<ActionState>(idle);\n const timer = React.useRef<number | undefined>(undefined);\n const unreported = React.useRef<{ thrown: unknown } | { invalid: FieldErrors } | undefined>(undefined);\n const latest = React.useRef({ action, onError, settleMs, describeError, validate, onInvalid });\n React.useLayoutEffect(() => {\n latest.current = { action, onError, settleMs, describeError, validate, onInvalid };\n });\n // An action that settles after the component has gone (a test's teardown, a route change) must not set state or start the settle timer: after jsdom is torn down React reads `window` and throws (issue #267).\n const mounted = React.useRef(true);\n React.useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n window.clearTimeout(timer.current);\n };\n }, []);\n const run = React.useCallback(async (...args: A) => {\n window.clearTimeout(timer.current);\n const invalid = messages(latest.current.validate?.(...args));\n if (invalid) {\n unreported.current = { invalid };\n setState({ ...idle, fieldErrors: invalid });\n return;\n }\n setState({ ...idle, phase: \"pending\" });\n try {\n await latest.current.action(...args);\n if (!mounted.current) return;\n setState({ ...idle, phase: \"done\" });\n timer.current = window.setTimeout(() => setState(idle), latest.current.settleMs);\n } catch (thrown) {\n if (!mounted.current) return;\n unreported.current = { thrown };\n setState({ phase: \"error\", error: latest.current.describeError(thrown), thrown, fieldErrors: fieldErrorsOf(thrown) });\n }\n }, []);\n // onError and onInvalid run after their render commits, not inside run: there the button is\n // still disabled from `pending` and a 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 const note = unreported.current;\n if (!note) return;\n if (\"thrown\" in note && state.phase === \"error\") latest.current.onError?.(note.thrown);\n else if (\"invalid\" in note) latest.current.onInvalid?.(note.invalid);\n else return;\n unreported.current = undefined;\n }, [state]);\n const clearFieldError = React.useCallback(\n (field?: string) =>\n setState((s) => {\n if (field === undefined) return Object.keys(s.fieldErrors).length ? { ...s, fieldErrors: {} } : s;\n if (!(field in s.fieldErrors)) return s;\n const { [field]: _gone, ...rest } = s.fieldErrors;\n return { ...s, fieldErrors: rest };\n }),\n [],\n );\n return { phase: state.phase, run, error: state.error, thrown: state.thrown, fieldErrors: state.fieldErrors, clearFieldError };\n}\n\ntype ActionState = { phase: Phase; error: string | undefined; thrown: unknown; fieldErrors: FieldErrors };\nconst idle: ActionState = { phase: \"idle\", error: undefined, thrown: undefined, fieldErrors: {} };\n\n/** The messages `validate` returned, without the empty ones; undefined when there are none. */\nfunction messages(found: Record<string, string | undefined> | undefined): FieldErrors | undefined {\n if (!found) return undefined;\n const kept = Object.fromEntries(Object.entries(found).filter((e): e is [string, string] => Boolean(e[1])));\n return Object.keys(kept).length ? kept : undefined;\n}\n","// Colour rules for `ColorField` (issue #73): reading a typed hex, and the WCAG contrast ratio\n// against what the colour is drawn on, which a user-chosen colour (content, not theme) is checked\n// with. Number parsing and stepping are React Aria's.\n\n/** Reads `#rgb`, `#rrggbb` (with or without the #) as lower-case `#rrggbb`, or null. */\nexport function parseHex(text: string): string | null {\n const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(text.trim());\n if (!m) return null;\n const h = m[1].toLowerCase();\n return \"#\" + (h.length === 3 ? [...h].map((c) => c + c).join(\"\") : h);\n}\n\nfunction luminance(hex: string): number {\n const v = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255).map((c) => (c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));\n return 0.2126 * v[0] + 0.7152 * v[1] + 0.0722 * v[2];\n}\n\n/** WCAG contrast ratio between two `#rrggbb` colours, 1 to 21. */\nexport function contrastRatio(a: string, b: string): number {\n const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);\n return (hi + 0.05) / (lo + 0.05);\n}\n","import * as React from \"react\";\nimport {\n I18nProvider,\n Input as AriaInput,\n NumberField as AriaNumberField,\n Slider as AriaSlider,\n SliderOutput,\n SliderThumb,\n SliderTrack,\n} from \"react-aria-components\";\nimport { useFieldControl } from \"./field\";\nimport { AsyncButton, useAsyncAction } from \"./async-button\";\nimport { Button } from \"./button\";\nimport { Toolbar } from \"./toolbar\";\nimport { NBSP, format } from \"../lib/format\";\nimport { contrastRatio, parseHex } from \"../lib/number-input\";\nimport { cn } from \"../lib/utils\";\nimport { controlHeight, type ControlSize } from \"../lib/control\";\n\n// Controls for setting a number or a colour precisely (strata-react issue #73, from moving\n// strata-vid onto Strata: opacity, rotation, volume, bitrate, a line colour). The native ones fail\n// in the same few ways, and each rule below answers one:\n//\n// - `parseFloat(e.target.value)` turns an empty field into NaN. Here a value that is not known is\n// `null`, stays `null`, and prints `format.missing`; a typed value outside the limits is NOT\n// clamped and NOT passed on: React Aria's field runs with `commitBehavior=\"validate\"` (it keeps\n// what was typed instead of snapping 600 to 500), and the control tells the surrounding `Field`\n// what is wrong (\"Enter a value from 0% to 500%.\"), the same place a server's 422 appears. The\n// callback only ever receives a number inside the limits, or null.\n// - The unit lives inside the control, muted. A slider's spoken value carries it (\"40%\", \"90°\")\n// when `Intl` knows the unit (percent, degree, millisecond, megabit-per-second and the like):\n// React Aria builds `aria-valuetext` from an `Intl.NumberFormat`, so \"px\" or \"steps\" are in the\n// printed value and the label but cannot be in the spoken one.\n// - Digits are the locale's: what is printed and what is read back go through `Intl` (React Aria's\n// `NumberParser`), so 12,5 works in a de-DE app, and the message is in the same digits.\n// - Behaviour is React Aria's: arrows step, PageUp/PageDown take ten steps, Home/End jump to the\n// limits, a field commits on Enter and blur. Nothing animates when a value changes: these are\n// dragged and stepped dozens of times a minute (character.md, the frequency budget).\n// - A colour a person picks for their own content (a route's line) is content, not theme, so it is\n// the one place a raw colour value is right; `against` checks it against what it is drawn on.\n// The colour field's text box is ours: React Aria's colour field puts the old colour back when\n// the text is not a colour, where this one says so under the control; the swatch opens the\n// platform picker.\n//\n// A value that is set a little at a time, or that costs work to change (strata-react issue #224,\n// from strata-360's camera clock offset, which re-times everything) gets three options on\n// `NumberField`, each an extension of React Aria's field, not a new control:\n// - `nudge={[0.1, 1, 10]}`: a `Toolbar` of \"−10 −1 −0.1 +0.1 +1 +10\" beside the field, each named\n// (\"Subtract 1 s\"). A press steps once at once; held, the first repeat comes after 400 ms and then\n// every 60 ms (React Aria's own stepper buttons repeat too, but it exposes no hook to put that\n// on buttons of ours, checked in `useNumberField`/`useSpinButton`; the timer here is the same\n// idea). The result is rounded to the field's places (0.1 + 0.2 is 0.3) and held at `min`/`max`;\n// a button that would go past a limit is disabled.\n// - `suggestion={{ value, label, reason }}`: a row under the field that says what the app suggests\n// and why, in text, with \"Use this value\". It never changes the field by itself, and it goes\n// away once the field holds the suggestion.\n// - `preview`: the field stops committing as it goes. `value` is the saved one, an entry or nudge\n// is only pending, and while it differs the preview (a node, or a function of the pending value)\n// is shown with Apply, the view's one filled button, and Revert. `onChange` is called once, by\n// Apply, and may return a promise, which Apply shows through `AsyncButton`.\n\nconst box =\n \"flex w-full min-w-0 items-center rounded-control border border-input bg-background px-3 type-body text-foreground transition-state disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-70 has-[input:disabled]:cursor-not-allowed has-[input:disabled]:bg-muted has-[input:disabled]:opacity-70 aria-invalid:border-danger has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-offset-2 has-[input:focus-visible]:outline-ring\";\n\n/** A number with its unit joined by a non-breaking space; `%` and `°` stay attached. */\nfunction withUnit(text: string, unit?: string) {\n if (!unit) return text;\n return unit === \"%\" || unit === \"°\" ? text + unit : text + NBSP + unit;\n}\n\n// Units `Intl` can speak, by the symbol an app prints. Anything else is printed but not spoken.\nconst intlUnits: Record<string, string> = {\n \"%\": \"percent\",\n \"°\": \"degree\",\n ms: \"millisecond\",\n s: \"second\",\n kB: \"kilobyte\",\n MB: \"megabyte\",\n GB: \"gigabyte\",\n kbps: \"kilobit-per-second\",\n Mbps: \"megabit-per-second\",\n};\n\nfunction decimalsOf(n: number): number {\n const s = String(n);\n if (s.includes(\"e-\")) return Number(s.split(\"e-\")[1]) + (s.split(\"e-\")[0].split(\".\")[1]?.length ?? 0);\n return s.split(\".\")[1]?.length ?? 0;\n}\n\nfunction useNumberText(locale: string, places: number) {\n return React.useMemo(() => {\n const f = new Intl.NumberFormat(locale, { maximumFractionDigits: places, minimumFractionDigits: 0 });\n return (n: number) => f.format(n);\n }, [locale, places]);\n}\n\nfunction formatOptionsFor(places: number, unit?: string): Intl.NumberFormatOptions {\n const base: Intl.NumberFormatOptions = { maximumFractionDigits: places, minimumFractionDigits: 0 };\n const known = unit ? intlUnits[unit] : undefined;\n return known ? { ...base, style: \"unit\", unit: known, unitDisplay: \"narrow\" } : base;\n}\n\n/** Props shared by the number field and the slider. */\nexport type RangeProps = {\n min?: number;\n max?: number;\n /** The size of one arrow-key step. Default 1. */\n step?: number;\n /** The unit shown with the value: \"%\", \"°\", \"Mbps\", \"px\". Spoken too when `Intl` has it (%, °, ms, s, kB, MB, GB, kbps, Mbps). */\n unit?: string;\n /** The locale for digits and the decimal mark. Default the app's `format` locale. */\n locale?: string;\n};\n\n/** Props for `NumberField`. */\nexport type NumberFieldProps = RangeProps & {\n /** The current value; `null` when it is not known (shown as an en dash, not 0). */\n value: number | null;\n /** Receives a number inside the limits, or `null` when the field is cleared. Never NaN, never out of range. With `preview`, only Apply calls it, and it may return a promise. */\n onChange: (value: number | null) => void | Promise<unknown>;\n /** Decimal places to show and keep. Default the places in `step` (and `min`). */\n places?: number;\n /** An empty field is an error (\"Enter a value.\") rather than `null`. */\n required?: boolean;\n disabled?: boolean;\n /** Names the control when it is used without a `Field`. */\n \"aria-label\"?: string;\n id?: string;\n name?: string;\n /** `sm` is --control-h-sm, the height of a small `Toggle` or `IconButton` beside it. Default --control-h. */\n size?: ControlSize;\n /** Step buttons beside the field, each a size in the field's unit: `[0.1, 1, 10]` draws \"−10 −1 −0.1 +0.1 +1 +10\". Held, they repeat. They honour `min` and `max`. */\n nudge?: readonly number[];\n /** What the app suggests, drawn as a row under the field with \"Use this value\". `label` is the value as the person reads it (\"+2.4 s\"); `reason` says why, in words. Choosing it sets the field's value, which `preview` still holds back until Apply. */\n suggestion?: { value: number; label?: string; reason: string };\n /** Hold changes back until the person applies them: shown while the value differs from `value` (the saved one), as a node or a function of the pending value. `onChange` is then called by Apply only. */\n preview?: React.ReactNode | ((pending: number | null) => React.ReactNode);\n /** Apply's words in preview mode, the same verb through its states. Default \"Apply\" → \"Applying…\" → \"Applied\". */\n applyLabels?: { idle: string; pending: string; done: string };\n className?: string;\n};\n\nfunction describeRange(min: number | undefined, max: number | undefined, show: (n: number) => string, unit?: string) {\n const a = min === undefined ? \"\" : withUnit(show(min), unit);\n const b = max === undefined ? \"\" : withUnit(show(max), unit);\n if (min !== undefined && max !== undefined) return `Enter a value from ${a} to ${b}.`;\n if (min !== undefined) return `Enter ${a} or more.`;\n if (max !== undefined) return `Enter ${b} or less.`;\n return \"Enter a number.\";\n}\n\nconst REPEAT_AFTER_MS = 400;\nconst REPEAT_EVERY_MS = 60;\n\nconst round = (n: number, places: number) => Number(n.toFixed(places));\nconst signed = (n: number) => (n < 0 ? \"\\u2212\" : \"+\") + String(Math.abs(n));\n\n/** A number with a unit on React Aria's number field: typed input is validated, not clamped, so an out-of-range value is explained in the surrounding `Field` and never passed on; empty stays `null`. `nudge` adds step buttons that repeat when held, `suggestion` a value the app proposes with its reason, and `preview` holds changes back behind Apply and Revert. */\nexport function NumberField({\n value,\n onChange,\n min,\n max,\n step = 1,\n places,\n unit,\n locale = format.locale,\n required = false,\n disabled,\n id: idProp,\n name,\n size = \"default\",\n nudge,\n suggestion,\n preview,\n applyLabels = { idle: \"Apply\", pending: \"Applying…\", done: \"Applied\" },\n className,\n \"aria-label\": ariaLabel,\n}: NumberFieldProps) {\n const { field, report } = useFieldControl();\n const digits = places ?? Math.max(decimalsOf(step), min === undefined ? 0 : decimalsOf(min), ...(nudge ?? []).map(decimalsOf));\n const show = useNumberText(locale, digits);\n const [own, setOwn] = React.useState(false); // invalid, when there is no Field to say so\n const unitId = React.useId();\n // What the field shows. It follows `value`, but also holds an entry we refused, so the person sees\n // (and can correct) what they typed instead of the field snapping back to the old value.\n const [local, setLocal] = React.useState<number>(value ?? Number.NaN);\n const [seen, setSeen] = React.useState(value);\n // With `preview`: the accepted entry that is not applied yet. `undefined` is none; `null` is \"cleared\".\n const [pending, setPending] = React.useState<number | null | undefined>(undefined);\n if (seen !== value) {\n setSeen(value);\n setLocal(value ?? Number.NaN);\n setPending(undefined);\n }\n const held = preview !== undefined;\n const latest = React.useRef(local);\n latest.current = local;\n\n const fail = (message: string) => {\n setOwn(true);\n report(message);\n };\n const ok = () => {\n setOwn(false);\n report(undefined);\n };\n\n const accept = (n: number | null) => {\n if (held) setPending(n === value ? undefined : n);\n else if (n !== value) void onChange(n);\n };\n const handle = (n: number) => {\n latest.current = n;\n setLocal(n);\n if (Number.isNaN(n)) {\n if (required) return fail(\"Enter a value.\");\n ok();\n accept(null);\n return;\n }\n if ((min !== undefined && n < min) || (max !== undefined && n > max)) return fail(describeRange(min, max, show, unit));\n ok();\n accept(n);\n };\n\n const apply = useAsyncAction(async () => {\n if (pending === undefined) return;\n await onChange(pending);\n });\n const revert = () => {\n setLocal(value ?? Number.NaN);\n setPending(undefined);\n ok();\n };\n\n // Nudging: from what the field shows (a refused entry counts), held at the limits.\n const timers = React.useRef<{ first?: number; every?: number }>({});\n const stopNudge = React.useCallback(() => {\n window.clearTimeout(timers.current.first);\n window.clearInterval(timers.current.every);\n }, []);\n React.useEffect(() => stopNudge, [stopNudge]);\n const stepBy = (delta: number) => {\n const base = Number.isNaN(latest.current) ? 0 : latest.current;\n let next = round(base + delta, digits);\n if (min !== undefined) next = Math.max(next, min);\n if (max !== undefined) next = Math.min(next, max);\n if (next === base) return stopNudge();\n handle(next);\n };\n const startNudge = (delta: number) => {\n stopNudge();\n stepBy(delta);\n timers.current.first = window.setTimeout(() => {\n timers.current.every = window.setInterval(() => stepBy(delta), REPEAT_EVERY_MS);\n }, REPEAT_AFTER_MS);\n };\n\n const invalid = field?.invalid || own;\n const name_ = ariaLabel ?? field?.label ?? \"value\";\n const current = Number.isNaN(local) ? null : local;\n const field_ = (\n <I18nProvider locale={locale}>\n <AriaNumberField\n value={local}\n onChange={handle}\n minValue={min}\n maxValue={max}\n step={step}\n formatOptions={{ maximumFractionDigits: digits, minimumFractionDigits: 0 }}\n commitBehavior=\"validate\"\n isDisabled={disabled}\n isInvalid={invalid || undefined}\n name={name}\n aria-label={ariaLabel ?? field?.label}\n className={cn(box, controlHeight[size], nudge ? \"min-w-32 flex-1\" : undefined, !nudge && !suggestion && !held && className)}\n >\n <AriaInput\n id={idProp ?? field?.id}\n placeholder={format.missing}\n aria-describedby={[field?.describedBy, unit ? unitId : undefined].filter(Boolean).join(\" \") || undefined}\n className=\"min-w-0 flex-1 bg-transparent tabular-nums outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed\"\n />\n {unit && (\n <span id={unitId} className=\"ml-2 shrink-0 type-body-sm text-muted-foreground\">\n <span aria-hidden>{unit}</span>\n <span className=\"sr-only\">{intlUnits[unit] ? intlUnits[unit].replace(/-/g, \" \") : unit}</span>\n </span>\n )}\n </AriaNumberField>\n </I18nProvider>\n );\n if (!nudge && !suggestion && !held) return field_;\n\n const sizes = [...new Set(nudge ?? [])].filter((n) => n > 0).sort((a, b) => a - b);\n const steps = [...sizes.slice().reverse().map((n) => -n), ...sizes];\n const row = (\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n {field_}\n {steps.length > 0 && (\n <Toolbar label={`Nudge ${name_}`} className=\"gap-1\">\n {steps.map((delta) => {\n const base = current ?? 0;\n const atLimit = delta < 0 ? min !== undefined && base <= min : max !== undefined && base >= max;\n return (\n <Button\n key={delta}\n size={size === \"sm\" ? \"sm\" : \"default\"}\n className=\"tabular-nums\"\n disabled={disabled || atLimit}\n aria-label={`${delta < 0 ? \"Subtract\" : \"Add\"} ${withUnit(show(Math.abs(delta)), unit)}`}\n onPressStart={() => startNudge(delta)}\n onPressEnd={stopNudge}\n >\n {signed(delta)}\n </Button>\n );\n })}\n </Toolbar>\n )}\n </div>\n );\n const shown = suggestion && current !== suggestion.value ? suggestion : undefined;\n const suggestionId = `${unitId}-suggestion`;\n const label = shown && (shown.label ?? withUnit(show(shown.value), unit));\n return (\n <div className={cn(\"grid min-w-0 gap-2\", className)}>\n {row}\n {shown && (\n <div className=\"flex flex-wrap items-center gap-x-3 gap-y-1\">\n <p id={suggestionId} className=\"min-w-0 flex-1 type-body-sm text-muted-foreground\">\n <span className=\"text-foreground\">Suggested {label}:</span> {shown.reason}\n </p>\n <Button size=\"sm\" disabled={disabled} aria-describedby={suggestionId} onPress={() => handle(shown.value)}>\n Use this value\n </Button>\n </div>\n )}\n {held && pending !== undefined && (\n <div role=\"group\" aria-label=\"Change not applied yet\" className=\"grid gap-3 rounded-surface bg-surface-sunken p-3\">\n {typeof preview === \"function\" ? preview(pending) : preview}\n <div className=\"flex flex-wrap items-center gap-2\">\n <AsyncButton\n variant=\"default\"\n size=\"sm\"\n phase={apply.phase}\n error={apply.error}\n labels={applyLabels}\n disabled={disabled || invalid}\n onPress={() => void apply.run()}\n />\n <Button size=\"sm\" variant=\"ghost\" disabled={apply.phase === \"pending\"} onPress={revert}>\n Revert\n </Button>\n </div>\n </div>\n )}\n </div>\n );\n}\n\n/** Props for `Slider`. */\nexport type SliderProps = RangeProps & {\n value: number;\n onChange: (value: number) => void;\n /** Both limits are required: a slider with no ends is not a slider. */\n min: number;\n max: number;\n /** Replace the printed value with a `NumberField` beside the track, so an exact value can be typed. */\n editable?: boolean;\n /** Hide the printed value (when something else beside it already shows it). */\n hideValue?: boolean;\n /** Decimal places in the printed and spoken value. Default the places in `step`. */\n places?: number;\n disabled?: boolean;\n /** Names the slider when it is used without a `Field`. */\n \"aria-label\"?: string;\n className?: string;\n};\n\n/** A slider on React Aria with its current value always printed beside the track (and spoken with the unit when `Intl` knows it); `editable` adds a number field to type an exact value. */\nexport function Slider({\n value,\n onChange,\n min,\n max,\n step = 1,\n unit,\n locale = format.locale,\n editable = false,\n hideValue = false,\n places,\n disabled,\n className,\n \"aria-label\": ariaLabel,\n}: SliderProps) {\n const { field } = useFieldControl();\n const digits = places ?? Math.max(decimalsOf(step), decimalsOf(min));\n const show = useNumberText(locale, digits);\n const name = ariaLabel ?? field?.label ?? \"Value\";\n const text = withUnit(show(value), unit);\n return (\n <I18nProvider locale={locale}>\n <AriaSlider\n value={value}\n onChange={(v) => onChange(v as number)}\n minValue={min}\n maxValue={max}\n step={step}\n formatOptions={formatOptionsFor(digits, unit)}\n isDisabled={disabled}\n aria-label={name}\n aria-describedby={field?.describedBy}\n className={cn(\"flex min-w-0 items-center gap-3\", className)}\n >\n <SliderTrack className=\"relative flex h-(--control-h) min-w-0 flex-1 cursor-pointer items-center disabled:cursor-not-allowed disabled:opacity-50\">\n {({ state }) => (\n <>\n <span aria-hidden className=\"absolute inset-x-0 h-1.5 rounded-pill bg-muted\" />\n <span aria-hidden className=\"absolute left-0 h-1.5 rounded-pill bg-primary\" style={{ width: `${state.getThumbPercent(0) * 100}%` }} />\n <SliderThumb className=\"top-1/2 size-5 rounded-pill border-2 border-primary bg-background focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\" />\n </>\n )}\n </SliderTrack>\n {editable ? (\n <NumberField className=\"w-28 shrink-0\" aria-label={`${name}, exact value`} value={value} onChange={(v) => { if (v !== null) onChange(v); }} min={min} max={max} step={step} unit={unit} locale={locale} places={digits} required disabled={disabled} />\n ) : (\n !hideValue && (\n <SliderOutput aria-hidden className=\"w-16 shrink-0 text-right type-body-sm tabular-nums text-foreground\">\n {text}\n </SliderOutput>\n )\n )}\n </AriaSlider>\n </I18nProvider>\n );\n}\n\n/** Props for `ColorField`. */\nexport type ColorFieldProps = {\n /** `#rrggbb`, or `null` when no colour is set. */\n value: string | null;\n /** Receives a valid `#rrggbb` (lower case) or `null` when cleared; never a half-typed value. */\n onChange: (value: string | null) => void;\n /** A short list the app suggests, as `#rrggbb`. Pressing one chooses it. */\n suggestions?: readonly string[];\n /** The colour this will be drawn on, `#rrggbb`: a note appears when the contrast would be low. */\n against?: string;\n /** What it is drawn on, in words: \"the map\". Completes the note. */\n againstLabel?: string;\n /** The lowest contrast ratio accepted before the note shows. Default 3, the WCAG minimum for graphics. */\n minContrast?: number;\n disabled?: boolean;\n \"aria-label\"?: string;\n id?: string;\n className?: string;\n};\n\n/** Choose a colour with the platform picker, see and type its hex value, pick from the app's suggestions, and get a note when it would be hard to see on `against`. A half-typed value is never passed on. */\nexport function ColorField({ value, onChange, suggestions, against, againstLabel = \"the background\", minContrast = 3, disabled, id: idProp, className, \"aria-label\": ariaLabel }: ColorFieldProps) {\n const { field, report } = useFieldControl();\n // Named for the `aria-label` or, failing that, the surrounding Field's label, so two colour fields in one panel never share a name (issue #116).\n const label = ariaLabel ?? field?.label;\n const pickerName = label ? `${label}, picker` : \"Colour picker\";\n const [draft, setDraft] = React.useState<string | null>(null);\n const [own, setOwn] = React.useState(false);\n const text = draft ?? value ?? \"\";\n const ratio = value && against ? contrastRatio(value, against) : null;\n\n const commitText = (t: string): boolean => {\n if (t.trim() === \"\") {\n setOwn(false);\n report(undefined);\n if (value !== null) onChange(null);\n return true;\n }\n const hex = parseHex(t);\n if (!hex) {\n setOwn(true);\n report(\"Enter a colour like #1a7f64.\");\n return false;\n }\n setOwn(false);\n report(undefined);\n if (hex !== value) onChange(hex);\n return true;\n };\n\n const pick = (hex: string) => {\n setDraft(null);\n setOwn(false);\n report(undefined);\n if (hex !== value) onChange(hex);\n };\n\n const invalid = field?.invalid || own;\n return (\n <div className={cn(\"grid min-w-0 gap-2\", className)}>\n <div className={cn(box, controlHeight.default, \"gap-2 px-2\")} aria-invalid={invalid || undefined}>\n <span className=\"relative size-6 shrink-0 overflow-hidden rounded-control border border-input\">\n {/* The swatch is the chosen colour itself: user content, not a theme role. */}\n <span aria-hidden className={cn(\"absolute inset-0\", value === null && \"bg-muted\")} style={value ? { background: value } : undefined} />\n <input\n type=\"color\"\n aria-label={pickerName}\n value={value ?? \"#000000\"}\n disabled={disabled}\n onChange={(e) => pick(e.target.value)}\n className=\"absolute inset-0 size-full cursor-pointer opacity-0 disabled:cursor-not-allowed\"\n />\n </span>\n <input\n id={idProp ?? field?.id}\n type=\"text\"\n autoComplete=\"off\"\n spellCheck={false}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-describedby={field?.describedBy}\n aria-invalid={invalid || undefined}\n placeholder={format.missing}\n value={text}\n onChange={(e) => setDraft(e.target.value)}\n onBlur={() => {\n if (draft !== null && commitText(draft)) setDraft(null);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && draft !== null && commitText(draft)) setDraft(null);\n if (e.key === \"Escape\" && draft !== null) {\n setDraft(null);\n setOwn(false);\n report(undefined);\n }\n }}\n className=\"min-w-0 flex-1 bg-transparent tabular-nums outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed\"\n />\n </div>\n {suggestions && suggestions.length > 0 && (\n <div role=\"group\" aria-label=\"Suggested colours\" className=\"flex flex-wrap gap-1.5\">\n {suggestions.map((hex) => (\n <button\n key={hex}\n type=\"button\"\n disabled={disabled}\n aria-label={hex}\n aria-pressed={value === hex}\n onClick={() => pick(hex)}\n className=\"size-6 cursor-pointer rounded-control border border-input transition-state aria-pressed:outline-2 aria-pressed:outline-offset-2 aria-pressed:outline-foreground disabled:cursor-not-allowed disabled:opacity-50\"\n style={{ background: hex }}\n />\n ))}\n </div>\n )}\n {ratio !== null && ratio < minContrast && (\n <p className=\"type-body-sm text-warning\">\n Hard to see on {againstLabel}: contrast {format.decimal(ratio)}:1, aim for {format.decimal(minContrast)}:1 or more.\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,SAAgB,UAAU,EAAE,SAAS,MAAM,aAAa,OAAO,OAAO,OAAO,cAAc,UAAyB,CAAC,GAAG;CACtH,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAS,KAAK;CAChD,MAAM,CAAC,IAAI,SAAS,MAAM,SAAyB,IAAI;CACvD,MAAM,OAAO,QAAQ;CACrB,MAAM,gBAAgB;EACpB,IAAI,MAAM;EACV,IAAI,CAAC,UAAU,CAAC,IAAI;GAClB,UAAU,KAA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;GACJ,eAAe,YAAY,SAAS,KACnC,oBAAC,OAAD;IAAK,MAAK;IAAQ,cAAW;IAAoB,WAAU;IACxD,UAAA,YAAY,KAAK,QAChB,oBAAC,UAAD;KAEE,MAAK;KACK;KACV,cAAY;KACZ,gBAAc,UAAU;KACxB,eAAe,KAAK,GAAG;KACvB,WAAU;KACV,OAAO,EAAE,YAAY,IAAI;IAC1B,GARM,GAQN,CACF;GACE,CAAA;GAEN,UAAU,QAAQ,QAAQ,eACzB,qBAAC,KAAD;IAAG,WAAU;IAAb,UAAA;KAAyC;KACvB;KAAa;KAAY,OAAO,QAAQ,KAAK;KAAE;KAAa,OAAO,QAAQ,WAAW;KAAE;IACvG;;EAEF;;AAET"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strata-react",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "React + Tailwind v4 components that ship structure, behaviour, states and a token contract, and no look: each product brings a theme generated from its own subject.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-CTd1l3md.js","names":["_Fragment","Tooltip","AriaTooltip","Input"],"sources":["../src/lib/utils.ts","../src/components/key-glyphs.tsx","../src/components/tooltip.tsx","../src/lib/control.ts","../src/components/field.tsx"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\n// Teach tailwind-merge that `type-*` utilities are font sizes. Without this, cn() cannot tell\n// `type-label` from a colour and may drop one of two classes that both survive in CSS; with stock\n// shadcn the same bug drops `text-muted-foreground` next to a custom `text-*` size.\nexport const typeSteps = [\"caption\", \"label\", \"body-sm\", \"body\", \"heading\", \"title\", \"figure\", \"display\", \"picture\"] as const;\n\n// The radius roles too, so `rounded-pill` at a call site (a round avatar Thumbnail) replaces a\n// component's `rounded-control` instead of both surviving and CSS order picking one.\nconst radiusRoles = [\"control\", \"surface\", \"overlay\", \"pill\"] as const;\n\nconst twMerge = extendTailwindMerge({\n extend: {\n theme: { radius: [...radiusRoles] },\n classGroups: {\n \"font-size\": [{ type: [...typeSteps] }],\n },\n },\n});\n\n/** clsx + tailwind-merge, taught that `type-*` utilities are font sizes and `rounded-control`, `-surface`, `-overlay`, `-pill` are radii. */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import * as React from \"react\";\nimport { ArrowBigUp, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ChevronUp, Command, Option, type LucideIcon } from \"lucide-react\";\n\n// Keys drawn as icons where a font cannot be trusted to have them (strata-react issue #136, from\n// strata-vid). The arrows (← → ↑ ↓) and the macOS modifiers (⌘ ⌃ ⌥ ⇧) are outside the latin subset of\n// the bundled variable fonts, so a legend drew them in whatever face the machine had: different on\n// every machine, and `strata-visual` fails a shot with text in a system font. Lucide's icons are\n// SVG, so they draw the same everywhere and take the text colour. Each is hidden from assistive\n// technology and followed by its name in screen-reader-only text (\"left arrow\", \"Command\"), so the\n// keycap reads as words rather than as a symbol each screen reader pronounces its own way.\n// Checked: React Aria has no keyboard-shortcut display beyond the `Keyboard` slot (which only\n// labels the text it is given), so this is the glyph mapping the slot's content needs.\n\nconst GLYPHS: Record<string, { icon: LucideIcon; name: string }> = {\n \"←\": { icon: ArrowLeft, name: \"left arrow\" },\n \"→\": { icon: ArrowRight, name: \"right arrow\" },\n \"↑\": { icon: ArrowUp, name: \"up arrow\" },\n \"↓\": { icon: ArrowDown, name: \"down arrow\" },\n \"⌘\": { icon: Command, name: \"Command\" },\n \"⌃\": { icon: ChevronUp, name: \"Control\" },\n \"⌥\": { icon: Option, name: \"Option\" },\n \"⇧\": { icon: ArrowBigUp, name: \"Shift\" },\n};\nconst PATTERN = new RegExp(`([${Object.keys(GLYPHS).join(\"\")}])`);\n\n/** Key text with its arrows and modifier symbols drawn as icons, each with its name for screen readers. Other text is left as it is. */\nexport function KeyText({ children }: { children: string }) {\n return (\n <>\n {children.split(PATTERN).map((part, i) => {\n const glyph = GLYPHS[part];\n if (!glyph) return part ? <React.Fragment key={i}>{part}</React.Fragment> : null;\n const Icon = glyph.icon;\n return (\n <React.Fragment key={i}>\n <Icon aria-hidden className=\"inline size-[1em] align-[-0.125em]\" />\n <span className=\"sr-only\">{glyph.name} </span>\n </React.Fragment>\n );\n })}\n </>\n );\n}\n","import { KeyText } from \"./key-glyphs\";\nimport * as React from \"react\";\nimport { Tooltip as AriaTooltip, TooltipTrigger } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\n\n// A tooltip names or explains a control; it is never the only place information lives. React Aria\n// opens it on keyboard focus as well as hover (strata-vid's old hover-only tooltip hid it from\n// keyboard users), after a short delay so a pointer crossing a toolbar does not flash every tip,\n// and shares the delay between neighbouring tips. It holds only words: anything interactive is a\n// Popover. It is portalled to the body, so a parent's overflow cannot clip it, and sits on the\n// `layer-tip` layer above dialogs, since it can name a control inside one.\n//\n// `IconButton` uses it for its required `label`, so the name and the visible hint come from one\n// string and cannot drift.\n\n/** Props for `Tooltip`. */\nexport type TooltipProps = {\n /** The words: a control's name or one sentence about it. Not interactive. */\n label: React.ReactNode;\n /** A shortcut or other aside shown after the label, muted (\"Ctrl+Z\"). */\n hint?: React.ReactNode;\n /** The element that gets the tip. It must be a React Aria pressable or focusable (a Strata `Button` is). */\n children: React.ReactElement;\n /** Which side of the trigger it prefers; it flips when there is no room. Default `top`. */\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n /** Milliseconds before it opens on hover. Focus opens it at once. Default 500. */\n delay?: number;\n /** A controlled open state, for a story or test that needs it shown. */\n open?: boolean;\n className?: string;\n};\n\n/** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */\nexport function Tooltip({ label, hint, children, side = \"top\", delay = 500, open, className }: TooltipProps) {\n return (\n <TooltipTrigger delay={delay} closeDelay={0} isOpen={open}>\n {children}\n <AriaTooltip\n placement={side}\n offset={6}\n className={cn(\"layer-tip enter-overlay max-w-xs rounded-control bg-foreground px-2 py-1 type-caption text-background\", className)}\n >\n {label}\n {hint != null && <span className=\"ml-2 opacity-70\">{typeof hint === \"string\" ? <KeyText>{hint}</KeyText> : hint}</span>}\n </AriaTooltip>\n </TooltipTrigger>\n );\n}\n","// Control sizes, one set for everything that sits in a toolbar or a property row: `default` is\n// --control-h and `sm` is --control-h-sm, so two controls of the same size name are the same height\n// in every density (issue #117). Button, IconButton, Toggle, ToggleGroup, Input, NativeSelect and\n// NumberField all take it as `size`.\n\n/** The size names a control takes: `default` (--control-h) or `sm` (--control-h-sm). */\nexport type ControlSize = \"default\" | \"sm\";\n\n/** The height class of each control size. */\nexport const controlHeight: Record<ControlSize, string> = {\n default: \"h-(--control-h)\",\n sm: \"h-(--control-h-sm)\",\n};\n","import * as React from \"react\";\nimport { CircleAlert } from \"lucide-react\";\nimport { Label, Radio, RadioGroup } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\nimport { controlHeight, type ControlSize } from \"../lib/control\";\n\n// Field owns the wiring a generated form usually forgets: the label's htmlFor, aria-describedby\n// pointing at the hint and the error, and aria-invalid. Controls read it from context, so a control\n// inside a Field cannot end up unlabelled or silently invalid.\n//\n// A one-field form (\"paste a link, Add\", a search box, \"invite by email\") puts its button on the\n// control's row, not beside the whole field (strata-react issue #46, from the Tubes Library\n// screen): in a plain flex row the button lines up with label, hint and error together and drifts\n// off the input whenever one shows. `action` is drawn on the control's row, both at --control-h,\n// with the hint and the error under both across the full width. It wraps under the control only\n// when the row cannot keep the control 10rem wide beside it (a 250px inspector body keeps a Reset beside its slider, issue #116): on a phone a short \"Add\" stays on the\n// row, as a search box's button does, and a long label or a narrow column wraps. The error and hint stay the input's description; the\n// button is not described by them. Field messages for a form come from `useAsyncAction`'s\n// `fieldErrors` (its `validate`, or the server's 422), so no `problem` state is kept by hand.\n\ntype FieldState = { id: string; label: string; describedBy?: string; invalid: boolean; report: (message: string | undefined) => void };\nconst FieldContext = React.createContext<FieldState | null>(null);\n\n// A control that checks what was typed (a number field, a colour field) reports its own message to\n// the Field it sits in, which draws it as the field's error, so a value outside the limits is\n// explained in the same place and way as a server's 422, with nothing for the screen to wire.\n// `error` from the screen wins over the control's own. Outside a Field `report` does nothing and\n// the control marks itself invalid without a message.\n/** @internal The surrounding Field, and where a control reports its own message. */\nexport function useFieldControl() {\n const field = React.useContext(FieldContext);\n return { field, report: field?.report ?? noReport };\n}\n\nfunction useField(id?: string) {\n const field = React.useContext(FieldContext);\n return {\n // Inside a Field the Field's id wins, so the label always points at the control. To choose the\n // id yourself, pass it to Field.\n id: field?.id ?? id,\n \"aria-describedby\": field?.describedBy,\n \"aria-invalid\": field?.invalid || undefined,\n };\n}\n\nconst noReport = () => {};\n\nexport type FieldProps = {\n label: string;\n /** The control's id, when the page needs a known one (an anchor, a test). Generated otherwise. */\n id?: string;\n /** What the person needs to know before typing, such as limits or units. */\n hint?: React.ReactNode;\n /** What went wrong and how to fix it, in one sentence. Shown under the control, never in a toast. */\n error?: string;\n /** A button on the control's row, for a one-field form (an `AsyncButton` \"Add\"). The hint and error run under both; on a narrow screen it wraps under the control. */\n action?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n};\n\n/** A labelled form field: wires the label, hint, error, `aria-describedby` and `aria-invalid` into the one control it wraps. */\nexport function Field({ label, id: idProp, hint, error, action, children, className }: FieldProps) {\n const generated = React.useId();\n const id = idProp ?? generated;\n const hintId = hint ? `${id}-hint` : undefined;\n const [reported, report] = React.useState<string>();\n const shown = error ?? reported;\n const errorId = shown ? `${id}-error` : undefined;\n const describedBy = [errorId, hintId].filter(Boolean).join(\" \") || undefined;\n\n return (\n <FieldContext.Provider value={{ id, label, describedBy, invalid: Boolean(shown), report }}>\n <div className={cn(\"grid min-w-0 content-start gap-1.5\", className)}>\n <label htmlFor={id} className=\"type-label text-foreground\">\n {label}\n </label>\n {action ? (\n <div className=\"flex flex-wrap items-start gap-2\">\n <div className=\"min-w-40 flex-1\">{children}</div>\n <div className=\"flex shrink-0 items-center\">{action}</div>\n </div>\n ) : (\n children\n )}\n {shown && (\n <p id={errorId} className=\"flex items-start gap-1.5 type-body-sm text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n {shown}\n </p>\n )}\n {hint && (\n <p id={hintId} className=\"type-body-sm text-muted-foreground\">\n {hint}\n </p>\n )}\n </div>\n </FieldContext.Provider>\n );\n}\n\nconst control =\n \"w-full min-w-0 rounded-control border border-input bg-background px-3 type-body text-foreground transition-state placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-70 aria-invalid:border-danger\";\n\n/** A text input that picks up its id and descriptions from the surrounding `Field`. `size=\"sm\"` is --control-h-sm; the native `size` (a width in characters) is not passed on. */\nexport function Input({ className, id, size = \"default\", ...props }: Omit<React.ComponentProps<\"input\">, \"size\"> & { size?: ControlSize }) {\n return <input {...useField(id)} className={cn(control, controlHeight[size], className)} {...props} />;\n}\n\n/** A multi-line input that picks up its id and descriptions from the surrounding `Field`. */\nexport function Textarea({ className, id, ...props }: React.ComponentProps<\"textarea\">) {\n return <textarea {...useField(id)} className={cn(control, \"min-h-24 py-2\", className)} {...props} />;\n}\n\n// A native select, styled. For short option lists on a touch screen it beats a custom listbox:\n// the platform picker, typeahead and form autofill all work with no code.\n/** The platform select, styled. The default for short lists, especially on touch screens. `size=\"sm\"` is --control-h-sm. */\nexport function NativeSelect({ className, id, size = \"default\", ...props }: Omit<React.ComponentProps<\"select\">, \"size\"> & { size?: ControlSize }) {\n return <select {...useField(id)} className={cn(control, controlHeight[size], \"pr-8\", className)} {...props} />;\n}\n\n// Radio choices: React Aria's RadioGroup (a group named by its label, arrow-key movement, one tab\n// stop), and each row wraps its control so the whole row is one hit target. The dot is drawn from\n// tokens, not the platform's accent-color radio.\nexport type Choice = { value: string; label: string; detail?: string };\n\n/** Radio choices in a fieldset with a legend; each whole row is the hit target. For 2 to 5 options that each need a sentence. */\nexport function ChoiceGroup({\n legend,\n name,\n choices,\n value,\n onChange,\n error,\n}: {\n legend: string;\n name: string;\n choices: Choice[];\n value: string;\n onChange: (value: string) => void;\n error?: string;\n}) {\n const errorId = React.useId();\n return (\n <RadioGroup name={name} value={value} onChange={onChange} aria-describedby={error ? errorId : undefined} className=\"grid gap-2\">\n <Label className=\"mb-1.5 type-label text-foreground\">{legend}</Label>\n {choices.map((c) => (\n <Radio key={c.value} value={c.value} className=\"group flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1\">\n <span\n aria-hidden\n className=\"mt-1 grid size-4 shrink-0 place-items-center rounded-pill border border-input bg-background transition-state group-selected:border-primary group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-ring\"\n >\n <span className=\"size-2 rounded-pill bg-primary opacity-0 group-selected:opacity-100\" />\n </span>\n <span className=\"grid\">\n <span className=\"type-body\">{c.label}</span>\n {c.detail && <span className=\"type-body-sm text-muted-foreground\">{c.detail}</span>}\n </span>\n </Radio>\n ))}\n {error && (\n <p id={errorId} className=\"flex items-start gap-1.5 type-body-sm text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n {error}\n </p>\n )}\n </RadioGroup>\n );\n}\n"],"mappings":";;;;;;;AAMA,IAAa,YAAY;CAAC;CAAW;CAAS;CAAW;CAAQ;CAAW;CAAS;CAAU;CAAW;AAAS;AAMnH,IAAM,UAAU,oBAAoB,EAClC,QAAQ;CACN,OAAO,EAAE,QAAQ,CAAC,GAAG;EAJJ;EAAW;EAAW;EAAW;CAI7B,CAAW,EAAE;CAClC,aAAa,EACX,aAAa,CAAC,EAAE,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC,EACxC;AACF,EACF,CAAC;;AAGD,SAAgB,GAAG,GAAG,QAAsB;CAC1C,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;ACXA,IAAM,SAA6D;CACjE,KAAK;EAAE,MAAM;EAAW,MAAM;CAAa;CAC3C,KAAK;EAAE,M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C,QAAD,EAAM,WAAU,sEAAuE,CAAA;IACnF,CAAA,GACN,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACE,oBAAC,QAAD;MAAM,WAAU;MAAa,UAAA,EAAE;KAAY,CAAA,GAC1C,EAAE,UAAU,oBAAC,QAAD;MAAM,WAAU;MAAsC,UAAA,EAAE;KAAa,CAAA,CAC9E;IACD,CAAA,CAAA;GAXK,GAAA,EAAE,KAWP,CACR;GACA,SACC,qBAAC,KAAD;IAAG,IAAI;IAAS,WAAU;IAA1B,UAAA,CACE,oBAAC,aAAD;KAAa,eAAA;KAAY,WAAU;IAA0B,CAAA,GAC5D,KACA;;EAEK;;AAEhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-DCRYZPJs.js","names":[],"sources":["../src/api-types/generate.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\n// The types behind `strata-api-types` (strata-react issue #263). A strata app's FastAPI server\n// publishes its routes, the shared contracts (`strata_python.contracts`: Health, Task, Page, ErrorBody…)\n// and its typed settings at `/api/openapi.json`; the TypeScript types follow that schema instead of\n// being written again by hand and drifting. The work of reading OpenAPI is `openapi-typescript`\n// (Jonathan, 2026-11-14: types only, nothing in the app's bundle); this file adds where the schema\n// comes from (a running server, or a file the server's own CLI wrote, so CI needs no server) and what\n// the committed file looks like. It lives behind its own entry (`strata-react/api-types`), like\n// `strata-react/visual`, and `openapi-typescript` is an optional peer, so an app that never runs the\n// command installs nothing and the main entry's peer contract is unchanged.\n//\n// The output is deterministic, so `--check` can compare it with the committed file and fail CI when\n// the Python side moved and the file did not. Nothing about the machine (the URL it was read from, a\n// date) goes into it, for the same reason.\n\n/** The OpenAPI document as the generator takes it: a parsed JSON object. */\nexport type OpenApiDocument = Record<string, unknown>;\n\n/** Reads an OpenAPI document from an `http(s)` URL (a running server) or a JSON file path. */\nexport async function loadSchema(source: string, fetcher: typeof fetch = fetch): Promise<OpenApiDocument> {\n let text: string;\n if (/^https?:\\/\\//i.test(source)) {\n const response = await fetcher(source, { headers: { accept: \"application/json\" } });\n if (!response.ok) throw new Error(`${source} answered ${response.status} ${response.statusText}`);\n text = await response.text();\n } else {\n text = await readFile(source, \"utf8\");\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n throw new Error(`${source} is not JSON. Give the OpenAPI document (/api/openapi.json), not the docs page.`);\n }\n if (!parsed || typeof parsed !== \"object\" || !(\"openapi\" in parsed)) throw new Error(`${source} is JSON but not an OpenAPI document (no \"openapi\" field).`);\n return parsed as OpenApiDocument;\n}\n\nconst header = `/* eslint-disable */\n// Generated by strata-api-types from the app's OpenAPI schema. Do not edit by hand:\n// regenerate with \\`strata-api-types <schema> -o <this file>\\`; CI runs it with --check.\n`;\n\n// Short names for the schemas, so a screen writes \\`Schema<\"Task\">\\` and not the whole path.\nconst footer = `\n/** A named schema of the API: \\`Schema<\"Task\">\\`. */\nexport type Schema<K extends keyof components[\"schemas\"]> = components[\"schemas\"][K];\n`;\n\n/** The URL relative references resolve against: the document's own URL, or its file's location. */\nfunction baseOf(source: string): URL {\n return /^https?:\\/\\//i.test(source) ? new URL(source) : pathToFileURL(resolve(source));\n}\n\n/**\n * The TypeScript types for an OpenAPI document, as the text of the generated file. `source` is where the\n * document was read from (a URL or file path): relative `$ref`s to other files resolve against it.\n */\nexport async function generateApiTypes(schema: OpenApiDocument, source?: string): Promise<string> {\n const mod = await import(\"openapi-typescript\").catch(() => {\n throw new Error(\"strata-api-types needs openapi-typescript: npm install --save-dev openapi-typescript (it also wants TypeScript 5 or an override that points it at yours).\");\n });\n const { default: openapiTS, astToString } = mod;\n const ast = await openapiTS(schema as never, source ? { cwd: baseOf(source) } : undefined);\n return `${header}\\n${astToString(ast).trimEnd()}\\n${footer}`;\n}\n"],"mappings":";;;;;AAsBA,eAAsB,WAAW,QAAgB,UAAwB,OAAiC;CACxG,IAAI;CACJ,IAAI,gBAAgB,KAAK,MAAM,GAAG;EAChC,MAAM,WAAW,MAAM,QAAQ,QAAQ,EAAE,SAAS,EAAE,QAAQ,mBAAmB,EAAE,CAAC;EAClF,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM,GAAG,OAAO,YAAY,SAAS,OAAO,GAAG,SAAS,YAAY;EAChG,OAAO,MAAM,SAAS,KAAK;CAC7B,OACE,OAAO,MAAM,SAAS,QAAQ,MAAM;CAEtC,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,IAAI;CAC1B,QAAQ;EACN,MAAM,IAAI,MAAM,GAAG,OAAO,gFAAgF;CAC5G;CACA,IAAI,CAAC,UAAU,OAAO,WAAW,YAAY,EAAE,aAAa,SAAS,MAAM,IAAI,MAAM,GAAG,OAAO,2DAA2D;CAC1J,OAAO;AACT;AAEA,IAAM,SAAS;;;;AAMf,IAAM,SAAS;;;;;AAMf,SAAS,OAAO,QAAqB;CACnC,OAAO,gBAAgB,KAAK,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,cAAc,QAAQ,MAAM,CAAC;AACvF;;;;;AAMA,eAAsB,iBAAiB,QAAyB,QAAkC;CAIhG,MAAM,EAAE,SAAS,WAAW,gBAAgB,MAH1B,OAAO,qBAAqB,CAAC,YAAY;EACzD,MAAM,IAAI,MAAM,2JAA2J;CAC7K,CAAC;CAGD,OAAO,GAAG,OAAO,IAAI,YAAY,MADf,UAAU,QAAiB,SAAS,EAAE,KAAK,OAAO,MAAM,EAAE,IAAI,KAAA,CAAS,CACrD,CAAC,CAAC,QAAQ,EAAE,IAAI;AACtD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-CgoGqE0T.js","names":["ToastQueue","ToastRegion","AriaToast","ToastContent","Button","AriaButton"],"sources":["../src/lib/overlay.ts","../src/components/toast.tsx","../src/query/index.tsx"],"sourcesContent":["// The look every floating surface shares (Dialog, Popover, and later Menu and Toast): the popover\n// role pair, an overlay radius, one hairline and the one shadow that exists for what floats\n// (components.md §3.11). One string, so a menu and a popover cannot drift apart.\nexport const overlaySurface =\n \"rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay\";\n","import * as React from \"react\";\nimport { UNSTABLE_Toast as AriaToast, UNSTABLE_ToastContent as ToastContent, UNSTABLE_ToastQueue as ToastQueue, UNSTABLE_ToastRegion as ToastRegion, Button as AriaButton, Text } from \"react-aria-components\";\nimport { CircleCheck, Info, TriangleAlert, X } from \"lucide-react\";\nimport { Button } from \"./button\";\nimport { cn } from \"../lib/utils\";\nimport { overlaySurface } from \"../lib/overlay\";\nimport { isDev } from \"../lib/dev\";\n\n// A toast confirms background work that finished (\"Export finished\", \"3 pieces synced\"). It is a\n// polite live region; it never carries an error a person must act on, which goes inline as an\n// `Alert` with its recovery (components.md §3.13, patterns.md §7), so there is no danger tone:\n// the type refuses it. `warning` is for a fact worth a glance (\"Kiln 2 is 40 min behind\").\n//\n// Rules the component owns so an app does not have to:\n// - One region, once, at the app root (`ToastRegion`), on the `layer-bar` layer: bottom end of the\n// window on a wide screen, the top on a phone, so it does not sit on the undo bar or cover the\n// focused control. It is a labelled landmark the keyboard reaches with F6 (React Aria).\n// - It stays long enough to read: 5 s plus 40 ms a character, up to 15 s, at least 8 s with an\n// action. The timer pauses while the pointer or focus is on it. There is always a dismiss control.\n// - At most one action, a button (\"Open file\"); content is words, not a form.\n// - Announcements are React Aria's: the toast's text is read when it appears and not again.\n// - The queue is module-level, so `toast.show()` works from a mutation's `onSuccess` outside any\n// component; `toast.clear()` empties it for a test. React Aria marks its toast API unstable; it\n// is used only here, behind this small surface, so a change upstream stays in this file.\n// - One region at a time, enforced (issue #230): the first mounted owns the queue and a second one draws nothing and\n// says so in development, naming the fix. Two regions on one queue show every toast twice, which looks like a bug in\n// the toast and (in a test) fails `findByText` with \"Found multiple elements\"; the usual cause is a route tree that\n// draws the region in its root layout while a test helper draws one too (`renderRoutes(..., { toasts: false })`),\n// or an app with a region in a layout and another in a page. Ownership is held by a mounted-order list, not by the\n// queue, so unmounting the owner hands it to the next region.\n// Toasts are rare and brief, so they get the overlay entrance and nothing else (character.md §3).\n\n/** What a toast says. */\nexport type ToastContentProps = {\n /** What finished, past tense, in the product's words: \"Export finished\". */\n title: string;\n /** One more sentence: what and where (\"run.mp4, 2:31 at 1080p, in your Downloads folder.\"). */\n description?: string;\n /** `info` by default. There is no danger tone: an error the person must act on is an `Alert`. */\n tone?: \"info\" | \"success\" | \"warning\";\n /** One action beside the words. */\n action?: { label: string; onPress: () => void };\n /** Milliseconds before it goes. Defaults to enough to read the words. */\n timeout?: number;\n};\n\nconst queue = new ToastQueue<ToastContentProps>({ maxVisibleToasts: 3 });\n\n/** Milliseconds a toast stays: 5 s plus 40 ms a character, to at most 15 s, and at least 8 s with an action. */\nexport function toastTimeout(content: Pick<ToastContentProps, \"title\" | \"description\" | \"action\" | \"timeout\">): number {\n if (content.timeout !== undefined) return content.timeout;\n const chars = content.title.length + (content.description?.length ?? 0) + (content.action?.label.length ?? 0);\n return Math.max(content.action ? 8000 : 0, Math.min(15000, 5000 + 40 * chars));\n}\n\n/** The toast queue: `toast.show({ title })` from anywhere; `toast.close(key)`; `toast.clear()`. */\nexport const toast = {\n /** Shows a toast and returns its key. */\n show(content: ToastContentProps): string {\n // Nothing appears without a region, and nothing says so: in development the first such call does (issue #249).\n if (mounted.length === 0 && !warnedNoRegion && isDev()) {\n warnedNoRegion = true;\n console.warn(\"strata-react: toast.show() was called but no StrataToastRegion is mounted, so nothing will appear. Render <StrataToastRegion /> once at the app root.\");\n }\n return queue.add(content, { timeout: toastTimeout(content) });\n },\n close(key: string) {\n queue.close(key);\n },\n clear() {\n queue.clear();\n },\n};\n\nconst marks = { info: { icon: Info, color: \"text-info\" }, success: { icon: CircleCheck, color: \"text-success\" }, warning: { icon: TriangleAlert, color: \"text-warning\" } } as const;\n\n/** Props for `ToastRegion`. */\nexport type StrataToastRegionProps = {\n /** Names the landmark. Default \"Notifications\". */\n label?: string;\n className?: string;\n};\n\n// The regions mounted now, oldest first: the first draws, the rest stay empty.\nconst mounted: string[] = [];\nlet warnedNoRegion = false;\n/** For tests: forget that the missing-region warning was given. */\nexport function resetToastWarnings() {\n warnedNoRegion = false;\n}\nconst watchers = new Set<() => void>();\nconst changed = () => watchers.forEach((w) => w());\nconst watch = (w: () => void) => {\n watchers.add(w);\n return () => void watchers.delete(w);\n};\n\n/** True while this region is the one that draws. The server and the first client render say yes, so hydration matches. */\nfunction useOwnsQueue(): boolean {\n const id = React.useId();\n React.useLayoutEffect(() => {\n mounted.push(id);\n changed();\n return () => {\n mounted.splice(mounted.indexOf(id), 1);\n changed();\n };\n }, [id]);\n const owns = React.useSyncExternalStore(watch, () => mounted[0] === id, () => true);\n const [warned, setWarned] = React.useState(false);\n React.useEffect(() => {\n if (owns || warned || mounted.indexOf(id) < 1) return;\n setWarned(true);\n if (isDev()) {\n console.warn(\"strata-react: a StrataToastRegion is already mounted, so this one draws nothing. Render it once at the app root; in a test of a route tree that draws its own, pass `toasts: false` to renderRoutes.\");\n }\n }, [owns, warned, id]);\n return owns;\n}\n\n/** The one place toasts appear. Render it once at the app root; a second one mounted at the same time draws nothing and warns in development. A labelled landmark (F6), polite, above panes and the undo bar. */\nexport function StrataToastRegion({ label = \"Notifications\", className }: StrataToastRegionProps) {\n const owns = useOwnsQueue();\n if (!owns) return null;\n return (\n <ToastRegion\n queue={queue}\n aria-label={label}\n className={cn(\"layer-bar fixed inset-x-4 top-4 grid justify-items-end gap-2 outline-none sm:inset-x-auto sm:top-auto sm:right-4 sm:bottom-4\", className)}\n >\n {({ toast: t }) => (\n <AriaToast\n toast={t}\n className={cn(\"flex w-full max-w-sm items-start gap-3 p-3 outline-none focus-visible:outline-2 focus-visible:outline-ring\", overlaySurface)}\n >\n {(() => {\n const { icon: Icon, color } = marks[t.content.tone ?? \"info\"];\n return <Icon aria-hidden className={cn(\"mt-0.5 size-4 shrink-0\", color)} />;\n })()}\n <ToastContent className=\"grid min-w-0 flex-1 gap-0.5\">\n <Text slot=\"title\" className=\"type-label\">\n {t.content.title}\n </Text>\n {t.content.description && <Text slot=\"description\" className=\"type-body-sm text-muted-foreground\">{t.content.description}</Text>}\n </ToastContent>\n {t.content.action && (\n <Button size=\"sm\" onPress={() => { t.content.action?.onPress(); queue.close(t.key); }}>\n {t.content.action.label}\n </Button>\n )}\n <AriaButton slot=\"close\" aria-label=\"Dismiss\" className=\"grid size-6 shrink-0 cursor-pointer place-items-center rounded-control text-muted-foreground transition-state hover:bg-muted hover:text-foreground\">\n <X aria-hidden className=\"size-4\" />\n </AriaButton>\n </AriaToast>\n )}\n </ToastRegion>\n );\n}\n","import * as React from \"react\";\nimport {\n QueryClient,\n QueryClientProvider,\n useQuery,\n type QueryKey,\n type UseQueryOptions,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport type { Load, Stale } from \"../components/data-view\";\nimport { HttpError, describeHttpError, errorPayload, readErrorBody, type DescribeError, type ErrorBody } from \"../lib/errors\";\n\nexport { HttpError, describeHttpError, errorPayload, readErrorBody, type DescribeError, type ErrorBody };\n\n// Data loading, the Strata way: TanStack Query fetches and caches, and every view of the result\n// goes through DataView, which takes a Load<T>. `toLoad` is the one bridge between them, so a\n// screen never re-derives loading/error/ready from a query's flags and never forgets one.\n//\n// Opinions in createQueryClient: one retry (a second failure is real and the person should see\n// it with a \"Try again\"), 30 s stale time (dashboards are read many times a minute but change\n// over minutes), and no refetch on window focus (a table that reorders itself while someone reads\n// it is worse than one that is 30 s old). Override per query when the data says otherwise.\n\n/** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */\nexport function createQueryClient(overrides?: ConstructorParameters<typeof QueryClient>[0]) {\n return new QueryClient({\n ...overrides,\n defaultOptions: {\n ...overrides?.defaultOptions,\n queries: { retry: 1, staleTime: 30_000, refetchOnWindowFocus: false, ...overrides?.defaultOptions?.queries },\n },\n });\n}\n\n/** Provides a query client (Strata's defaults unless one is passed) to the app. */\nexport function StrataQueryProvider({ client, children }: { client?: QueryClient; children: React.ReactNode }) {\n const [fallback] = React.useState(() => client ?? createQueryClient());\n return <QueryClientProvider client={client ?? fallback}>{children}</QueryClientProvider>;\n}\n\n/**\n * Turns a TanStack query result into the `Load<T>` that `DataView` takes; errors are described for a person by `describe`.\n * A refetch that fails after data arrived stays `ready`, with `stale` saying why and when the data was read.\n */\nexport function toLoad<T>(query: UseQueryResult<T>, describe: DescribeError = describeHttpError): Load<T> {\n if (query.status === \"success\") return { status: \"ready\", data: query.data };\n // TanStack keeps the last good data when a refetch fails and sets status \"error\" (isRefetchError).\n // That is old data, not no data: keep it on screen and say how old it is.\n if (query.status === \"error\" && query.data !== undefined) return { status: \"ready\", data: query.data, stale: staleOf(query, describe) };\n if (query.status === \"error\") return { status: \"error\", message: describe(query.error), retry: () => void query.refetch() };\n return { status: \"loading\" };\n}\n\n/** The `Stale` of a query whose refetch failed after a good read. Shared by `toLoad` and `useInfiniteLoad`. */\nexport function staleOf(\n query: { error: unknown; dataUpdatedAt: number; isFetching: boolean; refetch: () => unknown },\n describe: DescribeError = describeHttpError,\n): Stale {\n return { message: describe(query.error), readAt: new Date(query.dataUpdatedAt), retry: () => void query.refetch(), retrying: query.isFetching };\n}\n\n/** `useQuery`, returned as a `Load<T>` for `DataView`. */\nexport function useLoad<T, K extends QueryKey = QueryKey>(\n options: UseQueryOptions<T, Error, T, K> & { describeError?: DescribeError },\n): Load<T> {\n const { describeError, ...rest } = options;\n return toLoad(useQuery(rest), describeError);\n}\n\n/** Options for `fetchJson` beyond `fetch`'s own. */\nexport type FetchJsonOptions = {\n /** Finds the server's reason and per-field messages in an error body. Default `readErrorBody` (FastAPI's `detail`, `message`, `error`). */\n readError?: (body: unknown) => ErrorBody;\n};\n\n/**\n * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.\n * A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).\n */\nexport async function fetchJson<T>(input: string | URL, init?: RequestInit, { readError = readErrorBody }: FetchJsonOptions = {}): Promise<T> {\n // Headers, tuple arrays and plain objects are all valid HeadersInit; normalise before adding the\n // default so a caller's Authorization (or their own Accept) is never dropped.\n const headers = new Headers(init?.headers);\n if (!headers.has(\"Accept\")) headers.set(\"Accept\", \"application/json\");\n const res = await fetch(input, { ...init, headers });\n if (!res.ok) {\n // The body is read as text and parsed only when it parses: a proxy's HTML 502 page or an empty\n // body must still throw the HttpError, never a JSON SyntaxError in its place.\n const raw = await res.text().catch(() => \"\");\n let body: unknown = raw || undefined;\n try {\n if (raw) body = JSON.parse(raw);\n } catch {\n // Not JSON: keep the text.\n }\n throw new HttpError(res.status, res.statusText, String(input), body, readError(body));\n }\n // Writes (DELETE, a PUT that returns nothing) answer 204 or an empty body; that is success, not a\n // JSON parse error.\n const text = res.status === 204 ? \"\" : await res.text();\n return (text ? JSON.parse(text) : undefined) as T;\n}\n\nexport { useInfiniteLoad, apiPage, type ApiPage, type InfiniteLoad, type InfiniteLoadOptions, type More } from \"./infinite\";\nexport { useJob, isTaskRunning, type Job, type JobOptions } from \"./job\";\n"],"mappings":";;;;;;;;AAGA,IAAa,iBACX;;AC0CF,IAAM,QAAQ,IAAIA,oBAA8B,EAAE,kBAAkB,EAAE,CAAC;;AAGvE,SAAgB,aAAa,SAA0F;CACrH,IAAI,QAAQ,YAAY,KAAA,GAAW,OAAO,QAAQ;CAClD,MAAM,QAAQ,QAAQ,MAAM,UAAU,QAAQ,aAAa,UAAU,MAAM,QAAQ,QAAQ,MAAM,UAAU;CAC3G,OAAO,KAAK,IAAI,QAAQ,SAAS,MAAO,GAAG,KAAK,IAAI,MAAO,MAAO,KAAK,KAAK,CAAC;AAC/E;;AAGA,IAAa,QAAQ;;CAEnB,KAAK,SAAoC;EAEvC,IAAI,QAAQ,WAAW,KAAK,CAAC,kBAAkB,MAAM,GAAG;GACtD,iBAAiB;GACjB,QAAQ,KAAK,uJAAuJ;EACtK;EACA,OAAO,MAAM,IAAI,SAAS,EAAE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