strata-react 1.3.25 → 1.3.27

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.
Files changed (256) hide show
  1. package/README.md +1 -0
  2. package/UPGRADING.md +4 -0
  3. package/dist/{api-types/cli.d.ts → api-types-cli.d.ts} +1 -0
  4. package/dist/api-types-cli.js +4 -3
  5. package/dist/api-types-cli.js.map +1 -1
  6. package/dist/{api-types/generate.d.ts → api-types.d.ts} +3 -3
  7. package/dist/api-types.js +3 -1
  8. package/dist/{button-KGJI6jQr.js → button-CYXjU-fs.js} +8 -5
  9. package/dist/button-CYXjU-fs.js.map +1 -0
  10. package/dist/{cursor-DDGBPiTJ.js → cursor-Cwyvgwsw.js} +9 -7
  11. package/dist/cursor-Cwyvgwsw.js.map +1 -0
  12. package/dist/{errors-BUvY1Z4d.js → errors-CmuwcWlb.js} +6 -6
  13. package/dist/{errors-BUvY1Z4d.js.map → errors-CmuwcWlb.js.map} +1 -1
  14. package/dist/{field-BjeE_FeB.js → field-DBCsFIng.js} +27 -23
  15. package/dist/field-DBCsFIng.js.map +1 -0
  16. package/dist/{follow-BTPs49FP.js → follow-CXQsL86O.js} +2 -2
  17. package/dist/follow-CXQsL86O.js.map +1 -0
  18. package/dist/{generate-CjTHKJ39.js → generate-BkWhh4k4.js} +8 -6
  19. package/dist/generate-BkWhh4k4.js.map +1 -0
  20. package/dist/{lib/geo.d.ts → geo-DfKa9JtK.d.ts} +35 -33
  21. package/dist/{hls/index.d.ts → hls.d.ts} +13 -12
  22. package/dist/hls.js +5 -4
  23. package/dist/hls.js.map +1 -1
  24. package/dist/index.d.ts +5401 -142
  25. package/dist/index.js +1072 -227
  26. package/dist/index.js.map +1 -1
  27. package/dist/map.d.ts +184 -0
  28. package/dist/map.js +21 -17
  29. package/dist/map.js.map +1 -1
  30. package/dist/media-player-BETa3P7K.d.ts +758 -0
  31. package/dist/{microphone-Bo3WaXgD.js → microphone-76skMt6i.js} +41 -30
  32. package/dist/microphone-76skMt6i.js.map +1 -0
  33. package/dist/microphone-DDOnQHxf.d.ts +237 -0
  34. package/dist/{migrate/cli.d.ts → migrate-cli.d.ts} +1 -0
  35. package/dist/migrate-cli.js +8 -6
  36. package/dist/migrate-cli.js.map +1 -1
  37. package/dist/panorama.d.ts +102 -0
  38. package/dist/panorama.js +18 -15
  39. package/dist/panorama.js.map +1 -1
  40. package/dist/{run-BT2WKzMz.js → run-D_Ic1jE7.js} +23 -16
  41. package/dist/run-D_Ic1jE7.js.map +1 -0
  42. package/dist/scene.d.ts +147 -0
  43. package/dist/scene.js +15 -13
  44. package/dist/scene.js.map +1 -1
  45. package/dist/testing.d.ts +468 -0
  46. package/dist/testing.js +11 -3
  47. package/dist/testing.js.map +1 -1
  48. package/dist/{theme-CxYZkUNk.js → theme-1oOSMj_D.js} +19 -17
  49. package/dist/theme-1oOSMj_D.js.map +1 -0
  50. package/dist/{tooltip-DhqrDtyu.js → tooltip-BosfsWYh.js} +9 -6
  51. package/dist/tooltip-BosfsWYh.js.map +1 -0
  52. package/dist/types-B3TsF0Ey.d.ts +241 -0
  53. package/dist/{value-controls-Dm_EYfZW.js → value-controls-5u7sD_wG.js} +22 -17
  54. package/dist/value-controls-5u7sD_wG.js.map +1 -0
  55. package/dist/{viewer-input-CHU0Hx4A.js → viewer-input-3Qa-o35k.js} +3 -2
  56. package/dist/{viewer-input-CHU0Hx4A.js.map → viewer-input-3Qa-o35k.js.map} +1 -1
  57. package/dist/{visual/cli.d.ts → visual-cli.d.ts} +2 -1
  58. package/dist/visual-cli.js +5 -4
  59. package/dist/visual-cli.js.map +1 -1
  60. package/dist/visual.d.ts +105 -0
  61. package/dist/visual.js +4 -3
  62. package/dist/visual.js.map +1 -1
  63. package/package.json +24 -19
  64. package/dist/api-types/index.d.ts +0 -1
  65. package/dist/button-KGJI6jQr.js.map +0 -1
  66. package/dist/components/active-list.d.ts +0 -46
  67. package/dist/components/alert.d.ts +0 -17
  68. package/dist/components/app-shell.d.ts +0 -32
  69. package/dist/components/async-button.d.ts +0 -48
  70. package/dist/components/auto-recorder.d.ts +0 -67
  71. package/dist/components/book-viewer.d.ts +0 -50
  72. package/dist/components/box-overlay.d.ts +0 -44
  73. package/dist/components/boxed-picture.d.ts +0 -34
  74. package/dist/components/button.d.ts +0 -45
  75. package/dist/components/byte-view.d.ts +0 -32
  76. package/dist/components/checkbox.d.ts +0 -39
  77. package/dist/components/choice-grid.d.ts +0 -42
  78. package/dist/components/commands.d.ts +0 -104
  79. package/dist/components/compare-audio.d.ts +0 -30
  80. package/dist/components/compare-grid.d.ts +0 -24
  81. package/dist/components/compare-parts.d.ts +0 -90
  82. package/dist/components/compare-regions.d.ts +0 -37
  83. package/dist/components/compare-text.d.ts +0 -32
  84. package/dist/components/compare-video-grid.d.ts +0 -52
  85. package/dist/components/compare-video.d.ts +0 -61
  86. package/dist/components/compare.d.ts +0 -90
  87. package/dist/components/composition.d.ts +0 -44
  88. package/dist/components/console.d.ts +0 -34
  89. package/dist/components/conversation.d.ts +0 -83
  90. package/dist/components/cursor.d.ts +0 -44
  91. package/dist/components/data-table.d.ts +0 -89
  92. package/dist/components/data-view.d.ts +0 -66
  93. package/dist/components/density.d.ts +0 -16
  94. package/dist/components/dialog.d.ts +0 -45
  95. package/dist/components/difference.d.ts +0 -19
  96. package/dist/components/disclosure.d.ts +0 -49
  97. package/dist/components/done.d.ts +0 -14
  98. package/dist/components/drag-source.d.ts +0 -29
  99. package/dist/components/field.d.ts +0 -79
  100. package/dist/components/file-intake.d.ts +0 -60
  101. package/dist/components/film-strip.d.ts +0 -35
  102. package/dist/components/folder-picker.d.ts +0 -59
  103. package/dist/components/fullscreen-frame.d.ts +0 -18
  104. package/dist/components/history.d.ts +0 -61
  105. package/dist/components/hotkeys.d.ts +0 -44
  106. package/dist/components/infinite-list.d.ts +0 -77
  107. package/dist/components/inspector.d.ts +0 -66
  108. package/dist/components/job-action.d.ts +0 -30
  109. package/dist/components/job-status.d.ts +0 -55
  110. package/dist/components/jobs-table.d.ts +0 -35
  111. package/dist/components/key-glyphs.d.ts +0 -5
  112. package/dist/components/key-owner.d.ts +0 -11
  113. package/dist/components/lightbox.d.ts +0 -61
  114. package/dist/components/line-chart.d.ts +0 -169
  115. package/dist/components/link-card.d.ts +0 -32
  116. package/dist/components/link.d.ts +0 -54
  117. package/dist/components/markable-text.d.ts +0 -60
  118. package/dist/components/media-contents.d.ts +0 -28
  119. package/dist/components/media-group.d.ts +0 -32
  120. package/dist/components/media-player.d.ts +0 -251
  121. package/dist/components/media-progress.d.ts +0 -17
  122. package/dist/components/media-skip.d.ts +0 -31
  123. package/dist/components/media-spans.d.ts +0 -93
  124. package/dist/components/media.d.ts +0 -133
  125. package/dist/components/meter.d.ts +0 -32
  126. package/dist/components/metric.d.ts +0 -17
  127. package/dist/components/outbox-status.d.ts +0 -10
  128. package/dist/components/page-header.d.ts +0 -14
  129. package/dist/components/pair-vote.d.ts +0 -70
  130. package/dist/components/pause-button.d.ts +0 -7
  131. package/dist/components/pixel-image.d.ts +0 -29
  132. package/dist/components/place-board.d.ts +0 -39
  133. package/dist/components/player-warning.d.ts +0 -24
  134. package/dist/components/popover.d.ts +0 -20
  135. package/dist/components/recorder.d.ts +0 -73
  136. package/dist/components/region-editor.d.ts +0 -67
  137. package/dist/components/save.d.ts +0 -46
  138. package/dist/components/say-again.d.ts +0 -13
  139. package/dist/components/schedule-table.d.ts +0 -24
  140. package/dist/components/secret-field.d.ts +0 -34
  141. package/dist/components/selectable-grid.d.ts +0 -57
  142. package/dist/components/selection.d.ts +0 -104
  143. package/dist/components/sequence-timeline.d.ts +0 -50
  144. package/dist/components/shortcut-editor.d.ts +0 -44
  145. package/dist/components/sortable-list.d.ts +0 -39
  146. package/dist/components/status.d.ts +0 -9
  147. package/dist/components/switch.d.ts +0 -15
  148. package/dist/components/system-panel.d.ts +0 -58
  149. package/dist/components/tabs.d.ts +0 -16
  150. package/dist/components/theme.d.ts +0 -106
  151. package/dist/components/thumbnail.d.ts +0 -50
  152. package/dist/components/tile-grid.d.ts +0 -67
  153. package/dist/components/timeline-player.d.ts +0 -18
  154. package/dist/components/timeline.d.ts +0 -115
  155. package/dist/components/toast.d.ts +0 -36
  156. package/dist/components/toggle.d.ts +0 -51
  157. package/dist/components/toolbar.d.ts +0 -15
  158. package/dist/components/tooltip.d.ts +0 -19
  159. package/dist/components/transcript-view.d.ts +0 -63
  160. package/dist/components/tree.d.ts +0 -74
  161. package/dist/components/undo.d.ts +0 -63
  162. package/dist/components/use-timeline.d.ts +0 -44
  163. package/dist/components/value-controls.d.ts +0 -91
  164. package/dist/components/video-clock.d.ts +0 -68
  165. package/dist/components/view-options.d.ts +0 -105
  166. package/dist/components/viewport.d.ts +0 -85
  167. package/dist/components/virtual-list.d.ts +0 -19
  168. package/dist/components/waveform.d.ts +0 -71
  169. package/dist/components/workflow-steps.d.ts +0 -71
  170. package/dist/components/workspace.d.ts +0 -83
  171. package/dist/cursor-DDGBPiTJ.js.map +0 -1
  172. package/dist/field-BjeE_FeB.js.map +0 -1
  173. package/dist/follow-BTPs49FP.js.map +0 -1
  174. package/dist/generate-CjTHKJ39.js.map +0 -1
  175. package/dist/lib/base.d.ts +0 -10
  176. package/dist/lib/book.d.ts +0 -25
  177. package/dist/lib/boxes.d.ts +0 -55
  178. package/dist/lib/breakpoint.d.ts +0 -4
  179. package/dist/lib/choice.d.ts +0 -29
  180. package/dist/lib/chords.d.ts +0 -20
  181. package/dist/lib/client-work.d.ts +0 -24
  182. package/dist/lib/control.d.ts +0 -4
  183. package/dist/lib/dev.d.ts +0 -2
  184. package/dist/lib/errors.d.ts +0 -43
  185. package/dist/lib/file-intake.d.ts +0 -60
  186. package/dist/lib/follow.d.ts +0 -18
  187. package/dist/lib/format.d.ts +0 -243
  188. package/dist/lib/grouped-grid-layout.d.ts +0 -44
  189. package/dist/lib/icon.d.ts +0 -6
  190. package/dist/lib/image-diff.d.ts +0 -30
  191. package/dist/lib/in-view.d.ts +0 -21
  192. package/dist/lib/loudness.d.ts +0 -18
  193. package/dist/lib/marks.d.ts +0 -6
  194. package/dist/lib/microphone.d.ts +0 -24
  195. package/dist/lib/number-input.d.ts +0 -4
  196. package/dist/lib/object-url.d.ts +0 -2
  197. package/dist/lib/overlay.d.ts +0 -1
  198. package/dist/lib/recording.d.ts +0 -16
  199. package/dist/lib/region.d.ts +0 -64
  200. package/dist/lib/rich-text.d.ts +0 -44
  201. package/dist/lib/search-param.d.ts +0 -16
  202. package/dist/lib/segmenter.d.ts +0 -40
  203. package/dist/lib/sequence.d.ts +0 -34
  204. package/dist/lib/speech.d.ts +0 -53
  205. package/dist/lib/text-diff.d.ts +0 -16
  206. package/dist/lib/timeline.d.ts +0 -14
  207. package/dist/lib/transcript.d.ts +0 -53
  208. package/dist/lib/utils.d.ts +0 -4
  209. package/dist/lib/viewer-input.d.ts +0 -29
  210. package/dist/lib/viewport.d.ts +0 -55
  211. package/dist/lib/waveform.d.ts +0 -46
  212. package/dist/map/fan.d.ts +0 -15
  213. package/dist/map/index.d.ts +0 -3
  214. package/dist/map/map-styles.d.ts +0 -2
  215. package/dist/map/markers.d.ts +0 -60
  216. package/dist/map/route-map.d.ts +0 -146
  217. package/dist/microphone-Bo3WaXgD.js.map +0 -1
  218. package/dist/migrate/stock-classes.d.ts +0 -11
  219. package/dist/panorama/gl.d.ts +0 -16
  220. package/dist/panorama/index.d.ts +0 -2
  221. package/dist/panorama/panorama-viewer.d.ts +0 -56
  222. package/dist/panorama/projection.d.ts +0 -45
  223. package/dist/query/api.d.ts +0 -23
  224. package/dist/query/clips.d.ts +0 -48
  225. package/dist/query/index.d.ts +0 -55
  226. package/dist/query/infinite.d.ts +0 -60
  227. package/dist/query/job.d.ts +0 -26
  228. package/dist/query/outbox.d.ts +0 -85
  229. package/dist/query/poll.d.ts +0 -24
  230. package/dist/query/reserve.d.ts +0 -33
  231. package/dist/query/typed-api.d.ts +0 -84
  232. package/dist/query/workflow.d.ts +0 -17
  233. package/dist/run-BT2WKzMz.js.map +0 -1
  234. package/dist/scene/camera.d.ts +0 -99
  235. package/dist/scene/index.d.ts +0 -2
  236. package/dist/scene/scene-viewport.d.ts +0 -48
  237. package/dist/testing/buttons.d.ts +0 -7
  238. package/dist/testing/index.d.ts +0 -161
  239. package/dist/testing/intersection-observer.d.ts +0 -34
  240. package/dist/testing/layout.d.ts +0 -13
  241. package/dist/testing/microphone.d.ts +0 -35
  242. package/dist/testing/setup.d.ts +0 -14
  243. package/dist/testing/speech.d.ts +0 -38
  244. package/dist/testing/storage.d.ts +0 -7
  245. package/dist/theme-CxYZkUNk.js.map +0 -1
  246. package/dist/tooltip-DhqrDtyu.js.map +0 -1
  247. package/dist/value-controls-Dm_EYfZW.js.map +0 -1
  248. package/dist/visual/capture.d.ts +0 -37
  249. package/dist/visual/compare.d.ts +0 -46
  250. package/dist/visual/drop.d.ts +0 -19
  251. package/dist/visual/fonts.d.ts +0 -18
  252. package/dist/visual/index.d.ts +0 -19
  253. package/dist/visual/run.d.ts +0 -22
  254. package/dist/visual/serve.d.ts +0 -13
  255. package/dist/visual/targets.d.ts +0 -17
  256. package/dist/visual/types.d.ts +0 -188
