strata-react 1.0.39 → 1.0.41

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 (44) hide show
  1. package/README.md +29 -5
  2. package/UPGRADING.md +11 -0
  3. package/bin/strata-stock-classes.js +5 -0
  4. package/dist/components/button.d.ts +3 -0
  5. package/dist/components/checkbox.d.ts +3 -2
  6. package/dist/components/compare-parts.d.ts +25 -0
  7. package/dist/components/compare-video.d.ts +4 -2
  8. package/dist/components/compare.d.ts +4 -2
  9. package/dist/components/secret-field.d.ts +34 -0
  10. package/dist/components/selection.d.ts +45 -1
  11. package/dist/components/toast.d.ts +3 -2
  12. package/dist/components/transcript-view.d.ts +18 -2
  13. package/dist/components/tree.d.ts +16 -6
  14. package/dist/components/value-controls.d.ts +20 -4
  15. package/dist/{query-CJ1pSPiC.js → errors-BunUBqpA.js} +5 -176
  16. package/dist/errors-BunUBqpA.js.map +1 -0
  17. package/dist/{field-7Z4N5r5g.js → field-DeKNvGox.js} +74 -5
  18. package/dist/field-DeKNvGox.js.map +1 -0
  19. package/dist/index.d.ts +4 -2
  20. package/dist/index.js +847 -332
  21. package/dist/index.js.map +1 -1
  22. package/dist/lib/choice.d.ts +29 -0
  23. package/dist/lib/transcript.d.ts +16 -0
  24. package/dist/map.js +2 -2
  25. package/dist/migrate/cli.d.ts +2 -0
  26. package/dist/migrate/stock-classes.d.ts +11 -0
  27. package/dist/migrate-cli.js +128 -0
  28. package/dist/migrate-cli.js.map +1 -0
  29. package/dist/panorama.js +2 -2
  30. package/dist/query-B934ufsW.js +209 -0
  31. package/dist/query-B934ufsW.js.map +1 -0
  32. package/dist/strata.css +6 -0
  33. package/dist/strata.migrate.css +224 -0
  34. package/dist/testing.js +2 -2
  35. package/dist/{theme-CFNi6WUO.js → theme-DVaIxyNn.js} +6 -75
  36. package/dist/theme-DVaIxyNn.js.map +1 -0
  37. package/dist/value-controls-FO4zQiHP.js +735 -0
  38. package/dist/value-controls-FO4zQiHP.js.map +1 -0
  39. package/package.json +7 -2
  40. package/dist/field-7Z4N5r5g.js.map +0 -1
  41. package/dist/query-CJ1pSPiC.js.map +0 -1
  42. package/dist/theme-CFNi6WUO.js.map +0 -1
  43. package/dist/value-controls-D6O9TsM6.js +0 -356
  44. package/dist/value-controls-D6O9TsM6.js.map +0 -1
@@ -1,11 +1,8 @@
1
- import { c as cn } from "./field-7Z4N5r5g.js";
2
- import { c as Tooltip$1 } from "./theme-CFNi6WUO.js";
3
- import * as React from "react";
4
- import { Button, Text, UNSTABLE_Toast, UNSTABLE_ToastContent, UNSTABLE_ToastQueue, UNSTABLE_ToastRegion } from "react-aria-components";
1
+ import { c as Tooltip$1, u as cn } from "./field-DeKNvGox.js";
2
+ import "react";
3
+ import { Button } from "react-aria-components";
5
4
  import { cva } from "class-variance-authority";
6
- import { CircleCheck, Info, TriangleAlert, X } from "lucide-react";
7
5
  import { jsx, jsxs } from "react/jsx-runtime";
8
- import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/react-query";
9
6
  // src/components/button.tsx
