strata-react 1.0.15 → 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 +4 -3
- package/UPGRADING.md +2 -0
- package/dist/components/file-intake.d.ts +7 -2
- package/dist/components/line-chart.d.ts +3 -1
- package/dist/components/timeline.d.ts +19 -2
- package/dist/components/workspace.d.ts +63 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +495 -88
- package/dist/index.js.map +1 -1
- package/dist/lib/format.d.ts +12 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@ 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, Redo2, RotateCcw, Scan, Search, SkipBack, SkipForward, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, 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. */
|
|
@@ -2958,7 +2961,7 @@ function TableSkeleton({ rows = 4, columns = 5 }) {
|
|
|
2958
2961
|
});
|
|
2959
2962
|
}
|
|
2960
2963
|
// src/components/media.tsx
|
|
2961
|
-
var clamp$
|
|
2964
|
+
var clamp$2 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
2962
2965
|
var timecode = (t, { precision, fps }) => format.timecode(t, {
|
|
2963
2966
|
precision,
|
|
2964
2967
|
fps
|
|
@@ -3003,8 +3006,8 @@ function TimeReadout({ time, duration, precision = "seconds", fps = 30, classNam
|
|
|
3003
3006
|
function SeekBar({ time, duration, onSeek, marks = [], buffered, step = 5, bigStep = 30, label = "Seek", precision = "seconds", fps = 30, disabled, className }) {
|
|
3004
3007
|
const track = React.useRef(null);
|
|
3005
3008
|
const input = React.useRef(null);
|
|
3006
|
-
const frac = duration > 0 ? clamp$
|
|
3007
|
-
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));
|
|
3008
3011
|
const timeText = React.useMemo(() => {
|
|
3009
3012
|
const say = (t) => timecode(t, {
|
|
3010
3013
|
precision,
|
|
@@ -3021,7 +3024,7 @@ function SeekBar({ time, duration, onSeek, marks = [], buffered, step = 5, bigSt
|
|
|
3021
3024
|
minValue: 0,
|
|
3022
3025
|
maxValue: Math.max(duration, fine),
|
|
3023
3026
|
step: fine,
|
|
3024
|
-
value: [clamp$
|
|
3027
|
+
value: [clamp$2(time, 0, duration)],
|
|
3025
3028
|
onChange: ([t]) => seekTo(t),
|
|
3026
3029
|
numberFormatter: timeText,
|
|
3027
3030
|
isDisabled: disabled
|
|
@@ -3070,7 +3073,7 @@ function SeekBar({ time, duration, onSeek, marks = [], buffered, step = 5, bigSt
|
|
|
3070
3073
|
buffered !== void 0 && duration > 0 && /* @__PURE__ */ jsx("span", {
|
|
3071
3074
|
"aria-hidden": true,
|
|
3072
3075
|
className: "absolute left-0 h-1.5 rounded-pill bg-neutral-4",
|
|
3073
|
-
style: { width: `${clamp$
|
|
3076
|
+
style: { width: `${clamp$2(buffered / duration, 0, 1) * 100}%` }
|
|
3074
3077
|
}),
|
|
3075
3078
|
/* @__PURE__ */ jsx("span", {
|
|
3076
3079
|
"aria-hidden": true,
|
|
@@ -3206,7 +3209,7 @@ function RateChoice({ rate, onRateChange, rates = [
|
|
|
3206
3209
|
* to the ends, M mutes. Pass the player's actions; the labels are the legend's words.
|
|
3207
3210
|
*/
|
|
3208
3211
|
function transportShortcuts({ toggle, seek, time, duration, frame = 1 / 30, jump = 1, toggleMute }) {
|
|
3209
|
-
const to = (t) => () => seek(clamp$
|
|
3212
|
+
const to = (t) => () => seek(clamp$2(t, 0, duration));
|
|
3210
3213
|
return [
|
|
3211
3214
|
{
|
|
3212
3215
|
keys: [" ", "k"],
|
|
@@ -3412,7 +3415,7 @@ function tickLabel(time, step) {
|
|
|
3412
3415
|
const base = h > 0 ? `${h}:${two(m)}:${two(s)}` : `${m}:${two(s)}`;
|
|
3413
3416
|
return decimals ? `${base}.${String(Math.round((time - whole) * 10 ** decimals)).padStart(decimals, "0")}` : base;
|
|
3414
3417
|
}
|
|
3415
|
-
function clamp(value, min, max) {
|
|
3418
|
+
function clamp$1(value, min, max) {
|
|
3416
3419
|
return Math.min(Math.max(value, min), max);
|
|
3417
3420
|
}
|
|
3418
3421
|
/** The point to snap `time` to: the nearest of `points` within `thresholdPx` at this zoom, or `null`. */
|
|
@@ -3427,14 +3430,13 @@ function snapTo(time, points, pxPerUnit, thresholdPx = 8) {
|
|
|
3427
3430
|
/** Round away float noise from adding steps (0.1 + 0.2). */
|
|
3428
3431
|
var tidy = (n) => Math.round(n * 1e6) / 1e6;
|
|
3429
3432
|
// src/components/timeline.tsx
|
|
3430
|
-
var HEADER_W = "w-40";
|
|
3431
3433
|
var EDGE_PX = 8;
|
|
3432
3434
|
var DRAG_THRESHOLD = 3;
|
|
3433
3435
|
var defaultFormat = (t) => tickLabel(t, 1);
|
|
3434
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`. */
|
|
3435
3437
|
function useTimelineZoom({ initial = 20, min = .5, max = 400 } = {}) {
|
|
3436
3438
|
const [zoom, set] = React.useState(initial);
|
|
3437
|
-
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]);
|
|
3438
3440
|
return {
|
|
3439
3441
|
zoom,
|
|
3440
3442
|
setZoom,
|
|
@@ -3479,7 +3481,7 @@ function noOverlap(items) {
|
|
|
3479
3481
|
};
|
|
3480
3482
|
}
|
|
3481
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. */
|
|
3482
|
-
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 }) {
|
|
3483
3485
|
const min = minLength ?? step;
|
|
3484
3486
|
const scroller = React.useRef(null);
|
|
3485
3487
|
const laneRefs = React.useRef(/* @__PURE__ */ new Map());
|
|
@@ -3491,6 +3493,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3491
3493
|
const dragRef = React.useRef(null);
|
|
3492
3494
|
const [focusId, setFocusId] = React.useState(null);
|
|
3493
3495
|
const [said, setSaid] = React.useState("");
|
|
3496
|
+
const [hover, setHover] = React.useState(null);
|
|
3494
3497
|
const refocus = React.useRef(null);
|
|
3495
3498
|
const selected = selectedIds ?? /* @__PURE__ */ new Set();
|
|
3496
3499
|
const laneIndex = React.useMemo(() => new Map(lanes.map((l, i) => [l.id, i])), [lanes]);
|
|
@@ -3588,7 +3591,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3588
3591
|
handled();
|
|
3589
3592
|
const dir = k === "ArrowLeft" ? -1 : 1;
|
|
3590
3593
|
commit(item, {
|
|
3591
|
-
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),
|
|
3592
3595
|
length: item.length,
|
|
3593
3596
|
lane: item.lane
|
|
3594
3597
|
});
|
|
@@ -3608,7 +3611,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3608
3611
|
handled();
|
|
3609
3612
|
const dir = k === "ArrowLeft" ? -1 : 1;
|
|
3610
3613
|
if (e.shiftKey) {
|
|
3611
|
-
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);
|
|
3612
3615
|
commit(item, {
|
|
3613
3616
|
start,
|
|
3614
3617
|
length: tidy(item.start + item.length - start),
|
|
@@ -3616,7 +3619,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3616
3619
|
});
|
|
3617
3620
|
} else commit(item, {
|
|
3618
3621
|
start: item.start,
|
|
3619
|
-
length: clamp(tidy(item.length + dir * step), min, to - item.start),
|
|
3622
|
+
length: clamp$1(tidy(item.length + dir * step), min, to - item.start),
|
|
3620
3623
|
lane: item.lane
|
|
3621
3624
|
});
|
|
3622
3625
|
return;
|
|
@@ -3658,6 +3661,58 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3658
3661
|
}
|
|
3659
3662
|
}
|
|
3660
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);
|
|
3661
3716
|
const begin = (e, item, mode) => {
|
|
3662
3717
|
if (e.button !== 0) return;
|
|
3663
3718
|
e.stopPropagation();
|
|
@@ -3706,28 +3761,21 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3706
3761
|
return s ? s.time : t;
|
|
3707
3762
|
};
|
|
3708
3763
|
if (d.mode === "move") {
|
|
3709
|
-
|
|
3710
|
-
const
|
|
3711
|
-
|
|
3712
|
-
if (a && (!b || Math.abs(a.time - start) <= Math.abs(b.time - (start + o.length)))) {
|
|
3713
|
-
start = a.time;
|
|
3714
|
-
guide = a.point;
|
|
3715
|
-
} else if (b) {
|
|
3716
|
-
start = b.time - o.length;
|
|
3717
|
-
guide = b.point;
|
|
3718
|
-
}
|
|
3764
|
+
const m = snapMove(o.start + dt, o.length, o.id);
|
|
3765
|
+
const start = m.start;
|
|
3766
|
+
guide = m.guide;
|
|
3719
3767
|
next = {
|
|
3720
|
-
start: clamp(tidy(start), from, to - o.length),
|
|
3768
|
+
start: clamp$1(tidy(start), from, to - o.length),
|
|
3721
3769
|
length: o.length,
|
|
3722
3770
|
lane: laneAt(e.clientY, o.lane)
|
|
3723
3771
|
};
|
|
3724
3772
|
} else if (d.mode === "end") next = {
|
|
3725
3773
|
start: o.start,
|
|
3726
|
-
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),
|
|
3727
3775
|
lane: o.lane
|
|
3728
3776
|
};
|
|
3729
3777
|
else {
|
|
3730
|
-
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);
|
|
3731
3779
|
next = {
|
|
3732
3780
|
start,
|
|
3733
3781
|
length: tidy(o.start + o.length - start),
|
|
@@ -3764,7 +3812,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3764
3812
|
to,
|
|
3765
3813
|
stepSize
|
|
3766
3814
|
]);
|
|
3767
|
-
const setPosition = (t) => onPositionChange?.(clamp(tidy(t), from, to));
|
|
3815
|
+
const setPosition = (t) => onPositionChange?.(clamp$1(tidy(t), from, to));
|
|
3768
3816
|
const scrubTrack = React.useRef(null);
|
|
3769
3817
|
const scrubInput = React.useRef(null);
|
|
3770
3818
|
const spokenTime = React.useMemo(() => ({
|
|
@@ -3776,7 +3824,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3776
3824
|
minValue: from,
|
|
3777
3825
|
maxValue: Math.max(to, from + 1e-9),
|
|
3778
3826
|
step: .001,
|
|
3779
|
-
value: [clamp(position ?? from, from, to)],
|
|
3827
|
+
value: [clamp$1(position ?? from, from, to)],
|
|
3780
3828
|
onChange: ([t]) => setPosition(t),
|
|
3781
3829
|
numberFormatter: spokenTime,
|
|
3782
3830
|
isDisabled: position === void 0 || !onPositionChange
|
|
@@ -3840,6 +3888,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3840
3888
|
"aria-label": label,
|
|
3841
3889
|
onKeyDown,
|
|
3842
3890
|
className: cn("min-w-0 text-foreground", className),
|
|
3891
|
+
style: { "--lane-h": `calc(var(--control-h) * ${Math.max(laneRows, 1)})` },
|
|
3843
3892
|
children: [
|
|
3844
3893
|
/* @__PURE__ */ jsx("p", {
|
|
3845
3894
|
role: "status",
|
|
@@ -3849,12 +3898,12 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3849
3898
|
/* @__PURE__ */ jsxs("div", {
|
|
3850
3899
|
className: "flex",
|
|
3851
3900
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
3852
|
-
className:
|
|
3901
|
+
className: "w-max max-w-80 min-w-40 shrink-0 border-r border-border",
|
|
3853
3902
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3854
3903
|
className: "h-8 border-b border-border",
|
|
3855
3904
|
"aria-hidden": true
|
|
3856
3905
|
}), lanes.map((l) => /* @__PURE__ */ jsxs("div", {
|
|
3857
|
-
className: "flex h-(--
|
|
3906
|
+
className: "flex h-(--lane-h) items-center gap-1 border-b border-border px-2 type-label",
|
|
3858
3907
|
children: [/* @__PURE__ */ jsx("span", {
|
|
3859
3908
|
className: "min-w-0 flex-1 truncate",
|
|
3860
3909
|
title: l.label,
|
|
@@ -3919,12 +3968,21 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3919
3968
|
className: "p-4",
|
|
3920
3969
|
children: empty
|
|
3921
3970
|
}),
|
|
3922
|
-
lanes.map((l) => /* @__PURE__ */
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
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) => {
|
|
3928
3986
|
const live = drag?.id === item.id && drag.moved ? drag : null;
|
|
3929
3987
|
const shown = live ? live.next : item;
|
|
3930
3988
|
const laneShift = live ? (laneIndex.get(live.next.lane) ?? 0) - (laneIndex.get(item.lane) ?? 0) : 0;
|
|
@@ -3946,8 +4004,8 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3946
4004
|
style: {
|
|
3947
4005
|
left: px,
|
|
3948
4006
|
width: w,
|
|
3949
|
-
borderTopColor: item.kind ? kindColour(item.kind, items) : void 0,
|
|
3950
|
-
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,
|
|
3951
4009
|
zIndex: live ? 10 : void 0
|
|
3952
4010
|
},
|
|
3953
4011
|
children: [
|
|
@@ -3976,36 +4034,45 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
3976
4034
|
})
|
|
3977
4035
|
]
|
|
3978
4036
|
}, item.id);
|
|
3979
|
-
})
|
|
4037
|
+
})]
|
|
3980
4038
|
}, l.id)),
|
|
3981
4039
|
position !== void 0 && /* @__PURE__ */ jsx("div", {
|
|
3982
4040
|
"aria-hidden": true,
|
|
3983
4041
|
className: "pointer-events-none absolute top-8 bottom-0 w-0.5 bg-primary",
|
|
3984
4042
|
style: { left: x(position) - 1 }
|
|
3985
4043
|
}),
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
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
|
+
})()
|
|
3991
4052
|
]
|
|
3992
4053
|
})
|
|
3993
4054
|
})]
|
|
3994
4055
|
}),
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
"
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
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
|
+
})()
|
|
4009
4076
|
]
|
|
4010
4077
|
});
|
|
4011
4078
|
}
|
|
@@ -4025,6 +4092,32 @@ function DefaultItem({ item, width }) {
|
|
|
4025
4092
|
})]
|
|
4026
4093
|
});
|
|
4027
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
|
+
}
|
|
4028
4121
|
// src/components/sortable-list.tsx
|
|
4029
4122
|
var KIND = "strata-kind/";
|
|
4030
4123
|
var ID = "strata-item/id";
|
|
@@ -4267,30 +4360,38 @@ function FileOutcomes({ intake, className }) {
|
|
|
4267
4360
|
})]
|
|
4268
4361
|
});
|
|
4269
4362
|
}
|
|
4270
|
-
/**
|
|
4271
|
-
|
|
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 }) {
|
|
4272
4368
|
return /* @__PURE__ */ jsxs("div", {
|
|
4273
4369
|
className: cn("flex min-w-0 items-center gap-3", className),
|
|
4274
|
-
children: [
|
|
4275
|
-
|
|
4276
|
-
|
|
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",
|
|
4277
4377
|
title: name,
|
|
4278
4378
|
children: name
|
|
4279
|
-
}),
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
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
|
+
})]
|
|
4294
4395
|
});
|
|
4295
4396
|
}
|
|
4296
4397
|
// src/lib/file-intake.ts
|
|
@@ -5059,7 +5160,7 @@ function fitTicks(ticks, scale, widthOf, gap = 12) {
|
|
|
5059
5160
|
return sorted.slice(0, 1);
|
|
5060
5161
|
}
|
|
5061
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`. */
|
|
5062
|
-
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 }) {
|
|
5063
5164
|
const [ref, width] = useWidth();
|
|
5064
5165
|
const gradientId = `heat-${React.useId().replace(/[^\w-]/g, "")}`;
|
|
5065
5166
|
const all = [...series, ...planned ?? []];
|
|
@@ -5220,7 +5321,7 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5220
5321
|
/* @__PURE__ */ jsx("caption", { children: label }),
|
|
5221
5322
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
5222
5323
|
scope: "col",
|
|
5223
|
-
children:
|
|
5324
|
+
children: xLabel
|
|
5224
5325
|
}), /* @__PURE__ */ jsx("th", {
|
|
5225
5326
|
scope: "col",
|
|
5226
5327
|
children: seriesLabel
|
|
@@ -5232,7 +5333,8 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5232
5333
|
seriesLabel,
|
|
5233
5334
|
series,
|
|
5234
5335
|
formatX,
|
|
5235
|
-
formatY
|
|
5336
|
+
formatY,
|
|
5337
|
+
xLabel
|
|
5236
5338
|
]);
|
|
5237
5339
|
const sorted = React.useMemo(() => [...series].sort((p, q) => p.x - q.x), [series]);
|
|
5238
5340
|
const interactive = Boolean(readout || onPick);
|
|
@@ -7054,6 +7156,311 @@ function CompareGrid({ label, items, blind, missing, actions, columns = 3, keys
|
|
|
7054
7156
|
})
|
|
7055
7157
|
});
|
|
7056
7158
|
}
|
|
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
|
+
}
|
|
7057
7464
|
// src/components/history.tsx
|
|
7058
7465
|
var compose = (older, newer) => ({
|
|
7059
7466
|
label: older.label,
|
|
@@ -7396,6 +7803,6 @@ function SaveStatus({ state, onRetry, className }) {
|
|
|
7396
7803
|
]
|
|
7397
7804
|
});
|
|
7398
7805
|
}
|
|
7399
|
-
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, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, 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, 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, zoomAt };
|
|
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 };
|
|
7400
7807
|
|
|
7401
7808
|
//# sourceMappingURL=index.js.map
|