strata-react 1.3.15 → 1.3.17
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 +47 -8
- package/UPGRADING.md +15 -0
- package/dist/components/data-table.d.ts +6 -0
- package/dist/components/field.d.ts +2 -0
- package/dist/components/hotkeys.d.ts +1 -1
- package/dist/components/link-card.d.ts +4 -2
- package/dist/components/pause-button.d.ts +7 -0
- package/dist/components/schedule-table.d.ts +24 -0
- package/dist/components/system-panel.d.ts +58 -0
- package/dist/components/theme.d.ts +46 -1
- package/dist/components/thumbnail.d.ts +2 -0
- package/dist/{errors-D99YX4XL.js → errors-jep2voNI.js} +42 -3
- package/dist/errors-jep2voNI.js.map +1 -0
- package/dist/field-t4Hoer0d.js +587 -0
- package/dist/field-t4Hoer0d.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +669 -463
- package/dist/index.js.map +1 -1
- package/dist/lib/breakpoint.d.ts +4 -0
- package/dist/lib/format.d.ts +59 -6
- package/dist/map.js +2 -3
- package/dist/map.js.map +1 -1
- package/dist/microphone-Cu1u5Yml.js +547 -0
- package/dist/microphone-Cu1u5Yml.js.map +1 -0
- package/dist/panorama.js +3 -2
- package/dist/panorama.js.map +1 -1
- package/dist/query/index.d.ts +5 -1
- package/dist/query/poll.d.ts +24 -0
- package/dist/reading.css +11 -0
- package/dist/{run-hR9neQHM.js → run-BT2WKzMz.js} +83 -17
- package/dist/run-BT2WKzMz.js.map +1 -0
- package/dist/strata.bare.css +279 -0
- package/dist/strata.css +840 -10
- package/dist/strata.migrate.css +15 -6
- package/dist/testing/index.d.ts +4 -2
- package/dist/testing.js +34 -6
- package/dist/testing.js.map +1 -1
- package/dist/{theme-By3DSUTs.js → theme-DXacprlw.js} +147 -6
- package/dist/theme-DXacprlw.js.map +1 -0
- package/dist/{value-controls-B7iNh4WO.js → value-controls-DB5l5Qe2.js} +21 -46
- package/dist/value-controls-DB5l5Qe2.js.map +1 -0
- package/dist/visual/capture.d.ts +2 -0
- package/dist/visual/fonts.d.ts +18 -0
- package/dist/visual/index.d.ts +1 -0
- package/dist/visual/types.d.ts +7 -1
- package/dist/visual-cli.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +12 -3
- package/dist/errors-D99YX4XL.js.map +0 -1
- package/dist/field-QCCmWTuY.js +0 -321
- package/dist/field-QCCmWTuY.js.map +0 -1
- package/dist/format-B32-PVi2.js +0 -201
- package/dist/format-B32-PVi2.js.map +0 -1
- package/dist/microphone-BZXMKTCM.js +0 -292
- package/dist/microphone-BZXMKTCM.js.map +0 -1
- package/dist/run-hR9neQHM.js.map +0 -1
- package/dist/theme-By3DSUTs.js.map +0 -1
- package/dist/value-controls-B7iNh4WO.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-DXacprlw.js","names":["_Fragment","Tooltip"],"sources":["../src/components/density.tsx","../src/components/theme.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// Density is how much a screen packs in: `default` for forms and pages, `compact` for a tool screen\n// worked for hours (an editor, an inspector, a timeline). strata.css moves --control-h and\n// --control-h-sm together on `[data-density]`; this is how an app says which (issue #117, from\n// strata-vid, whose export dialog came out at default density over a compact editor).\n//\n// There are two places it can live, and they are different on purpose:\n// - the page (`ThemeProvider density` or `<Density page>`): the attribute goes on the document's\n// root element, so everything Strata renders sees it, including `Dialog`, `Menu`, `ContextMenu`,\n// `Popover` and `CommandMenu`, which portal to <body> and so are never inside the app's own root.\n// An app chooses it once, here.\n// - a region (`<Density value=\"compact\">`): a wrapper element, for a dense inspector inside an\n// ordinary app. Its overlays portal out of it and stay at the page's density, which is right: a\n// confirm opened from a dense panel is still the app's confirm.\n//\n// `default` exists as a value so a region can step back inside a compact page. A coarse pointer\n// still gets 44px targets in every density (strata.css).\n\n/** How much a screen packs in: `default`, or `compact` for a tool screen. */\nexport type DensityName = \"default\" | \"compact\";\n\n/** The density attribute's page-level setter, shared by `ThemeProvider`. @internal */\nexport function useDensityOn(value: DensityName | undefined, target?: HTMLElement | null) {\n React.useLayoutEffect(() => {\n if (value === undefined) return;\n const element = target === undefined ? document.documentElement : target;\n if (!element) return;\n const before = element.getAttribute(\"data-density\");\n element.setAttribute(\"data-density\", value);\n return () => {\n if (before === null) element.removeAttribute(\"data-density\");\n else element.setAttribute(\"data-density\", before);\n };\n }, [value, target]);\n}\n\n/** Props for `Density`. */\nexport type DensityProps = {\n value: DensityName;\n /** Set it on the document's root element for the whole page, overlays included, instead of wrapping a region. Renders only its children. */\n page?: boolean;\n /** For the wrapper of a region: layout classes (the wrapper is a plain `div`; `contents` takes it out of layout). */\n className?: string;\n children?: React.ReactNode;\n};\n\n/** Sets the density of a region (a wrapper `div`), or of the whole page with `page`, where overlays are reached too. */\nexport function Density({ value, page = false, className, children }: DensityProps) {\n useDensityOn(page ? value : undefined);\n if (page) return <>{children}</>;\n return (\n <div data-density={value} className={cn(className)}>\n {children}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { useDensityOn, type DensityName } from \"./density\";\nimport { Radio, RadioGroup } from \"react-aria-components\";\nimport { Tooltip } from \"./tooltip\";\nimport { Monitor, Moon, Sun } from \"lucide-react\";\nimport type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\nimport { ChoiceGroup } from \"./field\";\n\n// strata.css keys dark mode on a `.dark` ancestor (`@custom-variant dark (&:is(.dark *))`) and\n// gives `.dark` its `color-scheme`, but nothing in the library set the class, so every app wrote\n// the same matchMedia listener by hand (strata-listory did, in web/src/main.tsx). This is that\n// listener, once:\n// - Three choices, not two. \"system\" follows the operating system and keeps following it when it\n// changes at dusk; \"light\" and \"dark\" are a person's override. A toggle with only light and dark\n// loses the system setting the first time it is pressed.\n// - The choice persists in localStorage, read and written inside try/catch. Storage throws in\n// private windows, with blocked site data and in sandboxed frames; the theme then simply does\n// not persist, and the page still renders. A stored value that is not one of the three is\n// ignored.\n// - Another tab changing the choice changes this one too (the `storage` event).\n// - The first render uses the default preference, as a server render would, and the stored choice\n// is applied in a layout effect, so server-rendered markup hydrates cleanly and nothing paints\n// with the wrong scheme (found in review).\n// - The class is set in a layout effect, before paint. A page that must not flash light on first\n// load before React runs puts `colorSchemeScript()` in an inline script in its `<head>`.\n// - `ColorSchemeChoice` is the picker for a settings page: a `ChoiceGroup` of the three, with\n// \"Match this device\" first because it is the default and the one most people should keep. A\n// product that wants the choice elsewhere (a menu item, a header button) builds it from\n// `useColorScheme`. Changing theme is rare, so the picker has no motion and no icon flourish.\n// - `compact` is the same choice for an app with no settings page (a homepage, a single-page\n// tool), sized to sit in a header or footer: three segments with an icon each, named\n// \"Appearance\" (strata-react issue #25). They are still native radio buttons, so arrow keys move\n// the choice and a screen reader hears \"Match this device, radio button, 1 of 3, Appearance\".\n// Each segment is named by `aria-label` on its radio and shows the same words as a tooltip; the\n// icons are the familiar three (screen, sun, moon), and none of them is a toggle that loses the\n// system setting. The visible words are left out only because the icons are that well known.\n// - A palette is chosen independently of the scheme (2026-11-25, Jonathan: \"palettes as themes alongside\n// dark mode, each app an easy toggle\"). The provider sets `data-palette` on the same element as `.dark`;\n// strata.css has a light and a dark block per palette keyed on it (`src/styles/palettes.css`), and the\n// default palette is the plain :root, so no attribute and `\"petrol\"` are the same. The palette persists\n// under its own key like the scheme does, with the same safeguards (storage in try/catch, a stored\n// value that is not a palette name is ignored, other tabs follow). `PaletteChoice` is the picker: each\n// option carries a swatch drawn in its own palette by scoping `data-palette` on the swatch, so a person\n// sees the colours before choosing; a swatch is never the only name, the words are always there.\n// - Storybook's decorator and `renderWithStrata({ colorScheme })` run through this provider, so\n// stories and tests see the same class, in the same place, as an app.\n\n/** What a person chose: follow the operating system, or a fixed light or dark theme. */\nexport type ColorSchemePreference = \"system\" | \"light\" | \"dark\";\n/** The scheme in effect after \"system\" is resolved. */\nexport type ColorScheme = \"light\" | \"dark\";\n\n/** The localStorage key `ThemeProvider` uses unless given another. */\nexport const COLOR_SCHEME_STORAGE_KEY = \"strata-color-scheme\";\n\nconst QUERY = \"(prefers-color-scheme: dark)\";\nconst PREFERENCES: readonly ColorSchemePreference[] = [\"system\", \"light\", \"dark\"];\n\n/** A palette Strata ships: its name (the `data-palette` value) and the words `PaletteChoice` shows. */\nexport type PaletteOption = { name: string; label: string; detail?: string };\n\n/** The palettes in `strata.css`: the default first, then four others. An app that adds its own in CSS passes its own list to `PaletteChoice`. */\nexport const palettes: readonly PaletteOption[] = [\n { name: \"petrol\", label: \"Petrol and marigold\", detail: \"The default\" },\n { name: \"pine\", label: \"Pine and coral\" },\n { name: \"cobalt\", label: \"Cobalt and tangerine\" },\n { name: \"steel\", label: \"Steel and mint\" },\n { name: \"clay\", label: \"Clay and teal\" },\n];\n\n/** The default palette: the plain `:root` look, with no override. */\nexport const DEFAULT_PALETTE = \"petrol\";\n\n/** The localStorage key `ThemeProvider` keeps the palette under unless given another. */\nexport const PALETTE_STORAGE_KEY = \"strata-palette\";\n\nconst PALETTE_NAME = /^[a-z][a-z0-9-]{0,31}$/;\n\nfunction isPalette(value: unknown): value is string {\n return typeof value === \"string\" && PALETTE_NAME.test(value);\n}\n\nfunction readStoredPalette(key: string | null): string | null {\n if (key === null) return null;\n try {\n const value = window.localStorage.getItem(key);\n return isPalette(value) ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction writeStoredPalette(key: string | null, value: string) {\n if (key === null) return;\n try {\n window.localStorage.setItem(key, value);\n } catch {\n // Storage unavailable: the palette lasts this visit only.\n }\n}\n\nfunction isPreference(value: unknown): value is ColorSchemePreference {\n return typeof value === \"string\" && (PREFERENCES as readonly string[]).includes(value);\n}\n\nfunction readStored(key: string | null): ColorSchemePreference | null {\n if (key === null) return null;\n try {\n const value = window.localStorage.getItem(key);\n return isPreference(value) ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction writeStored(key: string | null, value: ColorSchemePreference) {\n if (key === null) return;\n try {\n window.localStorage.setItem(key, value);\n } catch {\n // Storage unavailable (private window, blocked site data): the choice lasts this visit only.\n }\n}\n\nfunction media(): MediaQueryList | null {\n return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" ? window.matchMedia(QUERY) : null;\n}\n\nfunction subscribeSystem(onChange: () => void) {\n const list = media();\n if (!list) return () => undefined;\n list.addEventListener(\"change\", onChange);\n return () => list.removeEventListener(\"change\", onChange);\n}\n\nconst systemSnapshot = (): ColorScheme => (media()?.matches ? \"dark\" : \"light\");\nconst serverSnapshot = (): ColorScheme => \"light\";\n\n/** The operating system's colour scheme, kept current as it changes. Light where it cannot be read (the server, jsdom). */\nexport function useSystemColorScheme(): ColorScheme {\n return React.useSyncExternalStore(subscribeSystem, systemSnapshot, serverSnapshot);\n}\n\n/** What `useColorScheme` returns: the chosen preference, the scheme in effect, and a setter that persists the choice. */\nexport type ColorSchemeState = {\n preference: ColorSchemePreference;\n scheme: ColorScheme;\n setPreference: (preference: ColorSchemePreference) => void;\n};\n\nconst Context = React.createContext<ColorSchemeState | null>(null);\n\n/** What `usePalette` returns: the palette name in effect and a setter that persists it. */\nexport type PaletteState = { palette: string; setPalette: (palette: string) => void };\n\nconst PaletteContext = React.createContext<PaletteState | null>(null);\n\n/** Sets the `.dark` class strata.css keys on, from a system, light or dark preference that persists in localStorage when it can. */\nexport function ThemeProvider({\n children,\n defaultPreference = \"system\",\n storageKey = COLOR_SCHEME_STORAGE_KEY,\n defaultPalette = DEFAULT_PALETTE,\n paletteStorageKey = PALETTE_STORAGE_KEY,\n target,\n density,\n}: {\n children: React.ReactNode;\n /** The preference before a person has chosen one. */\n defaultPreference?: ColorSchemePreference;\n /** Where the choice is kept in localStorage; `null` keeps it for this visit only. */\n storageKey?: string | null;\n /** The palette before a person has chosen one: a `data-palette` name from `palettes` (or the app's own). Left out, the default palette. */\n defaultPalette?: string;\n /** Where the palette is kept in localStorage; `null` keeps it for this visit only. */\n paletteStorageKey?: string | null;\n /**\n * The element that gets the `.dark` class; the document's root element when left out. A nested\n * target can turn a light page's panel dark, not the reverse: strata.css keys dark on any\n * `.dark` ancestor. Pass the element itself (keep it in state with a callback ref, since a\n * wrapping element's ref is not attached yet when this provider's effect first runs); `null`\n * means it has not mounted yet, and nothing is set until it has.\n */\n target?: HTMLElement | null;\n /**\n * How much the screen packs in, set on the same element as the colour scheme (the root, so\n * overlays are reached): `compact` for a tool screen. See `Density`. Left out, nothing is set.\n */\n density?: DensityName;\n}) {\n // The first render uses the default, as the server does, so a server-rendered tree hydrates\n // without a mismatch; the stored choice is read in a layout effect, which re-renders before the\n // browser paints, so a client-only app still never shows the default first.\n const [preference, setState] = React.useState<ColorSchemePreference>(defaultPreference);\n React.useLayoutEffect(() => {\n const stored = readStored(storageKey);\n if (stored) setState(stored);\n }, [storageKey]);\n const system = useSystemColorScheme();\n const scheme: ColorScheme = preference === \"system\" ? system : preference;\n\n const setPreference = React.useCallback(\n (next: ColorSchemePreference) => {\n setState(next);\n writeStored(storageKey, next);\n },\n [storageKey],\n );\n\n // Another tab changed the choice. A cleared key (`newValue` null) falls back to the default.\n React.useEffect(() => {\n if (storageKey === null) return;\n const onStorage = (event: StorageEvent) => {\n if (event.key !== storageKey && event.key !== null) return;\n const value = event.key === null ? null : event.newValue;\n setState(isPreference(value) ? value : defaultPreference);\n };\n window.addEventListener(\"storage\", onStorage);\n return () => window.removeEventListener(\"storage\", onStorage);\n }, [storageKey, defaultPreference]);\n\n React.useLayoutEffect(() => {\n const element = target === undefined ? document.documentElement : target;\n if (!element) return;\n element.classList.toggle(\"dark\", scheme === \"dark\");\n return () => element.classList.remove(\"dark\");\n }, [scheme, target]);\n\n // The palette follows the scheme's pattern: default first, the stored choice in a layout effect.\n const [palette, setPaletteState] = React.useState<string>(defaultPalette);\n React.useLayoutEffect(() => {\n const stored = readStoredPalette(paletteStorageKey);\n if (stored) setPaletteState(stored);\n }, [paletteStorageKey]);\n const setPalette = React.useCallback(\n (next: string) => {\n if (!isPalette(next)) return;\n setPaletteState(next);\n writeStoredPalette(paletteStorageKey, next);\n },\n [paletteStorageKey],\n );\n React.useEffect(() => {\n if (paletteStorageKey === null) return;\n const onStorage = (event: StorageEvent) => {\n if (event.key !== paletteStorageKey && event.key !== null) return;\n const value = event.key === null ? null : event.newValue;\n setPaletteState(isPalette(value) ? value : defaultPalette);\n };\n window.addEventListener(\"storage\", onStorage);\n return () => window.removeEventListener(\"storage\", onStorage);\n }, [paletteStorageKey, defaultPalette]);\n React.useLayoutEffect(() => {\n const element = target === undefined ? document.documentElement : target;\n if (!element) return;\n element.setAttribute(\"data-palette\", palette);\n return () => element.removeAttribute(\"data-palette\");\n }, [palette, target]);\n\n useDensityOn(density, target);\n\n const value = React.useMemo(() => ({ preference, scheme, setPreference }), [preference, scheme, setPreference]);\n const paletteValue = React.useMemo(() => ({ palette, setPalette }), [palette, setPalette]);\n return (\n <Context.Provider value={value}>\n <PaletteContext.Provider value={paletteValue}>{children}</PaletteContext.Provider>\n </Context.Provider>\n );\n}\n\n/** The person's colour-scheme preference, the scheme in effect, and a setter that persists it. Must be inside `ThemeProvider`. */\nexport function useColorScheme(): ColorSchemeState {\n const value = React.useContext(Context);\n if (!value) throw new Error(\"useColorScheme must be used inside a ThemeProvider.\");\n return value;\n}\n\n/**\n * The body of an inline `<script>` for the page's `<head>` that sets `.dark` before the first\n * paint, from the stored choice or the operating system, so a dark page does not flash light while\n * the bundle loads. Pass the same key and default as the `ThemeProvider`.\n */\nexport function colorSchemeScript(\n storageKey: string = COLOR_SCHEME_STORAGE_KEY,\n defaultPreference: ColorSchemePreference = \"system\",\n): string {\n const key = JSON.stringify(storageKey);\n const fallback = JSON.stringify(defaultPreference);\n return (\n `(function(){var p=${fallback};try{var s=localStorage.getItem(${key});` +\n `if(s===\"system\"||s===\"light\"||s===\"dark\")p=s}catch(e){}` +\n `var d=p===\"dark\"||(p===\"system\"&&window.matchMedia&&matchMedia(${JSON.stringify(QUERY)}).matches);` +\n `document.documentElement.classList.toggle(\"dark\",!!d)})()`\n );\n}\n\n/** The words `ColorSchemeChoice` shows for each preference. */\nexport type ColorSchemeLabels = Record<ColorSchemePreference, { label: string; detail?: string }>;\n\nconst defaultLabels: ColorSchemeLabels = {\n system: { label: \"Match this device\", detail: \"Light or dark as your system setting changes\" },\n light: { label: \"Light\" },\n dark: { label: \"Dark\" },\n};\n\nconst icons: Record<ColorSchemePreference, IconComponent> = { system: Monitor, light: Sun, dark: Moon };\n\n/** The three colour-scheme preferences as radio buttons, bound to the nearest `ThemeProvider`. A list for a settings page, or `compact` icon segments named \"Appearance\" for a header. */\nexport function ColorSchemeChoice({\n legend,\n labels = defaultLabels,\n compact = false,\n className,\n}: {\n /** The group's name, as the page words it. Defaults to \"Theme\", or \"Appearance\" when `compact`. */\n legend?: string;\n /** Overrides the words for each choice, in the product's voice. */\n labels?: Partial<ColorSchemeLabels>;\n /** Three icon segments for a header or footer, for an app with no settings page. */\n compact?: boolean;\n /** Layout at the call site (compact only). */\n className?: string;\n}) {\n const { preference, setPreference } = useColorScheme();\n const name = React.useId();\n const words = { ...defaultLabels, ...labels };\n if (compact) {\n return (\n <RadioGroup\n aria-label={legend ?? \"Appearance\"}\n orientation=\"horizontal\"\n name={name}\n value={preference}\n onChange={(value) => {\n if (isPreference(value)) setPreference(value);\n }}\n className={cn(\"inline-flex gap-0.5 rounded-surface border border-border bg-background p-0.5\", className)}\n >\n {PREFERENCES.map((value) => {\n const Icon = icons[value];\n return (\n <Tooltip key={value} label={words[value].label}>\n <Radio\n value={value}\n aria-label={words[value].label}\n className={cn(\n // Outer 6px less 2px padding: the segments are 4px, as optical nesting asks.\n \"grid size-(--control-h-sm) cursor-pointer place-items-center rounded-control text-muted-foreground transition-state\",\n \"hover:text-foreground selected:bg-muted selected:text-foreground\",\n \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\",\n )}\n >\n <Icon aria-hidden className=\"size-4\" />\n </Radio>\n </Tooltip>\n );\n })}\n </RadioGroup>\n );\n }\n return (\n <ChoiceGroup\n legend={legend ?? \"Theme\"}\n name={name}\n value={preference}\n onChange={(value) => {\n if (isPreference(value)) setPreference(value);\n }}\n choices={PREFERENCES.map((value) => ({ value, ...words[value] }))}\n />\n );\n}\n\n/** The palette in effect and a setter that persists it. Must be inside `ThemeProvider`. */\nexport function usePalette(): PaletteState {\n const value = React.useContext(PaletteContext);\n if (!value) throw new Error(\"usePalette must be used inside a ThemeProvider.\");\n return value;\n}\n\n/**\n * The body of an inline `<script>` for the page's `<head>` that sets `data-palette` before the first paint\n * from the stored choice, so a page does not flash the default palette while the bundle loads. Pass the\n * same key and default as the `ThemeProvider`; put it beside `colorSchemeScript()`.\n */\nexport function paletteScript(storageKey: string = PALETTE_STORAGE_KEY, defaultPalette: string = DEFAULT_PALETTE): string {\n const key = JSON.stringify(storageKey);\n const fallback = JSON.stringify(defaultPalette);\n return (\n `(function(){var p=${fallback};try{var s=localStorage.getItem(${key});` +\n `if(s&&/^[a-z][a-z0-9-]{0,31}$/.test(s))p=s}catch(e){}` +\n `document.documentElement.setAttribute(\"data-palette\",p)})()`\n );\n}\n\n/**\n * The palettes as radio buttons, bound to the nearest `ThemeProvider`, each with a swatch drawn in its own\n * palette (primary and the one warm accent) so the colours are seen before they are chosen. A list for a\n * settings page, or `compact` swatches named \"Palette\" for a header. The words are always present (the\n * list shows them, the compact form names each swatch and shows the same words as a tooltip).\n */\nexport function PaletteChoice({\n legend,\n options = palettes,\n compact = false,\n className,\n}: {\n /** The group's name, as the page words it. Defaults to \"Palette\". */\n legend?: string;\n /** The palettes offered: names that `strata.css` (or the app's own CSS) defines under `data-palette`, with their words. Defaults to `palettes`. */\n options?: readonly PaletteOption[];\n /** Swatches only, for a header or footer, for an app with no settings page. */\n compact?: boolean;\n /** Layout at the call site (compact only). */\n className?: string;\n}) {\n const { palette, setPalette } = usePalette();\n const name = React.useId();\n const swatch = (option: PaletteOption) => (\n // Scoping the palette on the swatch draws it in its own colours, in light and in a dark page.\n <span data-palette={option.name} aria-hidden className=\"inline-flex size-5 shrink-0 overflow-hidden rounded-pill border border-border\">\n <span className=\"w-1/2 bg-primary\" />\n <span className=\"w-1/2 bg-secondary-9\" />\n </span>\n );\n if (compact) {\n return (\n <RadioGroup\n aria-label={legend ?? \"Palette\"}\n orientation=\"horizontal\"\n name={name}\n value={palette}\n onChange={setPalette}\n className={cn(\"inline-flex gap-0.5 rounded-surface border border-border bg-background p-0.5\", className)}\n >\n {options.map((option) => (\n <Tooltip key={option.name} label={option.label}>\n <Radio\n value={option.name}\n aria-label={option.label}\n className={cn(\n \"grid size-(--control-h-sm) cursor-pointer place-items-center rounded-control transition-state\",\n \"hover:bg-muted selected:bg-muted selected:ring-1 selected:ring-border\",\n \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\",\n )}\n >\n {swatch(option)}\n </Radio>\n </Tooltip>\n ))}\n </RadioGroup>\n );\n }\n return (\n <ChoiceGroup\n legend={legend ?? \"Palette\"}\n name={name}\n value={palette}\n onChange={setPalette}\n choices={options.map((option) => ({ value: option.name, label: option.label, detail: option.detail, leading: swatch(option) }))}\n />\n );\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,aAAa,OAAgC,QAA6B;CACxF,MAAM,sBAAsB;EAC1B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,UAAU,WAAW,KAAA,IAAY,SAAS,kBAAkB;EAClE,IAAI,CAAC,SAAS;EACd,MAAM,SAAS,QAAQ,aAAa,cAAc;EAClD,QAAQ,aAAa,gBAAgB,KAAK;EAC1C,aAAa;GACX,IAAI,WAAW,MAAM,QAAQ,gBAAgB,cAAc;QACtD,QAAQ,aAAa,gBAAgB,MAAM;EAClD;CACF,GAAG,CAAC,OAAO,MAAM,CAAC;AACpB;;AAaA,SAAgB,QAAQ,EAAE,OAAO,OAAO,OAAO,WAAW,YAA0B;CAClF,aAAa,OAAO,QAAQ,KAAA,CAAS;CACrC,IAAI,MAAM,OAAO,oBAAAA,UAAA,EAAG,SAAW,CAAA;CAC/B,OACE,oBAAC,OAAD;EAAK,gBAAc;EAAO,WAAW,GAAG,SAA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mFACF;IAEC,UAAA,OAAO,MAAM;GACT,CAAA;EACA,GAZK,OAAO,IAYZ,CACV;CACS,CAAA;CAGhB,OACE,oBAAC,aAAD;EACE,QAAQ,UAAU;EACZ;EACN,OAAO;EACP,UAAU;EACV,SAAS,QAAQ,KAAK,YAAY;GAAE,OAAO,OAAO;GAAM,OAAO,OAAO;GAAO,QAAQ,OAAO;GAAQ,SAAS,OAAO,MAAM;EAAE,EAAE;CAC/H,CAAA;AAEL"}
|
|
@@ -1,49 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as fieldErrorsOf, n as describeActionError, s as Button$1 } from "./errors-D99YX4XL.js";
|
|
1
|
+
import { g as cn, m as format, o as useFieldControl, s as controlHeight, u as KeyText } from "./field-t4Hoer0d.js";
|
|
2
|
+
import { a as fieldErrorsOf, n as describeActionError, s as Button$1 } from "./errors-jep2voNI.js";
|
|
4
3
|
import * as React from "react";
|
|
5
4
|
import { I18nProvider, Input, NumberField, Separator, Slider, SliderOutput, SliderThumb, SliderTrack, Toolbar } from "react-aria-components";
|
|
6
5
|
import { Check, CircleAlert, LoaderCircle } from "lucide-react";
|
|
7
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
// src/lib/in-view.ts
|
|
9
|
-
/**
|
|
10
|
-
* Whether an element is within `rootMargin` of its scroll region (the nearest
|
|
11
|
-
* `[data-strata-scroll]` ancestor, else the viewport). Returns a callback ref, so it follows the
|
|
12
|
-
* element as it mounts and unmounts.
|
|
13
|
-
*/
|
|
14
|
-
function useInView({ active = true, rootMargin = "0px", once = false, unsupported = false } = {}) {
|
|
15
|
-
const [inView, setInView] = React.useState(false);
|
|
16
|
-
const [el, setEl] = React.useState(null);
|
|
17
|
-
const seen = once && inView;
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
if (seen) return;
|
|
20
|
-
if (!active || !el) {
|
|
21
|
-
setInView(false);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (typeof IntersectionObserver === "undefined") {
|
|
25
|
-
setInView(unsupported);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const root = el.parentElement?.closest("[data-strata-scroll]") ?? null;
|
|
29
|
-
const observer = new IntersectionObserver((entries) => setInView(entries[entries.length - 1].isIntersecting), {
|
|
30
|
-
root,
|
|
31
|
-
rootMargin
|
|
32
|
-
});
|
|
33
|
-
observer.observe(el);
|
|
34
|
-
return () => observer.disconnect();
|
|
35
|
-
}, [
|
|
36
|
-
active,
|
|
37
|
-
el,
|
|
38
|
-
rootMargin,
|
|
39
|
-
seen,
|
|
40
|
-
unsupported
|
|
41
|
-
]);
|
|
42
|
-
return {
|
|
43
|
-
ref: setEl,
|
|
44
|
-
inView
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
7
|
// src/components/hotkeys.tsx
|
|
48
8
|
var TEXT_INPUTS_EXEMPT = /* @__PURE__ */ new Set([
|
|
49
9
|
"checkbox",
|
|
@@ -63,6 +23,11 @@ function isTypingTarget(target) {
|
|
|
63
23
|
if (target instanceof HTMLInputElement) return !TEXT_INPUTS_EXEMPT.has(target.type);
|
|
64
24
|
return false;
|
|
65
25
|
}
|
|
26
|
+
function isRowChild(target) {
|
|
27
|
+
if (!(target instanceof Element)) return false;
|
|
28
|
+
const row = target.closest("[role=row]");
|
|
29
|
+
return row !== null && row !== target;
|
|
30
|
+
}
|
|
66
31
|
function toShortcuts(input) {
|
|
67
32
|
return Array.isArray(input) ? input : Object.entries(input).map(([key, run]) => ({
|
|
68
33
|
keys: [key],
|
|
@@ -71,7 +36,7 @@ function toShortcuts(input) {
|
|
|
71
36
|
}));
|
|
72
37
|
}
|
|
73
38
|
/**
|
|
74
|
-
* Binds single-key shortcuts on the window, ignoring keys typed into fields, chords with Ctrl, Meta
|
|
39
|
+
* Binds single-key shortcuts on the window (also for a key pressed on a control inside a grid row, whose React Aria hooks stop propagation), ignoring keys typed into fields, chords with Ctrl, Meta
|
|
75
40
|
* or Alt, IME composition and (unless `repeat`) held keys. Pass the same list to `KeysLegend`.
|
|
76
41
|
*/
|
|
77
42
|
function useHotkeys(shortcuts, { enabled = true } = {}) {
|
|
@@ -79,7 +44,10 @@ function useHotkeys(shortcuts, { enabled = true } = {}) {
|
|
|
79
44
|
latest.current = toShortcuts(shortcuts);
|
|
80
45
|
React.useEffect(() => {
|
|
81
46
|
if (!enabled) return;
|
|
47
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
82
48
|
const onKeyDown = (e) => {
|
|
49
|
+
if (seen.has(e)) return;
|
|
50
|
+
seen.add(e);
|
|
83
51
|
if (e.defaultPrevented || e.isComposing || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
84
52
|
if (isTypingTarget(e.target)) return;
|
|
85
53
|
const hit = latest.current.find((s) => !s.disabled && s.keys.includes(e.key));
|
|
@@ -87,8 +55,15 @@ function useHotkeys(shortcuts, { enabled = true } = {}) {
|
|
|
87
55
|
e.preventDefault();
|
|
88
56
|
hit.run();
|
|
89
57
|
};
|
|
58
|
+
const early = (e) => {
|
|
59
|
+
if (isRowChild(e.target)) onKeyDown(e);
|
|
60
|
+
};
|
|
61
|
+
window.addEventListener("keydown", early, true);
|
|
90
62
|
window.addEventListener("keydown", onKeyDown);
|
|
91
|
-
return () =>
|
|
63
|
+
return () => {
|
|
64
|
+
window.removeEventListener("keydown", early, true);
|
|
65
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
66
|
+
};
|
|
92
67
|
}, [enabled]);
|
|
93
68
|
}
|
|
94
69
|
var KEY_NAMES = {
|
|
@@ -741,6 +716,6 @@ function ColorField({ value, onChange, suggestions, against, againstLabel = "the
|
|
|
741
716
|
]
|
|
742
717
|
});
|
|
743
718
|
}
|
|
744
|
-
export { useAsyncAction as a, KeysLegend as c,
|
|
719
|
+
export { useAsyncAction as a, KeysLegend as c, AsyncButton as i, isTypingTarget as l, NumberField$1 as n, Toolbar$1 as o, Slider$1 as r, ToolbarSeparator as s, ColorField as t, useHotkeys as u };
|
|
745
720
|
|
|
746
|
-
//# sourceMappingURL=value-controls-
|
|
721
|
+
//# sourceMappingURL=value-controls-DB5l5Qe2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-controls-DB5l5Qe2.js","names":["Toolbar","AriaToolbar","_Fragment","Button","NumberField","AriaNumberField","AriaInput","Toolbar","Button","Slider","AriaSlider","_Fragment"],"sources":["../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 { 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// 4. They are also heard in the capture phase for a key pressed on a control inside a grid or\n// table row (a tile's checkbox, a row's button). React Aria's `useGridListItem` calls\n// `stopPropagation` for every key but Tab pressed on such a child (\"we don't want to trigger\n// grid level interactions\"), which also stops the native event bubbling to `window`, so after\n// a click on a tile's checkbox `a` never arrived (issue #328). Only that case is taken early:\n// the grid does nothing with those keys, so nothing is done twice. Every other key keeps the\n// bubble phase, which lets a part that handles a key itself (a slider's arrows and Space, a\n// menu's typeahead) call `preventDefault` or stop it first, as it always could.\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\n// A control inside a row of a grid or table: React Aria's row hooks stop the keys pressed on it.\nfunction isRowChild(target: EventTarget | null): boolean {\n if (!(target instanceof Element)) return false;\n const row = target.closest(\"[role=row]\");\n return row !== null && row !== target;\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 (also for a key pressed on a control inside a grid row, whose React Aria hooks stop propagation), 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 // One press may be seen twice (capture, then bubble): it runs once.\n const seen = new WeakSet<Event>();\n const onKeyDown = (e: KeyboardEvent) => {\n if (seen.has(e)) return;\n seen.add(e);\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 const early = (e: KeyboardEvent) => {\n if (isRowChild(e.target)) onKeyDown(e);\n };\n window.addEventListener(\"keydown\", early, true);\n window.addEventListener(\"keydown\", onKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", early, true);\n window.removeEventListener(\"keydown\", onKeyDown);\n };\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":";;;;;;;AAqCA,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,mBAAmB,IAAI,OAAO,IAAI;CAClF,OAAO;AACT;AAGA,SAAS,WAAW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OAAO,QAAQ,KAAK;KAAE;KAAa,OAAO,QAAQ,WAAW;KAAE;IACvG;;EAEF;;AAET"}
|
package/dist/visual/capture.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface CaptureOptions {
|
|
|
12
12
|
onUnhandledRequest?: "error" | "bypass";
|
|
13
13
|
/** Look up which faces drew the page's text and return the ones that are not web fonts. Default true. */
|
|
14
14
|
checkFonts?: boolean;
|
|
15
|
+
/** A family the runner pinned every system family to (`systemFonts: { pin }`): text drawn in it is deterministic, so it is not reported. */
|
|
16
|
+
pinnedFamily?: string;
|
|
15
17
|
/** Scroll a page taller than the window through before the shot, so pictures that wait until they are near the window have loaded (issue #273). Default true. */
|
|
16
18
|
scrollThrough?: boolean;
|
|
17
19
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A system face to pin, from `VisualConfig.systemFonts`. */
|
|
2
|
+
export interface PinnedSystemFont {
|
|
3
|
+
/** The family name inside the font files, e.g. `"DejaVu Sans"`. Every system family the page uses resolves to it. */
|
|
4
|
+
pin: string;
|
|
5
|
+
/** Font files (`.ttf`, `.otf`) holding that family, relative to the config file: the regular face and any bold or italic the page uses. */
|
|
6
|
+
files: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
/** A pinned face made ready for a launch. */
|
|
9
|
+
export interface PinnedFonts {
|
|
10
|
+
/** Environment for Chromium: points fontconfig at the generated file. */
|
|
11
|
+
env: Record<string, string>;
|
|
12
|
+
/** The family that now stands for every system family; text drawn in it is not a system-font fault. */
|
|
13
|
+
family: string;
|
|
14
|
+
/** Removes the generated folder. */
|
|
15
|
+
dispose(): void;
|
|
16
|
+
}
|
|
17
|
+
/** Writes the fontconfig that pins `font` and returns what a launch needs. Throws when a file is missing. */
|
|
18
|
+
export declare function pinSystemFont(font: PinnedSystemFont, cwd: string): PinnedFonts;
|
package/dist/visual/index.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ export { capture, resolveShotUrl, toFetchRequest, type CaptureOptions, type Capt
|
|
|
15
15
|
export { dropFiles, DROPPED_FILE_MODIFIED, type DroppedFile } from './drop';
|
|
16
16
|
export { serveStatic, type StaticServer } from './serve';
|
|
17
17
|
export { compare, decode, encode, boxBlur, THRESHOLD, BLUR, MAX_DIFF_PIXELS, type CompareOptions, type Image, type CompareResult } from './compare';
|
|
18
|
+
export type { PinnedSystemFont } from './fonts';
|
|
18
19
|
export { viewports, type Theme, type Viewport, type ViewportChoice, type Clip, type Setup, type Shot, type StorybookTarget, type RouteState, type Route, type AppTarget, type VisualConfig, type VisualReport, } from './types';
|
package/dist/visual/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PinnedSystemFont } from './fonts';
|
|
1
2
|
import { Page } from 'playwright';
|
|
2
3
|
import { RequestHandler } from 'msw';
|
|
3
4
|
import { CompareOptions } from './compare';
|
|
@@ -139,8 +140,13 @@ export interface VisualConfig {
|
|
|
139
140
|
* lacks). `error` (default) fails the shot, because no comparison threshold makes Cantarell
|
|
140
141
|
* match San Francisco; `warn` reports it; `allow` skips the check. Bundle every face with
|
|
141
142
|
* `@fontsource` (or your own `@font-face`) and name it first in the theme's `--font-*`.
|
|
143
|
+
*
|
|
144
|
+
* An app that chooses `system-ui` on purpose (so a page never waits on a font download) pins it
|
|
145
|
+
* instead: `{ pin: "DejaVu Sans", files: ["tests/visual/fonts/DejaVuSans.ttf"] }` makes every
|
|
146
|
+
* system family mean that face in the runner's Chromium, on every machine (issue #342), through
|
|
147
|
+
* a fontconfig file the runner generates. Linux only; elsewhere it warns and takes the machine's face.
|
|
142
148
|
*/
|
|
143
|
-
systemFonts?: "error" | "warn" | "allow";
|
|
149
|
+
systemFonts?: "error" | "warn" | "allow" | PinnedSystemFont;
|
|
144
150
|
/**
|
|
145
151
|
* Before a whole-page shot (a route's) of a page taller than the window, show it to the page in a window as tall as itself and wait for the
|
|
146
152
|
* pictures that start loading, then go back to the window's size, so a `Thumbnail` or any other lazy picture below the fold is in the
|
package/dist/visual-cli.js
CHANGED
package/dist/visual.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as capture, a as defaultThemes, c as viewports, d as MAX_DIFF_PIXELS, f as THRESHOLD, g as encode, h as decode, i as runVisual, l as serveStatic, m as compare, n as formatReport, o as routeShots, p as boxBlur, r as pinWarnings, s as storybookShots, t as defineVisualConfig, u as BLUR, v as resolveShotUrl, y as toFetchRequest } from "./run-
|
|
1
|
+
import { _ as capture, a as defaultThemes, c as viewports, d as MAX_DIFF_PIXELS, f as THRESHOLD, g as encode, h as decode, i as runVisual, l as serveStatic, m as compare, n as formatReport, o as routeShots, p as boxBlur, r as pinWarnings, s as storybookShots, t as defineVisualConfig, u as BLUR, v as resolveShotUrl, y as toFetchRequest } from "./run-BT2WKzMz.js";
|
|
2
2
|
// src/visual/drop.ts
|
|
3
3
|
/** What `dropFiles` uses when a file gives no `lastModified`. */
|
|
4
4
|
var DROPPED_FILE_MODIFIED = Date.UTC(2026, 0, 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strata-react",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.17",
|
|
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",
|
|
@@ -38,6 +38,14 @@
|
|
|
38
38
|
"style": "./dist/strata.css",
|
|
39
39
|
"default": "./dist/strata.css"
|
|
40
40
|
},
|
|
41
|
+
"./reading.css": {
|
|
42
|
+
"style": "./dist/reading.css",
|
|
43
|
+
"default": "./dist/reading.css"
|
|
44
|
+
},
|
|
45
|
+
"./strata.bare.css": {
|
|
46
|
+
"style": "./dist/strata.bare.css",
|
|
47
|
+
"default": "./dist/strata.bare.css"
|
|
48
|
+
},
|
|
41
49
|
"./strata.migrate.css": {
|
|
42
50
|
"style": "./dist/strata.migrate.css",
|
|
43
51
|
"default": "./dist/strata.migrate.css"
|
|
@@ -133,6 +141,9 @@
|
|
|
133
141
|
},
|
|
134
142
|
"dependencies": {
|
|
135
143
|
"@fontsource-variable/geist": "^5.3.0",
|
|
144
|
+
"@fontsource-variable/instrument-sans": "^5.3.0",
|
|
145
|
+
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
|
146
|
+
"@fontsource-variable/source-serif-4": "^5.3.1",
|
|
136
147
|
"@tanstack/react-table": "^9.3.1",
|
|
137
148
|
"class-variance-authority": "^0.7.1",
|
|
138
149
|
"clsx": "^2.1.1",
|
|
@@ -146,8 +157,6 @@
|
|
|
146
157
|
"tailwindcss-react-aria-components": "^2.2.0"
|
|
147
158
|
},
|
|
148
159
|
"devDependencies": {
|
|
149
|
-
"@fontsource-variable/archivo": "^5.3.0",
|
|
150
|
-
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
|
151
160
|
"@fontsource-variable/public-sans": "^5.3.0",
|
|
152
161
|
"@storybook/addon-a11y": "^10.6.6",
|
|
153
162
|
"@storybook/addon-docs": "^10.6.6",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-D99YX4XL.js","names":["Button","AriaButton","Tooltip"],"sources":["../src/lib/dev.ts","../src/components/button.tsx","../src/lib/errors.ts"],"sourcesContent":["// Development-only checks (a warning for a mistake a type cannot catch). `import.meta.env.DEV` is\n// replaced by the library build itself, so in the published package it is always false and the check\n// never runs in an app's development. `process.env.NODE_ENV` is left for the app's bundler to replace\n// (Vite, webpack and the rest do, in dependencies too), so the app decides. Where nothing replaces it\n// `process` does not exist, and the check is off.\n\n/** Whether the app is running in development, decided by the app's bundler. */\nexport function isDev(): boolean {\n try {\n return process.env.NODE_ENV !== \"production\";\n } catch {\n return false;\n }\n}\n","import * as React from \"react\";\nimport { Button as AriaButton, type PressEvent } from \"react-aria-components\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\nimport type { ControlSize } from \"../lib/control\";\nimport { Tooltip } from \"./tooltip\";\nimport { isDev } from \"../lib/dev\";\n\n// Variant names are shadcn's, so copied code and agents' prior knowledge still work. Two things\n// differ on purpose:\n// 1. The default variant is `outline`, not the filled accent. A bare <Button> is the restrained\n// one; the accent (`variant=\"default\"`) has to be asked for, once per view. Generated app screens\n// put the accent on every button; 12 of 23 real product screens had no filled primary at all.\n// 2. Heights come from --control-h, shared with Input and NativeSelect, so density changes move\n// every control together.\n// 3. React Aria is the primitives layer (CLAUDE.md, \"The stack\"): behaviour and accessibility come\n// from it, the look from our tokens. `asChild`/`Slot` is gone; a button that navigates is a link.\n// 4. `press`: the button gives 2% under a click or a finger, over 100ms. Buttons are used tens of\n// times a day, so that is all the motion they get (character.md, the frequency budget).\n// 5. `title` is refused, not passed through (issue #231). React Aria's `Button` does not forward it,\n// so a tip moved over from a native button vanished with nothing said. Passing it through would\n// give a tip that has no keyboard focus, no touch and a long, unstyled delay; the answer is a\n// `Tooltip` (and `IconButton`'s `label` and `hint`). The type says so (`title?: never`) and, for\n// an untyped caller, so does a development warning. A button whose only child is one symbol\n// (`✕`, `−`, `+`) has no accessible name from its text and gets a development warning too.\nexport const buttonVariants = cva(\n \"inline-flex max-w-full shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-(--control-icon) [&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary-10\",\n outline: \"border border-input bg-background text-foreground hover:bg-muted\",\n secondary: \"bg-muted text-foreground hover:bg-neutral-4\",\n ghost: \"text-foreground hover:bg-muted\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-danger\",\n link: \"h-auto px-0 text-primary-11 underline underline-offset-4 hover:text-primary-12\",\n },\n size: {\n default: \"h-(--control-h) px-(--control-px)\",\n sm: \"h-(--control-h-sm) px-(--control-px-sm)\",\n icon: \"size-(--control-h)\",\n \"icon-sm\": \"size-(--control-h-sm)\",\n },\n },\n defaultVariants: { variant: \"outline\", size: \"default\" },\n },\n);\n\nexport type ButtonProps = Omit<React.ComponentProps<\"button\">, \"className\" | \"style\" | \"title\"> &\n VariantProps<typeof buttonVariants> & {\n className?: string;\n /** Not accepted: a `title` is a poor tooltip (no keyboard focus, no touch) and React Aria's button drops it. Wrap the button in a `Tooltip`, or use `IconButton`'s `label` and `hint`. */\n title?: never;\n /** React Aria's press event (mouse, touch, pen and keyboard alike). `onClick` also works. */\n onPress?: (event: PressEvent) => void;\n /** When a press begins and ends: for a control that acts while held (a nudge that repeats). */\n onPressStart?: (event: PressEvent) => void;\n onPressEnd?: (event: PressEvent) => void;\n };\n\n/**\n * A button with shadcn's variant names, built on React Aria's `Button` (press handling that behaves\n * the same for mouse, touch, pen and keyboard, focus-visible and hover state). The default variant is\n * `outline`; ask for the filled accent (`variant=\"default\"`) once per view. `type` defaults to `button`.\n * `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.\n */\nexport function Button({ className, variant, size, type = \"button\", disabled, children, \"aria-busy\": ariaBusy, ...props }: ButtonProps) {\n // React Aria's button drops `aria-busy` (it forwards only the aria props it knows), so it is set\n // on the element here; a pending row action says it is busy to a screen reader (issue #248).\n const ref = React.useRef<HTMLButtonElement>(null);\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n if (ariaBusy) el.setAttribute(\"aria-busy\", String(ariaBusy));\n else el.removeAttribute(\"aria-busy\");\n }, [ariaBusy]);\n if (isDev()) warnOnLoss(props as Record<string, unknown>, children);\n // data-variant says which variant was drawn, so a test can check \"one filled button per view\"\n // without reading class names (strata-react issue #48, `filledButtons` in strata-react/testing).\n return (\n <AriaButton\n ref={ref}\n type={type}\n isDisabled={disabled}\n data-variant={variant ?? \"outline\"}\n className={cn(buttonVariants({ variant, size }), className)}\n {...(props as object)}\n >\n {/* A text label that cannot fit its column is cut with an ellipsis, not drawn past the button (issue #116). */}\n {typeof children === \"string\" ? <span className=\"min-w-0 truncate\">{children}</span> : children}\n </AriaButton>\n );\n}\n\n/** Development only: what a native button had that this one loses or cannot name (issue #231). */\nfunction warnOnLoss(props: Record<string, unknown>, children: React.ReactNode) {\n if (props.title !== undefined && !warned.has(\"title\")) {\n warned.add(\"title\");\n console.warn(\"strata-react: Button does not pass `title` through (React Aria's button drops it, and a title has no keyboard or touch). Wrap the button in a `Tooltip`, or use IconButton's `label` and `hint`.\");\n }\n const glyph = typeof children === \"string\" ? children.trim() : \"\";\n if (glyph && Array.from(glyph).length === 1 && !/[\\p{L}\\p{N}]/u.test(glyph) && !props[\"aria-label\"] && !props[\"aria-labelledby\"] && !warned.has(\"glyph\")) {\n warned.add(\"glyph\");\n console.warn(`strata-react: a Button whose only content is \"${glyph}\" has no accessible name. Give it an aria-label, or use an IconButton with a label.`);\n }\n}\nconst warned = new Set<string>();\n\n// An icon-only button cannot be written without a name: `label` is required by the type, becomes\n// the accessible name and is shown as a `Tooltip` on hover and keyboard focus, so the name and the\n// visible hint come from one string and cannot drift. This makes the most common generated\n// accessibility defect (an unlabelled icon button) a compile error instead of an audit finding.\nexport type IconButtonProps = Omit<ButtonProps, \"size\" | \"children\" | \"aria-label\"> & {\n /** `sm` is --control-h-sm, the height of a small `Toggle` or `Button`, for a toolbar or property row. Default --control-h. */\n size?: ControlSize;\n icon: IconComponent;\n label: string;\n /** Shown after the label in its tooltip, muted: \"Ctrl+Z\". */\n hint?: React.ReactNode;\n};\n\n/** An icon-only button. `label` is required and becomes the accessible name and the tooltip (hover and keyboard focus); `hint` adds a muted aside to it, such as a shortcut. */\nexport function IconButton({ icon: Icon, label, hint, variant = \"ghost\", size = \"default\", ...props }: IconButtonProps) {\n return (\n <Tooltip label={label} hint={hint}>\n <Button size={size === \"sm\" ? \"icon-sm\" : \"icon\"} variant={variant} aria-label={label} {...props}>\n <Icon aria-hidden />\n </Button>\n </Tooltip>\n );\n}\n\n// A row action says what it does in the row (\"Withdraw\") and whom it does it to in its name\n// (\"Withdraw Tom Ellery\"): a table of eight \"Withdraw\" buttons is eight identical names in a\n// screen reader's list of controls. The name is an aria-label that starts with the visible verb,\n// so it meets WCAG 2.5.3 (label in name) and voice control still finds it by \"Withdraw\". Visually\n// hidden suffix text is not used: a hidden span joined to the verb did not form a name with its\n// space in dom-testing-library (strata-react issue #11). Ghost and small, one per row, shown only\n// on the rows where it applies; an icon-only row action is an `IconButton` whose `label` names the\n// row the same way. It keeps the row's pitch: rows with and without the action are the same height.\nexport type RowActionProps = Omit<ButtonProps, \"children\" | \"aria-label\"> & {\n /** The visible verb, sentence case: \"Withdraw\", \"Remove\". */\n label: string;\n /** What the row is, as a person would say it: \"Tom Ellery\", \"Moonbeam\". Completes the accessible name. */\n subject: string;\n icon?: IconComponent;\n};\n\n/** A small ghost action for one table row: shows `label`, and is named \"`label` `subject`\" so every row's action has its own name. */\nexport function RowAction({ label, subject, icon: Icon, variant = \"ghost\", size = \"sm\", className, ...props }: RowActionProps) {\n // -my-1.5 lets the 32px button sit in the 20px line of a table row, inside the row's padding, so\n // rows with an action keep the same pitch as rows without one.\n return (\n <Button variant={variant} size={size} aria-label={`${label} ${subject}`} className={cn(\"-my-1.5\", className)} {...props}>\n {Icon && <Icon aria-hidden />}\n {label}\n </Button>\n );\n}\n","// Errors, described for a person. Anything that fails in front of someone (a load in DataView, an\n// action in AsyncButton) says what happened in a sentence, in the product's words, not the\n// developer's: `HttpError`'s own message (\"409 Conflict from /api/bookings\") is for logs. Loads\n// and actions share HttpError's status sentences, so the same failure reads the same everywhere,\n// and differ only in what is true afterwards: a failed load changed nothing, while a failed action\n// may have reached the server, so its sentence does not promise that.\n//\n// A server's own reason beats the status text (strata-react issue #42, from python-app-template).\n// FastAPI and most JSON APIs say why a 4xx happened in the body (`{\"detail\": \"the data folder must\n// be an absolute path\"}`), and a client that drops it has to repeat every server rule to show the\n// person anything better than \"Bad Request\", which drifts and cannot cover rules only the server\n// can check. So `fetchJson` reads an error response's body, `HttpError` keeps it with the reason\n// and any per-field messages found in it, and the sentences below use the reason for a 4xx.\n// Per-field messages (FastAPI's 422 `detail: [{loc, msg}]`) are keyed by field name, so\n// `useAsyncAction`'s `fieldErrors` can put each under its `Field`, never in a toast. A 5xx body is\n// not shown: it is usually a stack trace or a proxy's HTML page, and is kept on `body` for logs.\n\n/** What `readErrorBody` finds in an error response: the server's sentence, and messages per field. */\nexport type ErrorBody = {\n /** Why the server refused, in its own words. */\n reason?: string;\n /** Messages for individual fields, keyed by field name (`\"name\"`, `\"address.city\"`). */\n fields?: Record<string, string>;\n /** The structured part of the body (`ErrorBody.payload` of the shared contract): what the app can act on, such as what is already running on a 409. Typed by the caller with `errorPayload`. */\n payload?: unknown;\n};\n\n/** Thrown by `fetchJson` on a non-2xx response; carries the status, the response body and the server's reason for `describeHttpError` and `describeActionError`. */\nexport class HttpError extends Error {\n /** The server's sentence for why it refused, from the body (`detail`, `message`, `error`), if it gave one. */\n readonly reason?: string;\n /** Messages for individual fields from the body (FastAPI's 422 `detail: [{loc, msg}]`), keyed by field name. Empty when there are none. */\n readonly fieldErrors: Readonly<Record<string, string>>;\n /** The body's `payload`, when it has one (`{ detail, payload }`): data for the app, not words for the person. Read it typed with `errorPayload`. */\n readonly payload?: unknown;\n\n constructor(\n readonly status: number,\n readonly statusText: string,\n readonly url: string,\n /** The response body: parsed JSON when it was JSON, else its text; undefined when empty. */\n readonly body?: unknown,\n found: ErrorBody = readErrorBody(body),\n ) {\n super(`${status} ${statusText} from ${url}`);\n this.name = \"HttpError\";\n this.reason = found.reason;\n this.fieldErrors = found.fields ?? {};\n this.payload = found.payload;\n }\n}\n\nconst text = (value: unknown) => (typeof value === \"string\" && value.trim() ? value.trim() : undefined);\n\n/** A field name from a FastAPI/pydantic `loc`: the path after where it came from (`[\"body\", \"address\", \"city\"]` is `\"address.city\"`). */\nfunction fieldName(loc: unknown) {\n if (!Array.isArray(loc)) return undefined;\n const path = loc.map(String);\n if ([\"body\", \"query\", \"path\", \"header\", \"cookie\", \"form\"].includes(path[0]) && path.length > 1) path.shift();\n return path.join(\".\") || undefined;\n}\n\n/**\n * The default reading of an error body, for the shapes most JSON APIs use: `{ detail: \"…\" }`\n * (FastAPI), `{ message: \"…\" }`, `{ error: \"…\" }` or `{ error: { message: \"…\" } }` for the reason,\n * and FastAPI's validation list `{ detail: [{ loc, msg }] }` for per-field messages. A short\n * plain-text body (not HTML) is taken as the reason too. Pass your own to `fetchJson` for other APIs.\n */\nexport function readErrorBody(body: unknown): ErrorBody {\n if (typeof body === \"string\") {\n const t = text(body);\n return t && t.length <= 300 && !t.startsWith(\"<\") ? { reason: t } : {};\n }\n if (!body || typeof body !== \"object\") return {};\n const b = body as Record<string, unknown>;\n const payload = b.payload !== undefined && b.payload !== null ? { payload: b.payload } : {};\n if (Array.isArray(b.detail)) {\n const fields: Record<string, string> = {};\n for (const item of b.detail as unknown[]) {\n const entry = item as { loc?: unknown; msg?: unknown } | null;\n const name = fieldName(entry?.loc);\n const msg = text(entry?.msg);\n if (name && msg && !fields[name]) fields[name] = msg;\n }\n return { fields, ...payload };\n }\n const nested = b.error && typeof b.error === \"object\" ? text((b.error as Record<string, unknown>).message) : undefined;\n return { reason: text(b.detail) ?? text(b.message) ?? text(b.error) ?? nested, ...payload };\n}\n\n/** Writes an error for a person: what happened, in a sentence. A product passes its own words. */\nexport type DescribeError = (error: unknown) => string;\n\n/** A sentence ends once: \"…absolute path\" and \"…absolute path.\" both end in one full stop. */\nconst sentence = (s: string) => (/[.!?…]$/.test(s) ? s : `${s}.`);\n\nfunction refused(error: HttpError) {\n if (error.reason) return `The request was refused: ${sentence(error.reason)}`;\n if (Object.keys(error.fieldErrors).length) return \"The request was refused: check the fields marked.\";\n return `The request was refused (${error.status}): ${error.statusText || \"no reason given\"}.`;\n}\n\n/** The default `DescribeError` for loads: the HTTP status in a sentence (with the server's reason for a 4xx), else the error's message, else a plain fallback. */\nexport const describeHttpError: DescribeError = (error) =>\n error instanceof HttpError\n ? error.status >= 500\n ? `The server could not answer (${error.status}). Nothing was changed.`\n : refused(error)\n : error instanceof Error && error.message\n ? error.message\n : \"The data could not be loaded. Nothing was changed.\";\n\n/** The default for `useAsyncAction`: the HTTP status in a sentence (with the server's reason for a 4xx), else the thrown Error's message, else undefined (the retry label alone). */\nexport const describeActionError = (error: unknown): string | undefined =>\n error instanceof HttpError\n ? error.status >= 500\n ? `The server could not answer (${error.status}).`\n : refused(error)\n : error instanceof Error && error.message\n ? error.message\n : undefined;\n\n/** Messages for individual fields carried by what was thrown: an `HttpError`'s `fieldErrors`, else none. */\nexport function fieldErrorsOf(error: unknown): Readonly<Record<string, string>> {\n return error instanceof HttpError ? error.fieldErrors : {};\n}\n\n/** The payload of an error from the server as the type the app expects (`errorPayload<{ running: string }>(error)`), or `undefined` when it is not an `HttpError` or carries none. The type is the caller's claim: check it against the API's schema. */\nexport function errorPayload<T>(error: unknown): T | undefined {\n return error instanceof HttpError ? (error.payload as T | undefined) : undefined;\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,QAAiB;CAC/B,IAAI;EACF,OAAA,QAAA,IAAA,aAAgC;CAClC,QAAQ;EACN,OAAO;CACT;AACF;;ACaA,IAAa,iBAAiB,IAC5B,oRACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,SAAS;GACT,WAAW;GACX,OAAO;GACP,aAAa;GACb,MAAM;EACR;EACA,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,MAAM;GACN,WAAW;EACb;CACF;CACA,iBAAiB;EAAE,SAAS;EAAW,MAAM;CAAU;AACzD,CACF;;;;;;;AAoBA,SAAgBA,SAAO,EAAE,WAAW,SAAS,MAAM,OAAO,UAAU,UAAU,UAAU,aAAa,UAAU,GAAG,SAAsB;CAGtI,MAAM,MAAM,MAAM,OAA0B,IAAI;CAChD,MAAM,gBAAgB;EACpB,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,IAAI,UAAU,GAAG,aAAa,aAAa,OAAO,QAAQ,CAAC;OACtD,G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