10
7
  var buttonVariants = cva("inline-flex max-w-full shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-(--control-icon) [&_svg]:shrink-0", {
11
8
  variants: {
@@ -76,8 +73,6 @@ function RowAction({ label, subject, icon: Icon, variant = "ghost", size = "sm",
76
73
  children: [Icon && /* @__PURE__ */ jsx(Icon, { "aria-hidden": true }), label]
77
74
  });
78
75
  }
79
- // src/lib/overlay.ts
80
- var overlaySurface = "rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay";
81
76
  // src/lib/errors.ts
82
77
  /** Thrown by `fetchJson` on a non-2xx response; carries the status, the response body and the server's reason for `describeHttpError` and `describeActionError`. */
83
78
  var HttpError = class extends Error {
@@ -156,172 +151,6 @@ var describeActionError = (error) => error instanceof HttpError ? error.status >
156
151
  function fieldErrorsOf(error) {
157
152
  return error instanceof HttpError ? error.fieldErrors : {};
158
153
  }
159
- // src/components/toast.tsx
160
- var queue = new UNSTABLE_ToastQueue({ maxVisibleToasts: 3 });
161
- /** Milliseconds a toast stays: 5 s plus 40 ms a character, to at most 15 s, and at least 8 s with an action. */
162
- function toastTimeout(content) {
163
- if (content.timeout !== void 0) return content.timeout;
164
- const chars = content.title.length + (content.description?.length ?? 0) + (content.action?.label.length ?? 0);
165
- return Math.max(content.action ? 8e3 : 0, Math.min(15e3, 5e3 + 40 * chars));
166
- }
167
- /** The toast queue: `toast.show({ title })` from anywhere; `toast.close(key)`; `toast.clear()`. */
168
- var toast = {
169
- /** Shows a toast and returns its key. */
170
- show(content) {
171
- return queue.add(content, { timeout: toastTimeout(content) });
172
- },
173
- close(key) {
174
- queue.close(key);
175
- },
176
- clear() {
177
- queue.clear();
178
- }
179
- };
180
- var marks = {
181
- info: {
182
- icon: Info,
183
- color: "text-info"
184
- },
185
- success: {
186
- icon: CircleCheck,
187
- color: "text-success"
188
- },
189
- warning: {
190
- icon: TriangleAlert,
191
- color: "text-warning"
192
- }
193
- };
194
- /** The one place toasts appear. Render it once at the app root. A labelled landmark (F6), polite, above panes and the undo bar. */
195
- function StrataToastRegion({ label = "Notifications", className }) {
196
- return /* @__PURE__ */ jsx(UNSTABLE_ToastRegion, {
197
- queue,
198
- "aria-label": label,
199
- className: cn("layer-bar fixed inset-x-4 top-4 grid justify-items-end gap-2 outline-none sm:inset-x-auto sm:top-auto sm:right-4 sm:bottom-4", className),
200
- children: ({ toast: t }) => /* @__PURE__ */ jsxs(UNSTABLE_Toast, {
201
- toast: t,
202
- className: cn("flex w-full max-w-sm items-start gap-3 p-3 outline-none focus-visible:outline-2 focus-visible:outline-ring", overlaySurface),
203
- children: [
204
- (() => {
205
- const { icon: Icon, color } = marks[t.content.tone ?? "info"];
206
- return /* @__PURE__ */ jsx(Icon, {
207
- "aria-hidden": true,
208
- className: cn("mt-0.5 size-4 shrink-0", color)
209
- });
210
- })(),
211
- /* @__PURE__ */ jsxs(UNSTABLE_ToastContent, {
212
- className: "grid min-w-0 flex-1 gap-0.5",
213
- children: [/* @__PURE__ */ jsx(Text, {
214
- slot: "title",
215
- className: "type-label",
216
- children: t.content.title
217
- }), t.content.description && /* @__PURE__ */ jsx(Text, {
218
- slot: "description",
219
- className: "type-body-sm text-muted-foreground",
220
- children: t.content.description
221
- })]
222
- }),
223
- t.content.action && /* @__PURE__ */ jsx(Button$1, {
224
- size: "sm",
225
- onPress: () => {
226
- t.content.action?.onPress();
227
- queue.close(t.key);
228
- },
229
- children: t.content.action.label
230
- }),
231
- /* @__PURE__ */ jsx(Button, {
232
- slot: "close",
233
- "aria-label": "Dismiss",
234
- className: "grid size-6 shrink-0 cursor-pointer place-items-center rounded-control text-muted-foreground transition-state hover:bg-muted hover:text-foreground",
235
- children: /* @__PURE__ */ jsx(X, {
236
- "aria-hidden": true,
237
- className: "size-4"
238
- })
239
- })
240
- ]
241
- })
242
- });
243
- }
244
- // src/query/index.tsx
245
- /** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */
246
- function createQueryClient(overrides) {
247
- return new QueryClient({
248
- ...overrides,
249
- defaultOptions: {
250
- ...overrides?.defaultOptions,
251
- queries: {
252
- retry: 1,
253
- staleTime: 3e4,
254
- refetchOnWindowFocus: false,
255
- ...overrides?.defaultOptions?.queries
256
- }
257
- }
258
- });
259
- }
260
- /** Provides a query client (Strata's defaults unless one is passed) to the app. */
261
- function StrataQueryProvider({ client, children }) {
262
- const [fallback] = React.useState(() => client ?? createQueryClient());
263
- return /* @__PURE__ */ jsx(QueryClientProvider, {
264
- client: client ?? fallback,
265
- children
266
- });
267
- }
268
- /**
269
- * Turns a TanStack query result into the `Load<T>` that `DataView` takes; errors are described for a person by `describe`.
270
- * A refetch that fails after data arrived stays `ready`, with `stale` saying why and when the data was read.
271
- */
272
- function toLoad(query, describe = describeHttpError) {
273
- if (query.status === "success") return {
274
- status: "ready",
275
- data: query.data
276
- };
277
- if (query.status === "error" && query.data !== void 0) return {
278
- status: "ready",
279
- data: query.data,
280
- stale: staleOf(query, describe)
281
- };
282
- if (query.status === "error") return {
283
- status: "error",
284
- message: describe(query.error),
285
- retry: () => void query.refetch()
286
- };
287
- return { status: "loading" };
288
- }
289
- /** The `Stale` of a query whose refetch failed after a good read. Shared by `toLoad` and `useInfiniteLoad`. */
290
- function staleOf(query, describe = describeHttpError) {
291
- return {
292
- message: describe(query.error),
293
- readAt: new Date(query.dataUpdatedAt),
294
- retry: () => void query.refetch(),
295
- retrying: query.isFetching
296
- };
297
- }
298
- /** `useQuery`, returned as a `Load<T>` for `DataView`. */
299
- function useLoad(options) {
300
- const { describeError, ...rest } = options;
301
- return toLoad(useQuery(rest), describeError);
302
- }
303
- /**
304
- * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.
305
- * A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).
306
- */
307
- async function fetchJson(input, init, { readError = readErrorBody } = {}) {
308
- const headers = new Headers(init?.headers);
309
- if (!headers.has("Accept")) headers.set("Accept", "application/json");
310
- const res = await fetch(input, {
311
- ...init,
312
- headers
313
- });
314
- if (!res.ok) {
315
- const raw = await res.text().catch(() => "");
316
- let body = raw || void 0;
317
- try {
318
- if (raw) body = JSON.parse(raw);
319
- } catch {}
320
- throw new HttpError(res.status, res.statusText, String(input), body, readError(body));
321
- }
322
- const text = res.status === 204 ? "" : await res.text();
323
- return text ? JSON.parse(text) : void 0;
324
- }
325
- export { IconButton as _, toLoad as a, toast as c, describeActionError as d, describeHttpError as f, Button$1 as g, overlaySurface as h, staleOf as i, toastTimeout as l, readErrorBody as m, createQueryClient as n, useLoad as o, fieldErrorsOf as p, fetchJson as r, StrataToastRegion as s, StrataQueryProvider as t, HttpError as u, RowAction as v, buttonVariants as y };
154
+ export { readErrorBody as a, RowAction as c, fieldErrorsOf as i, buttonVariants as l, describeActionError as n, Button$1 as o, describeHttpError as r, IconButton as s, HttpError as t };
326
155
 
327
- //# sourceMappingURL=query-CJ1pSPiC.js.map
156
+ //# sourceMappingURL=errors-BunUBqpA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-BunUBqpA.js","names":["Button","AriaButton","Tooltip"],"sources":["../src/components/button.tsx","../src/lib/errors.ts"],"sourcesContent":["import * as React from \"react\";\nimport { Button as AriaButton, type PressEvent } from \"react-aria-components\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\nimport type { ControlSize } from \"../lib/control\";\nimport { Tooltip } from \"./tooltip\";\n\n// Variant names are shadcn's, so copied code and agents' prior knowledge still work. Two things\n// differ on purpose:\n// 1. The default variant is `outline`, not the filled accent. A bare <Button> is the restrained\n// one; the accent (`variant=\"default\"`) has to be asked for, once per view. Generated app screens\n// put the accent on every button; 12 of 23 real product screens had no filled primary at all.\n// 2. Heights come from --control-h, shared with Input and NativeSelect, so density changes move\n// every control together.\n// 3. React Aria is the primitives layer (CLAUDE.md, \"The stack\"): behaviour and accessibility come\n// from it, the look from our tokens. `asChild`/`Slot` is gone; a button that navigates is a link.\n// 4. `press`: the button gives 2% under a click or a finger, over 100ms. Buttons are used tens of\n// times a day, so that is all the motion they get (character.md, the frequency budget).\nexport const buttonVariants = cva(\n \"inline-flex max-w-full shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-(--control-icon) [&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary-10\",\n outline: \"border border-input bg-background text-foreground hover:bg-muted\",\n secondary: \"bg-muted text-foreground hover:bg-neutral-4\",\n ghost: \"text-foreground hover:bg-muted\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-danger\",\n link: \"h-auto px-0 text-primary-11 underline underline-offset-4 hover:text-primary-12\",\n },\n size: {\n default: \"h-(--control-h) px-(--control-px)\",\n sm: \"h-(--control-h-sm) px-(--control-px-sm)\",\n icon: \"size-(--control-h)\",\n \"icon-sm\": \"size-(--control-h-sm)\",\n },\n },\n defaultVariants: { variant: \"outline\", size: \"default\" },\n },\n);\n\nexport type ButtonProps = Omit<React.ComponentProps<\"button\">, \"className\" | \"style\"> &\n VariantProps<typeof buttonVariants> & {\n className?: string;\n /** React Aria's press event (mouse, touch, pen and keyboard alike). `onClick` also works. */\n onPress?: (event: PressEvent) => void;\n /** When a press begins and ends: for a control that acts while held (a nudge that repeats). */\n onPressStart?: (event: PressEvent) => void;\n onPressEnd?: (event: PressEvent) => void;\n };\n\n/**\n * A button with shadcn's variant names, built on React Aria's `Button` (press handling that behaves\n * the same for mouse, touch, pen and keyboard, focus-visible and hover state). The default variant is\n * `outline`; ask for the filled accent (`variant=\"default\"`) once per view. `type` defaults to `button`.\n * `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.\n */\nexport function Button({ className, variant, size, type = \"button\", disabled, children, ...props }: ButtonProps) {\n // data-variant says which variant was drawn, so a test can check \"one filled button per view\"\n // without reading class names (strata-react issue #48, `filledButtons` in strata-react/testing).\n return (\n <AriaButton\n type={type}\n isDisabled={disabled}\n data-variant={variant ?? \"outline\"}\n className={cn(buttonVariants({ variant, size }), className)}\n {...(props as object)}\n >\n {/* A text label that cannot fit its column is cut with an ellipsis, not drawn past the button (issue #116). */}\n {typeof children === \"string\" ? <span className=\"min-w-0 truncate\">{children}</span> : children}\n </AriaButton>\n );\n}\n\n// An icon-only button cannot be written without a name: `label` is required by the type, becomes\n// the accessible name and is shown as a `Tooltip` on hover and keyboard focus, so the name and the\n// visible hint come from one string and cannot drift. This makes the most common generated\n// accessibility defect (an unlabelled icon button) a compile error instead of an audit finding.\nexport type IconButtonProps = Omit<ButtonProps, \"size\" | \"children\" | \"aria-label\"> & {\n /** `sm` is --control-h-sm, the height of a small `Toggle` or `Button`, for a toolbar or property row. Default --control-h. */\n size?: ControlSize;\n icon: IconComponent;\n label: string;\n /** Shown after the label in its tooltip, muted: \"Ctrl+Z\". */\n hint?: React.ReactNode;\n};\n\n/** An icon-only button. `label` is required and becomes the accessible name and the tooltip (hover and keyboard focus); `hint` adds a muted aside to it, such as a shortcut. */\nexport function IconButton({ icon: Icon, label, hint, variant = \"ghost\", size = \"default\", ...props }: IconButtonProps) {\n return (\n <Tooltip label={label} hint={hint}>\n <Button size={size === \"sm\" ? \"icon-sm\" : \"icon\"} variant={variant} aria-label={label} {...props}>\n <Icon aria-hidden />\n </Button>\n </Tooltip>\n );\n}\n\n// A row action says what it does in the row (\"Withdraw\") and whom it does it to in its name\n// (\"Withdraw Tom Ellery\"): a table of eight \"Withdraw\" buttons is eight identical names in a\n// screen reader's list of controls. The name is an aria-label that starts with the visible verb,\n// so it meets WCAG 2.5.3 (label in name) and voice control still finds it by \"Withdraw\". Visually\n// hidden suffix text is not used: a hidden span joined to the verb did not form a name with its\n// space in dom-testing-library (strata-react issue #11). Ghost and small, one per row, shown only\n// on the rows where it applies; an icon-only row action is an `IconButton` whose `label` names the\n// row the same way. It keeps the row's pitch: rows with and without the action are the same height.\nexport type RowActionProps = Omit<ButtonProps, \"children\" | \"aria-label\"> & {\n /** The visible verb, sentence case: \"Withdraw\", \"Remove\". */\n label: string;\n /** What the row is, as a person would say it: \"Tom Ellery\", \"Moonbeam\". Completes the accessible name. */\n subject: string;\n icon?: IconComponent;\n};\n\n/** A small ghost action for one table row: shows `label`, and is named \"`label` `subject`\" so every row's action has its own name. */\nexport function RowAction({ label, subject, icon: Icon, variant = \"ghost\", size = \"sm\", className, ...props }: RowActionProps) {\n // -my-1.5 lets the 32px button sit in the 20px line of a table row, inside the row's padding, so\n // rows with an action keep the same pitch as rows without one.\n return (\n <Button variant={variant} size={size} aria-label={`${label} ${subject}`} className={cn(\"-my-1.5\", className)} {...props}>\n {Icon && <Icon aria-hidden />}\n {label}\n </Button>\n );\n}\n","// Errors, described for a person. Anything that fails in front of someone (a load in DataView, an\n// action in AsyncButton) says what happened in a sentence, in the product's words, not the\n// developer's: `HttpError`'s own message (\"409 Conflict from /api/bookings\") is for logs. Loads\n// and actions share HttpError's status sentences, so the same failure reads the same everywhere,\n// and differ only in what is true afterwards: a failed load changed nothing, while a failed action\n// may have reached the server, so its sentence does not promise that.\n//\n// A server's own reason beats the status text (strata-react issue #42, from python-app-template).\n// FastAPI and most JSON APIs say why a 4xx happened in the body (`{\"detail\": \"the data folder must\n// be an absolute path\"}`), and a client that drops it has to repeat every server rule to show the\n// person anything better than \"Bad Request\", which drifts and cannot cover rules only the server\n// can check. So `fetchJson` reads an error response's body, `HttpError` keeps it with the reason\n// and any per-field messages found in it, and the sentences below use the reason for a 4xx.\n// Per-field messages (FastAPI's 422 `detail: [{loc, msg}]`) are keyed by field name, so\n// `useAsyncAction`'s `fieldErrors` can put each under its `Field`, never in a toast. A 5xx body is\n// not shown: it is usually a stack trace or a proxy's HTML page, and is kept on `body` for logs.\n\n/** What `readErrorBody` finds in an error response: the server's sentence, and messages per field. */\nexport type ErrorBody = {\n /** Why the server refused, in its own words. */\n reason?: string;\n /** Messages for individual fields, keyed by field name (`\"name\"`, `\"address.city\"`). */\n fields?: Record<string, string>;\n};\n\n/** Thrown by `fetchJson` on a non-2xx response; carries the status, the response body and the server's reason for `describeHttpError` and `describeActionError`. */\nexport class HttpError extends Error {\n /** The server's sentence for why it refused, from the body (`detail`, `message`, `error`), if it gave one. */\n readonly reason?: string;\n /** Messages for individual fields from the body (FastAPI's 422 `detail: [{loc, msg}]`), keyed by field name. Empty when there are none. */\n readonly fieldErrors: Readonly<Record<string, string>>;\n\n constructor(\n readonly status: number,\n readonly statusText: string,\n readonly url: string,\n /** The response body: parsed JSON when it was JSON, else its text; undefined when empty. */\n readonly body?: unknown,\n found: ErrorBody = readErrorBody(body),\n ) {\n super(`${status} ${statusText} from ${url}`);\n this.name = \"HttpError\";\n this.reason = found.reason;\n this.fieldErrors = found.fields ?? {};\n }\n}\n\nconst text = (value: unknown) => (typeof value === \"string\" && value.trim() ? value.trim() : undefined);\n\n/** A field name from a FastAPI/pydantic `loc`: the path after where it came from (`[\"body\", \"address\", \"city\"]` is `\"address.city\"`). */\nfunction fieldName(loc: unknown) {\n if (!Array.isArray(loc)) return undefined;\n const path = loc.map(String);\n if ([\"body\", \"query\", \"path\", \"header\", \"cookie\", \"form\"].includes(path[0]) && path.length > 1) path.shift();\n return path.join(\".\") || undefined;\n}\n\n/**\n * The default reading of an error body, for the shapes most JSON APIs use: `{ detail: \"…\" }`\n * (FastAPI), `{ message: \"…\" }`, `{ error: \"…\" }` or `{ error: { message: \"…\" } }` for the reason,\n * and FastAPI's validation list `{ detail: [{ loc, msg }] }` for per-field messages. A short\n * plain-text body (not HTML) is taken as the reason too. Pass your own to `fetchJson` for other APIs.\n */\nexport function readErrorBody(body: unknown): ErrorBody {\n if (typeof body === \"string\") {\n const t = text(body);\n return t && t.length <= 300 && !t.startsWith(\"<\") ? { reason: t } : {};\n }\n if (!body || typeof body !== \"object\") return {};\n const b = body as Record<string, unknown>;\n if (Array.isArray(b.detail)) {\n const fields: Record<string, string> = {};\n for (const item of b.detail as unknown[]) {\n const entry = item as { loc?: unknown; msg?: unknown } | null;\n const name = fieldName(entry?.loc);\n const msg = text(entry?.msg);\n if (name && msg && !fields[name]) fields[name] = msg;\n }\n return { fields };\n }\n const nested = b.error && typeof b.error === \"object\" ? text((b.error as Record<string, unknown>).message) : undefined;\n return { reason: text(b.detail) ?? text(b.message) ?? text(b.error) ?? nested };\n}\n\n/** Writes an error for a person: what happened, in a sentence. A product passes its own words. */\nexport type DescribeError = (error: unknown) => string;\n\n/** A sentence ends once: \"…absolute path\" and \"…absolute path.\" both end in one full stop. */\nconst sentence = (s: string) => (/[.!?…]$/.test(s) ? s : `${s}.`);\n\nfunction refused(error: HttpError) {\n if (error.reason) return `The request was refused: ${sentence(error.reason)}`;\n if (Object.keys(error.fieldErrors).length) return \"The request was refused: check the fields marked.\";\n return `The request was refused (${error.status}): ${error.statusText || \"no reason given\"}.`;\n}\n\n/** The default `DescribeError` for loads: the HTTP status in a sentence (with the server's reason for a 4xx), else the error's message, else a plain fallback. */\nexport const describeHttpError: DescribeError = (error) =>\n error instanceof HttpError\n ? error.status >= 500\n ? `The server could not answer (${error.status}). Nothing was changed.`\n : refused(error)\n : error instanceof Error && error.message\n ? error.message\n : \"The data could not be loaded. Nothing was changed.\";\n\n/** The default for `useAsyncAction`: the HTTP status in a sentence (with the server's reason for a 4xx), else the thrown Error's message, else undefined (the retry label alone). */\nexport const describeActionError = (error: unknown): string | undefined =>\n error instanceof HttpError\n ? error.status >= 500\n ? `The server could not answer (${error.status}).`\n : refused(error)\n : error instanceof Error && error.message\n ? error.message\n : undefined;\n\n/** Messages for individual fields carried by what was thrown: an `HttpError`'s `fieldErrors`, else none. */\nexport function fieldErrorsOf(error: unknown): Readonly<Record<string, string>> {\n return error instanceof HttpError ? error.fieldErrors : {};\n}\n"],"mappings":";;;;;;AAmBA,IAAa,iBAAiB,IAC5B,oRACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,SAAS;GACT,WAAW;GACX,OAAO;GACP,aAAa;GACb,MAAM;EACR;EACA,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,MAAM;GACN,WAAW;EACb;CACF;CACA,iBAAiB;EAAE,SAAS;EAAW,MAAM;CAAU;AACzD,CACF;;;;;;;AAkBA,SAAgBA,SAAO,EAAE,WAAW,SAAS,MAAM,OAAO,UAAU,UAAU,UAAU,GAAG,SAAsB;CAG/G,OACE,oBAACC,QAAD;EACQ;EACN,YAAY;EACZ,gBAAc,WAAW;EACzB,WAAW,GAAG,eAAe;GAAE;GAAS;EAAK,CAAC,GAAG,SAAS;EAC1D,GAAK;EAGJ,UAAA,OAAO,aAAa,WAAW,oBAAC,QAAD;GAAM,WAAU;GAAoB;EAAe,CAAA,IAAI;CAC7E,CAAA;AAEhB;;AAgBA,SAAgB,WAAW,EAAE,MAA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Aa,uBAAuB,UAClC,iBAAiB,YACb,MAAM,UAAU,MACd,gCAAgC,MAAM,OAAO,MAC7C,QAAQ,KAAK,IACf,iBAAiB,SAAS,MAAM,UAC9B,MAAM,UACN,KAAA;;AAGR,SAAgB,cAAc,OAAkD;CAC9E,OAAO,iBAAiB,YAAY,MAAM,cAAc,CAAC;AAC3D"}
@@ -1,9 +1,9 @@
1
1
  import { clsx } from "clsx";
2
2
  import { extendTailwindMerge } from "tailwind-merge";
3
3
  import * as React from "react";
4
- import { Label, Radio, RadioGroup } from "react-aria-components";
5
- import { CircleAlert } from "lucide-react";
6
- import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { Label, Radio, RadioGroup, Tooltip, TooltipTrigger } from "react-aria-components";
5
+ import { ArrowBigUp, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ChevronUp, CircleAlert, Command, Option } from "lucide-react";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  // src/lib/utils.ts
8
8
  var typeSteps = [
9
9
  "caption",
@@ -28,6 +28,75 @@ var twMerge = extendTailwindMerge({ extend: {
28
28
  function cn(...inputs) {
29
29
  return twMerge(clsx(inputs));
30
30
  }
31
+ // src/components/key-glyphs.tsx
32
+ var GLYPHS = {
33
+ "←": {
34
+ icon: ArrowLeft,
35
+ name: "left arrow"
36
+ },
37
+ "→": {
38
+ icon: ArrowRight,
39
+ name: "right arrow"
40
+ },
41
+ "↑": {
42
+ icon: ArrowUp,
43
+ name: "up arrow"
44
+ },
45
+ "↓": {
46
+ icon: ArrowDown,
47
+ name: "down arrow"
48
+ },
49
+ "⌘": {
50
+ icon: Command,
51
+ name: "Command"
52
+ },
53
+ "⌃": {
54
+ icon: ChevronUp,
55
+ name: "Control"
56
+ },
57
+ "⌥": {
58
+ icon: Option,
59
+ name: "Option"
60
+ },
61
+ "⇧": {
62
+ icon: ArrowBigUp,
63
+ name: "Shift"
64
+ }
65
+ };
66
+ var PATTERN = new RegExp(`([${Object.keys(GLYPHS).join("")}])`);
67
+ /** Key text with its arrows and modifier symbols drawn as icons, each with its name for screen readers. Other text is left as it is. */
68
+ function KeyText({ children }) {
69
+ return /* @__PURE__ */ jsx(Fragment, { children: children.split(PATTERN).map((part, i) => {
70
+ const glyph = GLYPHS[part];
71
+ if (!glyph) return part ? /* @__PURE__ */ jsx(React.Fragment, { children: part }, i) : null;
72
+ const Icon = glyph.icon;
73
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
74
+ "aria-hidden": true,
75
+ className: "inline size-[1em] align-[-0.125em]"
76
+ }), /* @__PURE__ */ jsxs("span", {
77
+ className: "sr-only",
78
+ children: [glyph.name, " "]
79
+ })] }, i);
80
+ }) });
81
+ }
82
+ // src/components/tooltip.tsx
83
+ /** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */
84
+ function Tooltip$1({ label, hint, children, side = "top", delay = 500, open, className }) {
85
+ return /* @__PURE__ */ jsxs(TooltipTrigger, {
86
+ delay,
87
+ closeDelay: 0,
88
+ isOpen: open,
89
+ children: [children, /* @__PURE__ */ jsxs(Tooltip, {
90
+ placement: side,
91
+ offset: 6,
92
+ className: cn("layer-tip enter-overlay max-w-xs rounded-control bg-foreground px-2 py-1 type-caption text-background", className),
93
+ children: [label, hint != null && /* @__PURE__ */ jsx("span", {
94
+ className: "ml-2 opacity-70",
95
+ children: typeof hint === "string" ? /* @__PURE__ */ jsx(KeyText, { children: hint }) : hint
96
+ })]
97
+ })]
98
+ });
99
+ }
31
100
  // src/lib/control.ts
32
101
  /** The height class of each control size. */
33
102
  var controlHeight = {
@@ -173,6 +242,6 @@ function ChoiceGroup({ legend, name, choices, value, onChange, error }) {
173
242
  ]
174
243
  });
175
244
  }