@@ -0,0 +1,241 @@
1
+ import { Page } from "playwright";
2
+ import { RequestHandler } from "msw";
3
+ /** A system face to pin, from `VisualConfig.systemFonts`. */
4
+ interface PinnedSystemFont {
5
+ /** The family name inside the font files, e.g. `"DejaVu Sans"`. Every system family the page uses resolves to it. */
6
+ pin: string;
7
+ /** Font files (`.ttf`, `.otf`) holding that family, relative to the config file: the regular face and any bold or italic the page uses. */
8
+ files: readonly string[];
9
+ }
10
+ /** Per-pixel colour distance pixelmatch treats as equal (0–1), measured after the blur. */
11
+ declare const THRESHOLD = 0.1;
12
+ /** Radius in pixels of the box blur applied to both images before comparing (1 is 3×3; 0 turns it off). */
13
+ declare const BLUR = 1;
14
+ /** Differing pixels (after the blur) tolerated before a screenshot counts as changed. */
15
+ declare const MAX_DIFF_PIXELS = 4;
16
+ /** How two screenshots are compared. Every field has the default above. */
17
+ interface CompareOptions {
18
+ /** Per-pixel colour distance treated as equal, 0–1 (pixelmatch's `threshold`). Default {@link THRESHOLD}. */
19
+ threshold?: number;
20
+ /** Box blur radius in whole pixels applied to both images first, absorbing anti-aliasing differences (0 turns it off). Default {@link BLUR}. */
21
+ blur?: number;
22
+ /** Differing pixels tolerated. Default {@link MAX_DIFF_PIXELS}. */
23
+ maxDiffPixels?: number;
24
+ /** Count pixels pixelmatch judges to be anti-aliasing as differences too. Default false. */
25
+ includeAA?: boolean;
26
+ }
27
+ /** A decoded RGBA image. */
28
+ interface Image {
29
+ width: number;
30
+ height: number;
31
+ data: Uint8Array;
32
+ }
33
+ /** The result of comparing a screenshot with its baseline. */
34
+ interface CompareResult {
35
+ /** Within tolerance: the screenshot matches. */
36
+ same: boolean;
37
+ /** Every pixel is identical, before any blur or threshold. */
38
+ identical: boolean;
39
+ /** Pixels that differ beyond the threshold after the blur (Infinity when the size changed). */
40
+ diffPixels: number;
41
+ /** The same count without the blur: how much anti-aliasing the blur absorbed. */
42
+ unblurredDiffPixels: number;
43
+ /** One line for a report: what changed. */
44
+ reason: string;
45
+ /** A PNG highlighting the differing pixels in red over the faded baseline, when the images differ in content. */
46
+ diff?: Buffer;
47
+ }
48
+ /** Decodes a PNG file's bytes. */
49
+ declare function decode(buffer: Buffer | Uint8Array): Image;
50
+ /** Encodes an RGBA image as PNG bytes. */
51
+ declare function encode({ width, height, data }: Image): Buffer;
52
+ /** Box-blurs an RGBA image with the given radius (separable, edges averaged over what exists). */
53
+ declare function boxBlur({ width: w, height: h, data }: Image, radius: number): Uint8Array;
54
+ /** Compares two decoded PNGs with pixelmatch after a small blur. A size change is always a change. */
55
+ declare function compare(expected: Image, actual: Image, options?: CompareOptions): CompareResult;
56
+ /** The two colour schemes every shot is taken in. */
57
+ type Theme = "light" | "dark";
58
+ /** A viewport in CSS pixels. Screenshots are taken at a device scale factor of 1. */
59
+ interface Viewport {
60
+ width: number;
61
+ height: number;
62
+ }
63
+ /** A named viewport (see {@link viewports}) or an explicit size. */
64
+ type ViewportChoice = keyof typeof viewports | Viewport;
65
+ /**
66
+ * Named viewports. `wide` and `phone` are what the Storybook tags `visual-wide` and
67
+ * `visual-phone` select; `default` is a laptop-sized screen for routes. (Untagged stories render
68
+ * 1024 wide and 200 tall and grow with the component, see {@link storybookShots}.)
69
+ */
70
+ declare const viewports: {
71
+ readonly default: {
72
+ readonly width: 1024;
73
+ readonly height: 768;
74
+ };
75
+ readonly wide: {
76
+ readonly width: 1440;
77
+ readonly height: 900;
78
+ };
79
+ readonly phone: {
80
+ readonly width: 390;
81
+ readonly height: 844;
82
+ };
83
+ };
84
+ /**
85
+ * What a screenshot covers. `paint` is the union of what the root element paints (text,
86
+ * controls, SVGs, and boxes with a background, border or shadow) plus 8px, so a component's
87
+ * baseline shows the component and not the empty canvas. `page` is the whole page, for screens.
88
+ */
89
+ type Clip = "paint" | "page";
90
+ /** A step run after a shot has rendered and before it is captured: open a menu, focus a field. */
91
+ type Setup = (page: Page, shot: Shot) => Promise<void> | void;
92
+ /** One screenshot: everything the runner needs to take it and to name its baseline. */
93
+ interface Shot {
94
+ /** The baseline's file name without `.png`, e.g. `review--empty--wide--dark`. */
95
+ name: string;
96
+ /** Path and query under the served base (`/review?tab=queue`), or an absolute URL. */
97
+ path: string;
98
+ theme: Theme;
99
+ viewport: Viewport;
100
+ /** Selector of the element the app renders into; the shot waits until it has children. */
101
+ root: string;
102
+ clip: Clip;
103
+ /** A Playwright selector that must be visible before the shot is taken (see {@link RouteState.waitFor}). */
104
+ waitFor?: string;
105
+ /** MSW handlers answering the page's requests, first match wins. Route shots only. */
106
+ handlers?: readonly RequestHandler[];
107
+ /** Class put on `<html>` in the dark theme (Strata's `dark:` variant reads `.dark`). */
108
+ darkClass?: string | false;
109
+ setup?: Setup;
110
+ }
111
+ /** An app's built Storybook. */
112
+ interface StorybookTarget {
113
+ /** The `storybook build` output folder. Default `storybook-static`. */
114
+ dir?: string;
115
+ /** The Storybook global the preview reads the theme from. Default `theme`, as Strata's preview. */
116
+ themeGlobal?: string;
117
+ }
118
+ /** One state of a route: the MSW handlers that put the server into it, and optional steps. */
119
+ interface RouteState {
120
+ /** Handlers tried before the target's base handlers (like `server.use(...)` in a test). */
121
+ handlers?: readonly RequestHandler[];
122
+ /** A different path for this state, e.g. the same screen with `?tab=sync`. */
123
+ path?: string;
124
+ /**
125
+ * A Playwright selector that must be visible before the shot is taken, such as `role=alert` or
126
+ * `text=Try again`. Needed when a state takes longer than the network to show: an error after
127
+ * the query client's retry, a toast after a timer.
128
+ */
129
+ waitFor?: string;
130
+ setup?: Setup;
131
+ }
132
+ /** A screen of the app, screenshotted in each of its states. */
133
+ interface Route {
134
+ /** Names the baselines: lower-case letters, digits and dashes. */
135
+ name: string;
136
+ /** Path and query under the app's base, e.g. `/review` or `/library?sort=-added`. */
137
+ path: string;
138
+ /**
139
+ * The server states to capture, by name. A list of handlers is shorthand for `{ handlers }`.
140
+ * Default: one state, `default`, served by the base handlers alone.
141
+ */
142
+ states?: Record<string, readonly RequestHandler[] | RouteState>;
143
+ viewports?: readonly ViewportChoice[];
144
+ clip?: Clip;
145
+ root?: string;
146
+ waitFor?: string;
147
+ setup?: Setup;
148
+ }
149
+ /** An app served from its production build (or a running server), screenshotted route by route. */
150
+ interface AppTarget {
151
+ /** The build folder to serve, e.g. `dist`. Unknown paths that ask for HTML get `index.html`. */
152
+ dir?: string;
153
+ /** Or a server that is already running, e.g. `http://localhost:4173`. */
154
+ url?: string;
155
+ /** The app's base path (Vite's `base`). Default `/`. */
156
+ base?: string;
157
+ /** MSW handlers for every route: the healthy server, usually the app's `handlers.ts`. */
158
+ handlers?: readonly RequestHandler[];
159
+ /** Default `#root`. */
160
+ root?: string;
161
+ /** Default `["wide"]`. Every route is taken at each. */
162
+ viewports?: readonly ViewportChoice[];
163
+ /** Default `page`. */
164
+ clip?: Clip;
165
+ /** Default `dark`; `false` to rely on `prefers-color-scheme` alone. */
166
+ darkClass?: string | false;
167
+ /**
168
+ * A `fetch` or XHR request no handler answers: `error` (default) fails the shot, because a
169
+ * screenshot that depends on a real server is not a baseline; `bypass` lets it through.
170
+ */
171
+ onUnhandledRequest?: "error" | "bypass";
172
+ routes: readonly Route[];
173
+ }
174
+ /** A visual suite: where baselines live and what to screenshot. Paths are relative to the config file. */
175
+ interface VisualConfig {
176
+ /** Committed baselines. Default `tests/visual/baselines`. */
177
+ baselines?: string;
178
+ /** Actual, expected and diff PNGs of changed shots (uploaded by CI). Default `tests/visual/output`. */
179
+ output?: string;
180
+ /** Default `["light", "dark"]`. */
181
+ themes?: readonly Theme[];
182
+ /** Freeze the page's clock at this time, so "3 minutes ago" and today's date stay put. */
183
+ time?: string | number | Date;
184
+ /** The page's time zone. Default `UTC`, so a date renders the same on every machine. */
185
+ timezone?: string;
186
+ /** The page's locale (`navigator.language`, `Intl` defaults). Default `en-US`. */
187
+ locale?: string;
188
+ /**
189
+ * What to do with text drawn in a font installed on the machine rather than one the page
190
+ * loaded (a theme whose `--font-*` falls through to `ui-sans-serif`, or a glyph the web font
191
+ * lacks). `error` (default) fails the shot, because no comparison threshold makes Cantarell
192
+ * match San Francisco; `warn` reports it; `allow` skips the check. Bundle every face with
193
+ * `@fontsource` (or your own `@font-face`) and name it first in the theme's `--font-*`.
194
+ *
195
+ * An app that chooses `system-ui` on purpose (so a page never waits on a font download) pins it
196
+ * instead: `{ pin: "DejaVu Sans", files: ["tests/visual/fonts/DejaVuSans.ttf"] }` makes every
197
+ * system family mean that face in the runner's Chromium, on every machine (issue #342), through
198
+ * a fontconfig file the runner generates. Linux only; elsewhere it warns and takes the machine's face.
199
+ */
200
+ systemFonts?: "error" | "warn" | "allow" | PinnedSystemFont;
201
+ /**
202
+ * 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
203
+ * 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
204
+ * baseline, not drawn as its loading box (issue #273). Default `true`; `false` takes the page as it loads.
205
+ */
206
+ scrollThrough?: boolean;
207
+ /**
208
+ * How a screenshot is compared with its baseline. The defaults (a 3×3 blur, then pixelmatch at
209
+ * threshold 0.1 with 4 differing pixels allowed) absorb anti-aliasing differences between
210
+ * machines and still fail on a changed letter; change them only with evidence from your own
211
+ * screens.
212
+ */
213
+ compare?: CompareOptions;
214
+ /** Pages captured at once. Default 4. */
215
+ concurrency?: number;
216
+ storybook?: StorybookTarget | string;
217
+ app?: AppTarget;
218
+ }
219
+ /** What a run found. */
220
+ interface VisualReport {
221
+ /** Shots taken. */
222
+ total: number;
223
+ same: number;
224
+ /** `name.png: reason` for each shot that matched without being pixel-identical (anti-aliasing absorbed). */
225
+ tolerated: string[];
226
+ /** `name.png: reason` for each shot that differs from its baseline. */
227
+ changed: string[];
228
+ /** Shots with no baseline yet (written, and copied to the output folder). */
229
+ added: string[];
230
+ /** Baselines no shot produced (removed when updating). */
231
+ obsolete: string[];
232
+ /** Shots that failed: page errors, console errors, unhandled requests, nothing rendered. */
233
+ errors: string[];
234
+ /** Things that make baselines less trustworthy, such as an unpinned Playwright. */
235
+ warnings: string[];
236
+ updated: boolean;
237
+ /** Whether the run should fail (in CI a missing baseline fails too). */
238
+ failed: boolean;
239
+ }
240
+ export { encode as C, decode as S, Image as _, Setup as a, boxBlur as b, Theme as c, VisualConfig as d, VisualReport as f, CompareResult as g, CompareOptions as h, RouteState as i, Viewport as l, BLUR as m, Clip as n, Shot as o, viewports as p, Route as r, StorybookTarget as s, AppTarget as t, ViewportChoice as u, MAX_DIFF_PIXELS as v, PinnedSystemFont as w, compare as x, THRESHOLD as y };
241
+ //# sourceMappingURL=types-B3TsF0Ey.d.ts.map
@@ -1,13 +1,14 @@
1
- import { f as format, o as useFieldControl, s as controlHeight } from "./field-BjeE_FeB.js";
2
- import { t as Button$1 } from "./button-KGJI6jQr.js";
3
- import { a as fieldErrorsOf, n as describeActionError } from "./errors-BUvY1Z4d.js";
4
- import { n as KeyText, r as cn } from "./tooltip-DhqrDtyu.js";
1
+ import { f as format, o as useFieldControl, s as controlHeight, u as NBSP } from "./field-DBCsFIng.js";
2
+ import { t as Button$1 } from "./button-CYXjU-fs.js";
3
+ import { a as fieldErrorsOf, n as describeActionError } from "./errors-CmuwcWlb.js";
4
+ import { n as KeyText, r as cn } from "./tooltip-BosfsWYh.js";
5
5
  import * as React from "react";
