strata-react 1.0.24 → 1.0.26

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 CHANGED
@@ -36,7 +36,7 @@ it against the built files:
36
36
  | Import | Needs | Why |
37
37
  |---|---|---|
38
38
  | `strata-react` | `react`, `react-dom`, `react-router`, `@tanstack/react-query`, `tailwindcss` | The stack is fixed: `DataTable` and `Tabs` keep sort and tab in the URL, `AppShell` links with `NavLink`, every remote read is `useLoad`. The barrel imports both libraries, so an app that uses only a `Button` still installs them (both are needed for anything past a static page) |
39
- | `strata-react/testing` | the above, plus `@testing-library/react` | `renderWithStrata` and `renderRoutes` wrap Testing Library's `render` |
39
+ | `strata-react/testing` | the above, plus `@testing-library/react` | `renderWithStrata` and `renderRoutes` wrap Testing Library's `render`, with a `StrataToastRegion` (so a toast can be found; `toasts: false` if your route tree renders the region, which a root layout route is the best place for) and the toast queue cleared first |
40
40
  | `strata-react/map` | `leaflet` (optional peer, `^1.9.4`) | `RouteMap`: themed routes and a moving position on the tiles an app supplies |
41
41
  | `strata-react/visual`, `strata-visual` | `playwright` (exact version), `msw`, `vite` | The screenshot runner; see [Visual regression for apps](#visual-regression-for-apps) |
42
42
 
package/UPGRADING.md CHANGED
@@ -14,6 +14,8 @@ Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Chang
14
14
  ## After v0.1.17 (2026-11-11 to 2026-11-12)
15
15
 
16
16
  - `MediaPlayer`: the `<audio>`/`<video>` element is now labelled "<label>, audio" (or "video") and the group keeps "<label>"; a test that queried the element by the bare label queries the group or the longer name. With several players on a page, Space, K, J, L and M go to the one last played, focused or pressed (a single player is unchanged); `shortcuts={false}` still opts out.
17
+ - `Switch` and `Checkbox` `detail` is now the control's accessible description, not part of its name: `getByRole("switch", { name: "Show 1 video" })` finds it, and a test that matched the name with a regex to include the detail should query the exact label (and `toHaveAccessibleDescription` for the detail).
18
+ - `renderWithStrata` and `renderRoutes` render a `StrataToastRegion` and clear the toast queue before each render. A test whose route tree already renders the region (a root layout route) passes `toasts: false`, or finds every toast twice.
17
19
  - `LineChart` no longer marks its last point "<value> now" when `current` is set (the rule, dot and label at the end of the line are gone; `current` already says where now is). A chart that has `current` and wants the end marked passes `end="now"`; a chart without `current` that does not want it passes `end="none"`. Baselines of charts with `current` change.
18
20
  - `SeekBar` with a `duration` of 0, `NaN` or `Infinity` (or `null`, now allowed) is drawn disabled; before it was enabled with the thumb at 0. Nothing to change unless a test seeks a bar with no duration.
19
21
  - Arrows and macOS modifiers in `KeysLegend`, `CommandLegend`, menu shortcuts and tooltip hints are drawn as icons, each followed by a screen-reader name (`←` reads "left arrow", `⌘` "Command"), so the text no longer contains the symbol: a test that queries `"j or ↓"` queries `"j or down arrow"`, and `"⌘Z"` is `"Command Z"`. Their baselines change a little.
@@ -1,3 +1,4 @@
1
+ import * as React from "react";
1
2
  /** Props for `Switch`. */
2
3
  export type SwitchProps = {
3
4
  /** What it turns on, as the visible label: "Show elevation profile". Required. */
@@ -11,4 +12,4 @@ export type SwitchProps = {
11
12
  className?: string;
12
13
  };
13
14
  /** An on/off setting that applies at once, its label and control one target. */
14
- export declare function Switch({ label, detail, on, defaultOn, onChange, disabled, className }: SwitchProps): import('react').JSX.Element;
15
+ export declare function Switch({ label, detail, on, defaultOn, onChange, disabled, className }: SwitchProps): React.JSX.Element;
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { _ as cn, a as useColorScheme, c as ChoiceGroup, d as NativeSelect, f as Textarea, g as KeyText, h as Tooltip, i as colorSchemeScript, l as Field, m as controlHeight, n as ColorSchemeChoice, o as useSystemColorScheme, p as useFieldControl, r as ThemeProvider, s as Density, t as COLOR_SCHEME_STORAGE_KEY, u as Input, v as typeSteps } from "./theme-BgTOESmN.js";
2
2
  import { a as format, i as createFormat, n as MISSING, o as toDate, r as NBSP, t as geo } from "./geo-C0jcFp4q.js";
3
- import { a as toLoad, c as describeActionError, d as readErrorBody, i as staleOf, l as describeHttpError, n as createQueryClient, o as useLoad, r as fetchJson, s as HttpError, t as StrataQueryProvider, u as fieldErrorsOf } from "./query-CP78goXj.js";
3
+ import { _ as IconButton, a as toLoad, c as toast, d as describeActionError, f as describeHttpError, g as Button, h as overlaySurface, i as staleOf, l as toastTimeout, m as readErrorBody, n as createQueryClient, o as useLoad, p as fieldErrorsOf, r as fetchJson, s as StrataToastRegion, t as StrataQueryProvider, u as HttpError, v as RowAction, y as buttonVariants } from "./query-DgJMyXTT.js";
4
4
  import * as React from "react";
5
- import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, I18nProvider, Input as Input$1, Keyboard, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, NumberField as NumberField$1, Popover as Popover$1, Row, SearchField, Separator, Slider as Slider$1, SliderOutput, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Toolbar as Toolbar$1, UNSTABLE_Toast, UNSTABLE_ToastContent, UNSTABLE_ToastQueue, UNSTABLE_ToastRegion, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
6
- import { cva } from "class-variance-authority";
5
+ import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, I18nProvider, Input as Input$1, Keyboard, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, NumberField as NumberField$1, Popover as Popover$1, Row, SearchField, Separator, Slider as Slider$1, SliderOutput, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Toolbar as Toolbar$1, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
7
6
  import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronRight, CircleAlert, CircleCheck, FileQuestion, Flag, GripVertical, History, ImageOff, Info, Loader, LoaderCircle, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Play, Redo2, RotateCcw, Scan, Search, SkipBack, SkipForward, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
8
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
8
  import { Link, NavLink, useSearchParams } from "react-router";
@@ -51,78 +50,6 @@ function useInView({ active = true, rootMargin = "0px", once = false, unsupporte
51
50
  inView
52
51
  };
53
52
  }
54
- // src/components/button.tsx
55
- var buttonVariants = cva("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-4 [&_svg]:shrink-0", {
56
- variants: {
57
- variant: {
58
- default: "bg-primary text-primary-foreground hover:bg-primary-10",
59
- outline: "border border-input bg-background text-foreground hover:bg-muted",
60
- secondary: "bg-muted text-foreground hover:bg-neutral-4",
61
- ghost: "text-foreground hover:bg-muted",
62
- destructive: "bg-destructive text-destructive-foreground hover:bg-danger",
63
- link: "h-auto px-0 text-primary-11 underline underline-offset-4 hover:text-primary-12"
64
- },
65
- size: {
66
- default: "h-(--control-h) px-4",
67
- sm: "h-(--control-h-sm) px-3",
68
- icon: "size-(--control-h)",
69
- "icon-sm": "size-(--control-h-sm)"
70
- }
71
- },
72
- defaultVariants: {
73
- variant: "outline",
74
- size: "default"
75
- }
76
- });
77
- /**
78
- * A button with shadcn's variant names, built on React Aria's `Button` (press handling that behaves
79
- * the same for mouse, touch, pen and keyboard, focus-visible and hover state). The default variant is
80
- * `outline`; ask for the filled accent (`variant="default"`) once per view. `type` defaults to `button`.
81
- * `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.
82
- */
83
- function Button({ className, variant, size, type = "button", disabled, children, ...props }) {
84
- return /* @__PURE__ */ jsx(Button$1, {
85
- type,
86
- isDisabled: disabled,
87
- "data-variant": variant ?? "outline",
88
- className: cn(buttonVariants({
89
- variant,
90
- size
91
- }), className),
92
- ...props,
93
- children: typeof children === "string" ? /* @__PURE__ */ jsx("span", {
94
- className: "min-w-0 truncate",
95
- children
96
- }) : children
97
- });
98
- }
99
- /** 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. */
100
- function IconButton({ icon: Icon, label, hint, variant = "ghost", size = "default", ...props }) {
101
- return /* @__PURE__ */ jsx(Tooltip, {
102
- label,
103
- hint,
104
- children: /* @__PURE__ */ jsx(Button, {
105
- size: size === "sm" ? "icon-sm" : "icon",
106
- variant,
107
- "aria-label": label,
108
- ...props,
109
- children: /* @__PURE__ */ jsx(Icon, { "aria-hidden": true })
110
- })
111
- });
112
- }
113
- /** A small ghost action for one table row: shows `label`, and is named "`label` `subject`" so every row's action has its own name. */
114
- function RowAction({ label, subject, icon: Icon, variant = "ghost", size = "sm", className, ...props }) {
115
- return /* @__PURE__ */ jsxs(Button, {
116
- variant,
117
- size,
118
- "aria-label": `${label} ${subject}`,
119
- className: cn("-my-1.5", className),
120
- ...props,
121
- children: [Icon && /* @__PURE__ */ jsx(Icon, { "aria-hidden": true }), label]
122
- });
123
- }
124
- // src/lib/overlay.ts
125
- var overlaySurface = "rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay";
126
53
  // src/lib/chords.ts
127
54
  /** The platform this page runs on, read from the browser (`mac` for macOS and iOS). Server and test default: `other`. */
128
55
  function detectPlatform() {
@@ -718,11 +645,14 @@ function ToggleGroup({ label, options, value, onChange, size = "default", classN
718
645
  // src/components/switch.tsx
719
646
  /** An on/off setting that applies at once, its label and control one target. */
720
647
  function Switch({ label, detail, on, defaultOn, onChange, disabled, className }) {
648
+ const id = React.useId();
721
649
  return /* @__PURE__ */ jsxs(Switch$1, {
722
650
  isSelected: on,
723
651
  defaultSelected: defaultOn,
724
652
  onChange,
725
653
  isDisabled: disabled,
654
+ "aria-labelledby": `${id}-label`,
655
+ "aria-describedby": detail ? `${id}-detail` : void 0,
726
656
  className: cn("group inline-flex min-h-6 cursor-pointer items-start gap-3 disabled:cursor-not-allowed disabled:opacity-50", className),
727
657
  children: [/* @__PURE__ */ jsx("span", {
728
658
  "aria-hidden": true,
@@ -734,9 +664,11 @@ function Switch({ label, detail, on, defaultOn, onChange, disabled, className })
734
664
  }), /* @__PURE__ */ jsxs("span", {
735
665
  className: "grid",
736
666
  children: [/* @__PURE__ */ jsx("span", {
667
+ id: `${id}-label`,
737
668
  className: "type-body",
738
669
  children: label
739
670
  }), detail && /* @__PURE__ */ jsx("span", {
671
+ id: `${id}-detail`,
740
672
  className: "type-body-sm text-muted-foreground",
741
673
  children: detail
742
674
  })]
@@ -943,6 +875,7 @@ function Popover({ label, trigger, children, side = "bottom", align = "start", o
943
875
  /** A checkbox and its label as one target. `label` is required; `hideLabel` keeps it as the accessible name only. */
944
876
  function Checkbox({ label, hideLabel = false, detail, checked, onCheckedChange, className, disabled, required, ...props }) {
945
877
  const shift = useShiftNote();
878
+ const id = React.useId();
946
879
  return /* @__PURE__ */ jsx("span", {
947
880
  className: "contents",
948
881
  onMouseDownCapture: shift.handlers.onMouseDown,
@@ -954,6 +887,8 @@ function Checkbox({ label, hideLabel = false, detail, checked, onCheckedChange,
954
887
  isRequired: required,
955
888
  onChange: (selected) => onCheckedChange(selected, shift.take()),
956
889
  "aria-label": hideLabel ? label : void 0,
890
+ "aria-labelledby": hideLabel ? void 0 : `${id}-label`,
891
+ "aria-describedby": !hideLabel && detail ? `${id}-detail` : void 0,
957
892
  ...props,
958
893
  className: cn("group inline-flex min-h-6 min-w-6 items-start gap-3", hideLabel && "items-center justify-center", disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer", className),
959
894
  children: ({ isSelected, isIndeterminate }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CheckboxBox, {
@@ -963,9 +898,11 @@ function Checkbox({ label, hideLabel = false, detail, checked, onCheckedChange,
963
898
  }), !hideLabel && /* @__PURE__ */ jsxs("span", {
964
899
  className: "grid",
965
900
  children: [/* @__PURE__ */ jsx("span", {
901
+ id: `${id}-label`,
966
902
  className: "type-body",
967
903
  children: label
968
904
  }), detail && /* @__PURE__ */ jsx("span", {
905
+ id: `${id}-detail`,
969
906
  className: "type-body-sm text-muted-foreground",
970
907
  children: detail
971
908
  })]
@@ -1920,91 +1857,6 @@ function Alert({ tone, title, children, action, announce = false, className }) {
1920
1857
  ]
1921
1858
  });
1922
1859
  }
1923
- // src/components/toast.tsx
1924
- var queue = new UNSTABLE_ToastQueue({ maxVisibleToasts: 3 });
1925
- /** Milliseconds a toast stays: 5 s plus 40 ms a character, to at most 15 s, and at least 8 s with an action. */
1926
- function toastTimeout(content) {
1927
- if (content.timeout !== void 0) return content.timeout;
1928
- const chars = content.title.length + (content.description?.length ?? 0) + (content.action?.label.length ?? 0);
1929
- return Math.max(content.action ? 8e3 : 0, Math.min(15e3, 5e3 + 40 * chars));
1930
- }
1931
- /** The toast queue: `toast.show({ title })` from anywhere; `toast.close(key)`; `toast.clear()`. */
1932
- var toast = {
1933
- /** Shows a toast and returns its key. */
1934
- show(content) {
1935
- return queue.add(content, { timeout: toastTimeout(content) });
1936
- },
1937
- close(key) {
1938
- queue.close(key);
1939
- },
1940
- clear() {
1941
- queue.clear();
1942
- }
1943
- };
1944
- var marks = {
1945
- info: {
1946
- icon: Info,
1947
- color: "text-info"
1948
- },
1949
- success: {
1950
- icon: CircleCheck,
1951
- color: "text-success"
1952
- },
1953
- warning: {
1954
- icon: TriangleAlert,
1955
- color: "text-warning"
1956
- }
1957
- };
1958
- /** The one place toasts appear. Render it once at the app root. A labelled landmark (F6), polite, above panes and the undo bar. */
1959
- function StrataToastRegion({ label = "Notifications", className }) {
1960
- return /* @__PURE__ */ jsx(UNSTABLE_ToastRegion, {
1961
- queue,
1962
- "aria-label": label,
1963
- className: cn("layer-bar fixed inset-x-4 top-4 grid justify-items-end gap-2 outline-none sm:inset-x-auto sm:top-auto sm:right-4 sm:bottom-4", className),
1964
- children: ({ toast: t }) => /* @__PURE__ */ jsxs(UNSTABLE_Toast, {
1965
- toast: t,
1966
- className: cn("flex w-full max-w-sm items-start gap-3 p-3 outline-none focus-visible:outline-2 focus-visible:outline-ring", overlaySurface),
1967
- children: [
1968
- (() => {
1969
- const { icon: Icon, color } = marks[t.content.tone ?? "info"];
1970
- return /* @__PURE__ */ jsx(Icon, {
1971
- "aria-hidden": true,
1972
- className: cn("mt-0.5 size-4 shrink-0", color)
1973
- });
1974
- })(),
1975
- /* @__PURE__ */ jsxs(UNSTABLE_ToastContent, {
1976
- className: "grid min-w-0 flex-1 gap-0.5",
1977
- children: [/* @__PURE__ */ jsx(Text, {
1978
- slot: "title",
1979
- className: "type-label",
1980
- children: t.content.title
1981
- }), t.content.description && /* @__PURE__ */ jsx(Text, {
1982
- slot: "description",
1983
- className: "type-body-sm text-muted-foreground",
1984
- children: t.content.description
1985
- })]
1986
- }),
1987
- t.content.action && /* @__PURE__ */ jsx(Button, {
1988
- size: "sm",
1989
- onPress: () => {
1990
- t.content.action?.onPress();
1991
- queue.close(t.key);
1992
- },
1993
- children: t.content.action.label
1994
- }),
1995
- /* @__PURE__ */ jsx(Button$1, {
1996
- slot: "close",
1997
- "aria-label": "Dismiss",
1998
- className: "grid size-6 shrink-0 cursor-pointer place-items-center rounded-control text-muted-foreground transition-state hover:bg-muted hover:text-foreground",
1999
- children: /* @__PURE__ */ jsx(X, {
2000
- "aria-hidden": true,
2001
- className: "size-4"
2002
- })
2003
- })
2004
- ]
2005
- })
2006
- });
2007
- }
2008
1860
  // src/lib/client-work.ts
2009
1861
  /** Runs browser-side work with progress, cancel and a clear end state, ready for `JobStatus`. */
2010
1862
  function useClientWork(run) {