176
- export { Textarea as a, cn as c, NativeSelect as i, typeSteps as l, Field as n, useFieldControl as o, Input$1 as r, controlHeight as s, ChoiceGroup as t };
245
+ export { Textarea as a, Tooltip$1 as c, typeSteps as d, NativeSelect as i, KeyText as l, Field as n, useFieldControl as o, Input$1 as r, controlHeight as s, ChoiceGroup as t, cn as u };
177
246
 
178
- //# sourceMappingURL=field-7Z4N5r5g.js.map
247
+ //# sourceMappingURL=field-DeKNvGox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-DeKNvGox.js","names":["_Fragment","Tooltip","AriaTooltip","Input"],"sources":["../src/lib/utils.ts","../src/components/key-glyphs.tsx","../src/components/tooltip.tsx","../src/lib/control.ts","../src/components/field.tsx"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\n// Teach tailwind-merge that `type-*` utilities are font sizes. Without this, cn() cannot tell\n// `type-label` from a colour and may drop one of two classes that both survive in CSS; with stock\n// shadcn the same bug drops `text-muted-foreground` next to a custom `text-*` size.\nexport const typeSteps = [\"caption\", \"label\", \"body-sm\", \"body\", \"heading\", \"title\", \"figure\", \"display\"] as const;\n\n// The radius roles too, so `rounded-pill` at a call site (a round avatar Thumbnail) replaces a\n// component's `rounded-control` instead of both surviving and CSS order picking one.\nconst radiusRoles = [\"control\", \"surface\", \"overlay\", \"pill\"] as const;\n\nconst twMerge = extendTailwindMerge({\n extend: {\n theme: { radius: [...radiusRoles] },\n classGroups: {\n \"font-size\": [{ type: [...typeSteps] }],\n },\n },\n});\n\n/** clsx + tailwind-merge, taught that `type-*` utilities are font sizes and `rounded-control`, `-surface`, `-overlay`, `-pill` are radii. */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import * as React from \"react\";\nimport { ArrowBigUp, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ChevronUp, Command, Option, type LucideIcon } from \"lucide-react\";\n\n// Keys drawn as icons where a font cannot be trusted to have them (strata-react issue #136, from\n// strata-vid). The arrows (← → ↑ ↓) and the macOS modifiers (⌘ ⌃ ⌥ ⇧) are outside the latin subset of\n// the bundled variable fonts, so a legend drew them in whatever face the machine had: different on\n// every machine, and `strata-visual` fails a shot with text in a system font. Lucide's icons are\n// SVG, so they draw the same everywhere and take the text colour. Each is hidden from assistive\n// technology and followed by its name in screen-reader-only text (\"left arrow\", \"Command\"), so the\n// keycap reads as words rather than as a symbol each screen reader pronounces its own way.\n// Checked: React Aria has no keyboard-shortcut display beyond the `Keyboard` slot (which only\n// labels the text it is given), so this is the glyph mapping the slot's content needs.\n\nconst GLYPHS: Record<string, { icon: LucideIcon; name: string }> = {\n \"←\": { icon: ArrowLeft, name: \"left arrow\" },\n \"→\": { icon: ArrowRight, name: \"right arrow\" },\n \"↑\": { icon: ArrowUp, name: \"up arrow\" },\n \"↓\": { icon: ArrowDown, name: \"down arrow\" },\n \"⌘\": { icon: Command, name: \"Command\" },\n \"⌃\": { icon: ChevronUp, name: \"Control\" },\n \"⌥\": { icon: Option, name: \"Option\" },\n \"⇧\": { icon: ArrowBigUp, name: \"Shift\" },\n};\nconst PATTERN = new RegExp(`([${Object.keys(GLYPHS).join(\"\")}])`);\n\n/** Key text with its arrows and modifier symbols drawn as icons, each with its name for screen readers. Other text is left as it is. */\nexport function KeyText({ children }: { children: string }) {\n return (\n <>\n {children.split(PATTERN).map((part, i) => {\n const glyph = GLYPHS[part];\n if (!glyph) return part ? <React.Fragment key={i}>{part}</React.Fragment> : null;\n const Icon = glyph.icon;\n return (\n <React.Fragment key={i}>\n <Icon aria-hidden className=\"inline size-[1em] align-[-0.125em]\" />\n <span className=\"sr-only\">{glyph.name} </span>\n </React.Fragment>\n );\n })}\n </>\n );\n}\n","import { KeyText } from \"./key-glyphs\";\nimport * as React from \"react\";\nimport { Tooltip as AriaTooltip, TooltipTrigger } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\n\n// A tooltip names or explains a control; it is never the only place information lives. React Aria\n// opens it on keyboard focus as well as hover (strata-vid's old hover-only tooltip hid it from\n// keyboard users), after a short delay so a pointer crossing a toolbar does not flash every tip,\n// and shares the delay between neighbouring tips. It holds only words: anything interactive is a\n// Popover. It is portalled to the body, so a parent's overflow cannot clip it, and sits on the\n// `layer-tip` layer above dialogs, since it can name a control inside one.\n//\n// `IconButton` uses it for its required `label`, so the name and the visible hint come from one\n// string and cannot drift.\n\n/** Props for `Tooltip`. */\nexport type TooltipProps = {\n /** The words: a control's name or one sentence about it. Not interactive. */\n label: React.ReactNode;\n /** A shortcut or other aside shown after the label, muted (\"Ctrl+Z\"). */\n hint?: React.ReactNode;\n /** The element that gets the tip. It must be a React Aria pressable or focusable (a Strata `Button` is). */\n children: React.ReactElement;\n /** Which side of the trigger it prefers; it flips when there is no room. Default `top`. */\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n /** Milliseconds before it opens on hover. Focus opens it at once. Default 500. */\n delay?: number;\n /** A controlled open state, for a story or test that needs it shown. */\n open?: boolean;\n className?: string;\n};\n\n/** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */\nexport function Tooltip({ label, hint, children, side = \"top\", delay = 500, open, className }: TooltipProps) {\n return (\n <TooltipTrigger delay={delay} closeDelay={0} isOpen={open}>\n {children}\n <AriaTooltip\n placement={side}\n offset={6}\n className={cn(\"layer-tip enter-overlay max-w-xs rounded-control bg-foreground px-2 py-1 type-caption text-background\", className)}\n >\n {label}\n {hint != null && <span className=\"ml-2 opacity-70\">{typeof hint === \"string\" ? <KeyText>{hint}</KeyText> : hint}</span>}\n </AriaTooltip>\n </TooltipTrigger>\n );\n}\n","// Control sizes, one set for everything that sits in a toolbar or a property row: `default` is\n// --control-h and `sm` is --control-h-sm, so two controls of the same size name are the same height\n// in every density (issue #117). Button, IconButton, Toggle, ToggleGroup, Input, NativeSelect and\n// NumberField all take it as `size`.\n\n/** The size names a control takes: `default` (--control-h) or `sm` (--control-h-sm). */\nexport type ControlSize = \"default\" | \"sm\";\n\n/** The height class of each control size. */\nexport const controlHeight: Record<ControlSize, string> = {\n default: \"h-(--control-h)\",\n sm: \"h-(--control-h-sm)\",\n};\n","import * as React from \"react\";\nimport { CircleAlert } from \"lucide-react\";\nimport { Label, Radio, RadioGroup } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\nimport { controlHeight, type ControlSize } from \"../lib/control\";\n\n// Field owns the wiring a generated form usually forgets: the label's htmlFor, aria-describedby\n// pointing at the hint and the error, and aria-invalid. Controls read it from context, so a control\n// inside a Field cannot end up unlabelled or silently invalid.\n//\n// A one-field form (\"paste a link, Add\", a search box, \"invite by email\") puts its button on the\n// control's row, not beside the whole field (strata-react issue #46, from the Tubes Library\n// screen): in a plain flex row the button lines up with label, hint and error together and drifts\n// off the input whenever one shows. `action` is drawn on the control's row, both at --control-h,\n// with the hint and the error under both across the full width. It wraps under the control only\n// when the row cannot keep the control 10rem wide beside it (a 250px inspector body keeps a Reset beside its slider, issue #116): on a phone a short \"Add\" stays on the\n// row, as a search box's button does, and a long label or a narrow column wraps. The error and hint stay the input's description; the\n// button is not described by them. Field messages for a form come from `useAsyncAction`'s\n// `fieldErrors` (its `validate`, or the server's 422), so no `problem` state is kept by hand.\n\ntype FieldState = { id: string; label: string; describedBy?: string; invalid: boolean; report: (message: string | undefined) => void };\nconst FieldContext = React.createContext<FieldState | null>(null);\n\n// A control that checks what was typed (a number field, a colour field) reports its own message to\n// the Field it sits in, which draws it as the field's error, so a value outside the limits is\n// explained in the same place and way as a server's 422, with nothing for the screen to wire.\n// `error` from the screen wins over the control's own. Outside a Field `report` does nothing and\n// the control marks itself invalid without a message.\n/** @internal The surrounding Field, and where a control reports its own message. */\nexport function useFieldControl() {\n const field = React.useContext(FieldContext);\n return { field, report: field?.report ?? noReport };\n}\n\nfunction useField(id?: string) {\n const field = React.useContext(FieldContext);\n return {\n // Inside a Field the Field's id wins, so the label always points at the control. To choose the\n // id yourself, pass it to Field.\n id: field?.id ?? id,\n \"aria-describedby\": field?.describedBy,\n \"aria-invalid\": field?.invalid || undefined,\n };\n}\n\nconst noReport = () => {};\n\nexport type FieldProps = {\n label: string;\n /** The control's id, when the page needs a known one (an anchor, a test). Generated otherwise. */\n id?: string;\n /** What the person needs to know before typing, such as limits or units. */\n hint?: React.ReactNode;\n /** What went wrong and how to fix it, in one sentence. Shown under the control, never in a toast. */\n error?: string;\n /** A button on the control's row, for a one-field form (an `AsyncButton` \"Add\"). The hint and error run under both; on a narrow screen it wraps under the control. */\n action?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n};\n\n/** A labelled form field: wires the label, hint, error, `aria-describedby` and `aria-invalid` into the one control it wraps. */\nexport function Field({ label, id: idProp, hint, error, action, children, className }: FieldProps) {\n const generated = React.useId();\n const id = idProp ?? generated;\n const hintId = hint ? `${id}-hint` : undefined;\n const [reported, report] = React.useState<string>();\n const shown = error ?? reported;\n const errorId = shown ? `${id}-error` : undefined;\n const describedBy = [errorId, hintId].filter(Boolean).join(\" \") || undefined;\n\n return (\n <FieldContext.Provider value={{ id, label, describedBy, invalid: Boolean(shown), report }}>\n <div className={cn(\"grid min-w-0 content-start gap-1.5\", className)}>\n <label htmlFor={id} className=\"type-label text-foreground\">\n {label}\n </label>\n {action ? (\n <div className=\"flex flex-wrap items-start gap-2\">\n <div className=\"min-w-40 flex-1\">{children}</div>\n <div className=\"flex shrink-0 items-center\">{action}</div>\n </div>\n ) : (\n children\n )}\n {shown && (\n <p id={errorId} className=\"flex items-start gap-1.5 type-body-sm text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n {shown}\n </p>\n )}\n {hint && (\n <p id={hintId} className=\"type-body-sm text-muted-foreground\">\n {hint}\n </p>\n )}\n </div>\n </FieldContext.Provider>\n );\n}\n\nconst control =\n \"w-full min-w-0 rounded-control border border-input bg-background px-3 type-body text-foreground transition-state placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-70 aria-invalid:border-danger\";\n\n/** A text input that picks up its id and descriptions from the surrounding `Field`. `size=\"sm\"` is --control-h-sm; the native `size` (a width in characters) is not passed on. */\nexport function Input({ className, id, size = \"default\", ...props }: Omit<React.ComponentProps<\"input\">, \"size\"> & { size?: ControlSize }) {\n return <input {...useField(id)} className={cn(control, controlHeight[size], className)} {...props} />;\n}\n\n/** A multi-line input that picks up its id and descriptions from the surrounding `Field`. */\nexport function Textarea({ className, id, ...props }: React.ComponentProps<\"textarea\">) {\n return <textarea {...useField(id)} className={cn(control, \"min-h-24 py-2\", className)} {...props} />;\n}\n\n// A native select, styled. For short option lists on a touch screen it beats a custom listbox:\n// the platform picker, typeahead and form autofill all work with no code.\n/** The platform select, styled. The default for short lists, especially on touch screens. `size=\"sm\"` is --control-h-sm. */\nexport function NativeSelect({ className, id, size = \"default\", ...props }: Omit<React.ComponentProps<\"select\">, \"size\"> & { size?: ControlSize }) {\n return <select {...useField(id)} className={cn(control, controlHeight[size], \"pr-8\", className)} {...props} />;\n}\n\n// Radio choices: React Aria's RadioGroup (a group named by its label, arrow-key movement, one tab\n// stop), and each row wraps its control so the whole row is one hit target. The dot is drawn from\n// tokens, not the platform's accent-color radio.\nexport type Choice = { value: string; label: string; detail?: string };\n\n/** Radio choices in a fieldset with a legend; each whole row is the hit target. For 2 to 5 options that each need a sentence. */\nexport function ChoiceGroup({\n legend,\n name,\n choices,\n value,\n onChange,\n error,\n}: {\n legend: string;\n name: string;\n choices: Choice[];\n value: string;\n onChange: (value: string) => void;\n error?: string;\n}) {\n const errorId = React.useId();\n return (\n <RadioGroup name={name} value={value} onChange={onChange} aria-describedby={error ? errorId : undefined} className=\"grid gap-2\">\n <Label className=\"mb-1.5 type-label text-foreground\">{legend}</Label>\n {choices.map((c) => (\n <Radio key={c.value} value={c.value} className=\"group flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1\">\n <span\n aria-hidden\n className=\"mt-1 grid size-4 shrink-0 place-items-center rounded-pill border border-input bg-background transition-state group-selected:border-primary group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-ring\"\n >\n <span className=\"size-2 rounded-pill bg-primary opacity-0 group-selected:opacity-100\" />\n </span>\n <span className=\"grid\">\n <span className=\"type-body\">{c.label}</span>\n {c.detail && <span className=\"type-body-sm text-muted-foreground\">{c.detail}</span>}\n </span>\n </Radio>\n ))}\n {error && (\n <p id={errorId} className=\"flex items-start gap-1.5 type-body-sm text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n {error}\n </p>\n )}\n </RadioGroup>\n );\n}\n"],"mappings":";;;;;;;AAMA,IAAa,YAAY;CAAC;CAAW;CAAS;CAAW;CAAQ;CAAW;CAAS;CAAU;AAAS;AAMxG,IAAM,UAAU,oBAAoB,EAClC,QAAQ;CACN,OAAO,EAAE,QAAQ,CAAC,GAAG;EAJJ;EAAW;EAAW;EAAW;CAI7B,CAAW,EAAE;CAClC,aAAa,EACX,aAAa,CAAC,EAAE,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC,EACxC;AACF,EACF,CAAC;;AAGD,SAAgB,GAAG,GAAG,QAAsB;CAC1C,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;ACXA,IAAM,SAA6D;CACjE,KAAK;EAAE,MAAM;EAAW,MAAM;CAAa;CAC3C,KAAK;EAAE,MAAM;EAAY,MAAM;CAAc;CAC7C,KAAK;EAAE,MAAM;EAAS,MAAM;CAAW;CACvC,KAAK;EAAE,MAAM;EAAW,MAAM;CAAa;CAC3C,KAAK;EAAE,MAAM;EAAS,MAAM;CAAU;CACtC,KAAK;EAAE,MAAM;EAAW,MAAM;CAAU;CACxC,KAAK;EAAE,MAAM;EAAQ,MAAM;CAAS;CACpC,KAAK;EAAE,MAAM;EAAY,MAAM;CAAQ;AACzC;AACA,IAAM,UAAU,IAAI,OAAO,KAAK,OAAO,KAAK,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,GAAG;;AAGhE,SAAgB,QAAQ,EAAE,YAAkC;CAC1D,OACE,oBAAAA,UAAA,EAAA,UACG,SAAS,MAAM,OAAO,CAAC,CAAC,KAAK,MAAM,MAAM;EACxC,MAAM,QAAQ,OAAO;EACrB,IAAI,CAAC,OAAO,OAAO,OAAO,oBAAC,MAAM,UAAP,EAAA,UA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AAW,GAAG,SAAS,iBAAiB,SAAS;EAAG,GAAI;CAAQ,CAAA;AACrG;;AAKA,SAAgB,aAAa,EAAE,WAAW,IAAI,OAAO,WAAW,GAAG,SAAgF;CACjJ,OAAO,oBAAC,UAAD;EAAQ,GAAI,SAAS,EAAE;EAAG,WAAW,GAAG,SAAS,cAAc,OAAO,QAAQ,SAAS;EAAG,GAAI;CAAQ,CAAA;AAC/G;;AAQA,SAAgB,YAAY,EAC1B,QACA,MACA,SACA,OACA,UACA,SAQC;CACD,MAAM,UAAU,MAAM,MAAM;CAC5B,OACE,qBAAC,YAAD;EAAkB;EAAa;EAAiB;EAAU,oBAAkB,QAAQ,UAAU,KAAA;EAAW,WAAU;EAAnH,UAAA;GACE,oBAAC,OAAD;IAAO,WAAU;IAAqC,UAAA;GAAc,CAAA;GACnE,QAAQ,KAAK,MACZ,qBAAC,OAAD;IAAqB,OAAO,EAAE;IAAO,WAAU;IAA/C,UAAA,CACE,oBAAC,QAAD;KACE,eAAA;KACA,WAAU;KAEV,UAAA,oBAAC,QAAD,EAAM,WAAU,sEAAuE,CAAA;IACnF,CAAA,GACN,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACE,oBAAC,QAAD;MAAM,WAAU;MAAa,UAAA,EAAE;KAAY,CAAA,GAC1C,EAAE,UAAU,oBAAC,QAAD;MAAM,WAAU;MAAsC,UAAA,EAAE;KAAa,CAAA,CAC9E;IACD,CAAA,CAAA;GAXK,GAAA,EAAE,KAWP,CACR;GACA,SACC,qBAAC,KAAD;IAAG,IAAI;IAAS,WAAU;IAA1B,UAAA,CACE,oBAAC,aAAD;KAAa,eAAA;KAAY,WAAU;IAA0B,CAAA,GAC5D,KACA;;EAEK;;AAEhB"}
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export { CompositionBar, type CompositionBarProps, type CompositionPart } from '
29
29
  export { LinkCard, LinkCardList, type LinkCardProps } from './components/link-card';
