strata-react 1.0.12 → 1.0.18
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 +10 -3
- package/UPGRADING.md +4 -0
- package/dist/components/button.d.ts +6 -3
- package/dist/components/density.d.ts +16 -0
- package/dist/components/field.d.ts +9 -4
- package/dist/components/file-intake.d.ts +7 -2
- package/dist/components/history.d.ts +61 -0
- package/dist/components/line-chart.d.ts +3 -1
- package/dist/components/save.d.ts +46 -0
- package/dist/components/theme.d.ts +7 -1
- package/dist/components/timeline.d.ts +19 -2
- package/dist/components/value-controls.d.ts +4 -1
- package/dist/components/workspace.d.ts +63 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +901 -111
- package/dist/index.js.map +1 -1
- package/dist/lib/control.d.ts +4 -0
- package/dist/lib/format.d.ts +12 -6
- package/dist/{query-CXlmWmrY.js → query-CIh1Dpgn.js} +43 -11
- package/dist/query-CIh1Dpgn.js.map +1 -0
- package/dist/strata.css +7 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/query-CXlmWmrY.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as describeHttpError, D as cn, E as Tooltip, O as typeSteps, S as describeActionError, T as readErrorBody, _ as NativeSelect, a as toLoad, b as controlHeight, c as ColorSchemeChoice, d as useColorScheme, f as useSystemColorScheme, g as Input, h as Field, i as staleOf, l as ThemeProvider, m as ChoiceGroup, n as createQueryClient, o as useLoad, p as Density, r as fetchJson, s as COLOR_SCHEME_STORAGE_KEY, t as StrataQueryProvider, u as colorSchemeScript, v as Textarea, w as fieldErrorsOf, x as HttpError, y as useFieldControl } from "./query-CIh1Dpgn.js";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, I18nProvider, Input as Input$1, Keyboard, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, NumberField as NumberField$1, Popover as Popover$1, Row, SearchField, Separator, Slider as Slider$1, SliderOutput, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Toolbar as Toolbar$1, UNSTABLE_Toast, UNSTABLE_ToastContent, UNSTABLE_ToastQueue, UNSTABLE_ToastRegion, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronRight, CircleAlert, CircleCheck, FileQuestion, GripVertical, History, ImageOff, Info, Loader, LoaderCircle, Maximize, Maximize2, Minimize, Minus, Pause, Play, RotateCcw, Scan, Search, SkipBack, SkipForward, Square, StepBack, StepForward, Trash2, TriangleAlert, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
6
|
+
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronRight, CircleAlert, CircleCheck, FileQuestion, GripVertical, History, ImageOff, Info, Loader, LoaderCircle, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Play, Redo2, RotateCcw, Scan, Search, SkipBack, SkipForward, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
7
7
|
import { Link, NavLink, useSearchParams } from "react-router";
|
|
8
8
|
import { createSortedRowModel, flexRender, rowSortingFeature, tableFeatures, useTable } from "@tanstack/react-table";
|
|
9
|
-
import { VisuallyHidden, mergeProps, useFocusRing, useSlider, useSliderThumb } from "react-aria";
|
|
9
|
+
import { VisuallyHidden, mergeProps, useDrop, useFocusRing, useMove, useSlider, useSliderThumb } from "react-aria";
|
|
10
10
|
import { Size, useSliderState } from "react-stately";
|
|
11
11
|
import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
12
12
|
import pixelmatch from "pixelmatch";
|
|
@@ -141,9 +141,12 @@ function createFormat(locale, options = {}) {
|
|
|
141
141
|
},
|
|
142
142
|
/**
|
|
143
143
|
* A position in media as an editor shows it, to a chosen precision: "4:05" (seconds), "4:05.250"
|
|
144
|
-
* (`"ms"`), or "
|
|
145
|
-
* one hour
|
|
146
|
-
* (
|
|
144
|
+
* (`"ms"`), or "0:04:05:07" (`"frames"` at `fps`, the last part the frame). Hours appear only
|
|
145
|
+
* from one hour, except in frames. Frames are always four parts, hours included, as SMPTE
|
|
146
|
+
* timecode is (non-drop frame, with colons): a three-part "1:05:00" reads as one hour five, so
|
|
147
|
+
* a frame count must never be three. Editors write the same four parts (strata-react issue
|
|
148
|
+
* #122). Floors, never rounds up, so a time never reads ahead of the picture. Unknown (null,
|
|
149
|
+
* negative, not finite) prints the placeholder. Set it in `tabular-nums`.
|
|
147
150
|
*/
|
|
148
151
|
timecode: (seconds, { precision = "seconds", fps = 30 } = {}) => {
|
|
149
152
|
if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;
|
|
@@ -152,7 +155,7 @@ function createFormat(locale, options = {}) {
|
|
|
152
155
|
const [h, m] = [Math.floor(whole / 3600), Math.floor(whole % 3600 / 60)];
|
|
153
156
|
const base = h > 0 ? `${h}:${two(m)}:${two(whole % 60)}` : `${m}:${two(whole % 60)}`;
|
|
154
157
|
if (precision === "ms") return `${base}.${String(Math.min(Math.floor((seconds - whole) * 1e3 + 1e-6), 999)).padStart(3, "0")}`;
|
|
155
|
-
if (precision === "frames") return `${
|
|
158
|
+
if (precision === "frames") return `${h}:${two(m)}:${two(whole % 60)}:${two(Math.min(Math.floor((seconds - whole) * fps + 1e-6), Math.ceil(fps) - 1))}`;
|
|
156
159
|
return base;
|
|
157
160
|
},
|
|
158
161
|
/** What a missing value prints as: an en dash unless `createFormat`'s `missing` says otherwise. */
|
|
@@ -233,7 +236,7 @@ function useInView({ active = true, rootMargin = "0px", once = false, unsupporte
|
|
|
233
236
|
};
|
|
234
237
|
}
|
|
235
238
|
// src/components/button.tsx
|
|
236
|
-
var buttonVariants = cva("inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", {
|
|
239
|
+
var buttonVariants = cva("inline-flex max-w-full shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", {
|
|
237
240
|
variants: {
|
|
238
241
|
variant: {
|
|
239
242
|
default: "bg-primary text-primary-foreground hover:bg-primary-10",
|
|
@@ -246,7 +249,8 @@ var buttonVariants = cva("inline-flex shrink-0 cursor-pointer items-center justi
|
|
|
246
249
|
size: {
|
|
247
250
|
default: "h-(--control-h) px-4",
|
|
248
251
|
sm: "h-(--control-h-sm) px-3",
|
|
249
|
-
icon: "size-(--control-h)"
|
|
252
|
+
icon: "size-(--control-h)",
|
|
253
|
+
"icon-sm": "size-(--control-h-sm)"
|
|
250
254
|
}
|
|
251
255
|
},
|
|
252
256
|
defaultVariants: {
|
|
@@ -260,7 +264,7 @@ var buttonVariants = cva("inline-flex shrink-0 cursor-pointer items-center justi
|
|
|
260
264
|
* `outline`; ask for the filled accent (`variant="default"`) once per view. `type` defaults to `button`.
|
|
261
265
|
* `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.
|
|
262
266
|
*/
|
|
263
|
-
function Button({ className, variant, size, type = "button", disabled, ...props }) {
|
|
267
|
+
function Button({ className, variant, size, type = "button", disabled, children, ...props }) {
|
|
264
268
|
return /* @__PURE__ */ jsx(Button$1, {
|
|
265
269
|
type,
|
|
266
270
|
isDisabled: disabled,
|
|
@@ -269,16 +273,20 @@ function Button({ className, variant, size, type = "button", disabled, ...props
|
|
|
269
273
|
variant,
|
|
270
274
|
size
|
|
271
275
|
}), className),
|
|
272
|
-
...props
|
|
276
|
+
...props,
|
|
277
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx("span", {
|
|
278
|
+
className: "min-w-0 truncate",
|
|
279
|
+
children
|
|
280
|
+
}) : children
|
|
273
281
|
});
|
|
274
282
|
}
|
|
275
283
|
/** An icon-only button. `label` is required and becomes the accessible name and the tooltip (hover and keyboard focus); `hint` adds a muted aside to it, such as a shortcut. */
|
|
276
|
-
function IconButton({ icon: Icon, label, hint, variant = "ghost", ...props }) {
|
|
284
|
+
function IconButton({ icon: Icon, label, hint, variant = "ghost", size = "default", ...props }) {
|
|
277
285
|
return /* @__PURE__ */ jsx(Tooltip, {
|
|
278
286
|
label,
|
|
279
287
|
hint,
|
|
280
288
|
children: /* @__PURE__ */ jsx(Button, {
|
|
281
|
-
size: "icon",
|
|
289
|
+
size: size === "sm" ? "icon-sm" : "icon",
|
|
282
290
|
variant,
|
|
283
291
|
"aria-label": label,
|
|
284
292
|
...props,
|
|
@@ -925,14 +933,47 @@ var sizes = {
|
|
|
925
933
|
md: "max-w-lg",
|
|
926
934
|
lg: "max-w-3xl"
|
|
927
935
|
};
|
|
936
|
+
function Overlay({ trigger, open, onOpenChange, children }) {
|
|
937
|
+
if (trigger) return /* @__PURE__ */ jsxs(DialogTrigger, {
|
|
938
|
+
isOpen: open,
|
|
939
|
+
onOpenChange,
|
|
940
|
+
children: [trigger, children]
|
|
941
|
+
});
|
|
942
|
+
return /* @__PURE__ */ jsx(Driven, {
|
|
943
|
+
open,
|
|
944
|
+
onOpenChange,
|
|
945
|
+
children
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
function Driven({ open, onOpenChange, children }) {
|
|
949
|
+
const opener = React.useRef(null);
|
|
950
|
+
const wasOpen = React.useRef(false);
|
|
951
|
+
if (open && !wasOpen.current) opener.current = typeof document === "undefined" ? null : document.activeElement;
|
|
952
|
+
wasOpen.current = Boolean(open);
|
|
953
|
+
React.useEffect(() => {
|
|
954
|
+
if (!open) return;
|
|
955
|
+
return () => {
|
|
956
|
+
const back = opener.current;
|
|
957
|
+
opener.current = null;
|
|
958
|
+
requestAnimationFrame(() => {
|
|
959
|
+
if ((!document.activeElement || document.activeElement === document.body) && back instanceof HTMLElement && back.isConnected) back.focus();
|
|
960
|
+
});
|
|
961
|
+
};
|
|
962
|
+
}, [open]);
|
|
963
|
+
return React.cloneElement(children, {
|
|
964
|
+
isOpen: open,
|
|
965
|
+
onOpenChange
|
|
966
|
+
});
|
|
967
|
+
}
|
|
928
968
|
var overlayClass = "layer-overlay fixed inset-0 grid overflow-hidden bg-foreground/40";
|
|
929
969
|
/** A modal dialog with a required title; focus goes in and returns, Escape and a close control dismiss it. `placement="end"` makes it a sheet. */
|
|
930
970
|
function Dialog({ title, description, trigger, open, onOpenChange, className, children, actions, hideTitle, closable = true, placement = "center", size = "md" }) {
|
|
931
971
|
const descriptionId = React.useId();
|
|
932
|
-
return /* @__PURE__ */
|
|
933
|
-
|
|
972
|
+
return /* @__PURE__ */ jsx(Overlay, {
|
|
973
|
+
trigger,
|
|
974
|
+
open,
|
|
934
975
|
onOpenChange,
|
|
935
|
-
children:
|
|
976
|
+
children: /* @__PURE__ */ jsx(ModalOverlay, {
|
|
936
977
|
isDismissable: closable,
|
|
937
978
|
isKeyboardDismissDisabled: !closable,
|
|
938
979
|
className: cn(overlayClass, placement === "end" ? "justify-items-end" : "place-items-center p-4"),
|
|
@@ -973,7 +1014,7 @@ function Dialog({ title, description, trigger, open, onOpenChange, className, ch
|
|
|
973
1014
|
] })
|
|
974
1015
|
})
|
|
975
1016
|
})
|
|
976
|
-
})
|
|
1017
|
+
})
|
|
977
1018
|
});
|
|
978
1019
|
}
|
|
979
1020
|
/**
|
|
@@ -1006,10 +1047,11 @@ function AlertDialog({ title, description, trigger, open, onOpenChange, classNam
|
|
|
1006
1047
|
setError(describeActionError(thrown) ?? "That did not go through. Nothing was confirmed; try again.");
|
|
1007
1048
|
}
|
|
1008
1049
|
};
|
|
1009
|
-
return /* @__PURE__ */
|
|
1010
|
-
|
|
1050
|
+
return /* @__PURE__ */ jsx(Overlay, {
|
|
1051
|
+
trigger,
|
|
1052
|
+
open: isOpen,
|
|
1011
1053
|
onOpenChange: change,
|
|
1012
|
-
children:
|
|
1054
|
+
children: /* @__PURE__ */ jsx(ModalOverlay, {
|
|
1013
1055
|
isDismissable: false,
|
|
1014
1056
|
isKeyboardDismissDisabled: busy,
|
|
1015
1057
|
className: cn(overlayClass, "place-items-center p-4"),
|
|
@@ -1054,7 +1096,7 @@ function AlertDialog({ title, description, trigger, open, onOpenChange, classNam
|
|
|
1054
1096
|
})] })
|
|
1055
1097
|
})
|
|
1056
1098
|
})
|
|
1057
|
-
})
|
|
1099
|
+
})
|
|
1058
1100
|
});
|
|
1059
1101
|
}
|
|
1060
1102
|
// src/components/popover.tsx
|
|
@@ -1727,7 +1769,7 @@ function contrastRatio(a, b) {
|
|
|
1727
1769
|
return (hi + .05) / (lo + .05);
|
|
1728
1770
|
}
|
|
1729
1771
|
// src/components/value-controls.tsx
|
|
1730
|
-
var box = "flex
|
|
1772
|
+
var box = "flex w-full min-w-0 items-center rounded-control border border-input bg-background px-3 type-body text-foreground transition-state disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-70 has-[input:disabled]:cursor-not-allowed has-[input:disabled]:bg-muted has-[input:disabled]:opacity-70 aria-invalid:border-danger has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-offset-2 has-[input:focus-visible]:outline-ring";
|
|
1731
1773
|
/** A number with its unit joined by a non-breaking space; `%` and `°` stay attached. */
|
|
1732
1774
|
function withUnit(text, unit) {
|
|
1733
1775
|
if (!unit) return text;
|
|
@@ -1780,7 +1822,7 @@ function describeRange(min, max, show, unit) {
|
|
|
1780
1822
|
return "Enter a number.";
|
|
1781
1823
|
}
|
|
1782
1824
|
/** A number with a unit on React Aria's number field: typed input is validated, not clamped, so an out-of-range value is explained in the surrounding `Field` and never passed on; empty stays `null`. */
|
|
1783
|
-
function NumberField({ value, onChange, min, max, step = 1, places, unit, locale = format.locale, required = false, disabled, id: idProp, name, className, "aria-label": ariaLabel }) {
|
|
1825
|
+
function NumberField({ value, onChange, min, max, step = 1, places, unit, locale = format.locale, required = false, disabled, id: idProp, name, size = "default", className, "aria-label": ariaLabel }) {
|
|
1784
1826
|
const { field, report } = useFieldControl();
|
|
1785
1827
|
const digits = places ?? Math.max(decimalsOf(step), min === void 0 ? 0 : decimalsOf(min));
|
|
1786
1828
|
const show = useNumberText(locale, digits);
|
|
@@ -1830,7 +1872,7 @@ function NumberField({ value, onChange, min, max, step = 1, places, unit, locale
|
|
|
1830
1872
|
isInvalid: invalid || void 0,
|
|
1831
1873
|
name,
|
|
1832
1874
|
"aria-label": ariaLabel ?? field?.label,
|
|
1833
|
-
className: cn(box, className),
|
|
1875
|
+
className: cn(box, controlHeight[size], className),
|
|
1834
1876
|
children: [/* @__PURE__ */ jsx(Input$1, {
|
|
1835
1877
|
id: idProp ?? field?.id,
|
|
1836
1878
|
placeholder: format.missing,
|
|
@@ -1908,6 +1950,8 @@ function Slider({ value, onChange, min, max, step = 1, unit, locale = format.loc
|
|
|
1908
1950
|
/** Choose a colour with the platform picker, see and type its hex value, pick from the app's suggestions, and get a note when it would be hard to see on `against`. A half-typed value is never passed on. */
|
|
1909
1951
|
function ColorField({ value, onChange, suggestions, against, againstLabel = "the background", minContrast = 3, disabled, id: idProp, className, "aria-label": ariaLabel }) {
|
|
1910
1952
|
const { field, report } = useFieldControl();
|
|
1953
|
+
const label = ariaLabel ?? field?.label;
|
|
1954
|
+
const pickerName = label ? `${label}, picker` : "Colour picker";
|
|
1911
1955
|
const [draft, setDraft] = React.useState(null);
|
|
1912
1956
|
const [own, setOwn] = React.useState(false);
|
|
1913
1957
|
const text = draft ?? value ?? "";
|
|
@@ -1941,7 +1985,7 @@ function ColorField({ value, onChange, suggestions, against, againstLabel = "the
|
|
|
1941
1985
|
className: cn("grid min-w-0 gap-2", className),
|
|
1942
1986
|
children: [
|
|
1943
1987
|
/* @__PURE__ */ jsxs("div", {
|
|
1944
|
-
className: cn(box, "gap-2 px-2"),
|
|
1988
|
+
className: cn(box, controlHeight.default, "gap-2 px-2"),
|
|
1945
1989
|
"aria-invalid": invalid || void 0,
|
|
1946
1990
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
1947
1991
|
className: "relative size-6 shrink-0 overflow-hidden rounded-control border border-input",
|
|
@@ -1951,7 +1995,7 @@ function ColorField({ value, onChange, suggestions, against, againstLabel = "the
|
|
|
1951
1995
|
style: value ? { background: value } : void 0
|
|
1952
1996
|
}), /* @__PURE__ */ jsx("input", {
|
|
1953
1997
|
type: "color",
|
|
1954
|
-
"aria-label":
|
|
1998
|
+
"aria-label": pickerName,
|
|
1955
1999
|
value: value ?? "#000000",
|
|
1956
2000
|
disabled,
|
|
1957
2001
|
onChange: (e) => pick(e.target.value),
|
|
@@ -2917,7 +2961,7 @@ function TableSkeleton({ rows = 4, columns = 5 }) {
|
|
|
2917
2961
|
});
|
|
2918
2962
|
}
|
|
2919
2963
|
// src/components/media.tsx
|
|
2920
|
-
var clamp$
|
|
2964
|
+
var clamp$2 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
2921
2965
|
var timecode = (t, { precision, fps }) => format.timecode(t, {
|
|
2922
2966
|
precision,
|
|
2923
2967
|
fps
|
|
@@ -2962,8 +3006,8 @@ function TimeReadout({ time, duration, precision = "seconds", fps = 30, classNam
|
|
|
2962
3006
|
function SeekBar({ time, duration, onSeek, marks = [], buffered, step = 5, bigStep = 30, label = "Seek", precision = "seconds", fps = 30, disabled, className }) {
|
|
2963
3007
|
const track = React.useRef(null);
|
|
2964
3008
|
const input = React.useRef(null);
|
|
2965
|
-
const frac = duration > 0 ? clamp$
|
|
2966
|
-
const seekTo = (t) => onSeek(clamp$
|
|
3009
|
+
const frac = duration > 0 ? clamp$2(time / duration, 0, 1) : 0;
|
|
3010
|
+
const seekTo = (t) => onSeek(clamp$2(t, 0, duration));
|
|
2967
3011
|
const timeText = React.useMemo(() => {
|
|
2968
3012
|
const say = (t) => timecode(t, {
|
|
2969
3013
|
precision,
|
|
@@ -2980,7 +3024,7 @@ function SeekBar({ time, duration, onSeek, marks = [], buffered, step = 5, bigSt
|
|
|
2980
3024
|
minValue: 0,
|
|
2981
3025
|
maxValue: Math.max(duration, fine),
|
|
2982
3026
|
step: fine,
|
|
2983
|
-
value: [clamp$
|
|
3027
|
+
value: [clamp$2(time, 0, duration)],
|
|
2984
3028
|
onChange: ([t]) => seekTo(t),
|
|
2985
3029
|
numberFormatter: timeText,
|
|
2986
3030
|
isDisabled: disabled
|
|
@@ -3029,7 +3073,7 @@ function SeekBar({ time, duration, onSeek, marks = [], buffered, step = 5, bigSt
|
|
|
3029
3073
|
buffered !== void 0 && duration > 0 && /* @__PURE__ */ jsx("span", {
|
|
3030
3074
|
"aria-hidden": true,
|
|
3031
3075
|
className: "absolute left-0 h-1.5 rounded-pill bg-neutral-4",
|
|
3032
|
-
style: { width: `${clamp$
|
|
3076
|
+
style: { width: `${clamp$2(buffered / duration, 0, 1) * 100}%` }
|
|
3033
3077
|
}),
|
|
3034
3078
|
/* @__PURE__ */ jsx("span", {
|
|
3035
3079
|
"aria-hidden": true,
|
|
@@ -3165,7 +3209,7 @@ function RateChoice({ rate, onRateChange, rates = [
|
|
|
3165
3209
|
* to the ends, M mutes. Pass the player's actions; the labels are the legend's words.
|
|
3166
3210
|
*/
|
|
3167
3211
|
function transportShortcuts({ toggle, seek, time, duration, frame = 1 / 30, jump = 1, toggleMute }) {
|
|
3168
|
-
const to = (t) => () => seek(clamp$
|
|
3212
|
+
const to = (t) => () => seek(clamp$2(t, 0, duration));
|
|
3169
3213
|
return [
|
|
3170
3214
|
{
|
|
3171
3215
|
keys: [" ", "k"],
|
|
@@ -3371,7 +3415,7 @@ function tickLabel(time, step) {
|
|
|
3371
3415
|
const base = h > 0 ? `${h}:${two(m)}:${two(s)}` : `${m}:${two(s)}`;
|
|
3372
3416
|
return decimals ? `${base}.${String(Math.round((time - whole) * 10 ** decimals)).padStart(decimals, "0")}` : base;
|
|
3373
3417
|
}
|
|
3374
|
-
function clamp(value, min, max) {
|
|
3418
|
+
function clamp$1(value, min, max) {
|
|
3375
3419
|
return Math.min(Math.max(value, min), max);
|
|
3376
3420
|
}
|
|
3377
3421
|
/** The point to snap `time` to: the nearest of `points` within `thresholdPx` at this zoom, or `null`. */
|
|
@@ -3386,14 +3430,13 @@ function snapTo(time, points, pxPerUnit, thresholdPx = 8) {
|
|
|
3386
3430
|
/** Round away float noise from adding steps (0.1 + 0.2). */
|
|
3387
3431
|
var tidy = (n) => Math.round(n * 1e6) / 1e6;
|
|
3388
3432
|
// src/components/timeline.tsx
|
|
3389
|
-
var HEADER_W = "w-40";
|
|
3390
3433
|
var EDGE_PX = 8;
|
|
3391
3434
|
var DRAG_THRESHOLD = 3;
|
|
3392
3435
|
var defaultFormat = (t) => tickLabel(t, 1);
|
|
3393
3436
|
/** Zoom state for a timeline: `zoomIn`, `zoomOut`, and `fit` to a viewport width. Pass `zoom` and `setZoom` as the timeline's `zoom` and `onZoomChange`. */
|
|
3394
3437
|
function useTimelineZoom({ initial = 20, min = .5, max = 400 } = {}) {
|
|
3395
3438
|
const [zoom, set] = React.useState(initial);
|
|
3396
|
-
const setZoom = React.useCallback((z) => set(clamp(z, min, max)), [min, max]);
|
|
3439
|
+
const setZoom = React.useCallback((z) => set(clamp$1(z, min, max)), [min, max]);
|
|
3397
3440
|
return {
|
|
3398
3441
|
zoom,
|
|
3399
3442
|
setZoom,
|
|
@@ -3438,7 +3481,7 @@ function noOverlap(items) {
|
|
|
3438
3481
|
};
|
|
3439
3482
|
}
|
|
3440
3483
|
/** Items placed on a zoomable time axis in lanes, with a current-time rule and markers. Reports every move, trim, selection and time change; the app applies them. Keyboard-complete, and only the items near the view are rendered. */
|
|
3441
|
-
function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, position, onPositionChange, follow, markers = [], selectedIds, onSelect, onItemChange, onDelete, validate, snapPoints = [], snap = true, step = 1, minLength, renderItem, formatTime = defaultFormat, empty, className }) {
|
|
3484
|
+
function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, position, onPositionChange, follow, markers = [], selectedIds, onSelect, onItemChange, onDelete, validate, snapPoints = [], snap = true, step = 1, minLength, renderItem, kindColours, laneRows = 1, dropTypes, dropLength, onDrop, validateDrop, formatTime = defaultFormat, empty, className }) {
|
|
3442
3485
|
const min = minLength ?? step;
|
|
3443
3486
|
const scroller = React.useRef(null);
|
|
3444
3487
|
const laneRefs = React.useRef(/* @__PURE__ */ new Map());
|
|
@@ -3450,6 +3493,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3450
3493
|
const dragRef = React.useRef(null);
|
|
3451
3494
|
const [focusId, setFocusId] = React.useState(null);
|
|
3452
3495
|
const [said, setSaid] = React.useState("");
|
|
3496
|
+
const [hover, setHover] = React.useState(null);
|
|
3453
3497
|
const refocus = React.useRef(null);
|
|
3454
3498
|
const selected = selectedIds ?? /* @__PURE__ */ new Set();
|
|
3455
3499
|
const laneIndex = React.useMemo(() => new Map(lanes.map((l, i) => [l.id, i])), [lanes]);
|
|
@@ -3547,7 +3591,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3547
3591
|
handled();
|
|
3548
3592
|
const dir = k === "ArrowLeft" ? -1 : 1;
|
|
3549
3593
|
commit(item, {
|
|
3550
|
-
start: clamp(tidy(item.start + dir * step * big), from, to - item.length),
|
|
3594
|
+
start: clamp$1(tidy(item.start + dir * step * big), from, to - item.length),
|
|
3551
3595
|
length: item.length,
|
|
3552
3596
|
lane: item.lane
|
|
3553
3597
|
});
|
|
@@ -3567,7 +3611,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3567
3611
|
handled();
|
|
3568
3612
|
const dir = k === "ArrowLeft" ? -1 : 1;
|
|
3569
3613
|
if (e.shiftKey) {
|
|
3570
|
-
const start = clamp(tidy(item.start + dir * step), from, item.start + item.length - min);
|
|
3614
|
+
const start = clamp$1(tidy(item.start + dir * step), from, item.start + item.length - min);
|
|
3571
3615
|
commit(item, {
|
|
3572
3616
|
start,
|
|
3573
3617
|
length: tidy(item.start + item.length - start),
|
|
@@ -3575,7 +3619,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3575
3619
|
});
|
|
3576
3620
|
} else commit(item, {
|
|
3577
3621
|
start: item.start,
|
|
3578
|
-
length: clamp(tidy(item.length + dir * step), min, to - item.start),
|
|
3622
|
+
length: clamp$1(tidy(item.length + dir * step), min, to - item.start),
|
|
3579
3623
|
lane: item.lane
|
|
3580
3624
|
});
|
|
3581
3625
|
return;
|
|
@@ -3617,6 +3661,58 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3617
3661
|
}
|
|
3618
3662
|
}
|
|
3619
3663
|
};
|
|
3664
|
+
/** Snaps an item of `length` starting at `start` to whichever of its ends is nearer an edge. */
|
|
3665
|
+
const snapMove = (start, length, exclude) => {
|
|
3666
|
+
const edges = [...snapTimes, ...items.filter((i) => i.id !== exclude).flatMap((i) => [i.start, i.start + i.length])];
|
|
3667
|
+
const a = snap ? snapTo(start, edges, zoom) : null;
|
|
3668
|
+
const b = snap ? snapTo(start + length, edges, zoom) : null;
|
|
3669
|
+
if (a && (!b || Math.abs(a.time - start) <= Math.abs(b.time - (start + length)))) return {
|
|
3670
|
+
start: a.time,
|
|
3671
|
+
guide: a.point
|
|
3672
|
+
};
|
|
3673
|
+
if (b) return {
|
|
3674
|
+
start: b.time - length,
|
|
3675
|
+
guide: b.point
|
|
3676
|
+
};
|
|
3677
|
+
return {
|
|
3678
|
+
start,
|
|
3679
|
+
guide: null
|
|
3680
|
+
};
|
|
3681
|
+
};
|
|
3682
|
+
const dropLen = dropLength ?? step * 5;
|
|
3683
|
+
const dropAt = (lane, px) => {
|
|
3684
|
+
const at = px === null ? position ?? from : from + px / zoom;
|
|
3685
|
+
const snapped = snapMove(at, dropLen);
|
|
3686
|
+
const next = {
|
|
3687
|
+
start: clamp$1(tidy(snapped.start), from, Math.max(to - dropLen, from)),
|
|
3688
|
+
length: dropLen,
|
|
3689
|
+
lane
|
|
3690
|
+
};
|
|
3691
|
+
return {
|
|
3692
|
+
next,
|
|
3693
|
+
guide: snapped.guide,
|
|
3694
|
+
reason: validateDrop?.(next) ?? null
|
|
3695
|
+
};
|
|
3696
|
+
};
|
|
3697
|
+
const onLaneHover = (lane, px) => {
|
|
3698
|
+
const h = dropAt(lane, px);
|
|
3699
|
+
setHover(h);
|
|
3700
|
+
if (px === null) setSaid(h.reason ?? `Drop here: ${laneLabel(lane)} at ${formatTime(h.next.start)}.`);
|
|
3701
|
+
};
|
|
3702
|
+
const onLaneDrop = (lane, px, dropped) => {
|
|
3703
|
+
setHover(null);
|
|
3704
|
+
const h = dropAt(lane, px);
|
|
3705
|
+
if (h.reason) {
|
|
3706
|
+
setSaid(h.reason);
|
|
3707
|
+
return;
|
|
3708
|
+
}
|
|
3709
|
+
onDrop?.({
|
|
3710
|
+
...h.next,
|
|
3711
|
+
items: dropped
|
|
3712
|
+
});
|
|
3713
|
+
setSaid(`Added at ${formatTime(h.next.start)}, ${laneLabel(lane)}.`);
|
|
3714
|
+
};
|
|
3715
|
+
const dropsOn = Boolean(dropTypes?.length && onDrop);
|
|
3620
3716
|
const begin = (e, item, mode) => {
|
|
3621
3717
|
if (e.button !== 0) return;
|
|
3622
3718
|
e.stopPropagation();
|
|
@@ -3665,28 +3761,21 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3665
3761
|
return s ? s.time : t;
|
|
3666
3762
|
};
|
|
3667
3763
|
if (d.mode === "move") {
|
|
3668
|
-
|
|
3669
|
-
const
|
|
3670
|
-
|
|
3671
|
-
if (a && (!b || Math.abs(a.time - start) <= Math.abs(b.time - (start + o.length)))) {
|
|
3672
|
-
start = a.time;
|
|
3673
|
-
guide = a.point;
|
|
3674
|
-
} else if (b) {
|
|
3675
|
-
start = b.time - o.length;
|
|
3676
|
-
guide = b.point;
|
|
3677
|
-
}
|
|
3764
|
+
const m = snapMove(o.start + dt, o.length, o.id);
|
|
3765
|
+
const start = m.start;
|
|
3766
|
+
guide = m.guide;
|
|
3678
3767
|
next = {
|
|
3679
|
-
start: clamp(tidy(start), from, to - o.length),
|
|
3768
|
+
start: clamp$1(tidy(start), from, to - o.length),
|
|
3680
3769
|
length: o.length,
|
|
3681
3770
|
lane: laneAt(e.clientY, o.lane)
|
|
3682
3771
|
};
|
|
3683
3772
|
} else if (d.mode === "end") next = {
|
|
3684
3773
|
start: o.start,
|
|
3685
|
-
length: clamp(tidy(snapped(o.start + o.length + dt) - o.start), min, to - o.start),
|
|
3774
|
+
length: clamp$1(tidy(snapped(o.start + o.length + dt) - o.start), min, to - o.start),
|
|
3686
3775
|
lane: o.lane
|
|
3687
3776
|
};
|
|
3688
3777
|
else {
|
|
3689
|
-
const start = clamp(tidy(snapped(o.start + dt)), from, o.start + o.length - min);
|
|
3778
|
+
const start = clamp$1(tidy(snapped(o.start + dt)), from, o.start + o.length - min);
|
|
3690
3779
|
next = {
|
|
3691
3780
|
start,
|
|
3692
3781
|
length: tidy(o.start + o.length - start),
|
|
@@ -3723,7 +3812,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3723
3812
|
to,
|
|
3724
3813
|
stepSize
|
|
3725
3814
|
]);
|
|
3726
|
-
const setPosition = (t) => onPositionChange?.(clamp(tidy(t), from, to));
|
|
3815
|
+
const setPosition = (t) => onPositionChange?.(clamp$1(tidy(t), from, to));
|
|
3727
3816
|
const scrubTrack = React.useRef(null);
|
|
3728
3817
|
const scrubInput = React.useRef(null);
|
|
3729
3818
|
const spokenTime = React.useMemo(() => ({
|
|
@@ -3735,7 +3824,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3735
3824
|
minValue: from,
|
|
3736
3825
|
maxValue: Math.max(to, from + 1e-9),
|
|
3737
3826
|
step: .001,
|
|
3738
|
-
value: [clamp(position ?? from, from, to)],
|
|
3827
|
+
value: [clamp$1(position ?? from, from, to)],
|
|
3739
3828
|
onChange: ([t]) => setPosition(t),
|
|
3740
3829
|
numberFormatter: spokenTime,
|
|
3741
3830
|
isDisabled: position === void 0 || !onPositionChange
|
|
@@ -3799,6 +3888,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3799
3888
|
"aria-label": label,
|
|
3800
3889
|
onKeyDown,
|
|
3801
3890
|
className: cn("min-w-0 text-foreground", className),
|
|
3891
|
+
style: { "--lane-h": `calc(var(--control-h) * ${Math.max(laneRows, 1)})` },
|
|
3802
3892
|
children: [
|
|
3803
3893
|
/* @__PURE__ */ jsx("p", {
|
|
3804
3894
|
role: "status",
|
|
@@ -3808,12 +3898,12 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3808
3898
|
/* @__PURE__ */ jsxs("div", {
|
|
3809
3899
|
className: "flex",
|
|
3810
3900
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
3811
|
-
className:
|
|
3901
|
+
className: "w-max max-w-80 min-w-40 shrink-0 border-r border-border",
|
|
3812
3902
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3813
3903
|
className: "h-8 border-b border-border",
|
|
3814
3904
|
"aria-hidden": true
|
|
3815
3905
|
}), lanes.map((l) => /* @__PURE__ */ jsxs("div", {
|
|
3816
|
-
className: "flex h-(--
|
|
3906
|
+
className: "flex h-(--lane-h) items-center gap-1 border-b border-border px-2 type-label",
|
|
3817
3907
|
children: [/* @__PURE__ */ jsx("span", {
|
|
3818
3908
|
className: "min-w-0 flex-1 truncate",
|
|
3819
3909
|
title: l.label,
|
|
@@ -3878,12 +3968,21 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3878
3968
|
className: "p-4",
|
|
3879
3969
|
children: empty
|
|
3880
3970
|
}),
|
|
3881
|
-
lanes.map((l) => /* @__PURE__ */
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3971
|
+
lanes.map((l) => /* @__PURE__ */ jsxs(LaneRow, {
|
|
3972
|
+
label: l.label,
|
|
3973
|
+
register: (el) => void (el ? laneRefs.current.set(l.id, el) : laneRefs.current.delete(l.id)),
|
|
3974
|
+
types: dropsOn ? dropTypes : void 0,
|
|
3975
|
+
onHover: (px) => onLaneHover(l.id, px),
|
|
3976
|
+
onLeave: () => setHover(null),
|
|
3977
|
+
onDropItems: (px, dropped) => onLaneDrop(l.id, px, dropped),
|
|
3978
|
+
children: [hover && hover.next.lane === l.id && /* @__PURE__ */ jsx("div", {
|
|
3979
|
+
"aria-hidden": true,
|
|
3980
|
+
className: cn("pointer-events-none absolute top-1 bottom-1 rounded-control border border-dashed", hover.reason ? "border-danger bg-danger-subtle" : "border-primary bg-muted"),
|
|
3981
|
+
style: {
|
|
3982
|
+
left: x(hover.next.start),
|
|
3983
|
+
width: Math.max(hover.next.length * zoom, 4)
|
|
3984
|
+
}
|
|
3985
|
+
}), (sorted.get(l.id) ?? []).filter(visible).map((item) => {
|
|
3887
3986
|
const live = drag?.id === item.id && drag.moved ? drag : null;
|
|
3888
3987
|
const shown = live ? live.next : item;
|
|
3889
3988
|
const laneShift = live ? (laneIndex.get(live.next.lane) ?? 0) - (laneIndex.get(item.lane) ?? 0) : 0;
|
|
@@ -3905,8 +4004,8 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3905
4004
|
style: {
|
|
3906
4005
|
left: px,
|
|
3907
4006
|
width: w,
|
|
3908
|
-
borderTopColor: item.kind ? kindColour(item.kind, items) : void 0,
|
|
3909
|
-
transform: laneShift ? `translateY(calc(var(--
|
|
4007
|
+
borderTopColor: item.kind ? kindColours?.[item.kind] ?? kindColour(item.kind, items) : void 0,
|
|
4008
|
+
transform: laneShift ? `translateY(calc(var(--lane-h) * ${laneShift}))` : void 0,
|
|
3910
4009
|
zIndex: live ? 10 : void 0
|
|
3911
4010
|
},
|
|
3912
4011
|
children: [
|
|
@@ -3935,36 +4034,45 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3935
4034
|
})
|
|
3936
4035
|
]
|
|
3937
4036
|
}, item.id);
|
|
3938
|
-
})
|
|
4037
|
+
})]
|
|
3939
4038
|
}, l.id)),
|
|
3940
4039
|
position !== void 0 && /* @__PURE__ */ jsx("div", {
|
|
3941
4040
|
"aria-hidden": true,
|
|
3942
4041
|
className: "pointer-events-none absolute top-8 bottom-0 w-0.5 bg-primary",
|
|
3943
4042
|
style: { left: x(position) - 1 }
|
|
3944
4043
|
}),
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
4044
|
+
(() => {
|
|
4045
|
+
const guide = drag?.moved ? drag.guide : hover?.guide ?? null;
|
|
4046
|
+
return guide !== null && /* @__PURE__ */ jsx("div", {
|
|
4047
|
+
"aria-hidden": true,
|
|
4048
|
+
className: "pointer-events-none absolute top-0 bottom-0 w-px bg-foreground",
|
|
4049
|
+
style: { left: x(guide) }
|
|
4050
|
+
});
|
|
4051
|
+
})()
|
|
3950
4052
|
]
|
|
3951
4053
|
})
|
|
3952
4054
|
})]
|
|
3953
4055
|
}),
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
"
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
4056
|
+
(() => {
|
|
4057
|
+
const info = drag?.moved ? {
|
|
4058
|
+
next: drag.next,
|
|
4059
|
+
reason: drag.reason
|
|
4060
|
+
} : hover;
|
|
4061
|
+
return info && /* @__PURE__ */ jsx("p", {
|
|
4062
|
+
"aria-hidden": true,
|
|
4063
|
+
className: "mt-1 flex items-center gap-1.5 type-body-sm tabular-nums text-muted-foreground",
|
|
4064
|
+
children: info.reason ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Ban, { className: "size-4 shrink-0 text-danger" }), /* @__PURE__ */ jsx("span", {
|
|
4065
|
+
className: "text-danger",
|
|
4066
|
+
children: info.reason
|
|
4067
|
+
})] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4068
|
+
formatTime(info.next.start),
|
|
4069
|
+
" to ",
|
|
4070
|
+
formatTime(info.next.start + info.next.length),
|
|
4071
|
+
", ",
|
|
4072
|
+
laneLabel(info.next.lane)
|
|
4073
|
+
] })
|
|
4074
|
+
});
|
|
4075
|
+
})()
|
|
3968
4076
|
]
|
|
3969
4077
|
});
|
|
3970
4078
|
}
|
|
@@ -3984,6 +4092,32 @@ function DefaultItem({ item, width }) {
|
|
|
3984
4092
|
})]
|
|
3985
4093
|
});
|
|
3986
4094
|
}
|
|
4095
|
+
/** One lane: a labelled group that is a React Aria drop target when `types` is given. `px` is the pointer's distance along the lane, or null for a keyboard drag (the lane is then the focused element). */
|
|
4096
|
+
function LaneRow({ label, register, types, onHover, onLeave, onDropItems, children }) {
|
|
4097
|
+
const ref = React.useRef(null);
|
|
4098
|
+
const keyboard = () => document.activeElement === ref.current;
|
|
4099
|
+
const { dropProps } = useDrop({
|
|
4100
|
+
ref,
|
|
4101
|
+
isDisabled: !types,
|
|
4102
|
+
getDropOperation: (t) => types?.some((type) => t.has(type)) ? "copy" : "cancel",
|
|
4103
|
+
onDropEnter: (e) => onHover(keyboard() ? null : e.x),
|
|
4104
|
+
onDropMove: (e) => onHover(keyboard() ? null : e.x),
|
|
4105
|
+
onDropExit: onLeave,
|
|
4106
|
+
onDrop: (e) => e.dropOperation !== "cancel" && onDropItems(keyboard() ? null : e.x, e.items)
|
|
4107
|
+
});
|
|
4108
|
+
return /* @__PURE__ */ jsx("div", {
|
|
4109
|
+
...types ? dropProps : {},
|
|
4110
|
+
ref: (el) => {
|
|
4111
|
+
ref.current = el;
|
|
4112
|
+
register(el);
|
|
4113
|
+
},
|
|
4114
|
+
role: "group",
|
|
4115
|
+
"aria-label": label,
|
|
4116
|
+
tabIndex: types ? -1 : void 0,
|
|
4117
|
+
className: "relative h-(--lane-h) border-b border-border",
|
|
4118
|
+
children
|
|
4119
|
+
});
|
|
4120
|
+
}
|
|
3987
4121
|
// src/components/sortable-list.tsx
|
|
3988
4122
|
var KIND = "strata-kind/";
|
|
3989
4123
|
var ID = "strata-item/id";
|
|
@@ -4226,30 +4360,38 @@ function FileOutcomes({ intake, className }) {
|
|
|
4226
4360
|
})]
|
|
4227
4361
|
});
|
|
4228
4362
|
}
|
|
4229
|
-
/**
|
|
4230
|
-
|
|
4363
|
+
/**
|
|
4364
|
+
* A saved item whose file is gone: the item's name, a "File missing" status (a word and an icon) and a "Relink" button that opens the picker for this one item.
|
|
4365
|
+
* In a narrow column the name keeps its own line, in full, and the status and button wrap under it. An optional `thumbnail` sits beside all three.
|
|
4366
|
+
*/
|
|
4367
|
+
function MissingFile({ name, accept, onRelink, thumbnail, className }) {
|
|
4231
4368
|
return /* @__PURE__ */ jsxs("div", {
|
|
4232
4369
|
className: cn("flex min-w-0 items-center gap-3", className),
|
|
4233
|
-
children: [
|
|
4234
|
-
|
|
4235
|
-
|
|
4370
|
+
children: [thumbnail && /* @__PURE__ */ jsx("div", {
|
|
4371
|
+
className: "shrink-0",
|
|
4372
|
+
children: thumbnail
|
|
4373
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
4374
|
+
className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1",
|
|
4375
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
4376
|
+
className: "min-w-40 flex-auto break-words type-body",
|
|
4236
4377
|
title: name,
|
|
4237
4378
|
children: name
|
|
4238
|
-
}),
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4379
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
4380
|
+
className: "flex items-center gap-2",
|
|
4381
|
+
children: [/* @__PURE__ */ jsx(Status, {
|
|
4382
|
+
tone: "warning",
|
|
4383
|
+
icon: FileQuestion,
|
|
4384
|
+
children: "File missing"
|
|
4385
|
+
}), /* @__PURE__ */ jsx(FileButton, {
|
|
4386
|
+
accept,
|
|
4387
|
+
variant: "ghost",
|
|
4388
|
+
size: "sm",
|
|
4389
|
+
"aria-label": `Relink ${name}`,
|
|
4390
|
+
onFiles: ([file]) => onRelink(file),
|
|
4391
|
+
children: "Relink"
|
|
4392
|
+
})]
|
|
4393
|
+
})]
|
|
4394
|
+
})]
|
|
4253
4395
|
});
|
|
4254
4396
|
}
|
|
4255
4397
|
// src/lib/file-intake.ts
|
|
@@ -4459,7 +4601,7 @@ function Inspector({ title, kind, empty, selectionKey, storageKey, actions, summ
|
|
|
4459
4601
|
"aria-label": title === null ? "Properties" : void 0,
|
|
4460
4602
|
className: cn("min-w-0", className),
|
|
4461
4603
|
children: title === null ? empty : /* @__PURE__ */ jsxs("div", {
|
|
4462
|
-
className: "grid gap-4",
|
|
4604
|
+
className: "grid grid-cols-1 gap-4",
|
|
4463
4605
|
children: [
|
|
4464
4606
|
/* @__PURE__ */ jsxs("header", {
|
|
4465
4607
|
className: "flex items-start gap-3",
|
|
@@ -4484,7 +4626,7 @@ function Inspector({ title, kind, empty, selectionKey, storageKey, actions, summ
|
|
|
4484
4626
|
}),
|
|
4485
4627
|
summary,
|
|
4486
4628
|
/* @__PURE__ */ jsx("div", {
|
|
4487
|
-
className: "grid",
|
|
4629
|
+
className: "grid grid-cols-1 *:min-w-0",
|
|
4488
4630
|
children
|
|
4489
4631
|
}, selectionKey)
|
|
4490
4632
|
]
|
|
@@ -4523,7 +4665,7 @@ function InspectorSection({ id, title, defaultOpen = true, actions, children, cl
|
|
|
4523
4665
|
children: actions
|
|
4524
4666
|
})]
|
|
4525
4667
|
}), /* @__PURE__ */ jsx(DisclosurePanel, { children: isExpanded && /* @__PURE__ */ jsx("div", {
|
|
4526
|
-
className: "grid gap-4 pt-2 pb-4 pl-6",
|
|
4668
|
+
className: "grid grid-cols-1 gap-4 pt-2 pb-4 pl-6 *:min-w-0",
|
|
4527
4669
|
children
|
|
4528
4670
|
}) })] })
|
|
4529
4671
|
});
|
|
@@ -5018,7 +5160,7 @@ function fitTicks(ticks, scale, widthOf, gap = 12) {
|
|
|
5018
5160
|
return sorted.slice(0, 1);
|
|
5019
5161
|
}
|
|
5020
5162
|
/** One measured series, drawn in real pixels, with the peak and current readings labelled on the chart and every reading in a screen-reader table. Optional plan, threshold band and `colourScale`. */
|
|
5021
|
-
function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, formatY, xTicks, yMin, yMax, colour = "var(--chart-1)", colourScale, colourScaleLabel, current, formatCurrent, readout, onPick, area, height = 280, className }) {
|
|
5163
|
+
function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel = "Time", formatY, xTicks, yMin, yMax, colour = "var(--chart-1)", colourScale, colourScaleLabel, current, formatCurrent, readout, onPick, area, height = 280, className }) {
|
|
5022
5164
|
const [ref, width] = useWidth();
|
|
5023
5165
|
const gradientId = `heat-${React.useId().replace(/[^\w-]/g, "")}`;
|
|
5024
5166
|
const all = [...series, ...planned ?? []];
|
|
@@ -5179,7 +5321,7 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5179
5321
|
/* @__PURE__ */ jsx("caption", { children: label }),
|
|
5180
5322
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
5181
5323
|
scope: "col",
|
|
5182
|
-
children:
|
|
5324
|
+
children: xLabel
|
|
5183
5325
|
}), /* @__PURE__ */ jsx("th", {
|
|
5184
5326
|
scope: "col",
|
|
5185
5327
|
children: seriesLabel
|
|
@@ -5191,7 +5333,8 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5191
5333
|
seriesLabel,
|
|
5192
5334
|
series,
|
|
5193
5335
|
formatX,
|
|
5194
|
-
formatY
|
|
5336
|
+
formatY,
|
|
5337
|
+
xLabel
|
|
5195
5338
|
]);
|
|
5196
5339
|
const sorted = React.useMemo(() => [...series].sort((p, q) => p.x - q.x), [series]);
|
|
5197
5340
|
const interactive = Boolean(readout || onPick);
|
|
@@ -7013,6 +7156,653 @@ function CompareGrid({ label, items, blind, missing, actions, columns = 3, keys
|
|
|
7013
7156
|
})
|
|
7014
7157
|
});
|
|
7015
7158
|
}
|
|
7016
|
-
|
|
7159
|
+
// src/components/workspace.tsx
|
|
7160
|
+
var readPersisted = (key) => {
|
|
7161
|
+
const empty = {
|
|
7162
|
+
sizes: {},
|
|
7163
|
+
collapsed: {}
|
|
7164
|
+
};
|
|
7165
|
+
if (!key) return empty;
|
|
7166
|
+
try {
|
|
7167
|
+
const raw = JSON.parse(window.localStorage.getItem(`strata:workspace:${key}`) ?? "null");
|
|
7168
|
+
if (!raw || typeof raw !== "object") return empty;
|
|
7169
|
+
const sizes = {};
|
|
7170
|
+
for (const [k, v] of Object.entries(raw.sizes ?? {})) if (typeof v === "number" && Number.isFinite(v)) sizes[k] = v;
|
|
7171
|
+
const collapsed = {};
|
|
7172
|
+
for (const [k, v] of Object.entries(raw.collapsed ?? {})) if (typeof v === "boolean") collapsed[k] = v;
|
|
7173
|
+
return {
|
|
7174
|
+
sizes,
|
|
7175
|
+
collapsed
|
|
7176
|
+
};
|
|
7177
|
+
} catch {
|
|
7178
|
+
return empty;
|
|
7179
|
+
}
|
|
7180
|
+
};
|
|
7181
|
+
/** The sizes and folded panes of a `Workspace`; with `persist`, remembered in localStorage under that name. */
|
|
7182
|
+
function useWorkspaceState(persist) {
|
|
7183
|
+
const [saved, setSaved] = React.useState(() => readPersisted(persist));
|
|
7184
|
+
const [narrow, setNarrow] = React.useState(false);
|
|
7185
|
+
const [narrowOpen, setNarrowOpen] = React.useState({});
|
|
7186
|
+
const defaults = React.useRef(/* @__PURE__ */ new Map());
|
|
7187
|
+
React.useEffect(() => {
|
|
7188
|
+
if (!persist) return;
|
|
7189
|
+
try {
|
|
7190
|
+
window.localStorage.setItem(`strata:workspace:${persist}`, JSON.stringify(saved));
|
|
7191
|
+
} catch {}
|
|
7192
|
+
}, [persist, saved]);
|
|
7193
|
+
return React.useMemo(() => {
|
|
7194
|
+
const isCollapsed = (id, fallback = defaults.current.get(id) ?? false) => narrow ? !narrowOpen[id] : saved.collapsed[id] ?? fallback;
|
|
7195
|
+
const setCollapsed = (id, collapsed) => {
|
|
7196
|
+
if (narrow) setNarrowOpen((o) => ({
|
|
7197
|
+
...o,
|
|
7198
|
+
[id]: !collapsed
|
|
7199
|
+
}));
|
|
7200
|
+
else setSaved((s) => ({
|
|
7201
|
+
...s,
|
|
7202
|
+
collapsed: {
|
|
7203
|
+
...s.collapsed,
|
|
7204
|
+
[id]: collapsed
|
|
7205
|
+
}
|
|
7206
|
+
}));
|
|
7207
|
+
};
|
|
7208
|
+
return {
|
|
7209
|
+
isCollapsed,
|
|
7210
|
+
setCollapsed,
|
|
7211
|
+
toggle: (id) => setCollapsed(id, !isCollapsed(id)),
|
|
7212
|
+
reset: () => setSaved({
|
|
7213
|
+
sizes: {},
|
|
7214
|
+
collapsed: {}
|
|
7215
|
+
}),
|
|
7216
|
+
sizeOf: (id) => saved.sizes[id],
|
|
7217
|
+
setSize: (id, size) => setSaved((s) => {
|
|
7218
|
+
const sizes = { ...s.sizes };
|
|
7219
|
+
if (size === null) delete sizes[id];
|
|
7220
|
+
else sizes[id] = Math.round(size);
|
|
7221
|
+
return {
|
|
7222
|
+
...s,
|
|
7223
|
+
sizes
|
|
7224
|
+
};
|
|
7225
|
+
}),
|
|
7226
|
+
register: (id, defaultCollapsed) => void defaults.current.set(id, defaultCollapsed),
|
|
7227
|
+
narrow,
|
|
7228
|
+
setNarrow
|
|
7229
|
+
};
|
|
7230
|
+
}, [
|
|
7231
|
+
saved,
|
|
7232
|
+
narrow,
|
|
7233
|
+
narrowOpen
|
|
7234
|
+
]);
|
|
7235
|
+
}
|
|
7236
|
+
var StateContext = React.createContext(null);
|
|
7237
|
+
var useState_ = () => {
|
|
7238
|
+
const state = React.useContext(StateContext);
|
|
7239
|
+
if (!state) throw new Error("strata-react: a Pane or Split must be inside a Workspace.");
|
|
7240
|
+
return state;
|
|
7241
|
+
};
|
|
7242
|
+
var SlotContext = React.createContext({
|
|
7243
|
+
direction: "row",
|
|
7244
|
+
edge: "only",
|
|
7245
|
+
stacked: false
|
|
7246
|
+
});
|
|
7247
|
+
/** The workspace: a labelled region that holds the splits and panes, and stacks them when narrow. */
|
|
7248
|
+
function Workspace({ label, state, narrowBelow = 720, className, children }) {
|
|
7249
|
+
const ref = React.useRef(null);
|
|
7250
|
+
const { setNarrow } = state;
|
|
7251
|
+
React.useLayoutEffect(() => {
|
|
7252
|
+
const el = ref.current;
|
|
7253
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
7254
|
+
const measure = () => {
|
|
7255
|
+
const width = el.getBoundingClientRect().width;
|
|
7256
|
+
setNarrow(width > 0 && width < narrowBelow);
|
|
7257
|
+
};
|
|
7258
|
+
measure();
|
|
7259
|
+
const observer = new ResizeObserver(measure);
|
|
7260
|
+
observer.observe(el);
|
|
7261
|
+
return () => observer.disconnect();
|
|
7262
|
+
}, [narrowBelow, setNarrow]);
|
|
7263
|
+
return /* @__PURE__ */ jsx(StateContext.Provider, {
|
|
7264
|
+
value: state,
|
|
7265
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
7266
|
+
ref,
|
|
7267
|
+
role: "group",
|
|
7268
|
+
"aria-label": label,
|
|
7269
|
+
className: cn("flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-background", className),
|
|
7270
|
+
children
|
|
7271
|
+
})
|
|
7272
|
+
});
|
|
7273
|
+
}
|
|
7274
|
+
var iconsFor = (direction, edge, stacked) => {
|
|
7275
|
+
if (stacked || direction === "column") return edge === "start" ? [PanelTopClose, PanelTopOpen] : [PanelBottomClose, PanelBottomOpen];
|
|
7276
|
+
return edge === "end" ? [PanelRightClose, PanelRightOpen] : [PanelLeftClose, PanelLeftOpen];
|
|
7277
|
+
};
|
|
7278
|
+
/** A region of a workspace with a consistent header (name, actions, fold button) and a body that scrolls. */
|
|
7279
|
+
function Pane({ id, name, grow, size = 280, min, max, collapsible, defaultCollapsed, actions, className, children }) {
|
|
7280
|
+
const state = useState_();
|
|
7281
|
+
const { direction, edge, stacked } = React.useContext(SlotContext);
|
|
7282
|
+
const headingId = React.useId();
|
|
7283
|
+
const { register } = state;
|
|
7284
|
+
React.useLayoutEffect(() => register(id, Boolean(defaultCollapsed)), [
|
|
7285
|
+
register,
|
|
7286
|
+
id,
|
|
7287
|
+
defaultCollapsed
|
|
7288
|
+
]);
|
|
7289
|
+
const folded = Boolean(collapsible) && state.isCollapsed(id, Boolean(defaultCollapsed));
|
|
7290
|
+
const rail = folded && direction === "row" && !stacked;
|
|
7291
|
+
const least = min ?? (grow ? direction === "row" ? 240 : 120 : 160);
|
|
7292
|
+
const current = state.sizeOf(id) ?? size;
|
|
7293
|
+
const [closeIcon, openIcon] = iconsFor(direction, edge, stacked);
|
|
7294
|
+
const style = grow ? {
|
|
7295
|
+
flex: "1 1 0%",
|
|
7296
|
+
[direction === "row" ? "minWidth" : "minHeight"]: least
|
|
7297
|
+
} : folded ? { flex: "0 0 auto" } : stacked ? {
|
|
7298
|
+
flex: "0 1 auto",
|
|
7299
|
+
maxHeight: "50%"
|
|
7300
|
+
} : {
|
|
7301
|
+
flex: `0 1 ${Math.max(least, Math.min(current, max ?? Infinity))}px`,
|
|
7302
|
+
[direction === "row" ? "minWidth" : "minHeight"]: least,
|
|
7303
|
+
...max ? { [direction === "row" ? "maxWidth" : "maxHeight"]: max } : {}
|
|
7304
|
+
};
|
|
7305
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
7306
|
+
id: `pane-${id}`,
|
|
7307
|
+
"aria-labelledby": headingId,
|
|
7308
|
+
"data-pane": id,
|
|
7309
|
+
"data-collapsed": folded || void 0,
|
|
7310
|
+
"data-grow": grow || void 0,
|
|
7311
|
+
"data-min": grow ? least : void 0,
|
|
7312
|
+
"data-size": grow || folded ? void 0 : current,
|
|
7313
|
+
style,
|
|
7314
|
+
className: cn("flex min-h-0 min-w-0 flex-col overflow-hidden bg-background", rail && cn("w-(--control-h) items-center", edge === "end" ? "border-l border-border" : "border-r border-border"), className),
|
|
7315
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
7316
|
+
className: cn("flex shrink-0 items-center gap-1 pl-3 pr-1", rail ? "h-auto flex-col py-1 pl-1" : "h-(--control-h) border-b border-border"),
|
|
7317
|
+
children: [
|
|
7318
|
+
/* @__PURE__ */ jsx("h2", {
|
|
7319
|
+
id: headingId,
|
|
7320
|
+
className: cn("type-label min-w-0 flex-1 truncate", rail && "sr-only"),
|
|
7321
|
+
children: name
|
|
7322
|
+
}),
|
|
7323
|
+
!folded && actions,
|
|
7324
|
+
collapsible && /* @__PURE__ */ jsx(IconButton, {
|
|
7325
|
+
size: "sm",
|
|
7326
|
+
icon: folded ? openIcon : closeIcon,
|
|
7327
|
+
label: folded ? `Show ${name}` : `Hide ${name}`,
|
|
7328
|
+
"aria-expanded": !folded,
|
|
7329
|
+
"aria-controls": `pane-body-${id}`,
|
|
7330
|
+
onPress: () => state.toggle(id)
|
|
7331
|
+
})
|
|
7332
|
+
]
|
|
7333
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
7334
|
+
id: `pane-body-${id}`,
|
|
7335
|
+
hidden: folded,
|
|
7336
|
+
className: "min-h-0 min-w-0 flex-1 overflow-auto",
|
|
7337
|
+
children
|
|
7338
|
+
})]
|
|
7339
|
+
});
|
|
7340
|
+
}
|
|
7341
|
+
var isPane = (c) => React.isValidElement(c) && c.type === Pane;
|
|
7342
|
+
var clamp = (n, lo, hi) => Math.min(Math.max(n, lo), hi);
|
|
7343
|
+
function Separator$1({ pane, direction, sign, container }) {
|
|
7344
|
+
const state = useState_();
|
|
7345
|
+
const [moving, setMoving] = React.useState(false);
|
|
7346
|
+
const min = pane.min ?? 160;
|
|
7347
|
+
const start = pane.size ?? 280;
|
|
7348
|
+
const size = state.sizeOf(pane.id) ?? start;
|
|
7349
|
+
const latest = React.useRef(size);
|
|
7350
|
+
latest.current = size;
|
|
7351
|
+
const measure = () => {
|
|
7352
|
+
const own = Array.from(container.current?.children ?? []).find((el) => el.dataset.pane === pane.id);
|
|
7353
|
+
return own ? Math.round(own.getBoundingClientRect()[direction === "row" ? "width" : "height"]) : 0;
|
|
7354
|
+
};
|
|
7355
|
+
const current = () => {
|
|
7356
|
+
const drawn = measure();
|
|
7357
|
+
return drawn > 0 && drawn < latest.current ? drawn : latest.current;
|
|
7358
|
+
};
|
|
7359
|
+
const [drawn, setDrawn] = React.useState(0);
|
|
7360
|
+
React.useEffect(() => {
|
|
7361
|
+
const root = container.current;
|
|
7362
|
+
if (!root || typeof ResizeObserver === "undefined") return;
|
|
7363
|
+
const observer = new ResizeObserver(() => setDrawn(measure()));
|
|
7364
|
+
observer.observe(root);
|
|
7365
|
+
setDrawn(measure());
|
|
7366
|
+
return () => observer.disconnect();
|
|
7367
|
+
}, [size, direction]);
|
|
7368
|
+
const shown = drawn > 0 && drawn < size ? drawn : size;
|
|
7369
|
+
const room = () => {
|
|
7370
|
+
const root = container.current;
|
|
7371
|
+
const kids = Array.from(root?.children ?? []);
|
|
7372
|
+
const own = kids.find((el) => el.dataset.pane === pane.id);
|
|
7373
|
+
const stage = kids.find((el) => el.dataset.grow !== void 0 || el.dataset.split !== void 0);
|
|
7374
|
+
if (!own || !stage) return Infinity;
|
|
7375
|
+
const dim = direction === "row" ? "width" : "height";
|
|
7376
|
+
const stageSize = stage.getBoundingClientRect()[dim];
|
|
7377
|
+
if (stageSize <= 0) return Infinity;
|
|
7378
|
+
const stageMin = Number(stage.dataset.min ?? 0);
|
|
7379
|
+
return own.getBoundingClientRect()[dim] + stageSize - stageMin;
|
|
7380
|
+
};
|
|
7381
|
+
const upper = () => Math.max(min, Math.min(pane.max ?? Infinity, room()));
|
|
7382
|
+
const apply = (next) => state.setSize(pane.id, clamp(next, min, upper()));
|
|
7383
|
+
const { moveProps } = useMove({
|
|
7384
|
+
onMoveStart: () => setMoving(true),
|
|
7385
|
+
onMove: ({ deltaX, deltaY, pointerType, shiftKey }) => {
|
|
7386
|
+
const delta = (direction === "row" ? deltaX : deltaY) * (pointerType === "keyboard" ? shiftKey ? 50 : 10 : 1);
|
|
7387
|
+
if (!delta) return;
|
|
7388
|
+
const next = clamp(current() + sign * delta, min, upper());
|
|
7389
|
+
latest.current = next;
|
|
7390
|
+
apply(next);
|
|
7391
|
+
},
|
|
7392
|
+
onMoveEnd: () => setMoving(false)
|
|
7393
|
+
});
|
|
7394
|
+
const restore = () => state.setSize(pane.id, null);
|
|
7395
|
+
const keys = {
|
|
7396
|
+
onKeyDown: (e) => {
|
|
7397
|
+
if (e.key === "Home") apply(min);
|
|
7398
|
+
else if (e.key === "End") apply(upper());
|
|
7399
|
+
else if (e.key === "Enter") restore();
|
|
7400
|
+
else return;
|
|
7401
|
+
e.preventDefault();
|
|
7402
|
+
},
|
|
7403
|
+
onDoubleClick: restore
|
|
7404
|
+
};
|
|
7405
|
+
const vertical = direction === "row";
|
|
7406
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7407
|
+
role: "separator",
|
|
7408
|
+
tabIndex: 0,
|
|
7409
|
+
"aria-orientation": vertical ? "vertical" : "horizontal",
|
|
7410
|
+
"aria-label": `Resize ${pane.name}`,
|
|
7411
|
+
"aria-controls": `pane-${pane.id}`,
|
|
7412
|
+
"aria-valuenow": Math.round(shown),
|
|
7413
|
+
"aria-valuemin": min,
|
|
7414
|
+
"aria-valuemax": Number.isFinite(pane.max ?? Infinity) ? pane.max : void 0,
|
|
7415
|
+
"data-moving": moving || void 0,
|
|
7416
|
+
...mergeProps(moveProps, keys),
|
|
7417
|
+
className: cn("relative shrink-0 touch-none bg-border transition-state hover:bg-primary focus-visible:bg-primary data-[moving]:bg-primary", vertical ? "w-px cursor-col-resize before:absolute before:inset-y-0 before:-inset-x-1" : "h-px cursor-row-resize before:absolute before:inset-x-0 before:-inset-y-1", "pointer-coarse:before:-inset-x-2")
|
|
7418
|
+
});
|
|
7419
|
+
}
|
|
7420
|
+
/** Lays its children out in a row or a column, with a separator between a fixed pane and its neighbour. A nested split takes the space the fixed panes leave. */
|
|
7421
|
+
function Split({ direction, className, children }) {
|
|
7422
|
+
const state = useState_();
|
|
7423
|
+
const ref = React.useRef(null);
|
|
7424
|
+
const stacked = direction === "row" && state.narrow;
|
|
7425
|
+
const effective = stacked ? "column" : direction;
|
|
7426
|
+
const items = React.Children.toArray(children);
|
|
7427
|
+
const slotted = (c) => isPane(c) || React.isValidElement(c) && c.type === Split;
|
|
7428
|
+
const grows = (c) => isPane(c) ? Boolean(c.props.grow) : true;
|
|
7429
|
+
const out = [];
|
|
7430
|
+
items.forEach((child, i) => {
|
|
7431
|
+
const growIndex = items.findIndex((c) => slotted(c) && grows(c));
|
|
7432
|
+
const edge = growIndex < 0 ? "only" : i < growIndex ? "start" : i > growIndex ? "end" : "only";
|
|
7433
|
+
out.push(/* @__PURE__ */ jsx(SlotContext.Provider, {
|
|
7434
|
+
value: {
|
|
7435
|
+
direction: effective,
|
|
7436
|
+
edge,
|
|
7437
|
+
stacked
|
|
7438
|
+
},
|
|
7439
|
+
children: child
|
|
7440
|
+
}, React.isValidElement(child) && child.key != null ? child.key : i));
|
|
7441
|
+
const next = items[i + 1];
|
|
7442
|
+
if (next === void 0 || !slotted(child) || !slotted(next)) return;
|
|
7443
|
+
const fixed = (c) => isPane(c) && !c.props.grow && !(c.props.collapsible && state.isCollapsed(c.props.id, c.props.defaultCollapsed));
|
|
7444
|
+
const before = fixed(child);
|
|
7445
|
+
const after = fixed(next);
|
|
7446
|
+
if (stacked || !before && !after) return;
|
|
7447
|
+
const controlled = before ? child : next;
|
|
7448
|
+
out.push(/* @__PURE__ */ jsx(Separator$1, {
|
|
7449
|
+
pane: controlled.props,
|
|
7450
|
+
direction: effective,
|
|
7451
|
+
sign: before ? 1 : -1,
|
|
7452
|
+
container: ref
|
|
7453
|
+
}, `sep-${i}`));
|
|
7454
|
+
});
|
|
7455
|
+
const growPane = items.find((c) => isPane(c) && Boolean(c.props.grow));
|
|
7456
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7457
|
+
ref,
|
|
7458
|
+
"data-split": direction,
|
|
7459
|
+
"data-min": growPane ? growPane.props.min ?? (direction === "row" ? 240 : 120) : void 0,
|
|
7460
|
+
className: cn("flex min-h-0 min-w-0 flex-1", effective === "row" ? "flex-row" : "flex-col", className),
|
|
7461
|
+
children: out
|
|
7462
|
+
});
|
|
7463
|
+
}
|
|
7464
|
+
// src/components/history.tsx
|
|
7465
|
+
var compose = (older, newer) => ({
|
|
7466
|
+
label: older.label,
|
|
7467
|
+
key: older.key,
|
|
7468
|
+
undo: () => {
|
|
7469
|
+
newer.undo();
|
|
7470
|
+
older.undo();
|
|
7471
|
+
},
|
|
7472
|
+
redo: () => {
|
|
7473
|
+
older.redo();
|
|
7474
|
+
newer.redo();
|
|
7475
|
+
}
|
|
7476
|
+
});
|
|
7477
|
+
/** A history of named, undoable steps with grouping, a limit, and Undo and Redo as commands. */
|
|
7478
|
+
function useHistory({ limit = 100 } = {}) {
|
|
7479
|
+
const store = React.useRef({
|
|
7480
|
+
past: [],
|
|
7481
|
+
future: [],
|
|
7482
|
+
open: [],
|
|
7483
|
+
merge: false
|
|
7484
|
+
});
|
|
7485
|
+
const [version, bump] = React.useReducer((n) => n + 1, 0);
|
|
7486
|
+
const max = Math.max(1, limit);
|
|
7487
|
+
const api = React.useMemo(() => {
|
|
7488
|
+
const s = store.current;
|
|
7489
|
+
const record = (step) => {
|
|
7490
|
+
const last = s.past[s.past.length - 1];
|
|
7491
|
+
if (s.merge && step.key && last && last.key === step.key) s.past[s.past.length - 1] = compose(last, step);
|
|
7492
|
+
else {
|
|
7493
|
+
s.past.push(step);
|
|
7494
|
+
if (s.past.length > max) s.past.splice(0, s.past.length - max);
|
|
7495
|
+
}
|
|
7496
|
+
s.future = [];
|
|
7497
|
+
s.merge = Boolean(step.key);
|
|
7498
|
+
bump();
|
|
7499
|
+
};
|
|
7500
|
+
const push = (step) => {
|
|
7501
|
+
const group = s.open[s.open.length - 1];
|
|
7502
|
+
if (group) group.push(step);
|
|
7503
|
+
else record(step);
|
|
7504
|
+
};
|
|
7505
|
+
const begin = (label) => {
|
|
7506
|
+
const steps = [];
|
|
7507
|
+
s.open.push(steps);
|
|
7508
|
+
let ended = false;
|
|
7509
|
+
return () => {
|
|
7510
|
+
if (ended) return;
|
|
7511
|
+
ended = true;
|
|
7512
|
+
s.open.pop();
|
|
7513
|
+
if (!steps.length) return;
|
|
7514
|
+
push({
|
|
7515
|
+
label,
|
|
7516
|
+
undo: () => [...steps].reverse().forEach((x) => x.undo()),
|
|
7517
|
+
redo: () => steps.forEach((x) => x.redo())
|
|
7518
|
+
});
|
|
7519
|
+
};
|
|
7520
|
+
};
|
|
7521
|
+
return {
|
|
7522
|
+
push,
|
|
7523
|
+
begin,
|
|
7524
|
+
group: (label, run) => {
|
|
7525
|
+
const end = begin(label);
|
|
7526
|
+
try {
|
|
7527
|
+
return run();
|
|
7528
|
+
} finally {
|
|
7529
|
+
end();
|
|
7530
|
+
}
|
|
7531
|
+
},
|
|
7532
|
+
undo: () => {
|
|
7533
|
+
if (s.open.length) return;
|
|
7534
|
+
const step = s.past.pop();
|
|
7535
|
+
if (!step) return;
|
|
7536
|
+
step.undo();
|
|
7537
|
+
s.future.unshift(step);
|
|
7538
|
+
s.merge = false;
|
|
7539
|
+
bump();
|
|
7540
|
+
},
|
|
7541
|
+
redo: () => {
|
|
7542
|
+
if (s.open.length) return;
|
|
7543
|
+
const step = s.future.shift();
|
|
7544
|
+
if (!step) return;
|
|
7545
|
+
step.redo();
|
|
7546
|
+
s.past.push(step);
|
|
7547
|
+
s.merge = false;
|
|
7548
|
+
bump();
|
|
7549
|
+
},
|
|
7550
|
+
clear: () => {
|
|
7551
|
+
s.past = [];
|
|
7552
|
+
s.future = [];
|
|
7553
|
+
s.merge = false;
|
|
7554
|
+
bump();
|
|
7555
|
+
}
|
|
7556
|
+
};
|
|
7557
|
+
}, [max]);
|
|
7558
|
+
return React.useMemo(() => {
|
|
7559
|
+
const { past, future } = store.current;
|
|
7560
|
+
const undoLabel = past[past.length - 1]?.label;
|
|
7561
|
+
const redoLabel = future[0]?.label;
|
|
7562
|
+
const commands = [{
|
|
7563
|
+
id: "history.undo",
|
|
7564
|
+
label: undoLabel ? `Undo ${undoLabel}` : "Undo",
|
|
7565
|
+
icon: Undo2,
|
|
7566
|
+
keys: ["Mod+Z"],
|
|
7567
|
+
disabled: undoLabel ? false : "Nothing to undo",
|
|
7568
|
+
run: api.undo
|
|
7569
|
+
}, {
|
|
7570
|
+
id: "history.redo",
|
|
7571
|
+
label: redoLabel ? `Redo ${redoLabel}` : "Redo",
|
|
7572
|
+
icon: Redo2,
|
|
7573
|
+
keys: ["Mod+Shift+Z", "Mod+Y"],
|
|
7574
|
+
disabled: redoLabel ? false : "Nothing to redo",
|
|
7575
|
+
run: api.redo
|
|
7576
|
+
}];
|
|
7577
|
+
return {
|
|
7578
|
+
...api,
|
|
7579
|
+
canUndo: past.length > 0,
|
|
7580
|
+
canRedo: future.length > 0,
|
|
7581
|
+
undoLabel,
|
|
7582
|
+
redoLabel,
|
|
7583
|
+
past: past.map((x) => x.label),
|
|
7584
|
+
future: future.map((x) => x.label),
|
|
7585
|
+
atLimit: past.length >= max,
|
|
7586
|
+
commands
|
|
7587
|
+
};
|
|
7588
|
+
}, [
|
|
7589
|
+
api,
|
|
7590
|
+
version,
|
|
7591
|
+
max
|
|
7592
|
+
]);
|
|
7593
|
+
}
|
|
7594
|
+
/**
|
|
7595
|
+
* React state with a history: `set(next, "move clip")` changes the value and records the step; Undo
|
|
7596
|
+
* and Redo put the old and new values back. For an app whose document is a plain value. An app on its
|
|
7597
|
+
* own store uses `useHistory` and pushes steps from its actions.
|
|
7598
|
+
*/
|
|
7599
|
+
function useHistoryState(initial, options) {
|
|
7600
|
+
const [value, setValue] = React.useState(initial);
|
|
7601
|
+
const latest = React.useRef(value);
|
|
7602
|
+
const history = useHistory(options);
|
|
7603
|
+
const { push } = history;
|
|
7604
|
+
const write = React.useCallback((next) => {
|
|
7605
|
+
latest.current = next;
|
|
7606
|
+
setValue(next);
|
|
7607
|
+
}, []);
|
|
7608
|
+
return {
|
|
7609
|
+
value,
|
|
7610
|
+
set: React.useCallback((next, label, { key } = {}) => {
|
|
7611
|
+
const before = latest.current;
|
|
7612
|
+
const after = typeof next === "function" ? next(before) : next;
|
|
7613
|
+
if (Object.is(before, after)) return;
|
|
7614
|
+
write(after);
|
|
7615
|
+
push({
|
|
7616
|
+
label,
|
|
7617
|
+
key,
|
|
7618
|
+
undo: () => write(before),
|
|
7619
|
+
redo: () => write(after)
|
|
7620
|
+
});
|
|
7621
|
+
}, [push, write]),
|
|
7622
|
+
reset: React.useCallback((next) => {
|
|
7623
|
+
write(next);
|
|
7624
|
+
history.clear();
|
|
7625
|
+
}, [write, history.clear]),
|
|
7626
|
+
history
|
|
7627
|
+
};
|
|
7628
|
+
}
|
|
7629
|
+
// src/components/save.tsx
|
|
7630
|
+
/** Saves `value` after changes settle, never two at once, and says where it stands. The document's first `value` counts as saved. */
|
|
7631
|
+
function useAutoSave({ value, save, delayMs = 1500, equals = Object.is, describeError = describeActionError }) {
|
|
7632
|
+
const [state, setState] = React.useState({
|
|
7633
|
+
status: "saved",
|
|
7634
|
+
at: null
|
|
7635
|
+
});
|
|
7636
|
+
const latest = React.useRef({
|
|
7637
|
+
value,
|
|
7638
|
+
save,
|
|
7639
|
+
equals,
|
|
7640
|
+
describeError,
|
|
7641
|
+
delayMs
|
|
7642
|
+
});
|
|
7643
|
+
latest.current = {
|
|
7644
|
+
value,
|
|
7645
|
+
save,
|
|
7646
|
+
equals,
|
|
7647
|
+
describeError,
|
|
7648
|
+
delayMs
|
|
7649
|
+
};
|
|
7650
|
+
const saved = React.useRef(value);
|
|
7651
|
+
const savedAt = React.useRef(null);
|
|
7652
|
+
const running = React.useRef(null);
|
|
7653
|
+
const timer = React.useRef(void 0);
|
|
7654
|
+
const mounted = React.useRef(true);
|
|
7655
|
+
React.useEffect(() => {
|
|
7656
|
+
mounted.current = true;
|
|
7657
|
+
return () => {
|
|
7658
|
+
mounted.current = false;
|
|
7659
|
+
window.clearTimeout(timer.current);
|
|
7660
|
+
};
|
|
7661
|
+
}, []);
|
|
7662
|
+
const schedule = React.useCallback(() => {
|
|
7663
|
+
window.clearTimeout(timer.current);
|
|
7664
|
+
if (latest.current.delayMs === null) return;
|
|
7665
|
+
timer.current = window.setTimeout(() => void run(), latest.current.delayMs);
|
|
7666
|
+
}, []);
|
|
7667
|
+
const run = React.useCallback(() => {
|
|
7668
|
+
window.clearTimeout(timer.current);
|
|
7669
|
+
if (running.current) return running.current;
|
|
7670
|
+
const current = latest.current.value;
|
|
7671
|
+
if (latest.current.equals(current, saved.current)) {
|
|
7672
|
+
setState((s) => s.status === "saved" ? s : {
|
|
7673
|
+
status: "saved",
|
|
7674
|
+
at: /* @__PURE__ */ new Date()
|
|
7675
|
+
});
|
|
7676
|
+
return Promise.resolve();
|
|
7677
|
+
}
|
|
7678
|
+
setState({ status: "saving" });
|
|
7679
|
+
let settled = false;
|
|
7680
|
+
const attempt = (async () => {
|
|
7681
|
+
try {
|
|
7682
|
+
await latest.current.save(current);
|
|
7683
|
+
saved.current = current;
|
|
7684
|
+
savedAt.current = /* @__PURE__ */ new Date();
|
|
7685
|
+
if (!mounted.current) return;
|
|
7686
|
+
if (latest.current.equals(latest.current.value, current)) setState({
|
|
7687
|
+
status: "saved",
|
|
7688
|
+
at: savedAt.current
|
|
7689
|
+
});
|
|
7690
|
+
else {
|
|
7691
|
+
setState({ status: "dirty" });
|
|
7692
|
+
schedule();
|
|
7693
|
+
}
|
|
7694
|
+
} catch (error) {
|
|
7695
|
+
if (mounted.current) setState({
|
|
7696
|
+
status: "failed",
|
|
7697
|
+
reason: latest.current.describeError(error)
|
|
7698
|
+
});
|
|
7699
|
+
} finally {
|
|
7700
|
+
settled = true;
|
|
7701
|
+
running.current = null;
|
|
7702
|
+
}
|
|
7703
|
+
})();
|
|
7704
|
+
if (!settled) running.current = attempt;
|
|
7705
|
+
return attempt;
|
|
7706
|
+
}, [schedule]);
|
|
7707
|
+
React.useEffect(() => {
|
|
7708
|
+
if (latest.current.equals(value, saved.current)) {
|
|
7709
|
+
if (!running.current) {
|
|
7710
|
+
window.clearTimeout(timer.current);
|
|
7711
|
+
setState((s) => s.status === "dirty" || s.status === "failed" ? {
|
|
7712
|
+
status: "saved",
|
|
7713
|
+
at: savedAt.current
|
|
7714
|
+
} : s);
|
|
7715
|
+
}
|
|
7716
|
+
return;
|
|
7717
|
+
}
|
|
7718
|
+
if (!running.current) setState((s) => s.status === "failed" ? s : { status: "dirty" });
|
|
7719
|
+
if (!running.current) schedule();
|
|
7720
|
+
}, [value, schedule]);
|
|
7721
|
+
return {
|
|
7722
|
+
state,
|
|
7723
|
+
saveNow: run
|
|
7724
|
+
};
|
|
7725
|
+
}
|
|
7726
|
+
/** Asks the browser to confirm before the page is closed or reloaded, while `active`. Off when there is nothing to lose. */
|
|
7727
|
+
function useLeaveGuard(active) {
|
|
7728
|
+
React.useEffect(() => {
|
|
7729
|
+
if (!active) return;
|
|
7730
|
+
const onBeforeUnload = (e) => {
|
|
7731
|
+
e.preventDefault();
|
|
7732
|
+
e.returnValue = "";
|
|
7733
|
+
};
|
|
7734
|
+
window.addEventListener("beforeunload", onBeforeUnload);
|
|
7735
|
+
return () => window.removeEventListener("beforeunload", onBeforeUnload);
|
|
7736
|
+
}, [active]);
|
|
7737
|
+
}
|
|
7738
|
+
var labelOf$1 = (s) => s.status === "saved" ? s.at ? `Saved ${format.clock(s.at)}` : "Saved" : s.status === "saving" ? "Saving…" : s.status === "dirty" ? "Unsaved changes" : "Not saved";
|
|
7739
|
+
/**
|
|
7740
|
+
* The sign of whether the work is safe: "Saved 10:42", "Saving…", "Unsaved changes", or "Not saved"
|
|
7741
|
+
* with the reason and "Try again". Fixed width, so it never moves what is beside it. Announces a
|
|
7742
|
+
* failure, and the recovery from one, politely; a routine save is silent.
|
|
7743
|
+
*/
|
|
7744
|
+
function SaveStatus({ state, onRetry, className }) {
|
|
7745
|
+
const lastFailure = React.useRef(false);
|
|
7746
|
+
const failed = state.status === "failed";
|
|
7747
|
+
let announcement = "";
|
|
7748
|
+
if (failed) announcement = `Not saved${state.reason ? `: ${state.reason}` : "."} Your changes are still here.`;
|
|
7749
|
+
else if (lastFailure.current && state.status === "saved") announcement = "Saved.";
|
|
7750
|
+
React.useEffect(() => {
|
|
7751
|
+
if (failed) lastFailure.current = true;
|
|
7752
|
+
else if (state.status === "saved") lastFailure.current = false;
|
|
7753
|
+
}, [failed, state.status]);
|
|
7754
|
+
const Icon = {
|
|
7755
|
+
saved: Check,
|
|
7756
|
+
saving: LoaderCircle,
|
|
7757
|
+
dirty: null,
|
|
7758
|
+
failed: CircleAlert
|
|
7759
|
+
}[state.status];
|
|
7760
|
+
const current = labelOf$1(state);
|
|
7761
|
+
const all = [
|
|
7762
|
+
"Saved 00:00",
|
|
7763
|
+
"Saving…",
|
|
7764
|
+
"Unsaved changes",
|
|
7765
|
+
"Not saved"
|
|
7766
|
+
];
|
|
7767
|
+
const shown = failed && state.reason ? `Not saved: ${state.reason}` : current;
|
|
7768
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
7769
|
+
"data-status": state.status,
|
|
7770
|
+
title: failed ? shown : void 0,
|
|
7771
|
+
className: cn("inline-flex w-72 items-center justify-end gap-2 type-body-sm", failed ? "text-danger" : "text-muted-foreground", className),
|
|
7772
|
+
children: [
|
|
7773
|
+
Icon && /* @__PURE__ */ jsx(Icon, {
|
|
7774
|
+
"aria-hidden": true,
|
|
7775
|
+
className: cn("size-4 shrink-0", state.status === "saving" && "motion-safe:animate-spin")
|
|
7776
|
+
}),
|
|
7777
|
+
failed ? /* @__PURE__ */ jsx("span", {
|
|
7778
|
+
className: "min-w-0 truncate",
|
|
7779
|
+
children: shown
|
|
7780
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
7781
|
+
className: "grid",
|
|
7782
|
+
children: all.map((l) => {
|
|
7783
|
+
const active = l === current || l === "Saved 00:00" && state.status === "saved";
|
|
7784
|
+
return /* @__PURE__ */ jsx("span", {
|
|
7785
|
+
"aria-hidden": !active,
|
|
7786
|
+
className: active ? "[grid-area:1/1] text-end tabular-nums" : "invisible [grid-area:1/1] text-end",
|
|
7787
|
+
children: active ? current : l
|
|
7788
|
+
}, l);
|
|
7789
|
+
})
|
|
7790
|
+
}),
|
|
7791
|
+
failed && /* @__PURE__ */ jsx(Button, {
|
|
7792
|
+
size: "sm",
|
|
7793
|
+
variant: "ghost",
|
|
7794
|
+
onClick: onRetry,
|
|
7795
|
+
className: "shrink-0",
|
|
7796
|
+
children: "Try again"
|
|
7797
|
+
}),
|
|
7798
|
+
/* @__PURE__ */ jsx("span", {
|
|
7799
|
+
role: "status",
|
|
7800
|
+
className: "sr-only",
|
|
7801
|
+
children: announcement
|
|
7802
|
+
})
|
|
7803
|
+
]
|
|
7804
|
+
});
|
|
7805
|
+
}
|
|
7806
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareGrid, CompositionBar, ContextMenu, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, differences, fetchJson, fieldErrorsOf, format, formatChord, isReservedChord, isTypingTarget, labelOf, matchesAccept, matchesChord, noOverlap, parseChord, parseSort, readErrorBody, readPixels, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useSelection, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, zoomAt };
|
|
7017
7807
|
|
|
7018
7808
|
//# sourceMappingURL=index.js.map
|