6
6
  import { I18nProvider, Input, NumberField, Separator, Slider, SliderOutput, SliderThumb, SliderTrack, Toolbar } from "react-aria-components";
7
7
  import { Check, CircleAlert, LoaderCircle } from "lucide-react";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+
9
10
  // src/components/hotkeys.tsx
10
- var TEXT_INPUTS_EXEMPT = /* @__PURE__ */ new Set([
11
+ const TEXT_INPUTS_EXEMPT = /* @__PURE__ */ new Set([
11
12
  "checkbox",
12
13
  "radio",
13
14
  "button",
@@ -89,8 +90,8 @@ function useHotkeys(shortcuts, { enabled = true, within } = {}) {
89
90
  return { live: enabled ? list.filter((s) => !s.disabled && (!within || inside || s.anywhere)) : [] };
90
91
  }
91
92
  /** How a `KeyboardEvent.key` is drawn in a legend and an editor: arrows as arrows, the rest by name. */
92
- var keyName = (key) => KEY_NAMES[key] ?? key;
93
- var KEY_NAMES = {
93
+ const keyName = (key) => KEY_NAMES[key] ?? key;
94
+ const KEY_NAMES = {
94
95
  ArrowDown: "↓",
95
96
  ArrowUp: "↑",
96
97
  ArrowLeft: "←",
@@ -121,8 +122,9 @@ function KeysLegend({ shortcuts, label = "Keyboard shortcuts", className }) {
121
122
  }, s.keys.join(" ")))
122
123
  });
123
124
  }
125
+
124
126
  // src/components/toolbar.tsx
125
- var isRange = (t) => t instanceof HTMLInputElement && t.type === "range";
127
+ const isRange = (t) => t instanceof HTMLInputElement && t.type === "range";
126
128
  /** A group of controls with one tab stop and arrow-key movement (the WAI-ARIA toolbar pattern). Needs a `label`. */
127
129
  function Toolbar$1({ label, orientation = "horizontal", children, className }) {
128
130
  const jump = (e) => {
@@ -149,6 +151,7 @@ function Toolbar$1({ label, orientation = "horizontal", children, className }) {
149
151
  function ToolbarSeparator({ className }) {
150
152
  return /* @__PURE__ */ jsx(Separator, { className: cn("mx-1 h-5 w-px self-center border-0 bg-border", className) });
151
153
  }
154
+
152
155
  // src/components/async-button.tsx
153
156
  /** 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. */
154
157
  function AsyncButton({ phase, labels, error, disabled, ...props }) {
@@ -288,7 +291,7 @@ function useAsyncAction(action, { settleMs = 2e3, onError, describeError = descr
288
291
  clearFieldError
289
292
  };
290
293
  }
291
- var idle = {
294
+ const idle = {
292
295
  phase: "idle",
293
296
  error: void 0,
294
297
  thrown: void 0,
@@ -300,6 +303,7 @@ function messages(found) {
300
303
  const kept = Object.fromEntries(Object.entries(found).filter((e) => Boolean(e[1])));
301
304
  return Object.keys(kept).length ? kept : void 0;
302
305
  }
306
+
303
307
  // src/lib/number-input.ts
304
308
  /** Reads `#rgb`, `#rrggbb` (with or without the #) as lower-case `#rrggbb`, or null. */
305
309
  function parseHex(text) {
@@ -321,14 +325,15 @@ function contrastRatio(a, b) {
321
325
  const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
322
326
  return (hi + .05) / (lo + .05);
323
327
  }
328
+
324
329
  // src/components/value-controls.tsx
325
- var box = "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";
330
+ const box = "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";
326
331
  /** A number with its unit joined by a non-breaking space; `%` and `°` stay attached. */
327
332
  function withUnit(text, unit) {
328
333
  if (!unit) return text;
329
334
  return unit === "%" || unit === "°" ? text + unit : text + "\xA0" + unit;
330
335
  }
331
- var intlUnits = {
336
+ const intlUnits = {
332
337
  "%": "percent",
333
338
  "°": "degree",
334
339
  ms: "millisecond",
@@ -374,10 +379,10 @@ function describeRange(min, max, show, unit) {
374
379
  if (max !== void 0) return `Enter ${b} or less.`;
375
380
  return "Enter a number.";
376
381
  }
377
- var REPEAT_AFTER_MS = 400;
378
- var REPEAT_EVERY_MS = 60;
379
- var round = (n, places) => Number(n.toFixed(places));
380
- var signed = (n) => (n < 0 ? "−" : "+") + String(Math.abs(n));
382
+ const REPEAT_AFTER_MS = 400;
383
+ const REPEAT_EVERY_MS = 60;
384
+ const round = (n, places) => Number(n.toFixed(places));
385
+ const signed = (n) => (n < 0 ? "−" : "+") + String(Math.abs(n));
381
386
  /** 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. */
382
387
  function NumberField$1({ value, onChange, min, max, step = 1, places, unit, locale = format.locale, required = false, disabled, id: idProp, name, size = "default", nudge, suggestion, preview, applyLabels = {
383
388
  idle: "Apply",
@@ -740,6 +745,6 @@ function ColorField({ value, onChange, suggestions, against, againstLabel = "the
740
745
  ]
741
746
  });
742
747
  }
743
- export { useAsyncAction as a, KeysLegend as c, useHotkeys as d, AsyncButton as i, isTypingTarget as l, NumberField$1 as n, Toolbar$1 as o, Slider$1 as r, ToolbarSeparator as s, ColorField as t, keyName as u };
744
748
 
745
- //# sourceMappingURL=value-controls-Dm_EYfZW.js.map
749
+ export { useAsyncAction as a, KeysLegend as c, useHotkeys as d, AsyncButton as i, isTypingTarget as l, NumberField$1 as n, Toolbar$1 as o, Slider$1 as r, ToolbarSeparator as s, ColorField as t, keyName as u };
750
+ //# sourceMappingURL=value-controls-5u7sD_wG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-controls-5u7sD_wG.js","names":["Toolbar","AriaToolbar","Button","NumberField","AriaNumberField","AriaInput","Toolbar","Button","Slider","AriaSlider"],"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 /** What names it when keys are rebound (`ShortcutEditor`): stable across releases, so a person's saved keys still mean the same action. Default: the label. */\n id?: 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 /** With `useHotkeys`' `within`: keep this key page-wide (Space to play, say) while the others only count with focus inside the region. */\n anywhere?: 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\nexport type HotkeysOptions = {\n enabled?: boolean;\n /**\n * Only count keys while focus is inside this region (strata-react issue #385): a player's own region, so a stage beside it keeps\n * its arrow keys. A shortcut with `anywhere` stays page-wide. A key whose target is outside the region goes to whoever else wants it.\n */\n within?: React.RefObject<Element | null>;\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`: better, pass it `live`, which is what answers a key\n * right now (nothing while `enabled` is off; with `within`, only the `anywhere` keys until focus is inside the region).\n */\nexport function useHotkeys(\n shortcuts: Shortcut[] | Record<string, () => void>,\n { enabled = true, within }: HotkeysOptions = {},\n): { live: Shortcut[] } {\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 const list = toShortcuts(shortcuts);\n latest.current = list;\n // Focus inside the region, as state, so the legend can follow it.\n const [inside, setInside] = React.useState(false);\n React.useEffect(() => {\n const region = within?.current;\n if (!region || !enabled) return setInside(false);\n const sync = () => setInside(region.contains(document.activeElement));\n sync();\n const leave = () => queueMicrotask(sync);\n region.addEventListener(\"focusin\", sync);\n region.addEventListener(\"focusout\", leave);\n return () => {\n region.removeEventListener(\"focusin\", sync);\n region.removeEventListener(\"focusout\", leave);\n setInside(false);\n };\n }, [enabled, within]);\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 // A `within` that was given but has no element (a region not rendered now) keeps only the `anywhere` keys.\n const region = within?.current;\n const here = !within || (!!region && e.target instanceof Node && region.contains(e.target));\n const hit = latest.current.find((s) => !s.disabled && (here || s.anywhere) && 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, within]);\n const live = enabled ? list.filter((s) => !s.disabled && (!within || inside || s.anywhere)) : [];\n return { live };\n}\n\n/** How a `KeyboardEvent.key` is drawn in a legend and an editor: arrows as arrows, the rest by name. */\nexport const keyName = (key: string) => KEY_NAMES[key] ?? key;\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\n aria-label={label}\n className={cn(\n \"flex flex-wrap gap-x-4 gap-y-1 type-caption text-muted-foreground pointer-coarse:hidden\",\n className,\n )}\n >\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 (\n (e.key !== \"Home\" && e.key !== \"End\") ||\n isTypingTarget(e.target) ||\n isRange(e.target) ||\n !e.currentTarget.contains(e.target as Node)\n )\n return;\n const items = [\n ...e.currentTarget.querySelectorAll<HTMLElement>(\"button, input, select, textarea, a[href], [tabindex]\"),\n ].filter(\n (el) =>\n !el.hasAttribute(\"disabled\") &&\n el.getAttribute(\"aria-disabled\") !== \"true\" &&\n el.tabIndex >= -1 &&\n 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(\n \"flex flex-wrap items-center gap-1\",\n orientation === \"vertical\" && \"flex-col items-stretch\",\n className,\n )}\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 =\n phase === \"done\" ? labels.done : phase === \"error\" ? (error ? `${error} ${errorLabel}` : errorLabel) : \"\";\n\n return (\n <>\n <Button\n {...props}\n data-phase={phase}\n disabled={disabled || phase === \"pending\"}\n aria-disabled={phase === \"pending\" || undefined}\n aria-busy={phase === \"pending\" || undefined}\n >\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\n key={l}\n aria-hidden={l !== current}\n className={l === current ? \"[grid-area:1/1]\" : \"invisible [grid-area:1/1]\"}\n >\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({\n phase: \"error\",\n error: latest.current.describeError(thrown),\n thrown,\n fieldErrors: fieldErrorsOf(thrown),\n });\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 {\n phase: state.phase,\n run,\n error: state.error,\n thrown: state.thrown,\n fieldErrors: state.fieldErrors,\n clearFieldError,\n };\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]\n .map((i) => parseInt(hex.slice(i, i + 2), 16) / 255)\n .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 =\n 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))\n 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(\n box,\n controlHeight[size],\n nudge ? \"min-w-32 flex-1\" : undefined,\n !nudge && !suggestion && !held && className,\n )}\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 = [\n ...sizes\n .slice()\n .reverse()\n .map((n) => -n),\n ...sizes,\n ];\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\n role=\"group\"\n aria-label=\"Change not applied yet\"\n className=\"grid gap-3 rounded-surface bg-surface-sunken p-3\"\n >\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\n aria-hidden\n className=\"absolute left-0 h-1.5 rounded-pill bg-primary\"\n style={{ width: `${state.getThumbPercent(0) * 100}%` }}\n />\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\n className=\"w-28 shrink-0\"\n aria-label={`${name}, exact value`}\n value={value}\n onChange={(v) => {\n if (v !== null) onChange(v);\n }}\n min={min}\n max={max}\n step={step}\n unit={unit}\n locale={locale}\n places={digits}\n required\n disabled={disabled}\n />\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({\n value,\n onChange,\n suggestions,\n against,\n againstLabel = \"the background\",\n minContrast = 3,\n disabled,\n id: idProp,\n className,\n \"aria-label\": ariaLabel,\n}: 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\n aria-hidden\n className={cn(\"absolute inset-0\", value === null && \"bg-muted\")}\n style={value ? { background: value } : undefined}\n />\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\n more.\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAyCA,MAAM,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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,QAAQ,UAAU;MAC9D,OAAO,QAAQ,EAAE,YAAY,MAAM,IAAI;KACxC,IACD,oBAAC,SAAD;MACE,MAAK;MACL,cAAY;MACZ,OAAO,SAAS;MACN;MACV,WAAW,MAAM,KAAK,EAAE,OAAO,KAAK;MACpC,WAAU;KACX,EACG;QACN,oBAAC,SAAD;KACE,IAAI,UAAU,OAAO;KACrB,MAAK;KACL,cAAa;KACb,YAAY;KACF;KACV,cAAY;KACZ,oBAAkB,OAAO;KACzB,gBAAc,WAAW;KACzB,aAAa,OAAO;KACpB,OAAO;KACP,WAAW,MAAM,SAAS,EAAE,OAAO,KAAK;KACxC,cAAc;MACZ,IAAI,UAAU,QAAQ,WAAW,KAAK,GAAG,SAAS,IAAI;KACxD;KACA,YAAY,MAAM;MAChB,IAAI,EAAE,QAAQ,WAAW,UAAU,QAAQ,WAAW,KAAK,GAAG,SAAS,IAAI;MAC3E,IAAI,EAAE,QAAQ,YAAY,UAAU,MAAM;OACxC,SAAS,IAAI;OACb,OAAO,KAAK;OACZ,OAAO,MAAS;MAClB;KACF;KACA,WAAU;IACX,EACE;;GACJ,eAAe,YAAY,SAAS,KACnC,oBAAC,OAAD;IAAK,MAAK;IAAQ,cAAW;IAAoB,WAAU;cACxD,YAAY,KAAK,QAChB,oBAAC,UAAD;KAEE,MAAK;KACK;KACV,cAAY;KACZ,gBAAc,UAAU;KACxB,eAAe,KAAK,GAAG;KACvB,WAAU;KACV,OAAO,EAAE,YAAY,IAAI;IAC1B,GARM,GAQN,CACF;GACE;GAEN,UAAU,QAAQ,QAAQ,eACzB,qBAAC,KAAD;IAAG,WAAU;cAAb;KAAyC;KACvB;KAAa;KAAY,OAAO,QAAQ,KAAK;KAAE;KAAa,OAAO,QAAQ,WAAW;KAAE;IAEvG;;EAEF;;AAET"}
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+
2
3
  // src/lib/viewer-input.ts
3
4
  /** The pointer handlers of a viewer: spread them on the focusable box. Handlers are read fresh each event, so they may close over state. */
4
5
  function useViewPointers(options) {
@@ -102,6 +103,6 @@ function useSettledStatus(words, ms = 600) {
102
103
  }, [words, ms]);
103
104
  return said;
104
105
  }
105
- export { useViewPointers as n, useWheelZoom as r, useSettledStatus as t };
106
106
 
107
- //# sourceMappingURL=viewer-input-CHU0Hx4A.js.map
107
+ export { useViewPointers as n, useWheelZoom as r, useSettledStatus as t };
108
+ //# sourceMappingURL=viewer-input-3Qa-o35k.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewer-input-CHU0Hx4A.js","names":[],"sources":["../src/lib/viewer-input.ts"],"sourcesContent":["import * as React from \"react\";\n\n// The input every 3D viewer needs, written once (strata-react issue #386, from the quake2ts explorer, whose labs wrote an orbit\n// camera, keys and words by hand beside `PanoramaViewer` and `SceneViewport`, which each had their own copy of the same three\n// things). `PanoramaViewer` (looking from inside a sphere) and `SceneViewport` (round or through a scene) differ in what a drag\n// does to the view, not in how a drag is read, so the reading is here and each viewer keeps its own meaning:\n//\n// - `useViewPointers`: one pointer drags (the viewer says what that turns), two pointers pinch, a press that did not move is a tap.\n// Pointer capture, focusing the viewer on press and the 4 px that tells a click from a drag are decided once.\n// - `useWheelZoom`: a native, non-passive wheel listener (React's is passive, so the page would scroll too), with a test for\n// which wheels count: a panorama zooms on any wheel, a scene only with Ctrl or Cmd, so the page still scrolls past it.\n// - `useSettledStatus`: the polite sentence said once the view has been still for a moment, never per frame, and not on first render.\n//\n// Checked: React Aria's `usePress` reports a press and its start and end with no movement, and `useMove` gives one pointer's\n// deltas with no pinch or capture; a viewer needs both pointers and a tap in one gesture, so this is plain pointer events.\n\ntype Point = { x: number; y: number };\n\nexport type ViewPointerOptions = {\n /** One pointer moved while down: the change since its last event, and the event (for Shift and the buttons). Called once the drag is past `threshold`. */\n onDrag: (dx: number, dy: number, event: React.PointerEvent<HTMLElement>) => void;\n /** Two pointers: the earlier distance over the new one, so more than 1 is fingers coming together. Called with the event. */\n onPinch?: (ratio: number, event: React.PointerEvent<HTMLElement>) => void;\n /** A press that did not drag, or pinch, ended. */\n onTap?: (event: React.PointerEvent<HTMLElement>) => void;\n /** Called first on a press that is taken (a scene cancels its Reset animation here). */\n onDown?: (event: React.PointerEvent<HTMLElement>) => void;\n /** A press to leave alone (a button in the viewer, a secondary mouse button). Default: none. */\n ignore?: (event: React.PointerEvent<HTMLElement>) => boolean;\n /** Pixels a press must move before it is a drag. Default 4; 0 drags at once. */\n threshold?: number;\n};\n\n/** The pointer handlers of a viewer: spread them on the focusable box. Handlers are read fresh each event, so they may close over state. */\nexport function useViewPointers(options: ViewPointerOptions) {\n const live = React.useRef(options);\n live.current = options;\n const pointers = React.useRef(new Map<number, Point>());\n const gesture = React.useRef<{ moved: boolean; pinch: number | null; start: Point } | null>(null);\n const spread = () => {\n const [a, b] = [...pointers.current.values()];\n return a && b ? Math.hypot(a.x - b.x, a.y - b.y) : null;\n };\n return React.useMemo(() => {\n const onPointerDown = (e: React.PointerEvent<HTMLElement>) => {\n if (live.current.ignore?.(e)) return;\n pointers.current.set(e.pointerId, { x: e.clientX, y: e.clientY });\n e.currentTarget.setPointerCapture?.(e.pointerId);\n e.currentTarget.focus({ preventScroll: true });\n live.current.onDown?.(e);\n gesture.current = { moved: false, pinch: spread(), start: { x: e.clientX, y: e.clientY } };\n };\n const onPointerMove = (e: React.PointerEvent<HTMLElement>) => {\n const last = pointers.current.get(e.pointerId);\n const g = gesture.current;\n if (!last || !g) return;\n const now = { x: e.clientX, y: e.clientY };\n pointers.current.set(e.pointerId, now);\n if (pointers.current.size === 2) {\n const d = spread();\n if (g.pinch && d) live.current.onPinch?.(g.pinch / d, e);\n g.pinch = d;\n g.moved = true;\n return;\n }\n const threshold = live.current.threshold ?? 4;\n if (!g.moved && Math.hypot(now.x - g.start.x, now.y - g.start.y) > threshold) g.moved = true;\n if (!g.moved) return;\n live.current.onDrag(now.x - last.x, now.y - last.y, e);\n };\n const end = (e: React.PointerEvent<HTMLElement>, tap: boolean) => {\n const g = gesture.current;\n pointers.current.delete(e.pointerId);\n if (pointers.current.size === 0) {\n gesture.current = null;\n if (tap && g && !g.moved) live.current.onTap?.(e);\n } else if (g) g.pinch = null;\n };\n return {\n onPointerDown,\n onPointerMove,\n onPointerUp: (e: React.PointerEvent<HTMLElement>) => end(e, true),\n // A cancelled pointer (the browser took a touch or pen gesture) leaves the gesture without a tap.\n onPointerCancel: (e: React.PointerEvent<HTMLElement>) => end(e, false),\n };\n }, []);\n}\n\n/** A wheel that zooms a viewer: `onZoom` gets a factor (above 1 is out). `when` says which wheels count; the rest scroll the page. */\nexport function useWheelZoom(ref: React.RefObject<HTMLElement | null>, onZoom: (factor: number, event: WheelEvent) => void, { when, enabled = true }: { when?: (event: WheelEvent) => boolean; enabled?: boolean } = {}) {\n const live = React.useRef({ onZoom, when });\n live.current = { onZoom, when };\n React.useEffect(() => {\n const el = ref.current;\n if (!el || !enabled) return;\n const onWheel = (e: WheelEvent) => {\n if (live.current.when && !live.current.when(e)) return;\n e.preventDefault();\n live.current.onZoom(Math.exp(e.deltaY * 0.0015), e);\n };\n el.addEventListener(\"wheel\", onWheel, { passive: false });\n return () => el.removeEventListener(\"wheel\", onWheel);\n }, [ref, enabled]);\n}\n\n/** The words for a view, once it has been still for `ms`: \"\" until then and on first render, so a screen reader hears where it ended up, not every frame. */\nexport function useSettledStatus(words: string, ms = 600): string {\n const [said, setSaid] = React.useState(\"\");\n const first = React.useRef(true);\n React.useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n const t = setTimeout(() => setSaid(words), ms);\n return () => clearTimeout(t);\n }, [words, ms]);\n return said;\n}\n"],"mappings":";;;AAkCA,SAAgB,gBAAgB,SAA6B;CAC3D,MAAM,OAAO,MAAM,OAAO,OAAO;CACjC,KAAK,UAAU;CACf,MAAM,WAAW,MAAM,uBAAO,IAAI,IAAmB,CAAC;CACtD,MAAM,UAAU,MAAM,OAAsE,IAAI;CAChG,MAAM,eAAe;EACnB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,SAA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;EAC7C,aAAa,aAAa,CAAC;CAC7B,GAAG,CAAC,OAAO,EAAE,CAAC;CACd,OAAO;AACT"}
1
+ {"version":3,"file":"viewer-input-3Qa-o35k.js","names":[],"sources":["../src/lib/viewer-input.ts"],"sourcesContent":["import * as React from \"react\";\n\n// The input every 3D viewer needs, written once (strata-react issue #386, from the quake2ts explorer, whose labs wrote an orbit\n// camera, keys and words by hand beside `PanoramaViewer` and `SceneViewport`, which each had their own copy of the same three\n// things). `PanoramaViewer` (looking from inside a sphere) and `SceneViewport` (round or through a scene) differ in what a drag\n// does to the view, not in how a drag is read, so the reading is here and each viewer keeps its own meaning:\n//\n// - `useViewPointers`: one pointer drags (the viewer says what that turns), two pointers pinch, a press that did not move is a tap.\n// Pointer capture, focusing the viewer on press and the 4 px that tells a click from a drag are decided once.\n// - `useWheelZoom`: a native, non-passive wheel listener (React's is passive, so the page would scroll too), with a test for\n// which wheels count: a panorama zooms on any wheel, a scene only with Ctrl or Cmd, so the page still scrolls past it.\n// - `useSettledStatus`: the polite sentence said once the view has been still for a moment, never per frame, and not on first render.\n//\n// Checked: React Aria's `usePress` reports a press and its start and end with no movement, and `useMove` gives one pointer's\n// deltas with no pinch or capture; a viewer needs both pointers and a tap in one gesture, so this is plain pointer events.\n\ntype Point = { x: number; y: number };\n\nexport type ViewPointerOptions = {\n /** One pointer moved while down: the change since its last event, and the event (for Shift and the buttons). Called once the drag is past `threshold`. */\n onDrag: (dx: number, dy: number, event: React.PointerEvent<HTMLElement>) => void;\n /** Two pointers: the earlier distance over the new one, so more than 1 is fingers coming together. Called with the event. */\n onPinch?: (ratio: number, event: React.PointerEvent<HTMLElement>) => void;\n /** A press that did not drag, or pinch, ended. */\n onTap?: (event: React.PointerEvent<HTMLElement>) => void;\n /** Called first on a press that is taken (a scene cancels its Reset animation here). */\n onDown?: (event: React.PointerEvent<HTMLElement>) => void;\n /** A press to leave alone (a button in the viewer, a secondary mouse button). Default: none. */\n ignore?: (event: React.PointerEvent<HTMLElement>) => boolean;\n /** Pixels a press must move before it is a drag. Default 4; 0 drags at once. */\n threshold?: number;\n};\n\n/** The pointer handlers of a viewer: spread them on the focusable box. Handlers are read fresh each event, so they may close over state. */\nexport function useViewPointers(options: ViewPointerOptions) {\n const live = React.useRef(options);\n live.current = options;\n const pointers = React.useRef(new Map<number, Point>());\n const gesture = React.useRef<{ moved: boolean; pinch: number | null; start: Point } | null>(null);\n const spread = () => {\n const [a, b] = [...pointers.current.values()];\n return a && b ? Math.hypot(a.x - b.x, a.y - b.y) : null;\n };\n return React.useMemo(() => {\n const onPointerDown = (e: React.PointerEvent<HTMLElement>) => {\n if (live.current.ignore?.(e)) return;\n pointers.current.set(e.pointerId, { x: e.clientX, y: e.clientY });\n e.currentTarget.setPointerCapture?.(e.pointerId);\n e.currentTarget.focus({ preventScroll: true });\n live.current.onDown?.(e);\n gesture.current = { moved: false, pinch: spread(), start: { x: e.clientX, y: e.clientY } };\n };\n const onPointerMove = (e: React.PointerEvent<HTMLElement>) => {\n const last = pointers.current.get(e.pointerId);\n const g = gesture.current;\n if (!last || !g) return;\n const now = { x: e.clientX, y: e.clientY };\n pointers.current.set(e.pointerId, now);\n if (pointers.current.size === 2) {\n const d = spread();\n if (g.pinch && d) live.current.onPinch?.(g.pinch / d, e);\n g.pinch = d;\n g.moved = true;\n return;\n }\n const threshold = live.current.threshold ?? 4;\n if (!g.moved && Math.hypot(now.x - g.start.x, now.y - g.start.y) > threshold) g.moved = true;\n if (!g.moved) return;\n live.current.onDrag(now.x - last.x, now.y - last.y, e);\n };\n const end = (e: React.PointerEvent<HTMLElement>, tap: boolean) => {\n const g = gesture.current;\n pointers.current.delete(e.pointerId);\n if (pointers.current.size === 0) {\n gesture.current = null;\n if (tap && g && !g.moved) live.current.onTap?.(e);\n } else if (g) g.pinch = null;\n };\n return {\n onPointerDown,\n onPointerMove,\n onPointerUp: (e: React.PointerEvent<HTMLElement>) => end(e, true),\n // A cancelled pointer (the browser took a touch or pen gesture) leaves the gesture without a tap.\n onPointerCancel: (e: React.PointerEvent<HTMLElement>) => end(e, false),\n };\n }, []);\n}\n\n/** A wheel that zooms a viewer: `onZoom` gets a factor (above 1 is out). `when` says which wheels count; the rest scroll the page. */\nexport function useWheelZoom(\n ref: React.RefObject<HTMLElement | null>,\n onZoom: (factor: number, event: WheelEvent) => void,\n { when, enabled = true }: { when?: (event: WheelEvent) => boolean; enabled?: boolean } = {},\n) {\n const live = React.useRef({ onZoom, when });\n live.current = { onZoom, when };\n React.useEffect(() => {\n const el = ref.current;\n if (!el || !enabled) return;\n const onWheel = (e: WheelEvent) => {\n if (live.current.when && !live.current.when(e)) return;\n e.preventDefault();\n live.current.onZoom(Math.exp(e.deltaY * 0.0015), e);\n };\n el.addEventListener(\"wheel\", onWheel, { passive: false });\n return () => el.removeEventListener(\"wheel\", onWheel);\n }, [ref, enabled]);\n}\n\n/** The words for a view, once it has been still for `ms`: \"\" until then and on first render, so a screen reader hears where it ended up, not every frame. */\nexport function useSettledStatus(words: string, ms = 600): string {\n const [said, setSaid] = React.useState(\"\");\n const first = React.useRef(true);\n React.useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n const t = setTimeout(() => setSaid(words), ms);\n return () => clearTimeout(t);\n }, [words, ms]);\n return said;\n}\n"],"mappings":";;;;AAkCA,SAAgB,gBAAgB,SAA6B;CAC3D,MAAM,OAAO,MAAM,OAAO,OAAO;CACjC,KAAK,UAAU;CACf,MAAM,WAAW,MAAM,uBAAO,IAAI,IAAmB,CAAC;CACtD,MAAM,UAAU,MAAM,OAAsE,IAAI;CAChG,MAAM,eAAe;EACnB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,SAAS,QAAQ,OAAO,CAAC;EAC5C,OAAO,KAAK,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,IAAI;CACrD;CACA,OAAO,MAAM,cAAc;EACzB,MAAM,iBAAiB,MAAuC;GAC5D,IAAI,KAAK,QAAQ,SAAS,C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,OAAO,KAAK,QAAQ,QAAQ,CAAC;GAClD,OAAO,IAAI,GAAG,EAAE,QAAQ;EAC1B;EACA,OAAO;GACL;GACA;GACA,cAAc,MAAuC,IAAI,GAAG,IAAI;GAEhE,kBAAkB,MAAuC,IAAI,GAAG,KAAK;EACvE;CACF,GAAG,CAAC,CAAC;AACP;;AAGA,SAAgB,aACd,KACA,QACA,EAAE,MAAM,UAAU,SAAuE,CAAC,GAC1F;CACA,MAAM,OAAO,MAAM,OAAO;EAAE;EAAQ;CAAK,CAAC;CAC1C,KAAK,UAAU;EAAE;EAAQ;CAAK;CAC9B,MAAM,gBAAgB;EACpB,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,MAAM,CAAC,SAAS;EACrB,MAAM,WAAW,MAAkB;GACjC,IAAI,KAAK,QAAQ,QAAQ,CAAC,KAAK,QAAQ,KAAK,CAAC,GAAG;GAChD,EAAE,eAAe;GACjB,KAAK,QAAQ,OAAO,KAAK,IAAI,EAAE,SAAS,KAAM,GAAG,CAAC;EACpD;EACA,GAAG,iBAAiB,SAAS,SAAS,EAAE,SAAS,MAAM,CAAC;EACxD,aAAa,GAAG,oBAAoB,SAAS,OAAO;CACtD,GAAG,CAAC,KAAK,OAAO,CAAC;AACnB;;AAGA,SAAgB,iBAAiB,OAAe,KAAK,KAAa;CAChE,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,EAAE;CACzC,MAAM,QAAQ,MAAM,OAAO,IAAI;CAC/B,MAAM,gBAAgB;EACpB,IAAI,MAAM,SAAS;GACjB,MAAM,UAAU;GAChB;EACF;EACA,MAAM,IAAI,iBAAiB,QAAQ,KAAK,GAAG,EAAE;EAC7C,aAAa,aAAa,CAAC;CAC7B,GAAG,CAAC,OAAO,EAAE,CAAC;CACd,OAAO;AACT"}
@@ -1,5 +1,6 @@
1
- import { VisualConfig } from './types';
1
+ import { d as VisualConfig } from "./types-B3TsF0Ey.js";
2
2
  /** Loads a config file's default export. */
3
3
  export declare function loadConfig(file: string): Promise<VisualConfig>;
4
4
  /** Runs the command with the given arguments and returns the exit code. */
5
5
  export declare function main(argv: readonly string[], cwd?: string): Promise<number>;
6
+ //# sourceMappingURL=visual-cli.d.ts.map
@@ -1,10 +1,11 @@
1
- import { i as runVisual, n as formatReport } from "./run-BT2WKzMz.js";
1
+ import { i as runVisual, n as formatReport } from "./run-D_Ic1jE7.js";
2
2
  import { existsSync } from "node:fs";
3
3
  import { resolve } from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
5
  import { parseArgs } from "node:util";
6
+
6
7
  // src/visual/cli.ts
7
- var usage = `Usage: strata-visual [options]
8
+ const usage = `Usage: strata-visual [options]
8
9
 
9
10
  Screenshots a built Storybook and/or an app's routes in light and dark, and compares each
10
11
  with its committed baseline (Playwright Chromium + pixelmatch).
@@ -18,7 +19,7 @@ with its committed baseline (Playwright Chromium + pixelmatch).
18
19
  --concurrency <n> pages at once (default 4)
19
20
  --help show this
20
21
  `;
21
- var configNames = [
22
+ const configNames = [
22
23
  "strata-visual.config.ts",
23
24
  "strata-visual.config.mts",
24
25
  "strata-visual.config.js",
@@ -113,6 +114,6 @@ async function main(argv, cwd = process.cwd()) {
113
114
  return 1;
114
115
  }
115
116
  }
116
- export { loadConfig, main };
117
117
 
118
+ export { loadConfig, main };
118
119
  //# sourceMappingURL=visual-cli.js.map