30
30
  export { DataView, EmptyState, LoadError, Skeleton, StaleNotice, type Load, type LoadFailure, type Stale } from './components/data-view';
31
31
  export { NumberField, Slider, ColorField, type NumberFieldProps, type SliderProps, type ColorFieldProps, type RangeProps } from './components/value-controls';
32
+ export { SecretField, type SecretFieldProps, type SecretTestResult } from './components/secret-field';
32
33
  export { Alert, type AlertProps } from './components/alert';
33
34
  export { toast, toastTimeout, StrataToastRegion, type ToastContentProps, type StrataToastRegionProps } from './components/toast';
34
35
  export { useClientWork, type ClientWork, type WorkContext, type WorkPhase } from './lib/client-work';
@@ -38,7 +39,7 @@ export { DataTable, TableSkeleton, parseSort, serialiseSort, type CellValue, typ
38
39
  export { MediaPlayer, useMediaElement, useAttachedSource, SPEECH_RATES, type MediaPlayerProps, type MediaElementState, type MediaElementOptions, type MediaWindow, type StreamContext, type StreamAttachment, type SourceAttacher, type MediaProblem, type MediaSource, type MediaSession } from './components/media-player';
39
40
  export { useMediaSpans, SpanActions, type MediaSpanData, type SpanKind, type SpanBehaviour, type SpanOutcome, type SpanWords, type MediaSpansState } from './components/media-spans';
40
41
  export { TranscriptView, type TranscriptViewProps, type TranscriptSeek } from './components/transcript-view';
41
- export { phraseAt, wordAt, type TranscriptGroup, type TranscriptPhrase, type TranscriptWord } from './lib/transcript';
42
+ export { phraseAt, wordAt, isDoubtful, phraseDoubtful, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptWord } from './lib/transcript';
42
43
  export { Waveform, type WaveformProps, type WaveformMark, type WaveformMarkKind, type WaveformSpan, type WaveformTone } from './components/waveform';
43
44
  export { resamplePeaks, toPeakPair, peaksFromAudio, type WaveformPeaks, type PeakPair, type DecodedAudio } from './lib/waveform';
44
45
  export { MediaGroup, PlayWindowButton, joinMediaGroup, type PlayWindowButtonProps } from './components/media-group';
@@ -50,7 +51,8 @@ export { FileButton, FileDropZone, FileOutcomes, MissingFile } from './component
50
51
  export { useFileIntake, matchesAccept, type FileIntake, type FileIntakeOptions, type FileOutcome } from './lib/file-intake';
51
52
  export { Inspector, InspectorSection, PropertyRow, PropertyList, type InspectorProps, type InspectorSectionProps, type PropertyRowProps, type Property, type PropertyListProps } from './components/inspector';
52
53
  export { Disclosure, useExpanded, type DisclosureProps, type DisclosureOpenProps, type Expanded, type ExpandedOptions } from './components/disclosure';
53
- export { BulkBar, useSelection, type InitialSelection } from './components/selection';
54
+ export { BulkBar, useSelection, useChoices, type InitialSelection, type Choices, type ChoiceCounts } from './components/selection';
55
+ export type { Implies } from './lib/choice';
54
56
  export { SelectableGrid, type SelectableGridProps, type TileAspect, type TileSize, } from './components/selectable-grid';
55
57
  export { VirtualList } from './components/virtual-list';
56
58
  export { InfiniteList, LoadMore, type InfiniteListProps, type LoadMoreProps } from './components/infinite-list';