strata-react 2.1.11 → 2.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{field-BY42OY3g.js → field-S12YUQxn.js} +18 -1
- package/dist/field-S12YUQxn.js.map +1 -0
- package/dist/index.d.ts +138 -44
- package/dist/index.js +269 -18
- package/dist/index.js.map +1 -1
- package/dist/map.js +2 -2
- package/dist/{microphone-Db5o3SHZ.js → microphone-Bt02Ky5u.js} +2 -2
- package/dist/{microphone-Db5o3SHZ.js.map → microphone-Bt02Ky5u.js.map} +1 -1
- package/dist/panorama.js +1 -1
- package/dist/testing.js +2 -2
- package/dist/{theme-5Mb1ydlA.js → theme-kCizTI4-.js} +2 -2
- package/dist/{theme-5Mb1ydlA.js.map → theme-kCizTI4-.js.map} +1 -1
- package/dist/{value-controls-i1aGyO_3.js → value-controls-04bfBLdb.js} +2 -2
- package/dist/{value-controls-i1aGyO_3.js.map → value-controls-04bfBLdb.js.map} +1 -1
- package/package.json +1 -1
- package/dist/field-BY42OY3g.js.map +0 -1
package/README.md
CHANGED
|
@@ -249,6 +249,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
|
|
|
249
249
|
| Timeline | `Timeline`, `useTimelineZoom`, `TimelineZoomControls`, `noOverlap` | Items with a start and a length in lanes on a zoomable time axis, for media edits, bookings, rotas and plans. The timeline draws and the app decides: every move, trim, lane change, selection and current-time change is reported (`onItemChange`, `onSelect`, `onPositionChange`) and the app applies it; `validate` refuses a change with a reason shown in words while it is made. One tab stop for the items; arrows move between them, Ctrl+arrows nudge and change lane, Alt+arrows trim, the current time is its own slider, `+` `-` `0` zoom, and each change is announced ("run-02.mp4 moved to 0:13"). The ruler picks steps people write on a scale so labels never collide. Lanes take drops from outside (`dropTypes`, `onDrop` with the lane and snapped time, `validateDrop`, and React Aria's keyboard drag landing at the current time), `laneRows` makes them taller, `kindColours` fixes each kind's stripe, and the header column fits its content. Only items near the view are rendered |
|
|
250
250
|
| Answering by tap | `ChoiceGrid`, `ChoiceGridSkeleton`, `ChoiceState`; the `type-picture` step | One question, large picture tiles, one right answer, for someone who may not read yet (a child's learning game). Each tile is `open`, `wrong` (greyed, never red), `right` or `answer` (shown after the tries ran out), always with its word; a choice with no answer key ("Which one next?", a rating) uses `picked` (primary border, neutral word, `marks={{ picked }}`), which closes the grid so a slow request cannot be tapped twice; the app owns the answer key. Answered tiles cannot be pressed again and the grid closes once the answer shows. React Aria's `GridList`: arrows across and down, Enter answers. Tiles at least 120px (`md`) or 160px (`lg`); `stretch` shares the row out so a few tiles fill a wide screen; `beckon` pulses the open tiles one at a time in a random order until the grid closes. For a learner who cannot read a tile's word: `renderCaption` (a fitted line under the picture, "12 December"), `onHover` (say a tile when a mouse or pen comes over it) and `reading` (the tile being read aloud, lit; `useReadAloud` reads the tiles once in turn after the prompt, and stops for good at the learner's first tap) |
|
|
251
251
|
| Answering by placing | `PlaceBoard`, `PlaceState` | An answer that is an arrangement (give a number, put in order, match pairs, sort), for someone who may not read yet. Two taps: pick a piece up (`aria-pressed`, "Picked up", a blue info ring), put it in a place ("Put apple in the basket"; every place that takes it gets the same ring); tap it again to put it down, or tap its gap in the pile ("Put … back"). Or drag it there by pointer (from the press, no long press). With one place a tap moves at once, in or out (a big X on hover). `limit` caps a place: a piece put in a full one sends the one there back ("in place of 4"). The pile keeps a slot per piece and each place room for all it can hold (a lone place takes the row), so nothing moves during a round (the held word sits over its piece's foot; the Check keeps its room once locked). Same presses by touch, mouse, keyboard and screen reader; places are disabled until a piece is held, so Tab walks the pieces, then the places; focus follows a moved piece. The app owns `placement`, applies `onMove` and checks (`check` draws its big Check, `Button size="lg"` with a tick either side; `check.untilPlaced` greys it out until the pile is empty, for a round with a set number of answers); `placeState` marks a place `right` or `wrong` (neutral, never red) with its word, `locked` ends the round. Pieces 96px or more in the pile, 72px once placed; `beckon` pulses the pile's pieces one at a time while none is held; `stretch` shares the pile's and places' rows out; a picture never outgrows its tile. `renderCaption`, `onHover`, `onHoverPlace` and `reading` as on `ChoiceGrid` |
|
|
252
|
+
| Telling the time | `ClockFace`, `clockWords` | An analogue clock showing one time, as a picture named with the time in words (`label` to name it otherwise when the time is the answer). The hour hand is short, thick and in the ink colour, the minute hand long and in the primary colour, and the hour hand moves part way to the next number as the minutes pass. `numbers` draws all twelve, the `quarters` or `none`, and `minuteMarks` the sixty small marks; it fills its width. `clockWords(h, m)` says a time as UK English does: "three o’clock", "half past three", "quarter to four", "twenty-five past ten", "seven minutes to four" |
|
|
252
253
|
| Seeing for a moment | `Glimpse`, `useCountdown` | Something shown briefly and then hidden ("How many did you see?"). A 3-2-1 (`count`) before every look, then the content for `ms` with a bar under it that empties as the time goes (`drain`), then hidden with its room kept, so nothing under it moves. Changing `again` shows it again, count and timer included (after a wrong answer); `peeks` offers that many looks again on a "Look again" button in the empty box, gone once used. `onLook` reports each look and why (`first`, `again`, `peek`). `useCountdown(running, seconds, onDone, run, { hold })` is the whole-second count on its own (an auto Next); `hold: useSpeaking()` makes the end wait, on 1, until the words have been said too (given up after `holdAtMost`, 10 s) |
|
|
253
254
|
| Sortable list | `SortableList` | Reorder a list and move items between lists, by pointer and by keyboard. React Aria's `GridList` with `useDragAndDrop` (no `@dnd-kit`): a grip per row is the drag handle, so clicking a row selects it and its own actions still work; Enter on the grip picks up, arrows and Tab choose a position or list, Enter drops, Escape cancels, with React Aria's screen-reader announcements. Items carry a kind (`getKind`); a list takes the kinds in `accepts` and says why it refuses another (`refuses`, shown with an icon while that kind is dragged over it). The list never changes the data: `onReorder` and `onInsert` report the move and the app applies it, undoably |
|
|
254
255
|
| Drag source | `DragSource` | A row that is dragged onto a drop target elsewhere (a `Timeline` lane), by pointer or from the keyboard. React Aria's `useDrag` with a drag button: a grip named "Drag <label>" picks it up with Enter, Tab moves between targets that take its types, Enter drops, Escape cancels, with React Aria's announcements; the pointer can pick up the whole row and the row's own buttons still work. `items` returns the drag's data (`DragData`, a type to a value), read by the target |
|
|
@@ -129,6 +129,23 @@ function createFormat(locale, options = {}) {
|
|
|
129
129
|
/** A figure in short form for counts that run to thousands: `format.compact(1234)` is "1.2k" in en-GB, "1.2K" in en-US. */
|
|
130
130
|
compact,
|
|
131
131
|
/**
|
|
132
|
+
* A monetary amount via `Intl.NumberFormat` with narrow currency symbol (`"$1.25"`, `"£4.50"`,
|
|
133
|
+
* or `format.currency(0.0042, { decimals: 4 })` → `"$0.0042"`). Unknown (`null`, `undefined`,
|
|
134
|
+
* `NaN`, non-finite) prints the placeholder.
|
|
135
|
+
*/
|
|
136
|
+
currency: (value, { currency = "USD", decimals } = {}) => {
|
|
137
|
+
if (value == null || !Number.isFinite(value)) return missing;
|
|
138
|
+
return new Intl.NumberFormat(locale, {
|
|
139
|
+
style: "currency",
|
|
140
|
+
currency,
|
|
141
|
+
currencyDisplay: "narrowSymbol",
|
|
142
|
+
...decimals !== void 0 ? {
|
|
143
|
+
minimumFractionDigits: decimals,
|
|
144
|
+
maximumFractionDigits: decimals
|
|
145
|
+
} : {}
|
|
146
|
+
}).format(value);
|
|
147
|
+
},
|
|
148
|
+
/**
|
|
132
149
|
* How long ago (or how far ahead) a time is, in the largest unit it reaches:
|
|
133
150
|
* "3 weeks ago", "yesterday", "in 2 hours", "now" under a minute. Pass `now` in tests.
|
|
134
151
|
*/
|
|
@@ -503,4 +520,4 @@ function ChoiceGroupView({ legend, name, choices, value, onChange, error }) {
|
|
|
503
520
|
}
|
|
504
521
|
|
|
505
522
|
export { Textarea as a, useSearchParam as c, createFormat as d, format as f, NativeSelect as i, MISSING as l, Field as n, useFieldControl as o, toDate as p, Input$1 as r, controlHeight as s, ChoiceGroup as t, NBSP as u };
|
|
506
|
-
//# sourceMappingURL=field-
|
|
523
|
+
//# sourceMappingURL=field-S12YUQxn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-S12YUQxn.js","names":["Input"],"sources":["../src/lib/format.ts","../src/lib/search-param.ts","../src/lib/control.ts","../src/components/field.tsx"],"sourcesContent":["// Every number and date on screen goes through Intl, once, here. Units are joined with a\n// non-breaking space so \"212 °C\" never wraps between figure and unit. A product that is not\n// en-GB calls createFormat with its locale once and exports the result from its own lib.\n//\n// The number formatters are callable (`format.integer(n)`) because that is the form people reach\n// for (strata-react issue #12), and they keep Intl's methods (`format.integer.format(n)`,\n// `formatToParts`, `resolvedOptions`) so existing calls and Intl knowledge still work.\n//\n// Dates follow the same shape. Every date formatter is callable with a Date, an ISO string or\n// epoch milliseconds (`format.dateTime(row.at)`), because rows arrive from an API as ISO strings\n// and an app that has to wrap each one in `new Date(...)` soon builds its own Intl.DateTimeFormat\n// beside it instead (strata-react issue #31, from the Bright Horizons History screen). An invalid\n// date throws a RangeError naming the input rather than printing \"Invalid Date\" into a row.\n// `date` and `dateTime` use Intl's medium/short styles, so the locale decides the order\n// (\"8 Nov 2026, 06:05\" in en-GB, \"Nov 8, 2026, 6:05 AM\" in en-US) and nobody hand-writes a\n// pattern. `timeZone` is optional: left out, times are the viewer's; a product that shows a place's\n// times (a kiln in one room, a shop's opening hours) passes that place's zone once.\n//\n// Tests: the non-breaking space is a real character in the DOM. Testing Library's text matchers\n// (`getByText`, `toHaveTextContent`) collapse whitespace and match \"6 pieces\", but accessible-name\n// matching (`getByRole(\"heading\", { name: \"6 pieces\" })`) compares the name exactly and does not.\n// Build the expected string with the same formatter (`{ name: format.count(6, \"piece\") }`), or\n// use a regex with `\\s` (`/6\\spieces/`), which matches U+00A0.\n//\n// A value that is not known (`null` or `undefined`: a count the source does not give, a date for\n// something never synced) prints as the placeholder, an en dash unless `createFormat`'s `missing`\n// says otherwise, from every number and date formatter (strata-react issue #47). Each screen used\n// to pick its own (\"–\", \"Never\", blank), so tables and cards disagreed. An invalid date still\n// throws: that is a bug, not a missing value.\n//\n// Three formatters came from the Tubes viewer, which wrote its own (strata-react issue #52): `ago`\n// (\"3 weeks ago\", from Intl.RelativeTimeFormat, with `now` passed in by tests), `compact` (\"1.2k\"\n// in en-GB, and `count`'s `{ compact: true }` for \"1.2k views\") and `runningTime` (\"4:05\", \"1:02:09\"), the\n// m:ss of a media player, which Intl.DurationFormat's long form is not. `share` is `percent` for a\n// part of a whole (strata-react issue #43): a part that is there never prints as \"0%\", nor a part\n// short of the whole as \"100%\".\n//\n// Four more came from a status page (strata-react issue #341, jburnhams/homepage), each written by\n// hand there because `format` had no equivalent: `bytes` in binary units (`{ binary: true }`:\n// memory is read in KiB, MiB, GiB, and `free -h` shows them, so a decimal GB reads 7% high);\n// `duration` (\"16 min\", \"3.5 h\", \"2 days\" to say how long, or `style: \"parts\"` for an uptime,\n// \"1d 1h 0m\"), which `runningTime`'s clock cannot say; `measure` (a reading and its unit, \"12.3 GB\",\n// \"41%\"); and `agoTick` (\"now\", \"−30 s\", \"−2 min\") for the axis of a history chart.\n\nexport const NBSP = \" \";\n\n/** The placeholder printed for a value that is not known: an en dash. */\nexport const MISSING = \"–\";\n\n/** The decimal byte units `format.bytes` writes. */\nexport type ByteUnit = \"B\" | \"kB\" | \"MB\" | \"GB\" | \"TB\" | \"PB\";\nconst BYTE_UNITS: readonly ByteUnit[] = [\"B\", \"kB\", \"MB\", \"GB\", \"TB\", \"PB\"];\nconst BYTE_SIZE = Object.fromEntries(BYTE_UNITS.map((u, i) => [u, 1000 ** i])) as Record<ByteUnit, number>;\n\n/** The binary byte units `format.bytes` writes with `{ binary: true }`. */\nexport type BinaryByteUnit = \"B\" | \"KiB\" | \"MiB\" | \"GiB\" | \"TiB\" | \"PiB\";\nconst BINARY_UNITS: readonly BinaryByteUnit[] = [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\"];\nconst BINARY_SIZE = Object.fromEntries(BINARY_UNITS.map((u, i) => [u, 1024 ** i])) as Record<BinaryByteUnit, number>;\nconst SIZE: Record<ByteUnit | BinaryByteUnit, number> = { ...BYTE_SIZE, ...BINARY_SIZE };\n\n/** What `format.bytes` and `format.byteUnit` take beyond the value: `{ binary: true }` for KiB, MiB, GiB (powers of 1024), or a unit to fix. A binary unit implies binary. */\nexport type BytesOptions = { binary?: boolean; unit?: ByteUnit | BinaryByteUnit };\n\nfunction chooseByteUnit(value: number, binary: boolean): ByteUnit | BinaryByteUnit {\n const units: readonly (ByteUnit | BinaryByteUnit)[] = binary ? BINARY_UNITS : BYTE_UNITS;\n return [...units].reverse().find((u) => Math.abs(value) >= SIZE[u]) ?? \"B\";\n}\n\n/** An `Intl.NumberFormat` that can also be called directly: `f(n)` is `f.format(n)`. `null` or `undefined` prints the placeholder. */\nexport type NumberFormatter = ((value: number | bigint | Intl.StringNumericLiteral | null | undefined) => string) & {\n format: (value: number | bigint | Intl.StringNumericLiteral | null | undefined) => string;\n} & Pick<Intl.NumberFormat, \"formatToParts\" | \"resolvedOptions\">;\n\n/** What a date formatter accepts: a Date, an ISO 8601 string, or epoch milliseconds. */\nexport type DateInput = Date | string | number;\n\n/** An `Intl.DateTimeFormat` that can also be called directly, with a Date, an ISO string or epoch milliseconds. */\nexport type DateFormatter = ((value: DateInput | null | undefined) => string) & {\n format: (value: DateInput | null | undefined) => string;\n formatToParts: (value: DateInput) => Intl.DateTimeFormatPart[];\n formatRange: (start: DateInput, end: DateInput) => string;\n} & Pick<Intl.DateTimeFormat, \"resolvedOptions\">;\n\n/** Options for `format.currency`. */\nexport interface CurrencyOptions {\n /** ISO 4217 currency code. Default `\"USD\"`. */\n currency?: string;\n /** Fixed fraction digits (e.g. `4` for micro-costs like API spend `\"$0.0042\"`). Left out, Intl picks the currency's default (usually 2). */\n decimals?: number;\n}\n\n/** Options shared by every date formatter one `createFormat` call makes. */\nexport interface FormatOptions {\n /** An IANA zone (\"Europe/London\", \"UTC\") to show times in. Left out, times are the viewer's own. */\n timeZone?: string;\n /** What a missing value (`null`, `undefined`) prints as. Default an en dash (`MISSING`). */\n missing?: string;\n}\n\n/** Options for `format.count`. */\nexport interface CountOptions {\n /** Write the figure compactly: \"1.2k views\". The noun still agrees with the exact count. */\n compact?: boolean;\n}\n\n/** A Date from a Date, an ISO string or epoch milliseconds; throws a RangeError naming the input when it is not a date. */\nexport function toDate(value: DateInput): Date {\n const date = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(date.getTime())) throw new RangeError(`Not a date: ${JSON.stringify(String(value))}`);\n return date;\n}\n\nfunction callableDate(df: Intl.DateTimeFormat, missing: string): DateFormatter {\n const format = (value: DateInput | null | undefined) => (value == null ? missing : df.format(toDate(value)));\n return Object.assign(format, {\n format,\n formatToParts: (value: DateInput) => df.formatToParts(toDate(value)),\n formatRange: (start: DateInput, end: DateInput) => df.formatRange(toDate(start), toDate(end)),\n resolvedOptions: () => df.resolvedOptions(),\n });\n}\n\nfunction callable(nf: Intl.NumberFormat, missing: string): NumberFormatter {\n const format = (value: number | bigint | Intl.StringNumericLiteral | null | undefined) =>\n value == null ? missing : nf.format(value);\n return Object.assign(format, {\n format,\n formatToParts: (value: number | bigint) => nf.formatToParts(value),\n resolvedOptions: () => nf.resolvedOptions(),\n });\n}\n\n// Largest first: `ago` says a span in the largest unit it fills at least once, rounded down, so\n// 13 days is \"last week\" and 20 days \"2 weeks ago\", never \"3 weeks\" too early.\nconst DAY = 86_400_000;\nconst AGO_STEPS: readonly [Intl.RelativeTimeFormatUnit, number][] = [\n [\"year\", 365 * DAY],\n [\"month\", 30 * DAY],\n [\"week\", 7 * DAY],\n [\"day\", DAY],\n [\"hour\", 3_600_000],\n [\"minute\", 60_000],\n];\n\n/** Intl formatters for one locale (and optionally one time zone): integers, decimals, percent, dates, times, units with a non-breaking space, byte sizes, and counted nouns. */\nexport function createFormat(locale: string, options: FormatOptions = {}) {\n const { timeZone, missing = MISSING } = options;\n const dates = (opts: Intl.DateTimeFormatOptions) =>\n callableDate(new Intl.DateTimeFormat(locale, { ...opts, timeZone }), missing);\n const integer = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }), missing);\n const decimal = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }), missing);\n const percent = callable(new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }), missing);\n const compact = callable(new Intl.NumberFormat(locale, { notation: \"compact\", maximumFractionDigits: 1 }), missing);\n const relative = new Intl.RelativeTimeFormat(locale, { numeric: \"auto\" });\n const plurals = new Intl.PluralRules(locale);\n const clock = dates({ hour: \"2-digit\", minute: \"2-digit\" });\n const day = dates({ weekday: \"long\", day: \"numeric\", month: \"long\" });\n const shortDay = dates({ weekday: \"short\", hour: \"2-digit\", minute: \"2-digit\" });\n const date = dates({ dateStyle: \"medium\" });\n const dateTime = dates({ dateStyle: \"medium\", timeStyle: \"short\" });\n const withUnit = (value: number, unit: string, fmt: Pick<Intl.NumberFormat, \"format\"> = integer) =>\n `${fmt.format(value)}${NBSP}${unit}`;\n return {\n locale,\n /** The zone times are shown in, or `undefined` for the viewer's own. */\n timeZone,\n /** Whole numbers with grouping: `format.integer(1222)` is \"1,222\". */\n integer,\n /** One decimal place at most: `format.decimal(3.14)` is \"3.1\". */\n decimal,\n /** A ratio as a whole percent: `format.percent(0.42)` is \"42%\". */\n percent,\n /**\n * A part's share of a whole, as `percent` but never misleading at the ends: a part above 0 that\n * rounds to 0 is \"<1%\", and one short of the whole that rounds to 100 is \">99%\".\n * `format.share(2.4 / 512)` is \"<1%\".\n */\n share: (value: number | null | undefined) => {\n if (value == null || Number.isNaN(value)) return missing;\n if (value > 0 && value < 0.005) return `<${percent.format(0.01)}`;\n if (value >= 0.995 && value < 1) return `>${percent.format(0.99)}`;\n return percent.format(value);\n },\n /** A figure in short form for counts that run to thousands: `format.compact(1234)` is \"1.2k\" in en-GB, \"1.2K\" in en-US. */\n compact,\n /**\n * A monetary amount via `Intl.NumberFormat` with narrow currency symbol (`\"$1.25\"`, `\"£4.50\"`,\n * or `format.currency(0.0042, { decimals: 4 })` → `\"$0.0042\"`). Unknown (`null`, `undefined`,\n * `NaN`, non-finite) prints the placeholder.\n */\n currency: (value: number | null | undefined, { currency = \"USD\", decimals }: CurrencyOptions = {}) => {\n if (value == null || !Number.isFinite(value)) return missing;\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n currencyDisplay: \"narrowSymbol\",\n ...(decimals !== undefined ? { minimumFractionDigits: decimals, maximumFractionDigits: decimals } : {}),\n }).format(value);\n },\n /**\n * How long ago (or how far ahead) a time is, in the largest unit it reaches:\n * \"3 weeks ago\", \"yesterday\", \"in 2 hours\", \"now\" under a minute. Pass `now` in tests.\n */\n ago: (value: DateInput | null | undefined, now: DateInput = new Date()) => {\n if (value == null) return missing;\n const diff = toDate(value).getTime() - toDate(now).getTime();\n const span = Math.abs(diff);\n for (const [unit, size] of AGO_STEPS) {\n if (span >= size) return relative.format(Math.sign(diff) * Math.floor(span / size), unit);\n }\n return relative.format(0, \"second\");\n },\n /**\n * A media running time from seconds, as a player shows it: \"4:05\", \"1:02:09\". Unknown\n * (null, negative, not finite) prints the placeholder. Set it in `tabular-nums`.\n */\n runningTime: (seconds: number | null | undefined) => {\n if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;\n const s = Math.floor(seconds);\n const two = (n: number) => String(n).padStart(2, \"0\");\n const [h, m] = [Math.floor(s / 3600), Math.floor((s % 3600) / 60)];\n return h > 0 ? `${h}:${two(m)}:${two(s % 60)}` : `${m}:${two(s % 60)}`;\n },\n /**\n * A position in media as an editor shows it, to a chosen precision: \"4:05\" (seconds), \"4:05.250\"\n * (`\"ms\"`), or \"0:04:05:07\" (`\"frames\"` at `fps`, the last part the frame). Hours appear only\n * from one hour, except in frames. Frames are always four parts, hours included, as SMPTE\n * timecode is (non-drop frame, with colons): a three-part \"1:05:00\" reads as one hour five, so\n * a frame count must never be three. Editors write the same four parts (strata-react issue\n * #122). Floors, never rounds up, so a time never reads ahead of the picture. Unknown (null,\n * negative, not finite) prints the placeholder. Set it in `tabular-nums`.\n */\n timecode: (\n seconds: number | null | undefined,\n { precision = \"seconds\", fps = 30 }: { precision?: \"seconds\" | \"ms\" | \"frames\"; fps?: number } = {},\n ) => {\n if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;\n const whole = Math.floor(seconds);\n const two = (n: number) => String(n).padStart(2, \"0\");\n const [h, m] = [Math.floor(whole / 3600), Math.floor((whole % 3600) / 60)];\n const base = h > 0 ? `${h}:${two(m)}:${two(whole % 60)}` : `${m}:${two(whole % 60)}`;\n if (precision === \"ms\")\n return `${base}.${String(Math.min(Math.floor((seconds - whole) * 1000 + 1e-6), 999)).padStart(3, \"0\")}`;\n if (precision === \"frames\")\n return `${h}:${two(m)}:${two(whole % 60)}:${two(Math.min(Math.floor((seconds - whole) * fps + 1e-6), Math.ceil(fps) - 1))}`;\n return base;\n },\n /** What a missing value prints as: an en dash unless `createFormat`'s `missing` says otherwise. */\n missing,\n /** A time of day: `format.clock(at)` is \"06:05\". */\n clock,\n /** A day without its year, for this week's things: `format.day(at)` is \"Sunday 8 November\". */\n day,\n /** A weekday and time, for chart axes and recent rows: `format.shortDay(at)` is \"Sun 06:05\". */\n shortDay,\n /** A date with its year, for a record or a deadline: `format.date(at)` is \"8 Nov 2026\". */\n date,\n /** A date and time, for a log or history row: `format.dateTime(at)` is \"8 Nov 2026, 06:05\". */\n dateTime,\n /** A figure and its unit joined by a non-breaking space (`NBSP`), so they never wrap apart. */\n withUnit,\n /** A temperature in °C, joined by a non-breaking space. */\n celsius: (value: number) => withUnit(value, \"°C\"),\n /**\n * A size in bytes in the largest decimal unit it reaches (kB, MB, GB, TB, as disks and\n * networks are sold): one decimal below 10 (\"5.2 GB\"), whole above (\"431 GB\"). Pass `unit`\n * to fix the unit, so figures compared side by side (\"431 of 466 GB\") share one. Memory is\n * read in binary units: `{ binary: true }` writes KiB, MiB, GiB (\"7.6 GiB\"), and a binary\n * unit (\"GiB\") picks that too. The second argument is a unit or `{ binary, unit }`.\n */\n bytes: (value: number, unitOrOptions?: ByteUnit | BinaryByteUnit | BytesOptions) => {\n const { binary = false, unit } =\n typeof unitOrOptions === \"string\" ? { unit: unitOrOptions } : (unitOrOptions ?? {});\n const chosen = unit ?? chooseByteUnit(value, binary);\n const scaled = value / SIZE[chosen];\n return withUnit(scaled, chosen, Math.abs(scaled) < 10 && chosen !== \"B\" ? decimal : integer);\n },\n /**\n * A rate in bits per second, in the largest decimal unit it reaches, as networks and video\n * are measured: \"850 kb/s\", \"4.2 Mb/s\", \"35 Mb/s\", \"1.2 Gb/s\" (one decimal below 10).\n */\n bitrate: (bitsPerSecond: number | null | undefined) => {\n if (bitsPerSecond == null || !Number.isFinite(bitsPerSecond) || bitsPerSecond < 0) return missing;\n const [scale, unit] =\n bitsPerSecond >= 1e9\n ? [1e9, \"Gb/s\"]\n : bitsPerSecond >= 1e6\n ? [1e6, \"Mb/s\"]\n : bitsPerSecond >= 1e3\n ? [1e3, \"kb/s\"]\n : [1, \"b/s\"];\n const scaled = bitsPerSecond / scale;\n return withUnit(scaled, unit, scaled < 10 && scale > 1 ? decimal : integer);\n },\n /**\n * A length of time in words, the unit chosen by size: \"45 s\", \"16 min\", \"3.5 h\", \"2 days\". Unknown\n * (null, negative, not finite) prints the placeholder. `style: \"parts\"` is an uptime, the two\n * largest units written out: \"1d 1h 0m\", \"2h 5m\", \"5m 3s\". Not `runningTime`, which is a media clock.\n */\n duration: (seconds: number | null | undefined, { style = \"approx\" }: { style?: \"approx\" | \"parts\" } = {}) => {\n if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;\n if (style === \"parts\") {\n const s = Math.floor(seconds);\n const [d, h, m] = [Math.floor(s / 86400), Math.floor((s % 86400) / 3600), Math.floor((s % 3600) / 60)];\n if (d > 0) return `${d}d${NBSP}${h}h${NBSP}${m}m`;\n if (h > 0) return `${h}h${NBSP}${m}m`;\n if (m > 0) return `${m}m${NBSP}${s % 60}s`;\n return `${s}s`;\n }\n if (seconds < 60) return withUnit(Math.floor(seconds), \"s\");\n if (seconds < 3600) return withUnit(Math.floor(seconds / 60), \"min\");\n if (seconds < 86400) return withUnit(seconds / 3600, \"h\", decimal);\n const days = seconds / 86400;\n return withUnit(days, plurals.select(Math.round(days * 10) / 10) === \"one\" ? \"day\" : \"days\", decimal);\n },\n /**\n * A reading and its unit: `format.measure(12.34, \"GB\")` is \"12.3 GB\" (one decimal at most, a\n * non-breaking space). `\"%\"` takes the figure as percent points and goes through `percent`, so\n * the locale decides the spacing: `format.measure(41, \"%\")` is \"41%\". Unknown prints the placeholder.\n */\n measure: (value: number | null | undefined, unit: string) =>\n value == null ? missing : unit === \"%\" ? percent.format(value / 100) : withUnit(value, unit, decimal),\n /**\n * A tick for the axis of a chart of the past, from seconds before now: \"now\", \"−30 s\", \"−2 min\",\n * \"−6 h\", \"−3 d\" (a true minus sign). Pass it as `LineChart`'s `formatX` after turning x into seconds ago.\n */\n agoTick: (secondsAgo: number | null | undefined) => {\n if (secondsAgo == null || !Number.isFinite(secondsAgo)) return missing;\n const s = Math.abs(secondsAgo);\n if (s < 1) return \"now\";\n const [n, unit] = s < 60 ? [s, \"s\"] : s < 3600 ? [s / 60, \"min\"] : s < 86400 ? [s / 3600, \"h\"] : [s / 86400, \"d\"];\n return `−${integer.format(n)}${NBSP}${unit}`;\n },\n /**\n * A distance in metres as a person says it: metres under a kilometre (\"850 m\"), then\n * kilometres, one decimal below 100 (\"12.4 km\"), whole above; `\"imperial\"` is feet under a\n * tenth of a mile (\"320 ft\"), then miles (\"7.7 mi\").\n */\n distance: (metres: number, system: \"metric\" | \"imperial\" = \"metric\") => {\n if (system === \"imperial\") {\n const miles = metres / 1609.344;\n return miles < 0.1 ? withUnit(metres * 3.28084, \"ft\") : withUnit(miles, \"mi\", miles < 100 ? decimal : integer);\n }\n return Math.abs(metres) < 1000\n ? withUnit(metres, \"m\")\n : withUnit(metres / 1000, \"km\", Math.abs(metres) < 100_000 ? decimal : integer);\n },\n /** The unit `bytes` would choose for a value, to share it across a set of figures. */\n byteUnit: (value: number, { binary = false }: { binary?: boolean } = {}) => chooseByteUnit(value, binary),\n /**\n * \"1 piece\", \"6 pieces\": the count and its noun, so copy never reads \"1 pieces\". They are\n * joined by a non-breaking space (`NBSP`), not a plain one: in a test, match with the same\n * call or a `\\s` regex, not a typed \"6 pieces\" string in a role's `name`.\n */\n count: (\n value: number | null | undefined,\n one: string,\n many = `${one}s`,\n { compact: short = false }: CountOptions = {},\n ) =>\n value == null\n ? missing\n : `${(short ? compact : integer).format(value)}${NBSP}${plurals.select(value) === \"one\" ? one : many}`,\n };\n}\n\nexport type Format = ReturnType<typeof createFormat>;\n\n/** The en-GB formatters. */\nexport const format = createFormat(\"en-GB\");\n","import * as React from \"react\";\nimport { useSearchParams } from \"react-router\";\n\n// \"Anything a person would link or reload into (tab, sort, filter, page, open item) is in the URL.\"\n// Tabs (`param=`), DataTable (`sortParam`) and `useExpanded({ param })` already do; a plain filter or\n// choice did not, so each app wrote the same `setParams(p => { new URLSearchParams(p) … })` (#297).\n// Rules fixed here once: the default is never written (the plain URL stays plain, as `Tabs` does),\n// a value that does not parse reads as the default (a stale or hand-edited link must not break the\n// screen), other params are kept, and a filter replaces the history entry (Back leaves the screen,\n// it does not walk through every filter change; `replace: false` for a choice worth a Back step).\n\n/** Options of `useSearchParam`. */\nexport type SearchParamOptions<T extends string> = {\n /** Read when the param is missing or invalid; setting it removes the param. */\n default: T;\n /** Says whether a raw value is allowed: a type guard (`isMode`), or a function that returns the typed value or `undefined`. */\n parse?: (raw: string) => T | boolean | undefined;\n /** Replace the history entry instead of adding one. Default `true`, since most params are filters. */\n replace?: boolean;\n};\n\n/** What `useSearchParam` returns: the value, and a setter that takes the next value or `null` for the default. */\nexport type SearchParam<T extends string> = readonly [T, (next: T | null) => void];\n\n/**\n * One value held in a URL search parameter (React Router): `const [mode, setMode] = useSearchParam(\"mode\", { default: \"all\", parse: isMode })`.\n * Reads and validates it, drops the param when set to the default or `null`, keeps the others, and replaces the history entry by default.\n */\nexport function useSearchParam<T extends string = string>(\n key: string,\n { default: fallback, parse, replace = true }: SearchParamOptions<T>,\n): SearchParam<T> {\n const [params, setParams] = useSearchParams();\n const raw = params.get(key);\n let value = fallback;\n if (raw !== null) {\n const parsed = parse ? parse(raw) : (raw as T);\n if (parsed === true) value = raw as T;\n else if (typeof parsed === \"string\") value = parsed;\n }\n const set = React.useCallback(\n (next: T | null) =>\n setParams(\n (p) => {\n const out = new URLSearchParams(p);\n if (next === null || next === fallback) out.delete(key);\n else out.set(key, next);\n return out;\n },\n { replace },\n ),\n [key, fallback, replace, setParams],\n );\n return [value, set];\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 { useSearchParam } from \"../lib/search-param\";\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 = {\n id: string;\n label: string;\n describedBy?: string;\n invalid: boolean;\n report: (message: string | undefined) => void;\n};\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({\n className,\n id,\n size = \"default\",\n ...props\n}: 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(props: NativeSelectProps) {\n // `param` is a different component so a select outside a router (no `param`) never calls router hooks.\n return props.param === undefined ? <PlainSelect {...(props as PlainSelectProps)} /> : <ParamSelect {...props} />;\n}\n\ntype PlainSelectProps = Omit<React.ComponentProps<\"select\">, \"size\"> & { size?: ControlSize };\n\n/** Props of `NativeSelect`: a native select's own, or (with `param`) a choice held in the URL. */\nexport type NativeSelectProps =\n | (PlainSelectProps & { param?: undefined; paramDefault?: undefined })\n | (Omit<PlainSelectProps, \"value\" | \"defaultValue\" | \"onChange\"> & {\n /** The search parameter that holds the choice (`?mode=…`), so it can be linked and survives a reload. */\n param: string;\n /** The option that is chosen when the URL says nothing; choosing it removes the param. */\n paramDefault: string;\n /** Called after the URL changes. */\n onChange?: (value: string) => void;\n });\n\nfunction PlainSelect({ className, id, size = \"default\", ...props }: PlainSelectProps) {\n return <select {...useField(id)} className={cn(control, controlHeight[size], \"pr-8\", className)} {...props} />;\n}\n\n/** The values of every `<option>`, looking inside `<optgroup>`s and fragments. */\nfunction optionValues(children: React.ReactNode): string[] {\n return React.Children.toArray(children).flatMap((c) => {\n if (!React.isValidElement<{ value?: string; children?: React.ReactNode }>(c)) return [];\n if (c.type === \"option\") return [c.props.value ?? String(c.props.children)];\n return optionValues(c.props.children);\n });\n}\n\nfunction ParamSelect({\n param,\n paramDefault,\n onChange,\n children,\n ...props\n}: Extract<NativeSelectProps, { param: string }>) {\n // An unknown value in the URL reads as the default: the select shows an option that exists.\n const options = optionValues(children);\n const [value, setValue] = useSearchParam(param, {\n default: paramDefault,\n parse: (raw) => options.length === 0 || options.includes(raw),\n });\n return (\n <PlainSelect\n {...props}\n value={value}\n onChange={(e) => {\n setValue(e.target.value);\n onChange?.(e.target.value);\n }}\n >\n {children}\n </PlainSelect>\n );\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.\n/** One option of a `ChoiceGroup`: its value, its words, and optionally a decorative `leading` mark (a swatch) before the words, which a screen reader skips, so the label must say it all. */\nexport type Choice = { value: string; label: string; detail?: string; leading?: React.ReactNode };\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(props: ChoiceGroupProps) {\n return props.param === undefined ? <ChoiceGroupView {...props} /> : <ParamChoiceGroup {...props} />;\n}\n\n/** Props of `ChoiceGroup`: the value and `onChange` are the caller's, or (with `param`) the URL's, the first choice being the default. */\nexport type ChoiceGroupProps = {\n legend: string;\n name: string;\n choices: Choice[];\n error?: string;\n} & (\n | { value: string; onChange: (value: string) => void; param?: undefined }\n | {\n /** The search parameter that holds the choice, so it can be linked and survives a reload. The first choice is the default and is not written. */\n param: string;\n value?: undefined;\n /** Called after the URL changes. */\n onChange?: (value: string) => void;\n }\n);\n\nfunction ParamChoiceGroup({ param, choices, onChange, ...props }: Extract<ChoiceGroupProps, { param: string }>) {\n const [value, setValue] = useSearchParam(param, {\n default: choices[0]?.value ?? \"\",\n parse: (raw) => choices.some((c) => c.value === raw),\n });\n return (\n <ChoiceGroupView\n {...props}\n choices={choices}\n value={value}\n onChange={(next) => {\n setValue(next);\n onChange?.(next);\n }}\n />\n );\n}\n\nfunction ChoiceGroupView({\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\n name={name}\n value={value}\n onChange={onChange}\n aria-describedby={error ? errorId : undefined}\n className=\"grid gap-2\"\n >\n <Label className=\"mb-1.5 type-label text-foreground\">{legend}</Label>\n {choices.map((c) => (\n <Radio\n key={c.value}\n value={c.value}\n className=\"group flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1\"\n >\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 {c.leading && <span className=\"mt-0.5 shrink-0\">{c.leading}</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":";;;;;;;;AA4CA,MAAa,OAAO;;AAGpB,MAAa,UAAU;AAIvB,MAAM,aAAkC;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;AAAI;AAC1E,MAAM,YAAY,OAAO,YAAY,WAAW,KAAK,GAAG,MAAM,CAAC,GAAG,OAAQ,CAAC,CAAC,CAAC;AAI7E,MAAM,eAA0C;CAAC;CAAK;CAAO;CAAO;CAAO;CAAO;AAAK;AACvF,MAAM,cAAc,OAAO,YAAY,aAAa,KAAK,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AACjF,MAAM,OAAkD;CAAE,GAAG;CAAW,GAAG;AAAY;AAKvF,SAAS,eAAe,OAAe,QAA4C;CAEjF,OAAO,CAAC,GAD8C,SAAS,eAAe,UAC9D,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,KAAK,EAAE,KAAK;AACzE;;AAwCA,SAAgB,OAAO,OAAwB;CAC7C,MAAM,OAAO,iBAAiB,OAAO,QAAQ,IAAI,KAAK,KAAK;CAC3D,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,GAAG,MAAM,IAAI,WAAW,eAAe,KAAK,UAAU,OAAO,KAAK,CAAC,GAAG;CACrG,OAAO;AACT;AAEA,SAAS,aAAa,IAAyB,SAAgC;CAC7E,MAAM,UAAU,UAAyC,SAAS,OAAO,UAAU,GAAG,OAAO,OAAO,KAAK,CAAC;CAC1G,OAAO,OAAO,OAAO,QAAQ;EAC3B;EACA,gBAAgB,UAAqB,GAAG,cAAc,OAAO,KAAK,CAAC;EACnE,cAAc,OAAkB,QAAmB,GAAG,YAAY,OAAO,KAAK,GAAG,OAAO,GAAG,CAAC;EAC5F,u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.ts
CHANGED
|
@@ -34,6 +34,13 @@ type DateFormatter = ((value: DateInput | null | undefined) => string) & {
|
|
|
34
34
|
formatToParts: (value: DateInput) => Intl.DateTimeFormatPart[];
|
|
35
35
|
formatRange: (start: DateInput, end: DateInput) => string;
|
|
36
36
|
} & Pick<Intl.DateTimeFormat, "resolvedOptions">;
|
|
37
|
+
/** Options for `format.currency`. */
|
|
38
|
+
interface CurrencyOptions {
|
|
39
|
+
/** ISO 4217 currency code. Default `"USD"`. */
|
|
40
|
+
currency?: string;
|
|
41
|
+
/** Fixed fraction digits (e.g. `4` for micro-costs like API spend `"$0.0042"`). Left out, Intl picks the currency's default (usually 2). */
|
|
42
|
+
decimals?: number;
|
|
43
|
+
}
|
|
37
44
|
/** Options shared by every date formatter one `createFormat` call makes. */
|
|
38
45
|
interface FormatOptions {
|
|
39
46
|
/** An IANA zone ("Europe/London", "UTC") to show times in. Left out, times are the viewer's own. */
|
|
@@ -67,6 +74,12 @@ export declare function createFormat(locale: string, options?: FormatOptions): {
|
|
|
67
74
|
share: (value: number | null | undefined) => string;
|
|
68
75
|
/** A figure in short form for counts that run to thousands: `format.compact(1234)` is "1.2k" in en-GB, "1.2K" in en-US. */
|
|
69
76
|
compact: NumberFormatter;
|
|
77
|
+
/**
|
|
78
|
+
* A monetary amount via `Intl.NumberFormat` with narrow currency symbol (`"$1.25"`, `"£4.50"`,
|
|
79
|
+
* or `format.currency(0.0042, { decimals: 4 })` → `"$0.0042"`). Unknown (`null`, `undefined`,
|
|
80
|
+
* `NaN`, non-finite) prints the placeholder.
|
|
81
|
+
*/
|
|
82
|
+
currency: (value: number | null | undefined, { currency, decimals }?: CurrencyOptions) => string;
|
|
70
83
|
/**
|
|
71
84
|
* How long ago (or how far ahead) a time is, in the largest unit it reaches:
|
|
72
85
|
* "3 weeks ago", "yesterday", "in 2 hours", "now" under a minute. Pass `now` in tests.
|
|
@@ -175,6 +188,12 @@ declare const format$1: {
|
|
|
175
188
|
share: (value: number | null | undefined) => string;
|
|
176
189
|
/** A figure in short form for counts that run to thousands: `format.compact(1234)` is "1.2k" in en-GB, "1.2K" in en-US. */
|
|
177
190
|
compact: NumberFormatter;
|
|
191
|
+
/**
|
|
192
|
+
* A monetary amount via `Intl.NumberFormat` with narrow currency symbol (`"$1.25"`, `"£4.50"`,
|
|
193
|
+
* or `format.currency(0.0042, { decimals: 4 })` → `"$0.0042"`). Unknown (`null`, `undefined`,
|
|
194
|
+
* `NaN`, non-finite) prints the placeholder.
|
|
195
|
+
*/
|
|
196
|
+
currency: (value: number | null | undefined, { currency, decimals }?: CurrencyOptions) => string;
|
|
178
197
|
/**
|
|
179
198
|
* How long ago (or how far ahead) a time is, in the largest unit it reaches:
|
|
180
199
|
* "3 weeks ago", "yesterday", "in 2 hours", "now" under a minute. Pass `now` in tests.
|
|
@@ -2705,6 +2724,100 @@ type ConsoleProps = {
|
|
|
2705
2724
|
};
|
|
2706
2725
|
/** A command console: a polite, virtualised log pinned to its end, above a command line with history (Up, Down) and Tab completion from the app's list. */
|
|
2707
2726
|
export declare function Console({ label, lines, onCommand, complete, historyKey, height, lineHeight, commandLabel, inputRef, className }: ConsoleProps): React.JSX.Element;
|
|
2727
|
+
/** Open and closed disclosure state: controlled with `open` and `onOpenChange`, or uncontrolled from `defaultOpen`. */
|
|
2728
|
+
type DisclosureOpenProps = {
|
|
2729
|
+
open: boolean;
|
|
2730
|
+
onOpenChange: (open: boolean) => void;
|
|
2731
|
+
defaultOpen?: never;
|
|
2732
|
+
} | {
|
|
2733
|
+
open?: never;
|
|
2734
|
+
onOpenChange?: (open: boolean) => void;
|
|
2735
|
+
defaultOpen?: boolean;
|
|
2736
|
+
};
|
|
2737
|
+
type DisclosureProps = DisclosureOpenProps & {
|
|
2738
|
+
/** The always-visible line, and the button's accessible name: text and marks, no controls. */
|
|
2739
|
+
summary: React.ReactNode;
|
|
2740
|
+
/** Mounted only while open, so a request inside runs when the person opens it. */
|
|
2741
|
+
children: React.ReactNode;
|
|
2742
|
+
/** Controls for the row (a `RowAction`), beside the summary and outside its button. */
|
|
2743
|
+
actions?: React.ReactNode;
|
|
2744
|
+
className?: string;
|
|
2745
|
+
};
|
|
2746
|
+
/** Shows more of one thing in place: a button with `aria-expanded` around `summary`, and a body mounted only while open (so a request inside it runs on first open). Controlled with `open`/`onOpenChange` or `useExpanded`, or uncontrolled with `defaultOpen`. */
|
|
2747
|
+
export declare function Disclosure({ summary, children, actions, open, defaultOpen, onOpenChange, className }: DisclosureProps): React.JSX.Element;
|
|
2748
|
+
/** Which of many disclosures are open, by key: spread into `DataTable`'s `expansion`, or read with `isOpen`/`setOpen` for a list of `Disclosure`s. */
|
|
2749
|
+
type Expanded = {
|
|
2750
|
+
/** Keys of the open items. */
|
|
2751
|
+
expanded: ReadonlySet<string>;
|
|
2752
|
+
/** Replaces the open set. `DataTable` calls this. */
|
|
2753
|
+
onChange: (next: Set<string>) => void;
|
|
2754
|
+
isOpen: (key: string) => boolean;
|
|
2755
|
+
setOpen: (key: string, open: boolean) => void;
|
|
2756
|
+
/** Opens a closed key, closes an open one (the same word as `WorkspaceState.toggle`). */
|
|
2757
|
+
toggle: (key: string) => void;
|
|
2758
|
+
collapseAll: () => void;
|
|
2759
|
+
};
|
|
2760
|
+
type ExpandedOptions = {
|
|
2761
|
+
/** Keep the open keys in this URL search parameter (`?open=a&open=b`), so an opened row can be linked and survives a reload. Needs a React Router context. */
|
|
2762
|
+
param?: string;
|
|
2763
|
+
/** Keys open at first. Ignored with `param`: there the URL says what is open, so a link that opens a row carries it. */
|
|
2764
|
+
initial?: Iterable<string>;
|
|
2765
|
+
/** Opening one closes the others (an accordion). Default false: people compare two rows. */
|
|
2766
|
+
single?: boolean;
|
|
2767
|
+
};
|
|
2768
|
+
/** Shared open state for the disclosures of one list or table, optionally kept in the URL (`param`). */
|
|
2769
|
+
export declare function useExpanded(options?: ExpandedOptions): Expanded;
|
|
2770
|
+
/** One image attached to an event row (e.g. a rendered artifact or inspection crop). */
|
|
2771
|
+
type EventLogImage = {
|
|
2772
|
+
src: string;
|
|
2773
|
+
alt: string;
|
|
2774
|
+
/** Opens the full image in a new tab when given. */
|
|
2775
|
+
href?: string;
|
|
2776
|
+
/** Words shown if the image fails to load. Default `"Image unavailable"`. */
|
|
2777
|
+
missing?: string;
|
|
2778
|
+
/** Thumbnail aspect ratio. Default `"4/3"`. */
|
|
2779
|
+
aspect?: AspectRatio;
|
|
2780
|
+
};
|
|
2781
|
+
/** One row in an `EventLog`. */
|
|
2782
|
+
type EventLogEntry = {
|
|
2783
|
+
/** Stable key for the row. */
|
|
2784
|
+
id: string | number;
|
|
2785
|
+
/** Optional 1-based sequence number, drawn as `#N`. */
|
|
2786
|
+
seq?: number;
|
|
2787
|
+
/** Monospace event kind (e.g. `"llm_response"`, `"tool_call"`). */
|
|
2788
|
+
kind: string;
|
|
2789
|
+
/** When the event occurred. */
|
|
2790
|
+
at?: DateInput | null;
|
|
2791
|
+
/** Optional short inline summary shown beside the kind. */
|
|
2792
|
+
summary?: React.ReactNode;
|
|
2793
|
+
/** Optional status word (rendered with `Status`). */
|
|
2794
|
+
status?: string;
|
|
2795
|
+
/** Tone for `status`. Default `"neutral"`. */
|
|
2796
|
+
tone?: Tone;
|
|
2797
|
+
/** Optional structured payload, formatted as JSON when present. */
|
|
2798
|
+
payload?: unknown;
|
|
2799
|
+
/** Optional images attached to the event. */
|
|
2800
|
+
images?: readonly EventLogImage[];
|
|
2801
|
+
/** Optional custom detail content rendered below the payload. */
|
|
2802
|
+
detail?: React.ReactNode;
|
|
2803
|
+
};
|
|
2804
|
+
type EventLogProps = {
|
|
2805
|
+
/** Ordered list of events. */
|
|
2806
|
+
entries: readonly EventLogEntry[];
|
|
2807
|
+
/** Accessible name for the `<ol>` list (e.g. `"Run events"`). */
|
|
2808
|
+
label?: string;
|
|
2809
|
+
/** Formatter instance for timestamps. Default en-GB `format`. */
|
|
2810
|
+
format?: Format;
|
|
2811
|
+
/** Collapse each entry's payload/detail inside a `Disclosure` (mounted only when open). Default `false`. */
|
|
2812
|
+
collapsible?: boolean;
|
|
2813
|
+
/** Shared open state from `useExpanded` when `collapsible` is true. */
|
|
2814
|
+
expanded?: Expanded;
|
|
2815
|
+
/** Shown when `entries` is empty. */
|
|
2816
|
+
empty?: React.ReactNode;
|
|
2817
|
+
className?: string;
|
|
2818
|
+
};
|
|
2819
|
+
/** Ordered, structured event ledger for run histories, agent traces, and audit logs. */
|
|
2820
|
+
export declare function EventLog({ entries, label, format, collapsible, expanded, empty, className }: EventLogProps): React.JSX.Element | null;
|
|
2708
2821
|
/** The keys a person has chosen, by shortcut id; an action absent here keeps its default keys. */
|
|
2709
2822
|
type ShortcutOverrides = Record<string, string[]>;
|
|
2710
2823
|
/** What `useRebindableShortcuts` returns: the list to hand to `useHotkeys` and `KeysLegend`, and what `ShortcutEditor` edits. */
|
|
@@ -2812,49 +2925,6 @@ type PropertyListProps = {
|
|
|
2812
2925
|
};
|
|
2813
2926
|
/** Read-only facts as a description list: term left, value right, long strings truncated with the full value on hover, a missing value printed as an en dash, units muted after a non-breaking space. */
|
|
2814
2927
|
export declare function PropertyList({ items, label, className }: PropertyListProps): React.JSX.Element;
|
|
2815
|
-
/** Open and closed disclosure state: controlled with `open` and `onOpenChange`, or uncontrolled from `defaultOpen`. */
|
|
2816
|
-
type DisclosureOpenProps = {
|
|
2817
|
-
open: boolean;
|
|
2818
|
-
onOpenChange: (open: boolean) => void;
|
|
2819
|
-
defaultOpen?: never;
|
|
2820
|
-
} | {
|
|
2821
|
-
open?: never;
|
|
2822
|
-
onOpenChange?: (open: boolean) => void;
|
|
2823
|
-
defaultOpen?: boolean;
|
|
2824
|
-
};
|
|
2825
|
-
type DisclosureProps = DisclosureOpenProps & {
|
|
2826
|
-
/** The always-visible line, and the button's accessible name: text and marks, no controls. */
|
|
2827
|
-
summary: React.ReactNode;
|
|
2828
|
-
/** Mounted only while open, so a request inside runs when the person opens it. */
|
|
2829
|
-
children: React.ReactNode;
|
|
2830
|
-
/** Controls for the row (a `RowAction`), beside the summary and outside its button. */
|
|
2831
|
-
actions?: React.ReactNode;
|
|
2832
|
-
className?: string;
|
|
2833
|
-
};
|
|
2834
|
-
/** Shows more of one thing in place: a button with `aria-expanded` around `summary`, and a body mounted only while open (so a request inside it runs on first open). Controlled with `open`/`onOpenChange` or `useExpanded`, or uncontrolled with `defaultOpen`. */
|
|
2835
|
-
export declare function Disclosure({ summary, children, actions, open, defaultOpen, onOpenChange, className }: DisclosureProps): React.JSX.Element;
|
|
2836
|
-
/** Which of many disclosures are open, by key: spread into `DataTable`'s `expansion`, or read with `isOpen`/`setOpen` for a list of `Disclosure`s. */
|
|
2837
|
-
type Expanded = {
|
|
2838
|
-
/** Keys of the open items. */
|
|
2839
|
-
expanded: ReadonlySet<string>;
|
|
2840
|
-
/** Replaces the open set. `DataTable` calls this. */
|
|
2841
|
-
onChange: (next: Set<string>) => void;
|
|
2842
|
-
isOpen: (key: string) => boolean;
|
|
2843
|
-
setOpen: (key: string, open: boolean) => void;
|
|
2844
|
-
/** Opens a closed key, closes an open one (the same word as `WorkspaceState.toggle`). */
|
|
2845
|
-
toggle: (key: string) => void;
|
|
2846
|
-
collapseAll: () => void;
|
|
2847
|
-
};
|
|
2848
|
-
type ExpandedOptions = {
|
|
2849
|
-
/** Keep the open keys in this URL search parameter (`?open=a&open=b`), so an opened row can be linked and survives a reload. Needs a React Router context. */
|
|
2850
|
-
param?: string;
|
|
2851
|
-
/** Keys open at first. Ignored with `param`: there the URL says what is open, so a link that opens a row carries it. */
|
|
2852
|
-
initial?: Iterable<string>;
|
|
2853
|
-
/** Opening one closes the others (an accordion). Default false: people compare two rows. */
|
|
2854
|
-
single?: boolean;
|
|
2855
|
-
};
|
|
2856
|
-
/** Shared open state for the disclosures of one list or table, optionally kept in the URL (`param`). */
|
|
2857
|
-
export declare function useExpanded(options?: ExpandedOptions): Expanded;
|
|
2858
2928
|
/** What a chosen key brings with it: keys, or nothing. */
|
|
2859
2929
|
type Implies = (key: string) => Iterable<string> | null | undefined;
|
|
2860
2930
|
/** Which rows start chosen: their keys, or a test on each row. Either applies to a row the first time it appears. */
|
|
@@ -5895,5 +5965,29 @@ export declare function rangeBetween(ids: readonly string[], a: string | null, b
|
|
|
5895
5965
|
export declare function countMarks(marks: Readonly<Record<string, string | undefined>>, ids?: readonly string[]): Record<string, number>;
|
|
5896
5966
|
/** The id `by` places from `from` in `ids`, held to the ends; the first (or last) when `from` is not set. */
|
|
5897
5967
|
export declare function stepId(ids: readonly string[], from: string | null, by: number): string | null;
|
|
5898
|
-
|
|
5968
|
+
/** How many numbers a `ClockFace` draws: all twelve, only 12, 3, 6 and 9, or none. */
|
|
5969
|
+
type ClockNumbers = "all" | "quarters" | "none";
|
|
5970
|
+
/** Props of `ClockFace`. */
|
|
5971
|
+
type ClockFaceProps = {
|
|
5972
|
+
/** The hour, 0 to 23 (a 12-hour face: 15 and 3 look the same). */
|
|
5973
|
+
hours: number;
|
|
5974
|
+
/** The minutes, 0 to 59. */
|
|
5975
|
+
minutes: number;
|
|
5976
|
+
/** The clock's accessible name; the time in words (`clockWords`) by default. Pass your own when the time is the answer. */
|
|
5977
|
+
label?: string;
|
|
5978
|
+
/** Which numbers are drawn; all by default. */
|
|
5979
|
+
numbers?: ClockNumbers;
|
|
5980
|
+
/** Draw the sixty minute marks as well as the twelve hour marks; on by default. */
|
|
5981
|
+
minuteMarks?: boolean;
|
|
5982
|
+
/** Layout only, such as a width: the clock fills its width and is square. */
|
|
5983
|
+
className?: string;
|
|
5984
|
+
};
|
|
5985
|
+
/**
|
|
5986
|
+
* A time as it is said in UK English on a 12-hour clock: "three o'clock", "half past three", "quarter to four",
|
|
5987
|
+
* "twenty-five past three", "seven minutes to four". The words a clock round speaks and a `ClockFace` is named by.
|
|
5988
|
+
*/
|
|
5989
|
+
export declare function clockWords(hours: number, minutes: number): string;
|
|
5990
|
+
/** An analogue clock showing one time, its hands telling hours from minutes by length, width and colour. */
|
|
5991
|
+
export declare function ClockFace({ hours, minutes, label, numbers, minuteMarks, className }: ClockFaceProps): import("react").JSX.Element;
|
|
5992
|
+
export { type ActiveItem, type AlertDialogProps, type AlertProps, type Api, type ApiOptions, type ApiPage, type AspectRatio, type AsyncAction, type AsyncActionOptions, AsyncButton, type AsyncLabels, type AudioMedia, type AutoRecorder, type AutoRecorderState, type AutoSave, type AutoSaveOptions, type AutoTake, type BinaryByteUnit, type BookPage, type BookUrl, type BookViewerProps, type BoxListProps, type BoxOverlayProps, type BoxSource, type BoxTone, type BoxedPictureProps, type BoxesState, type Brush, type BrushControl, type BrushKind, Button, type ButtonLinkProps, type ButtonProps, type ByteHighlight, type ByteRange, type ByteUnit, type ByteViewProps, type BytesOptions, COLOR_SCHEME_STORAGE_KEY, type Candidate, type CellValue, type ChartMark, type ChartSpan, type CheckboxGesture, type CheckboxProps, type Choice, type ChoiceCounts, type ChoiceGridProps, type ChoiceGroupProps, type ChoiceMarks, type ChoiceSize, type ChoiceState, type Choices, type ClientWork, type Clips, type ClipsContext, type ClipsProviderProps, type ClockFaceProps, type ClockNumbers, type ColorFieldProps, type ColorScheme, ColorSchemeChoice, type ColorSchemeLabels, type ColorSchemePreference, type ColorSchemeState, type Column, type Command, type CommandMenuProps, type CommandsOptions, type CompareAudioProps, type CompareGridProps, type CompareMode, type CompareProps, type CompareTextProps, type CompareVideoGridProps, type CompareVideoProps, type ComposerProps, type CompositionBarProps, type CompositionPart, type ConcealedProps, type ConsoleLevel, type ConsoleLine, type ConsoleProps, type ContextMenuProps, type ControlSize, type ConversationImage, type ConversationProps, type ConversationTurn, type CountOptions, type CountdownOptions, type CurrencyOptions, type CursorMapping, type CursorOwner, CursorScope, type CursorScopeProps, type CutChange, type CutLimit, type CutRoom, DEFAULT_PALETTE, type DataTableProps, type DateFormatter, type DateInput, type DecodedAudio, type Delivery, Density, type DensityName, type DensityProps, type DescribeError, type DialogProps, type Difference, type DifferenceState, type DisclosureOpenProps, type DisclosureProps, type DragData, type DragSourceProps, type DrawTool, type Drawing, type Box as DrawingBox, type DrawingLayerProps, type DrawingOp, type DrawingOptions, type DrawingState, type DrawingToolbarProps, type DropTarget, type Easing, type EditClip, type EditListOptions, type EditListPlayerProps, type EditListSlot, type EditListState, type EditTimes, type EditableRegion, type EntityMatch, type EntityMatcher, type ErrorBody, type EventLogEntry, type EventLogImage, type EventLogProps, type Expanded, type ExpandedOptions, type FailedRemoval, type FetchJsonInit, type FetchJsonOptions, type FieldErrors, type FieldProps, type FileIntake, type FileIntakeOptions, type FileOutcome, type FilmFrame, type FilmStripProps, type Folder, type FolderListing, type FolderPickerProps, type Format, type FormatOptions, type FullscreenFrameProps, type GlimpseLook, type GlimpseProps, type GlimpseWhy, type Grid, type GroupMember, type GroupedChart, type Handle, type History, type HistoryOptions, type HistoryStateOptions, type HistoryStep, type HotkeysOptions, IconButton, type IconButtonProps, type IconComponent, type ImageMedia, type Implies, type InViewOptions, type InfiniteListProps, type InfiniteLoad, type InfiniteLoadOptions, type InitialSelection, type InkColours, type InkMatch, type InkMatchState, type InputLevelProps, type InspectorProps, type InspectorSectionProps, type Job, type JobAction, type JobActionOptions, type JobFailure, type JobOptions, type JobProgress, type JobRow, type JobStatusProps, type JobWords, type JobsTableProps, type KeyCheck, KeysLegend, type LatLng, type LightboxItem, type LightboxProps, type LightboxUrl, LineChart, LineChartGroup, type LineChartGroupProps, type LineChartProps, type LinkCardProps, type ListeningLevelProps, type Load, type LoadFailure, type LoadMoreProps, type Loudness, type MarkKind, type MarkPattern, type MarkTone, type MarkableTextProps, type MediaContentsItem, type MediaContentsProps, type MediaElementOptions, type MediaElementState, type MediaHeading, type MediaMark, MediaPlayer, type MediaPlayerProps, type MediaProblem, type MediaProgress, type MediaSession, type MediaSource, type MediaSpanData, type MediaSpansState, MediaStage, type MediaStat, type MediaStats, type MediaWindow, type MenuEntry, type MenuProps, type MeterProps, type MeterThreshold, type MetricProps, type Microphone, MicrophoneContext, MicrophoneError, type MicrophoneStream, type More, type NativeSelectProps, type NavItem, type Nib, type NumberFieldProps, type NumberFormatter, type Outbox, type OutboxItem, type OutboxOptions, type OutboxRefusal, type OutboxRequest, type OutboxSnapshot, type OutboxStatusProps, PALETTE_STORAGE_KEY, type PageNames, type Pair, type PairAnswer, type PairJudgeProps, type PairVoteProps, type PairVoteSlot, type PairVoteWords, PaletteChoice, type PaletteOption, type PaletteState, type PaneProps, type PeakPair, type PendingRemoval, type Phase, type PictureBox, type PictureRegion, type PixelImageProps, type Pixels, type PlaceBoardProps, type PlaceState, type Platform, type PlayWindowButtonProps, PlayerNotice, type PlayerWarning, type PlayerWarningEvent, type Point, type Poll, type PopoverProps, type Precision, type Property, type PropertyListProps, type PropertyRowProps, type RangeProps, type RangeSliderProps, RateChoice, type ReadAlongPart, type ReadAlongProps, type ReadAloud, type ReadAloudOptions, type ReadPixels, type Rebinding, type Recorder, type RecorderState, type Recording, type Rect, type RectLimits, type Region, type RegionEditorProps, type RegionTone, type Reserve, type ReserveOptions, type ResumeWords, type Revealed, type Block as RichBlock, type Inline as RichInline, type RichTextProps, RowAction, type RowActionProps, type RowExpansion, type RowSelection, SPEECH_RATES, type SaveState, type SayAgainProps, type SayOnShowOptions, type SayPictureProps, type Saying, type ScheduleRow, type ScheduleTableProps, type SearchParam, type SearchParamOptions, type SecretFieldProps, type SecretTestResult, SeekBar, type SeekBarProps, type SeekBarSpan, type Segment, type Segmenter, type SegmenterOptions, type SelectableGridProps, type SequenceItem, type SequenceTimelineProps, type SetOptions, type ShareBox, type SharedCursor, type Shortcut, type ShortcutOverrides, type SkipAction, type SkipLevel, type SkipSteps, type SliderProps, type Sort, type SortableListProps, type SourceAttacher, SpanActions, type SpanActionsNotice, type SpanBehaviour, type SpanKind, type SpanOutcome, SpanStrip, type SpanTone, type SpanWords, type SpeakOptions, type Speech, type SpeechLevel, type SpeechPart, StageGuides, type StageState, type StageWords, type Stale, type StrataToastRegionProps, type StreamAttachment, type StreamContext, type StreamStats, type Stroke, type StrokeChange, type StrokeNoteWords, type StrokePoint, type StrokeShape, type SwitchProps, type SystemFact, type SystemFolder, type SystemInfoLike, type SystemPanelProps, type SystemService, type TabItem, type TakeLevelProps, type TextDifference, type TextLinkProps, type TextMedia, type TextSegment, ThemeProvider, type ThumbnailProps, type TileAspect, type TileGridProps, type TileSize, TimeReadout, type TimelineChange, type TimelineClock, type TimelineClockOptions, type TimelineDrop, type TimelineItem, type TimelineLane, type TimelineMarker, type TimelinePlayerProps, type TimelineProps, type ToastContentProps, type ToggleGroupProps, type ToggleOption, type ToggleProps, type Tone, type ToolChoice, type ToolbarProps, type TooltipProps, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptSeek, type TranscriptViewProps, type TranscriptWord, Transport, type TransportProps, type TreeNodeState, type TreeProps, type TypedApi, type Undoable, type UndoableOptions, type UseAutoRecorderOptions, type UseRecorderOptions, type UseSpeechOptions, type VideoLoop, type VideoMedia, type VideoMode, type ViewGroup, type ViewGroupRows, type ViewOptionsConfig, type ViewOptionsProps, type ViewOptionsState, type ViewPointerOptions, type ViewSort, type Viewport, type ViewportFrameProps, type ViewportState, VolumeControl, type VolumeControlProps, type WaveformMark, type WaveformMarkKind, type WaveformPeaks, type WaveformProps, type WaveformSpan, type WaveformTone, type WorkContext, type WorkPhase, type WorkflowRunLike, type WorkflowRunOptions, type WorkflowStage, type WorkflowStepsProps, type WorkflowSummaryData, type WorkflowSummaryProps, type WorkflowSummaryState, type WorkflowSummaryWords, type WorkspaceBarProps, type WorkspaceState, type YScale, browserMicrophone, buttonVariants, colorSchemeScript, explainMicrophoneError, format$1 as format, geo, isTypingTarget, keyName, logScale, marksFor, mediaStatRows, paletteScript, palettes, readPixels$1 as readPixels, skipAction, transportShortcuts, useAsyncAction, useAttachedSource, useColorScheme, useHotkeys, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, usePalette, usePlayerWarnings, useSharedCursor, useSystemColorScheme, valueAt };
|
|
5899
5993
|
//# sourceMappingURL=index.d.ts.map
|