strata-react 1.3.16 → 1.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/UPGRADING.md +2 -0
- package/dist/components/thumbnail.d.ts +2 -0
- package/dist/{errors-D0TsKLwJ.js → errors-jep2voNI.js} +42 -3
- package/dist/errors-jep2voNI.js.map +1 -0
- package/dist/{format-BNkXVwFx.js → field-t4Hoer0d.js} +327 -2
- package/dist/field-t4Hoer0d.js.map +1 -0
- package/dist/index.js +19 -200
- package/dist/index.js.map +1 -1
- package/dist/map.js +2 -3
- package/dist/map.js.map +1 -1
- package/dist/{microphone-CZy0bNEx.js → microphone-Cu1u5Yml.js} +214 -6
- package/dist/microphone-Cu1u5Yml.js.map +1 -0
- package/dist/panorama.js +3 -2
- package/dist/panorama.js.map +1 -1
- package/dist/testing.js +4 -2
- package/dist/testing.js.map +1 -1
- package/dist/{theme-CFBAYaiu.js → theme-DXacprlw.js} +2 -2
- package/dist/{theme-CFBAYaiu.js.map → theme-DXacprlw.js.map} +1 -1
- package/dist/{value-controls-WRXbtUp6.js → value-controls-DB5l5Qe2.js} +4 -44
- package/dist/value-controls-DB5l5Qe2.js.map +1 -0
- package/package.json +1 -1
- package/dist/errors-D0TsKLwJ.js.map +0 -1
- package/dist/field-jfhLD5XX.js +0 -328
- package/dist/field-jfhLD5XX.js.map +0 -1
- package/dist/format-BNkXVwFx.js.map +0 -1
- package/dist/microphone-CZy0bNEx.js.map +0 -1
- package/dist/value-controls-WRXbtUp6.js.map +0 -1
package/dist/field-jfhLD5XX.js
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { clsx } from "clsx";
|
|
2
|
-
import { extendTailwindMerge } from "tailwind-merge";
|
|
3
|
-
import * as React from "react";
|
|
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
|
-
import { useSearchParams } from "react-router";
|
|
8
|
-
// src/lib/utils.ts
|
|
9
|
-
var typeSteps = [
|
|
10
|
-
"caption",
|
|
11
|
-
"label",
|
|
12
|
-
"body-sm",
|
|
13
|
-
"body",
|
|
14
|
-
"heading",
|
|
15
|
-
"title",
|
|
16
|
-
"figure",
|
|
17
|
-
"display",
|
|
18
|
-
"picture"
|
|
19
|
-
];
|
|
20
|
-
var twMerge = extendTailwindMerge({ extend: {
|
|
21
|
-
theme: { radius: [...[
|
|
22
|
-
"control",
|
|
23
|
-
"surface",
|
|
24
|
-
"overlay",
|
|
25
|
-
"pill"
|
|
26
|
-
]] },
|
|
27
|
-
classGroups: { "font-size": [{ type: [...typeSteps] }] }
|
|
28
|
-
} });
|
|
29
|
-
/** clsx + tailwind-merge, taught that `type-*` utilities are font sizes and `rounded-control`, `-surface`, `-overlay`, `-pill` are radii. */
|
|
30
|
-
function cn(...inputs) {
|
|
31
|
-
return twMerge(clsx(inputs));
|
|
32
|
-
}
|
|
33
|
-
// src/components/key-glyphs.tsx
|
|
34
|
-
var GLYPHS = {
|
|
35
|
-
"←": {
|
|
36
|
-
icon: ArrowLeft,
|
|
37
|
-
name: "left arrow"
|
|
38
|
-
},
|
|
39
|
-
"→": {
|
|
40
|
-
icon: ArrowRight,
|
|
41
|
-
name: "right arrow"
|
|
42
|
-
},
|
|
43
|
-
"↑": {
|
|
44
|
-
icon: ArrowUp,
|
|
45
|
-
name: "up arrow"
|
|
46
|
-
},
|
|
47
|
-
"↓": {
|
|
48
|
-
icon: ArrowDown,
|
|
49
|
-
name: "down arrow"
|
|
50
|
-
},
|
|
51
|
-
"⌘": {
|
|
52
|
-
icon: Command,
|
|
53
|
-
name: "Command"
|
|
54
|
-
},
|
|
55
|
-
"⌃": {
|
|
56
|
-
icon: ChevronUp,
|
|
57
|
-
name: "Control"
|
|
58
|
-
},
|
|
59
|
-
"⌥": {
|
|
60
|
-
icon: Option,
|
|
61
|
-
name: "Option"
|
|
62
|
-
},
|
|
63
|
-
"⇧": {
|
|
64
|
-
icon: ArrowBigUp,
|
|
65
|
-
name: "Shift"
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
var PATTERN = new RegExp(`([${Object.keys(GLYPHS).join("")}])`);
|
|
69
|
-
/** 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. */
|
|
70
|
-
function KeyText({ children }) {
|
|
71
|
-
return /* @__PURE__ */ jsx(Fragment, { children: children.split(PATTERN).map((part, i) => {
|
|
72
|
-
const glyph = GLYPHS[part];
|
|
73
|
-
if (!glyph) return part ? /* @__PURE__ */ jsx(React.Fragment, { children: part }, i) : null;
|
|
74
|
-
const Icon = glyph.icon;
|
|
75
|
-
return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
|
|
76
|
-
"aria-hidden": true,
|
|
77
|
-
className: "inline size-[1em] align-[-0.125em]"
|
|
78
|
-
}), /* @__PURE__ */ jsxs("span", {
|
|
79
|
-
className: "sr-only",
|
|
80
|
-
children: [glyph.name, " "]
|
|
81
|
-
})] }, i);
|
|
82
|
-
}) });
|
|
83
|
-
}
|
|
84
|
-
// src/components/tooltip.tsx
|
|
85
|
-
/** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */
|
|
86
|
-
function Tooltip$1({ label, hint, children, side = "top", delay = 500, open, className }) {
|
|
87
|
-
return /* @__PURE__ */ jsxs(TooltipTrigger, {
|
|
88
|
-
delay,
|
|
89
|
-
closeDelay: 0,
|
|
90
|
-
isOpen: open,
|
|
91
|
-
children: [children, /* @__PURE__ */ jsxs(Tooltip, {
|
|
92
|
-
placement: side,
|
|
93
|
-
offset: 6,
|
|
94
|
-
className: cn("layer-tip enter-overlay max-w-xs rounded-control bg-foreground px-2 py-1 type-caption text-background", className),
|
|
95
|
-
children: [label, hint != null && /* @__PURE__ */ jsx("span", {
|
|
96
|
-
className: "ml-2 opacity-70",
|
|
97
|
-
children: typeof hint === "string" ? /* @__PURE__ */ jsx(KeyText, { children: hint }) : hint
|
|
98
|
-
})]
|
|
99
|
-
})]
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
// src/lib/search-param.ts
|
|
103
|
-
/**
|
|
104
|
-
* One value held in a URL search parameter (React Router): `const [mode, setMode] = useSearchParam("mode", { default: "all", parse: isMode })`.
|
|
105
|
-
* Reads and validates it, drops the param when set to the default or `null`, keeps the others, and replaces the history entry by default.
|
|
106
|
-
*/
|
|
107
|
-
function useSearchParam(key, { default: fallback, parse, replace = true }) {
|
|
108
|
-
const [params, setParams] = useSearchParams();
|
|
109
|
-
const raw = params.get(key);
|
|
110
|
-
let value = fallback;
|
|
111
|
-
if (raw !== null) {
|
|
112
|
-
const parsed = parse ? parse(raw) : raw;
|
|
113
|
-
if (parsed === true) value = raw;
|
|
114
|
-
else if (typeof parsed === "string") value = parsed;
|
|
115
|
-
}
|
|
116
|
-
const set = React.useCallback((next) => setParams((p) => {
|
|
117
|
-
const out = new URLSearchParams(p);
|
|
118
|
-
if (next === null || next === fallback) out.delete(key);
|
|
119
|
-
else out.set(key, next);
|
|
120
|
-
return out;
|
|
121
|
-
}, { replace }), [
|
|
122
|
-
key,
|
|
123
|
-
fallback,
|
|
124
|
-
replace,
|
|
125
|
-
setParams
|
|
126
|
-
]);
|
|
127
|
-
return [value, set];
|
|
128
|
-
}
|
|
129
|
-
// src/lib/control.ts
|
|
130
|
-
/** The height class of each control size. */
|
|
131
|
-
var controlHeight = {
|
|
132
|
-
default: "h-(--control-h)",
|
|
133
|
-
sm: "h-(--control-h-sm)"
|
|
134
|
-
};
|
|
135
|
-
// src/components/field.tsx
|
|
136
|
-
var FieldContext = React.createContext(null);
|
|
137
|
-
/** @internal The surrounding Field, and where a control reports its own message. */
|
|
138
|
-
function useFieldControl() {
|
|
139
|
-
const field = React.useContext(FieldContext);
|
|
140
|
-
return {
|
|
141
|
-
field,
|
|
142
|
-
report: field?.report ?? noReport
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function useField(id) {
|
|
146
|
-
const field = React.useContext(FieldContext);
|
|
147
|
-
return {
|
|
148
|
-
id: field?.id ?? id,
|
|
149
|
-
"aria-describedby": field?.describedBy,
|
|
150
|
-
"aria-invalid": field?.invalid || void 0
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
var noReport = () => {};
|
|
154
|
-
/** A labelled form field: wires the label, hint, error, `aria-describedby` and `aria-invalid` into the one control it wraps. */
|
|
155
|
-
function Field({ label, id: idProp, hint, error, action, children, className }) {
|
|
156
|
-
const generated = React.useId();
|
|
157
|
-
const id = idProp ?? generated;
|
|
158
|
-
const hintId = hint ? `${id}-hint` : void 0;
|
|
159
|
-
const [reported, report] = React.useState();
|
|
160
|
-
const shown = error ?? reported;
|
|
161
|
-
const errorId = shown ? `${id}-error` : void 0;
|
|
162
|
-
const describedBy = [errorId, hintId].filter(Boolean).join(" ") || void 0;
|
|
163
|
-
return /* @__PURE__ */ jsx(FieldContext.Provider, {
|
|
164
|
-
value: {
|
|
165
|
-
id,
|
|
166
|
-
label,
|
|
167
|
-
describedBy,
|
|
168
|
-
invalid: Boolean(shown),
|
|
169
|
-
report
|
|
170
|
-
},
|
|
171
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
172
|
-
className: cn("grid min-w-0 content-start gap-1.5", className),
|
|
173
|
-
children: [
|
|
174
|
-
/* @__PURE__ */ jsx("label", {
|
|
175
|
-
htmlFor: id,
|
|
176
|
-
className: "type-label text-foreground",
|
|
177
|
-
children: label
|
|
178
|
-
}),
|
|
179
|
-
action ? /* @__PURE__ */ jsxs("div", {
|
|
180
|
-
className: "flex flex-wrap items-start gap-2",
|
|
181
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
182
|
-
className: "min-w-40 flex-1",
|
|
183
|
-
children
|
|
184
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
185
|
-
className: "flex shrink-0 items-center",
|
|
186
|
-
children: action
|
|
187
|
-
})]
|
|
188
|
-
}) : children,
|
|
189
|
-
shown && /* @__PURE__ */ jsxs("p", {
|
|
190
|
-
id: errorId,
|
|
191
|
-
className: "flex items-start gap-1.5 type-body-sm text-danger",
|
|
192
|
-
children: [/* @__PURE__ */ jsx(CircleAlert, {
|
|
193
|
-
"aria-hidden": true,
|
|
194
|
-
className: "mt-0.5 size-4 shrink-0"
|
|
195
|
-
}), shown]
|
|
196
|
-
}),
|
|
197
|
-
hint && /* @__PURE__ */ jsx("p", {
|
|
198
|
-
id: hintId,
|
|
199
|
-
className: "type-body-sm text-muted-foreground",
|
|
200
|
-
children: hint
|
|
201
|
-
})
|
|
202
|
-
]
|
|
203
|
-
})
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
var control = "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";
|
|
207
|
-
/** 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. */
|
|
208
|
-
function Input$1({ className, id, size = "default", ...props }) {
|
|
209
|
-
return /* @__PURE__ */ jsx("input", {
|
|
210
|
-
...useField(id),
|
|
211
|
-
className: cn(control, controlHeight[size], className),
|
|
212
|
-
...props
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
/** A multi-line input that picks up its id and descriptions from the surrounding `Field`. */
|
|
216
|
-
function Textarea({ className, id, ...props }) {
|
|
217
|
-
return /* @__PURE__ */ jsx("textarea", {
|
|
218
|
-
...useField(id),
|
|
219
|
-
className: cn(control, "min-h-24 py-2", className),
|
|
220
|
-
...props
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
/** The platform select, styled. The default for short lists, especially on touch screens. `size="sm"` is --control-h-sm. */
|
|
224
|
-
function NativeSelect(props) {
|
|
225
|
-
return props.param === void 0 ? /* @__PURE__ */ jsx(PlainSelect, { ...props }) : /* @__PURE__ */ jsx(ParamSelect, { ...props });
|
|
226
|
-
}
|
|
227
|
-
function PlainSelect({ className, id, size = "default", ...props }) {
|
|
228
|
-
return /* @__PURE__ */ jsx("select", {
|
|
229
|
-
...useField(id),
|
|
230
|
-
className: cn(control, controlHeight[size], "pr-8", className),
|
|
231
|
-
...props
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
/** The values of every `<option>`, looking inside `<optgroup>`s and fragments. */
|
|
235
|
-
function optionValues(children) {
|
|
236
|
-
return React.Children.toArray(children).flatMap((c) => {
|
|
237
|
-
if (!React.isValidElement(c)) return [];
|
|
238
|
-
if (c.type === "option") return [c.props.value ?? String(c.props.children)];
|
|
239
|
-
return optionValues(c.props.children);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
function ParamSelect({ param, paramDefault, onChange, children, ...props }) {
|
|
243
|
-
const options = optionValues(children);
|
|
244
|
-
const [value, setValue] = useSearchParam(param, {
|
|
245
|
-
default: paramDefault,
|
|
246
|
-
parse: (raw) => options.length === 0 || options.includes(raw)
|
|
247
|
-
});
|
|
248
|
-
return /* @__PURE__ */ jsx(PlainSelect, {
|
|
249
|
-
...props,
|
|
250
|
-
value,
|
|
251
|
-
onChange: (e) => {
|
|
252
|
-
setValue(e.target.value);
|
|
253
|
-
onChange?.(e.target.value);
|
|
254
|
-
},
|
|
255
|
-
children
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
/** 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. */
|
|
259
|
-
function ChoiceGroup(props) {
|
|
260
|
-
return props.param === void 0 ? /* @__PURE__ */ jsx(ChoiceGroupView, { ...props }) : /* @__PURE__ */ jsx(ParamChoiceGroup, { ...props });
|
|
261
|
-
}
|
|
262
|
-
function ParamChoiceGroup({ param, choices, onChange, ...props }) {
|
|
263
|
-
const [value, setValue] = useSearchParam(param, {
|
|
264
|
-
default: choices[0]?.value ?? "",
|
|
265
|
-
parse: (raw) => choices.some((c) => c.value === raw)
|
|
266
|
-
});
|
|
267
|
-
return /* @__PURE__ */ jsx(ChoiceGroupView, {
|
|
268
|
-
...props,
|
|
269
|
-
choices,
|
|
270
|
-
value,
|
|
271
|
-
onChange: (next) => {
|
|
272
|
-
setValue(next);
|
|
273
|
-
onChange?.(next);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
function ChoiceGroupView({ legend, name, choices, value, onChange, error }) {
|
|
278
|
-
const errorId = React.useId();
|
|
279
|
-
return /* @__PURE__ */ jsxs(RadioGroup, {
|
|
280
|
-
name,
|
|
281
|
-
value,
|
|
282
|
-
onChange,
|
|
283
|
-
"aria-describedby": error ? errorId : void 0,
|
|
284
|
-
className: "grid gap-2",
|
|
285
|
-
children: [
|
|
286
|
-
/* @__PURE__ */ jsx(Label, {
|
|
287
|
-
className: "mb-1.5 type-label text-foreground",
|
|
288
|
-
children: legend
|
|
289
|
-
}),
|
|
290
|
-
choices.map((c) => /* @__PURE__ */ jsxs(Radio, {
|
|
291
|
-
value: c.value,
|
|
292
|
-
className: "group flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1",
|
|
293
|
-
children: [
|
|
294
|
-
/* @__PURE__ */ jsx("span", {
|
|
295
|
-
"aria-hidden": true,
|
|
296
|
-
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",
|
|
297
|
-
children: /* @__PURE__ */ jsx("span", { className: "size-2 rounded-pill bg-primary opacity-0 group-selected:opacity-100" })
|
|
298
|
-
}),
|
|
299
|
-
c.leading && /* @__PURE__ */ jsx("span", {
|
|
300
|
-
className: "mt-0.5 shrink-0",
|
|
301
|
-
children: c.leading
|
|
302
|
-
}),
|
|
303
|
-
/* @__PURE__ */ jsxs("span", {
|
|
304
|
-
className: "grid",
|
|
305
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
306
|
-
className: "type-body",
|
|
307
|
-
children: c.label
|
|
308
|
-
}), c.detail && /* @__PURE__ */ jsx("span", {
|
|
309
|
-
className: "type-body-sm text-muted-foreground",
|
|
310
|
-
children: c.detail
|
|
311
|
-
})]
|
|
312
|
-
})
|
|
313
|
-
]
|
|
314
|
-
}, c.value)),
|
|
315
|
-
error && /* @__PURE__ */ jsxs("p", {
|
|
316
|
-
id: errorId,
|
|
317
|
-
className: "flex items-start gap-1.5 type-body-sm text-danger",
|
|
318
|
-
children: [/* @__PURE__ */ jsx(CircleAlert, {
|
|
319
|
-
"aria-hidden": true,
|
|
320
|
-
className: "mt-0.5 size-4 shrink-0"
|
|
321
|
-
}), error]
|
|
322
|
-
})
|
|
323
|
-
]
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
export { Textarea as a, useSearchParam as c, cn as d, typeSteps as f, NativeSelect as i, Tooltip$1 as l, Field as n, useFieldControl as o, Input$1 as r, controlHeight as s, ChoiceGroup as t, KeyText as u };
|
|
327
|
-
|
|
328
|
-
//# sourceMappingURL=field-jfhLD5XX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-jfhLD5XX.js","names":["_Fragment","Tooltip","AriaTooltip","Input"],"sources":["../src/lib/utils.ts","../src/components/key-glyphs.tsx","../src/components/tooltip.tsx","../src/lib/search-param.ts","../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\", \"picture\"] 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","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>(key: string, { default: fallback, parse, replace = true }: SearchParamOptions<T>): 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 = { 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(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({ param, paramDefault, onChange, children, ...props }: 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, { default: paramDefault, parse: (raw) => options.length === 0 || options.includes(raw) });\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, { default: choices[0]?.value ?? \"\", parse: (raw) => choices.some((c) => c.value === raw) });\n return <ChoiceGroupView {...props} choices={choices} value={value} onChange={(next) => { setValue(next); onChange?.(next); }} />;\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 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 {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"],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AAmB,UAAA,EAAE;KAAc,CAAA;KACjE,qBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACE,oBAAC,QAAD;OAAM,WAAU;OAAa,UAAA,EAAE;MAAY,CAAA,GAC1C,EAAE,UAAU,oBAAC,QAAD;OAAM,WAAU;OAAsC,UAAA,EAAE;MAAa,CAAA,CAC9E;;IACD;GAZK,GAAA,EAAE,KAYP,CACR;GACA,SACC,qBAAC,KAAD;IAAG,IAAI;IAAS,WAAU;IAA1B,UAAA,CACE,oBAAC,aAAD;KAAa,eAAA;KAAY,WAAU;IAA0B,CAAA,GAC5D,KACA;;EAEK;;AAEhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-BNkXVwFx.js","names":[],"sources":["../src/lib/format.ts"],"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 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) => (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) => 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 * 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: (seconds: number | null | undefined, { precision = \"seconds\", fps = 30 }: { precision?: \"seconds\" | \"ms\" | \"frames\"; fps?: number } = {}) => {\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\") return `${base}.${String(Math.min(Math.floor((seconds - whole) * 1000 + 1e-6), 999)).padStart(3, \"0\")}`;\n if (precision === \"frames\") 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 } = 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 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 ? withUnit(metres, \"m\") : 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: (value: number | null | undefined, one: string, many = `${one}s`, { compact: short = false }: CountOptions = {}) =>\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"],"mappings":";AA4CA,IAAa,OAAO;;AAGpB,IAAa,UAAU;AAIvB,IAAM,aAAkC;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;AAAI;AAC1E,IAAM,YAAY,OAAO,YAAY,WAAW,KAAK,GAAG,MAAM,CAAC,GAAG,OAAQ,CAAC,CAAC,CAAC;AAI7E,IAAM,eAA0C;CAAC;CAAK;CAAO;CAAO;CAAO;CAAO;AAAK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Aa;GACtE,IAAI,WAAW,YAAY;IACzB,MAAM,QAAQ,SAAS;IACvB,OAAO,QAAQ,KAAM,SAAS,SAAS,SAAS,IAAI,IAAI,SAAS,OAAO,MAAM,QAAQ,MAAM,UAAU,OAAO;GAC/G;GACA,OAAO,KAAK,IAAI,MAAM,IAAI,MAAO,SAAS,QAAQ,GAAG,IAAI,SAAS,SAAS,KAAM,MAAM,KAAK,IAAI,MAAM,IAAI,MAAU,UAAU,OAAO;EACvI;;EAEA,WAAW,OAAe,EAAE,SAAS,UAAgC,CAAC,MAAM,eAAe,OAAO,MAAM;;;;;;EAMxG,QAAQ,OAAkC,KAAa,OAAO,GAAG,IAAI,IAAI,EAAE,SAAS,QAAQ,UAAwB,CAAC,MACnH,SAAS,OACL,UACA,IAAI,QAAQ,UAAU,QAAA,CAAS,OAAO,KAAK,KAAW,QAAQ,OAAO,KAAK,MAAM,QAAQ,MAAM;CACtG;AACF;;AAKA,IAAa,SAAS,aAAa,OAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"microphone-CZy0bNEx.js","names":["ToastQueue","ToastRegion","AriaToast","ToastContent","Button","AriaButton"],"sources":["../src/lib/overlay.ts","../src/query/poll.ts","../src/query/index.tsx","../src/components/toast.tsx","../src/lib/microphone.ts"],"sourcesContent":["// The look every floating surface shares (Dialog, Popover, and later Menu and Toast): the popover\n// role pair, an overlay radius, one hairline and the one shadow that exists for what floats\n// (components.md §3.11). One string, so a menu and a popover cannot drift apart.\nexport const overlaySurface =\n \"rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay\";\n","import * as React from \"react\";\nimport type { UseQueryResult } from \"@tanstack/react-query\";\n\n// Pausing a polled read (strata-react issue #344, from the status page in jburnhams/homepage). A\n// screen that re-reads every few seconds needs the same three parts every time: whether it is\n// paused, a button that says so, and when the readings were taken. A person reading a table while\n// it re-sorts under them needs the pause (ux-research `patterns.md` on live data: the person, not\n// the poll, decides when the view moves); a page whose readings may be minutes old needs the time.\n// Written by hand it was a `useState`, a button with `aria-pressed`, `refetchInterval: paused ?\n// false : ms` and an \"updated 12:00\" line, in every live screen.\n//\n// - `usePoll({ every })` holds the state and is passed to `useLoad({ poll })`, which polls at its\n// interval while it is not paused, notes when each read arrived, and reads once at once when the\n// poll is resumed (what was on screen is as old as the pause).\n// - `PauseButton` (components/pause-button.tsx) takes the same object, with its words fixed.\n// - One `Poll` may serve several reads: the page pauses together. The time is the latest read's. A read\n// with its own pace takes `poll.with({ every })`: same pause and time, other interval (#349).\n// - `useJob` keeps its own interval: a job is polled only while it runs, which is not the person's\n// to pause.\n\n/** The state of a polled read: its interval, whether the person paused it and when it last read. Made by `usePoll`. */\nexport type Poll = {\n /** Milliseconds between reads while not paused. */\n every: number;\n paused: boolean;\n /** Pause or resume. Resuming reads at once. */\n toggle: () => void;\n /** When the last read arrived, or `null` before the first. */\n updatedAt: Date | null;\n /** Used by `useLoad`: records the time of the read that just arrived (TanStack's `dataUpdatedAt`; 0 is none). */\n note: (dataUpdatedAt: number) => void;\n /** The same poll at another pace: a read that must be slower (or faster) than the page's keeps the shared pause, resume and \"updated\" time (`useLoad({ poll: poll.with({ every: 60_000 }) })`). */\n with: (override: { every: number }) => Poll;\n};\n\n/** The pause state and last-read time of a polled screen: pass it to `useLoad({ poll })` and to `PauseButton`. */\nexport function usePoll({ every, paused: initiallyPaused = false }: { every: number; paused?: boolean }): Poll {\n const [paused, setPaused] = React.useState(initiallyPaused);\n const [at, setAt] = React.useState(0);\n const toggle = React.useCallback(() => setPaused((p) => !p), []);\n const note = React.useCallback((dataUpdatedAt: number) => setAt((previous) => Math.max(previous, dataUpdatedAt)), []);\n return React.useMemo(() => {\n const poll: Poll = { every, paused, toggle, updatedAt: at ? new Date(at) : null, note, with: (override) => ({ ...poll, every: override.every, with: (again) => poll.with(again) }) };\n return poll;\n }, [every, paused, toggle, at, note]);\n}\n\n/** Wires a query to its `Poll`: the time of each read, and one read when the poll is resumed. */\nexport function usePollBinding(poll: Poll | undefined, query: Pick<UseQueryResult, \"dataUpdatedAt\" | \"refetch\">) {\n const note = poll?.note;\n React.useEffect(() => {\n if (note && query.dataUpdatedAt) note(query.dataUpdatedAt);\n }, [note, query.dataUpdatedAt]);\n const paused = poll?.paused;\n const wasPaused = React.useRef(paused);\n React.useEffect(() => {\n if (wasPaused.current && paused === false) void query.refetch();\n wasPaused.current = paused;\n // `refetch` is stable per query; only the pause changing should read.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [paused]);\n}\n","import * as React from \"react\";\nimport {\n QueryClient,\n QueryClientProvider,\n useQuery,\n type QueryKey,\n type UseQueryOptions,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport type { Load, Stale } from \"../components/data-view\";\nimport { usePollBinding, type Poll } from \"./poll\";\nimport { HttpError, describeHttpError, errorPayload, readErrorBody, type DescribeError, type ErrorBody } from \"../lib/errors\";\n\nexport { HttpError, describeHttpError, errorPayload, readErrorBody, type DescribeError, type ErrorBody };\n\n// Data loading, the Strata way: TanStack Query fetches and caches, and every view of the result\n// goes through DataView, which takes a Load<T>. `toLoad` is the one bridge between them, so a\n// screen never re-derives loading/error/ready from a query's flags and never forgets one.\n//\n// Opinions in createQueryClient: one retry (a second failure is real and the person should see\n// it with a \"Try again\"), 30 s stale time (dashboards are read many times a minute but change\n// over minutes), and no refetch on window focus (a table that reorders itself while someone reads\n// it is worse than one that is 30 s old). Override per query when the data says otherwise.\n\n/** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */\nexport function createQueryClient(overrides?: ConstructorParameters<typeof QueryClient>[0]) {\n return new QueryClient({\n ...overrides,\n defaultOptions: {\n ...overrides?.defaultOptions,\n queries: { retry: 1, staleTime: 30_000, refetchOnWindowFocus: false, ...overrides?.defaultOptions?.queries },\n },\n });\n}\n\n/** Provides a query client (Strata's defaults unless one is passed) to the app. */\nexport function StrataQueryProvider({ client, children }: { client?: QueryClient; children: React.ReactNode }) {\n const [fallback] = React.useState(() => client ?? createQueryClient());\n return <QueryClientProvider client={client ?? fallback}>{children}</QueryClientProvider>;\n}\n\n/**\n * Turns a TanStack query result into the `Load<T>` that `DataView` takes; errors are described for a person by `describe`.\n * A refetch that fails after data arrived stays `ready`, with `stale` saying why and when the data was read.\n */\nexport function toLoad<T>(query: UseQueryResult<T>, describe: DescribeError = describeHttpError): Load<T> {\n if (query.status === \"success\") return { status: \"ready\", data: query.data };\n // TanStack keeps the last good data when a refetch fails and sets status \"error\" (isRefetchError).\n // That is old data, not no data: keep it on screen and say how old it is.\n if (query.status === \"error\" && query.data !== undefined) return { status: \"ready\", data: query.data, stale: staleOf(query, describe) };\n if (query.status === \"error\") return { status: \"error\", message: describe(query.error), retry: () => void query.refetch() };\n return { status: \"loading\" };\n}\n\n/** The `Stale` of a query whose refetch failed after a good read. Shared by `toLoad` and `useInfiniteLoad`. */\nexport function staleOf(\n query: { error: unknown; dataUpdatedAt: number; isFetching: boolean; refetch: () => unknown },\n describe: DescribeError = describeHttpError,\n): Stale {\n return { message: describe(query.error), readAt: new Date(query.dataUpdatedAt), retry: () => void query.refetch(), retrying: query.isFetching };\n}\n\n/** `useQuery`, returned as a `Load<T>` for `DataView`. With `poll` (from `usePoll`) it reads again every `poll.every` ms until the person pauses it. */\nexport function useLoad<T, K extends QueryKey = QueryKey>(\n options: UseQueryOptions<T, Error, T, K> & {\n describeError?: DescribeError;\n /** Read again on this poll's interval unless it is paused; see `usePoll` and `PauseButton`. Replaces `refetchInterval`. */\n poll?: Poll;\n },\n): Load<T> {\n const { describeError, poll, ...rest } = options;\n const query = useQuery(poll ? { ...rest, refetchInterval: poll.paused ? false : poll.every } : rest);\n usePollBinding(poll, query);\n return toLoad(query, describeError);\n}\n\n/** What `fetchJson` takes as `fetch`'s init, plus `json`. */\nexport type FetchJsonInit = RequestInit & {\n /**\n * A value sent as the JSON body: `Content-Type: application/json` is set unless the caller gave one, and the method is `POST` unless given.\n * Replaces `body`; an app never builds the `RequestInit` for a write by hand.\n */\n json?: unknown;\n};\n\n/** Options for `fetchJson` beyond `fetch`'s own. */\nexport type FetchJsonOptions = {\n /** Finds the server's reason and per-field messages in an error body. Default `readErrorBody` (FastAPI's `detail`, `message`, `error`). */\n readError?: (body: unknown) => ErrorBody;\n};\n\n/**\n * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.\n * `init.json` sends a JSON body without building the headers. A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).\n */\nexport async function fetchJson<T>(input: string | URL, init?: FetchJsonInit, { readError = readErrorBody }: FetchJsonOptions = {}): Promise<T> {\n const { json, ...rest } = init ?? {};\n // Headers, tuple arrays and plain objects are all valid HeadersInit; normalise before adding the\n // default so a caller's Authorization (or their own Accept) is never dropped.\n const headers = new Headers(rest.headers);\n if (!headers.has(\"Accept\")) headers.set(\"Accept\", \"application/json\");\n if (json !== undefined) {\n if (!headers.has(\"Content-Type\")) headers.set(\"Content-Type\", \"application/json\");\n rest.body = JSON.stringify(json);\n rest.method ??= \"POST\";\n }\n const res = await fetch(input, { ...rest, headers });\n if (!res.ok) {\n // The body is read as text and parsed only when it parses: a proxy's HTML 502 page or an empty\n // body must still throw the HttpError, never a JSON SyntaxError in its place.\n const raw = await res.text().catch(() => \"\");\n let body: unknown = raw || undefined;\n try {\n if (raw) body = JSON.parse(raw);\n } catch {\n // Not JSON: keep the text.\n }\n throw new HttpError(res.status, res.statusText, String(input), body, readError(body));\n }\n // Writes (DELETE, a PUT that returns nothing) answer 204 or an empty body; that is success, not a\n // JSON parse error.\n const text = res.status === 204 ? \"\" : await res.text();\n return (text ? JSON.parse(text) : undefined) as T;\n}\n\nexport { usePoll, type Poll } from \"./poll\";\nexport { createApi, type Api, type ApiOptions } from \"./api\";\nexport { createTypedApi, type TypedApi } from \"./typed-api\";\nexport { useInfiniteLoad, apiPage, type ApiPage, type InfiniteLoad, type InfiniteLoadOptions, type More } from \"./infinite\";\nexport { useJob, isTaskRunning, type Job, type JobOptions } from \"./job\";\nexport { useWorkflowRun, isWorkflowRunning, type WorkflowRunLike, type WorkflowRunOptions } from \"./workflow\";\n","import * as React from \"react\";\nimport { UNSTABLE_Toast as AriaToast, UNSTABLE_ToastContent as ToastContent, UNSTABLE_ToastQueue as ToastQueue, UNSTABLE_ToastRegion as ToastRegion, Button as AriaButton, Text } from \"react-aria-components\";\nimport { CircleCheck, Info, TriangleAlert, X } from \"lucide-react\";\nimport { Button } from \"./button\";\nimport { cn } from \"../lib/utils\";\nimport { overlaySurface } from \"../lib/overlay\";\nimport { isDev } from \"../lib/dev\";\n\n// A toast confirms background work that finished (\"Export finished\", \"3 pieces synced\"). It is a\n// polite live region; it never carries an error a person must act on, which goes inline as an\n// `Alert` with its recovery (components.md §3.13, patterns.md §7), so there is no danger tone:\n// the type refuses it. `warning` is for a fact worth a glance (\"Kiln 2 is 40 min behind\").\n//\n// Rules the component owns so an app does not have to:\n// - One region, once, at the app root (`ToastRegion`), on the `layer-bar` layer: bottom end of the\n// window on a wide screen, the top on a phone, so it does not sit on the undo bar or cover the\n// focused control. It is a labelled landmark the keyboard reaches with F6 (React Aria).\n// - It stays long enough to read: 5 s plus 40 ms a character, up to 15 s, at least 8 s with an\n// action. The timer pauses while the pointer or focus is on it. There is always a dismiss control.\n// - At most one action, a button (\"Open file\"); content is words, not a form.\n// - Announcements are React Aria's: the toast's text is read when it appears and not again.\n// - The queue is module-level, so `toast.show()` works from a mutation's `onSuccess` outside any\n// component; `toast.clear()` empties it for a test. React Aria marks its toast API unstable; it\n// is used only here, behind this small surface, so a change upstream stays in this file.\n// - One region at a time, enforced (issue #230): the first mounted owns the queue and a second one draws nothing and\n// says so in development, naming the fix. Two regions on one queue show every toast twice, which looks like a bug in\n// the toast and (in a test) fails `findByText` with \"Found multiple elements\"; the usual cause is a route tree that\n// draws the region in its root layout while a test helper draws one too (`renderRoutes(..., { toasts: false })`),\n// or an app with a region in a layout and another in a page. Ownership is held by a mounted-order list, not by the\n// queue, so unmounting the owner hands it to the next region.\n// Toasts are rare and brief, so they get the overlay entrance and nothing else (character.md §3).\n\n/** What a toast says. */\nexport type ToastContentProps = {\n /** What finished, past tense, in the product's words: \"Export finished\". */\n title: string;\n /** One more sentence: what and where (\"run.mp4, 2:31 at 1080p, in your Downloads folder.\"). */\n description?: string;\n /** `info` by default. There is no danger tone: an error the person must act on is an `Alert`. */\n tone?: \"info\" | \"success\" | \"warning\";\n /** One action beside the words. */\n action?: { label: string; onPress: () => void };\n /** Milliseconds before it goes. Defaults to enough to read the words. */\n timeout?: number;\n};\n\nconst queue = new ToastQueue<ToastContentProps>({ maxVisibleToasts: 3 });\n\n/** Milliseconds a toast stays: 5 s plus 40 ms a character, to at most 15 s, and at least 8 s with an action. */\nexport function toastTimeout(content: Pick<ToastContentProps, \"title\" | \"description\" | \"action\" | \"timeout\">): number {\n if (content.timeout !== undefined) return content.timeout;\n const chars = content.title.length + (content.description?.length ?? 0) + (content.action?.label.length ?? 0);\n return Math.max(content.action ? 8000 : 0, Math.min(15000, 5000 + 40 * chars));\n}\n\n/** The toast queue: `toast.show({ title })` from anywhere; `toast.close(key)`; `toast.clear()`. */\nexport const toast = {\n /** Shows a toast and returns its key. */\n show(content: ToastContentProps): string {\n // Nothing appears without a region, and nothing says so: in development the first such call does (issue #249).\n if (mounted.length === 0 && !warnedNoRegion && isDev()) {\n warnedNoRegion = true;\n console.warn(\"strata-react: toast.show() was called but no StrataToastRegion is mounted, so nothing will appear. Render <StrataToastRegion /> once at the app root.\");\n }\n return queue.add(content, { timeout: toastTimeout(content) });\n },\n close(key: string) {\n queue.close(key);\n },\n clear() {\n queue.clear();\n },\n};\n\nconst marks = { info: { icon: Info, color: \"text-info\" }, success: { icon: CircleCheck, color: \"text-success\" }, warning: { icon: TriangleAlert, color: \"text-warning\" } } as const;\n\n/** Props for `ToastRegion`. */\nexport type StrataToastRegionProps = {\n /** Names the landmark. Default \"Notifications\". */\n label?: string;\n className?: string;\n};\n\n// The regions mounted now, oldest first: the first draws, the rest stay empty.\nconst mounted: string[] = [];\nlet warnedNoRegion = false;\n/** For tests: forget that the missing-region warning was given. */\nexport function resetToastWarnings() {\n warnedNoRegion = false;\n}\nconst watchers = new Set<() => void>();\nconst changed = () => watchers.forEach((w) => w());\nconst watch = (w: () => void) => {\n watchers.add(w);\n return () => void watchers.delete(w);\n};\n\n/** True while this region is the one that draws. The server and the first client render say yes, so hydration matches. */\nfunction useOwnsQueue(): boolean {\n const id = React.useId();\n React.useLayoutEffect(() => {\n mounted.push(id);\n changed();\n return () => {\n mounted.splice(mounted.indexOf(id), 1);\n changed();\n };\n }, [id]);\n const owns = React.useSyncExternalStore(watch, () => mounted[0] === id, () => true);\n const [warned, setWarned] = React.useState(false);\n React.useEffect(() => {\n if (owns || warned || mounted.indexOf(id) < 1) return;\n setWarned(true);\n if (isDev()) {\n console.warn(\"strata-react: a StrataToastRegion is already mounted, so this one draws nothing. Render it once at the app root; in a test of a route tree that draws its own, pass `toasts: false` to renderRoutes.\");\n }\n }, [owns, warned, id]);\n return owns;\n}\n\n/** The one place toasts appear. Render it once at the app root; a second one mounted at the same time draws nothing and warns in development. A labelled landmark (F6), polite, above panes and the undo bar. */\nexport function StrataToastRegion({ label = \"Notifications\", className }: StrataToastRegionProps) {\n const owns = useOwnsQueue();\n if (!owns) return null;\n return (\n <ToastRegion\n queue={queue}\n aria-label={label}\n 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)}\n >\n {({ toast: t }) => (\n <AriaToast\n toast={t}\n 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)}\n >\n {(() => {\n const { icon: Icon, color } = marks[t.content.tone ?? \"info\"];\n return <Icon aria-hidden className={cn(\"mt-0.5 size-4 shrink-0\", color)} />;\n })()}\n <ToastContent className=\"grid min-w-0 flex-1 gap-0.5\">\n <Text slot=\"title\" className=\"type-label\">\n {t.content.title}\n </Text>\n {t.content.description && <Text slot=\"description\" className=\"type-body-sm text-muted-foreground\">{t.content.description}</Text>}\n </ToastContent>\n {t.content.action && (\n <Button size=\"sm\" onPress={() => { t.content.action?.onPress(); queue.close(t.key); }}>\n {t.content.action.label}\n </Button>\n )}\n <AriaButton slot=\"close\" aria-label=\"Dismiss\" className=\"grid size-6 shrink-0 cursor-pointer place-items-center rounded-control text-muted-foreground transition-state hover:bg-muted hover:text-foreground\">\n <X aria-hidden className=\"size-4\" />\n </AriaButton>\n </AriaToast>\n )}\n </ToastRegion>\n );\n}\n","import * as React from \"react\";\n\n// The microphone as raw samples, for an app that records speech (strata-voice's studio). What an app would\n// otherwise write each time:\n// - MediaRecorder only writes compressed audio, so the samples come through an AudioWorklet (loaded from a\n// Blob URL, so the app ships no worklet file) that posts 2048 frames at a time (~43 ms at 48 kHz): about\n// 23 messages a second instead of one per 128-frame render quantum.\n// - Echo cancellation, noise suppression and automatic gain are off: each reshapes a voice, and a take is\n// meant to be the voice as it was. The worklet feeds a silent gain into the output, because a worklet\n// nothing pulls does not run.\n// - getUserMedia exists only on a secure page (https:// or http://localhost), and its refusals are\n// DOMExceptions by name; `explainMicrophoneError` turns both into a sentence a person can act on.\n// - The device is behind `MicrophoneContext`, so a screen takes it from `useMicrophone()` and a test or\n// story gives it `fakeMicrophone()` (strata-react/testing) instead: hardware is the one true external.\n// Not a React Aria part: there is none for capture, and nothing here is a control.\n// `browserMicrophone` is covered by the stories in Chromium only: jsdom has no audio graph.\n\n/** A microphone that is open and sending samples. */\nexport type MicrophoneStream = {\n sampleRate: number;\n /** What the browser calls the device (\"USB Audio Device\"), or null when it says nothing. */\n device: string | null;\n /** Stops the device (the browser's recording light goes out). */\n close: () => void;\n};\n\n/** Something that can be opened to send mono samples (-1 to 1) a chunk at a time. */\nexport type Microphone = {\n open: (onSamples: (chunk: Float32Array) => void) => Promise<MicrophoneStream>;\n};\n\n/** A microphone that would not open, with a sentence a person can act on. */\nexport class MicrophoneError extends Error {}\n\n/** The sentence for what getUserMedia threw. */\nexport function explainMicrophoneError(e: unknown): MicrophoneError {\n const name = e instanceof DOMException ? e.name : \"\";\n if (name === \"NotAllowedError\")\n return new MicrophoneError(\"The browser was not allowed to use the microphone. Allow it from the address bar, then try again.\");\n if (name === \"NotFoundError\") return new MicrophoneError(\"No microphone was found. Plug one in, then try again.\");\n if (name === \"NotReadableError\") return new MicrophoneError(\"The microphone is in use by another program. Close it, then try again.\");\n // DOMException is checked apart from Error: it is an Error in browsers but not in every runtime (jsdom).\n const said = e instanceof DOMException || e instanceof Error ? e.message : String(e);\n return new MicrophoneError(`The microphone could not be opened (${said}).`);\n}\n\nconst WORKLET = `\nclass StrataTap extends AudioWorkletProcessor {\n constructor() { super(); this.buf = new Float32Array(2048); this.n = 0 }\n process(inputs) {\n const ch = inputs[0] && inputs[0][0]\n if (ch) for (let i = 0; i < ch.length; i++) {\n this.buf[this.n++] = ch[i]\n if (this.n === this.buf.length) { this.port.postMessage(this.buf.slice()); this.n = 0 }\n }\n return true\n }\n}\nregisterProcessor('strata-tap', StrataTap)\n`;\n\n/** The browser's own microphone, with its processing off. */\nexport const browserMicrophone: Microphone = {\n async open(onSamples) {\n if (typeof navigator === \"undefined\" || !navigator.mediaDevices?.getUserMedia)\n throw new MicrophoneError(\"The microphone needs a secure page: open the app at http://localhost or over https.\");\n let media: MediaStream;\n try {\n media = await navigator.mediaDevices.getUserMedia({\n audio: { channelCount: 1, echoCancellation: false, noiseSuppression: false, autoGainControl: false },\n });\n } catch (e) {\n throw explainMicrophoneError(e);\n }\n let context: AudioContext | undefined;\n const close = () => {\n for (const t of media.getTracks()) t.stop();\n void context?.close();\n };\n // Once the device is open, any failure building the graph closes it again: the caller gets no stream to\n // close, and the browser's recording light would otherwise stay on.\n try {\n context = new AudioContext();\n const url = URL.createObjectURL(new Blob([WORKLET], { type: \"text/javascript\" }));\n try {\n await context.audioWorklet.addModule(url);\n } finally {\n URL.revokeObjectURL(url);\n }\n const tap = new AudioWorkletNode(context, \"strata-tap\");\n tap.port.onmessage = (event: MessageEvent<Float32Array>) => onSamples(event.data);\n const mute = context.createGain();\n mute.gain.value = 0;\n context.createMediaStreamSource(media).connect(tap).connect(mute).connect(context.destination);\n return { sampleRate: context.sampleRate, device: media.getAudioTracks()[0]?.label || null, close };\n } catch (e) {\n close();\n throw explainMicrophoneError(e);\n }\n },\n};\n\n/** The microphone screens record from: the browser's, unless a provider gives another (a fake in tests and stories). */\nexport const MicrophoneContext = React.createContext<Microphone>(browserMicrophone);\n\n/** The microphone from the nearest `MicrophoneContext`. */\nexport const useMicrophone = (): Microphone => React.useContext(MicrophoneContext);\n"],"mappings":";;;;;;;;AAGA,IAAa,iBACX;;;ACgCF,SAAgB,QAAQ,EAAE,OAAO,QAAQ,kBAAkB,SAAoD;CAC7G,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAS,eAAe;CAC1D,MAAM,CAAC,IAAI,SAAS,MAAM,SAAS,CAAC;CACpC,MAAM,SAAS,MAAM,kBAAkB,WAAW,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;CAC/D,MAAM,OAAO,MAAM,aAAa,kBAA0B,OAAO,aAAa,KAAK,IAAI,UAAU,aAAa,CAAC,GAAG,CAAC,CAAC;CACpH,OAAO,MAAM,cAAc;EACzB,MAAM,OAAa;GAAE;GAAO;GAAQ;GAAQ,WAAW,KAAK,IAAI,KAAK,EAAE,IAAI;GAAM;GAAM,OAAO,cAAc;IAAE,GAAG;IAAM,OAAO,SAAS;IAAO,OAAO,UAAU,KAAK,KAAK,KAAK;GAAE;EAAG;EACnL,OAAO;CACT,GAAG;EAAC;EAAO;EAAQ;EAAQ;EAAI;CAAI,CAAC;AACtC;;AAGA,SAAgB,eAAe,MAAwB,OAA0D;CAC/G,MAAM,OAAO,MAAM;CACnB,MAAM,gBAAgB;EACpB,IAAI,QAAQ,MAAM,eAAe,KAAK,MAAM,aAAa;CAC3D,GAAG,CAAC,MAAM,MAAM,aAAa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