reifyui 0.8.0 → 0.9.0
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/dist/index.cjs +317 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +74 -0
- package/dist/index.js +317 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.d.ts +74 -0
- package/src/index.js +8 -0
- package/src/timeline/Timeline.jsx +300 -0
- package/styles/chat.css +19 -2
- package/styles/timeline.css +134 -0
package/dist/index.d.ts
CHANGED
|
@@ -664,3 +664,77 @@ export const PanelGrid: ComponentType<PanelGridProps>;
|
|
|
664
664
|
/** Gravity applied to a layout you built yourself. Add a panel with `y: Infinity` to put it at
|
|
665
665
|
* the bottom, then pass the array through this to turn that into a real row. */
|
|
666
666
|
export function packLayout(layout: PanelLayoutItem[], cols?: number): PanelLayoutItem[];
|
|
667
|
+
|
|
668
|
+
/* ── Timeline ─────────────────────────────────────────────────────────────── */
|
|
669
|
+
|
|
670
|
+
export interface TimelineClip {
|
|
671
|
+
id?: string;
|
|
672
|
+
/** Seconds from the start of the lane. Ignored when the track is sequential (the default),
|
|
673
|
+
* where each clip begins where the previous one ended. */
|
|
674
|
+
start?: number;
|
|
675
|
+
/** Seconds. Omit or pass null when it has not been MEASURED yet: the clip is then drawn at a
|
|
676
|
+
* fixed placeholder width with a hatched fill, and carries no duration label. Never pass a
|
|
677
|
+
* guess — a width is a measurement here, and one invented width makes the ruler unreadable. */
|
|
678
|
+
duration?: number | null;
|
|
679
|
+
label?: string;
|
|
680
|
+
/** Tooltip. Falls back to `label`. */
|
|
681
|
+
title?: string;
|
|
682
|
+
/** Artwork filling the block — a poster frame, a waveform. */
|
|
683
|
+
poster?: string;
|
|
684
|
+
/** Shown centred when there is no poster. */
|
|
685
|
+
glyph?: ReactNode;
|
|
686
|
+
/** Small pill at the top left, e.g. an index. */
|
|
687
|
+
badge?: ReactNode;
|
|
688
|
+
/** 'failed' tints the block; any other value is yours to style as `.rui-tl-clip.is-<state>`. */
|
|
689
|
+
state?: string;
|
|
690
|
+
/** Border colour for this clip, as a CSS colour. */
|
|
691
|
+
accent?: string;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
export interface TimelineTrack {
|
|
695
|
+
id: string;
|
|
696
|
+
label: string;
|
|
697
|
+
icon?: ReactNode;
|
|
698
|
+
clips?: TimelineClip[];
|
|
699
|
+
/** Default true: clips run back to back and `start` is ignored. False places each clip at its
|
|
700
|
+
* own `start`, for a lane that is a set of placed items rather than a sequence. */
|
|
701
|
+
sequential?: boolean;
|
|
702
|
+
/** Shown in the lane when it has no clips. Omit to leave the lane blank. */
|
|
703
|
+
emptyLabel?: string;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
export interface TimelineProps {
|
|
707
|
+
tracks?: TimelineTrack[];
|
|
708
|
+
/** Seconds. Draws the playhead. */
|
|
709
|
+
currentTime?: number;
|
|
710
|
+
/** Scrubbing the ruler or a lane's background calls this with a time in seconds. Omit and the
|
|
711
|
+
* timeline is read-only: no scrub target, no slider role. */
|
|
712
|
+
onSeek?: (seconds: number) => void;
|
|
713
|
+
onSelectClip?: (clip: TimelineClip, index: number) => void;
|
|
714
|
+
selectedClipId?: string | null;
|
|
715
|
+
/** Controls revealed on a clip on hover or focus. */
|
|
716
|
+
clipActions?: (clip: TimelineClip, index: number) => ReactNode;
|
|
717
|
+
/** Rendered just past the last clip of a lane — an add button, usually. */
|
|
718
|
+
laneAppend?: (track: TimelineTrack) => ReactNode;
|
|
719
|
+
/** localStorage key for the zoom level, so it survives a reload. */
|
|
720
|
+
zoomStorageKey?: string | null;
|
|
721
|
+
emptyLabel?: string;
|
|
722
|
+
className?: string;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/** Lanes of clips against a ruler, with a playhead and pointer-anchored zoom (Cmd/Ctrl+wheel,
|
|
726
|
+
* +/−, the buttons). One number — pixels per second — converts time to x for the ruler, the
|
|
727
|
+
* clips and the playhead alike, so they cannot disagree. Needs styles/timeline.css. */
|
|
728
|
+
export const Timeline: ComponentType<TimelineProps>;
|
|
729
|
+
|
|
730
|
+
/** The smallest tick step whose labels stay ~64px apart at this zoom. */
|
|
731
|
+
export function majorTickStep(pps: number): number;
|
|
732
|
+
/** A ruler label: m:ss, with tenths only when the step is sub-second. */
|
|
733
|
+
export function tickLabel(t: number, step?: number): string;
|
|
734
|
+
/** m:ss, and '' for anything unmeasured — never '0:00' for an unknown. */
|
|
735
|
+
export function timelineDurationLabel(seconds: number): string;
|
|
736
|
+
|
|
737
|
+
export const TL_MIN_PPS: number;
|
|
738
|
+
export const TL_MAX_PPS: number;
|
|
739
|
+
export const TL_DEFAULT_PPS: number;
|
|
740
|
+
export const TL_HEAD_W: number;
|
package/dist/index.js
CHANGED
|
@@ -1182,7 +1182,7 @@ function useResizablePane(opts = {}) {
|
|
|
1182
1182
|
storageKey = null
|
|
1183
1183
|
// persist the chosen width per user (localStorage)
|
|
1184
1184
|
} = opts;
|
|
1185
|
-
const
|
|
1185
|
+
const clamp2 = useCallback2((x) => {
|
|
1186
1186
|
let hi = max ?? Infinity;
|
|
1187
1187
|
if (maxFraction && typeof window !== "undefined") hi = Math.min(hi, Math.round(window.innerWidth * maxFraction));
|
|
1188
1188
|
return Math.min(hi, Math.max(min, x));
|
|
@@ -1191,7 +1191,7 @@ function useResizablePane(opts = {}) {
|
|
|
1191
1191
|
if (storageKey && typeof window !== "undefined") {
|
|
1192
1192
|
try {
|
|
1193
1193
|
const n = parseInt(window.localStorage.getItem(storageKey) || "", 10);
|
|
1194
|
-
if (Number.isFinite(n)) return
|
|
1194
|
+
if (Number.isFinite(n)) return clamp2(n);
|
|
1195
1195
|
} catch {
|
|
1196
1196
|
}
|
|
1197
1197
|
}
|
|
@@ -1210,7 +1210,7 @@ function useResizablePane(opts = {}) {
|
|
|
1210
1210
|
e.preventDefault();
|
|
1211
1211
|
const sx = e.clientX, base = widthRef.current, dir = fromRight ? -1 : 1;
|
|
1212
1212
|
document.body.classList.add("uic-resizing");
|
|
1213
|
-
const move = (ev) => setWidth(
|
|
1213
|
+
const move = (ev) => setWidth(clamp2(base + dir * (ev.clientX - sx)));
|
|
1214
1214
|
const up = () => {
|
|
1215
1215
|
window.removeEventListener("mousemove", move);
|
|
1216
1216
|
window.removeEventListener("mouseup", up);
|
|
@@ -1221,7 +1221,7 @@ function useResizablePane(opts = {}) {
|
|
|
1221
1221
|
window.addEventListener("mousemove", move);
|
|
1222
1222
|
window.addEventListener("mouseup", up);
|
|
1223
1223
|
document.body.style.cursor = "col-resize";
|
|
1224
|
-
}, [
|
|
1224
|
+
}, [clamp2, fromRight, persist]);
|
|
1225
1225
|
const reset = useCallback2(() => {
|
|
1226
1226
|
setWidth(initial);
|
|
1227
1227
|
if (storageKey) {
|
|
@@ -3630,8 +3630,8 @@ function Panel(props) {
|
|
|
3630
3630
|
import React14, { useCallback as useCallback8, useEffect as useEffect15, useLayoutEffect, useMemo as useMemo3, useRef as useRef11, useState as useState14 } from "react";
|
|
3631
3631
|
|
|
3632
3632
|
// src/grid/layout.js
|
|
3633
|
-
function sortLayout(
|
|
3634
|
-
return [...
|
|
3633
|
+
function sortLayout(layout2) {
|
|
3634
|
+
return [...layout2].sort((a, b) => a.y - b.y || a.x - b.x);
|
|
3635
3635
|
}
|
|
3636
3636
|
function overlaps(a, b) {
|
|
3637
3637
|
return a.i !== b.i && a.x < b.x + b.w && a.x + a.w > b.x && a.y < b.y + b.h && a.y + a.h > b.y;
|
|
@@ -3648,8 +3648,8 @@ function clampItem(item, cols) {
|
|
|
3648
3648
|
const x = Math.min(Math.max(item.x ?? 0, 0), cols - w);
|
|
3649
3649
|
return { ...item, x, y: Math.max(0, item.y ?? 0), w, h };
|
|
3650
3650
|
}
|
|
3651
|
-
function compact(
|
|
3652
|
-
const sorted =
|
|
3651
|
+
function compact(layout2, cols, pinned) {
|
|
3652
|
+
const sorted = layout2.map((it) => clampItem(it, cols)).sort((a, b) => a.y - b.y || Number(b.i === pinned) - Number(a.i === pinned) || a.x - b.x);
|
|
3653
3653
|
const statics = sorted.filter((it) => it.static);
|
|
3654
3654
|
const rest = sorted.filter((it) => !it.static);
|
|
3655
3655
|
const placed = [...statics];
|
|
@@ -3661,34 +3661,34 @@ function compact(layout, cols, pinned) {
|
|
|
3661
3661
|
placed.push({ ...item, y });
|
|
3662
3662
|
}
|
|
3663
3663
|
const byId = new Map(placed.map((it) => [it.i, it]));
|
|
3664
|
-
return
|
|
3664
|
+
return layout2.map((it) => byId.get(it.i) || it);
|
|
3665
3665
|
}
|
|
3666
|
-
function moveItem(
|
|
3667
|
-
const next =
|
|
3666
|
+
function moveItem(layout2, id, x, y, cols) {
|
|
3667
|
+
const next = layout2.map((it) => it.i === id && !it.static ? clampItem({ ...it, x, y: Math.max(0, y) }, cols) : it);
|
|
3668
3668
|
return compact(next, cols, id);
|
|
3669
3669
|
}
|
|
3670
|
-
function nudgeItem(
|
|
3671
|
-
const item =
|
|
3672
|
-
if (!item || item.static) return
|
|
3673
|
-
if (dx) return moveItem(
|
|
3674
|
-
const sameCols =
|
|
3670
|
+
function nudgeItem(layout2, id, dx, dy, cols) {
|
|
3671
|
+
const item = layout2.find((it) => it.i === id);
|
|
3672
|
+
if (!item || item.static) return layout2;
|
|
3673
|
+
if (dx) return moveItem(layout2, id, item.x + dx, item.y, cols);
|
|
3674
|
+
const sameCols = layout2.filter((o) => o.i !== id && o.x < item.x + item.w && o.x + o.w > item.x);
|
|
3675
3675
|
if (dy < 0) {
|
|
3676
3676
|
const above = sameCols.filter((o) => o.y + o.h <= item.y);
|
|
3677
|
-
if (!above.length) return
|
|
3677
|
+
if (!above.length) return layout2;
|
|
3678
3678
|
const near2 = above.reduce((a, b) => a.y + a.h > b.y + b.h ? a : b);
|
|
3679
|
-
return moveItem(
|
|
3679
|
+
return moveItem(layout2, id, item.x, near2.y, cols);
|
|
3680
3680
|
}
|
|
3681
3681
|
const below = sameCols.filter((o) => o.y >= item.y + item.h);
|
|
3682
|
-
if (!below.length) return
|
|
3682
|
+
if (!below.length) return layout2;
|
|
3683
3683
|
const near = below.reduce((a, b) => a.y < b.y ? a : b);
|
|
3684
|
-
return moveItem(
|
|
3684
|
+
return moveItem(layout2, id, item.x, near.y + near.h, cols);
|
|
3685
3685
|
}
|
|
3686
|
-
function resizeItem(
|
|
3687
|
-
const next =
|
|
3686
|
+
function resizeItem(layout2, id, w, h, cols) {
|
|
3687
|
+
const next = layout2.map((it) => it.i === id && !it.static ? clampItem({ ...it, w, h }, cols) : it);
|
|
3688
3688
|
return compact(next, cols, id);
|
|
3689
3689
|
}
|
|
3690
|
-
function layoutRows(
|
|
3691
|
-
return
|
|
3690
|
+
function layoutRows(layout2) {
|
|
3691
|
+
return layout2.reduce((n, it) => Math.max(n, (it.y || 0) + (it.h || 1)), 0);
|
|
3692
3692
|
}
|
|
3693
3693
|
function sameLayout(a, b) {
|
|
3694
3694
|
if (a.length !== b.length) return false;
|
|
@@ -3718,7 +3718,7 @@ function useMeasuredWidth() {
|
|
|
3718
3718
|
var NO_DRAG = "button, a, input, select, textarea, [data-uic-nodrag]";
|
|
3719
3719
|
function PanelGrid(props) {
|
|
3720
3720
|
const {
|
|
3721
|
-
layout = [],
|
|
3721
|
+
layout: layout2 = [],
|
|
3722
3722
|
children,
|
|
3723
3723
|
cols = 12,
|
|
3724
3724
|
rowHeight = 40,
|
|
@@ -3736,7 +3736,7 @@ function PanelGrid(props) {
|
|
|
3736
3736
|
const swallowClick = useRef11(false);
|
|
3737
3737
|
const stacked = width > 0 && width < stackAt;
|
|
3738
3738
|
const arrangeable = editable && !stacked;
|
|
3739
|
-
const live = drag ? drag.preview :
|
|
3739
|
+
const live = drag ? drag.preview : layout2;
|
|
3740
3740
|
const colW = width > 0 ? (width - gap * (cols - 1)) / cols : 0;
|
|
3741
3741
|
const cellW = colW + gap;
|
|
3742
3742
|
const cellH = rowHeight + gap;
|
|
@@ -3754,18 +3754,18 @@ function PanelGrid(props) {
|
|
|
3754
3754
|
const rows = layoutRows(live);
|
|
3755
3755
|
const height = stacked ? stack2.height : rows ? rowsToPx(rows) : 0;
|
|
3756
3756
|
const commit = useCallback8((next) => {
|
|
3757
|
-
if (onLayoutChange && !sameLayout(next,
|
|
3758
|
-
}, [onLayoutChange,
|
|
3757
|
+
if (onLayoutChange && !sameLayout(next, layout2)) onLayoutChange(next);
|
|
3758
|
+
}, [onLayoutChange, layout2]);
|
|
3759
3759
|
const detach = useRef11(null);
|
|
3760
3760
|
useEffect15(() => () => detach.current?.(), []);
|
|
3761
3761
|
const start = (id, mode) => (e) => {
|
|
3762
3762
|
if (!arrangeable || e.button !== 0) return;
|
|
3763
|
-
const item =
|
|
3763
|
+
const item = layout2.find((it) => it.i === id);
|
|
3764
3764
|
if (!item || item.static) return;
|
|
3765
3765
|
if (mode === "move" && (!e.target.closest(dragHandle) || e.target.closest(NO_DRAG))) return;
|
|
3766
3766
|
e.preventDefault();
|
|
3767
3767
|
detach.current?.();
|
|
3768
|
-
const begin = { id, mode, origin: item, px: e.clientX, py: e.clientY, dx: 0, dy: 0, preview:
|
|
3768
|
+
const begin = { id, mode, origin: item, px: e.clientX, py: e.clientY, dx: 0, dy: 0, preview: layout2 };
|
|
3769
3769
|
dragRef.current = begin;
|
|
3770
3770
|
setDrag(begin);
|
|
3771
3771
|
const onMove = (ev) => {
|
|
@@ -3776,7 +3776,7 @@ function PanelGrid(props) {
|
|
|
3776
3776
|
if (Math.abs(dx) > 3 || Math.abs(dy) > 3) swallowClick.current = true;
|
|
3777
3777
|
const cx = Math.round(dx / cellW);
|
|
3778
3778
|
const cy = Math.round(dy / cellH);
|
|
3779
|
-
const preview = d.mode === "move" ? moveItem(
|
|
3779
|
+
const preview = d.mode === "move" ? moveItem(layout2, d.id, d.origin.x + cx, d.origin.y + cy, cols) : resizeItem(layout2, d.id, d.origin.w + cx, d.origin.h + cy, cols);
|
|
3780
3780
|
dragRef.current = { ...d, dx, dy, preview };
|
|
3781
3781
|
setDrag(dragRef.current);
|
|
3782
3782
|
};
|
|
@@ -3813,10 +3813,10 @@ function PanelGrid(props) {
|
|
|
3813
3813
|
const onHandleKey = (id) => (e) => {
|
|
3814
3814
|
const step = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[e.key];
|
|
3815
3815
|
if (!step) return;
|
|
3816
|
-
const item =
|
|
3816
|
+
const item = layout2.find((it) => it.i === id);
|
|
3817
3817
|
if (!item) return;
|
|
3818
3818
|
e.preventDefault();
|
|
3819
|
-
commit(e.shiftKey ? nudgeItem(
|
|
3819
|
+
commit(e.shiftKey ? nudgeItem(layout2, id, step[0], step[1], cols) : resizeItem(layout2, id, item.w + step[0], item.h + step[1], cols));
|
|
3820
3820
|
};
|
|
3821
3821
|
const boxOf = (it) => stacked ? { left: 0, top: stack2.tops.get(it.i), width, height: rowsToPx(it.h || 1) } : { left: it.x * cellW, top: it.y * cellH, width: it.w * colW + (it.w - 1) * gap, height: rowsToPx(it.h) };
|
|
3822
3822
|
const byId = new Map(live.map((it) => [it.i, it]));
|
|
@@ -3868,9 +3868,282 @@ function PanelGrid(props) {
|
|
|
3868
3868
|
}
|
|
3869
3869
|
);
|
|
3870
3870
|
}
|
|
3871
|
-
function packLayout(
|
|
3872
|
-
const bottom = layoutRows(
|
|
3873
|
-
return compact(
|
|
3871
|
+
function packLayout(layout2, cols = 12) {
|
|
3872
|
+
const bottom = layoutRows(layout2.filter((it) => Number.isFinite(it.y)));
|
|
3873
|
+
return compact(layout2.map((it) => Number.isFinite(it.y) ? it : { ...it, y: bottom }), cols);
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
// src/timeline/Timeline.jsx
|
|
3877
|
+
import { useCallback as useCallback9, useEffect as useEffect16, useLayoutEffect as useLayoutEffect2, useMemo as useMemo4, useRef as useRef12, useState as useState15 } from "react";
|
|
3878
|
+
import { jsx as jsx25, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3879
|
+
var TL_MIN_PPS = 4;
|
|
3880
|
+
var TL_MAX_PPS = 240;
|
|
3881
|
+
var TL_DEFAULT_PPS = 26;
|
|
3882
|
+
var TL_HEAD_W = 76;
|
|
3883
|
+
var UNKNOWN_W = 46;
|
|
3884
|
+
var MIN_CLIP_W = 26;
|
|
3885
|
+
var LANE_H = 48;
|
|
3886
|
+
var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
3887
|
+
var TICK_STEPS = [0.1, 0.2, 0.5, 1, 2, 5, 10, 15, 30, 60, 120, 300, 600];
|
|
3888
|
+
function majorTickStep(pps) {
|
|
3889
|
+
for (const s of TICK_STEPS) if (s * pps >= 64) return s;
|
|
3890
|
+
return TICK_STEPS[TICK_STEPS.length - 1];
|
|
3891
|
+
}
|
|
3892
|
+
function tickLabel(t, step = 1) {
|
|
3893
|
+
const m = Math.floor(t / 60);
|
|
3894
|
+
const s = t - m * 60;
|
|
3895
|
+
const whole = Math.floor(s + 1e-6);
|
|
3896
|
+
const base = `${m}:${String(whole).padStart(2, "0")}`;
|
|
3897
|
+
if (step >= 1) return base;
|
|
3898
|
+
const frac = Math.round((s - whole) * 10);
|
|
3899
|
+
return frac > 0 ? `${base}.${frac}` : base;
|
|
3900
|
+
}
|
|
3901
|
+
function durationLabel(seconds) {
|
|
3902
|
+
if (!Number.isFinite(seconds) || seconds < 0) return "";
|
|
3903
|
+
const m = Math.floor(seconds / 60);
|
|
3904
|
+
const s = Math.round(seconds - m * 60);
|
|
3905
|
+
return `${m}:${String(s).padStart(2, "0")}`;
|
|
3906
|
+
}
|
|
3907
|
+
function layout(clips, pps, sequential) {
|
|
3908
|
+
let cursor = 0;
|
|
3909
|
+
return clips.map((c) => {
|
|
3910
|
+
const known = Number.isFinite(c.duration);
|
|
3911
|
+
const w = known ? Math.max(MIN_CLIP_W, c.duration * pps) : UNKNOWN_W;
|
|
3912
|
+
const x = sequential ? cursor * pps : (c.start || 0) * pps;
|
|
3913
|
+
if (sequential) cursor += known ? c.duration : UNKNOWN_W / pps;
|
|
3914
|
+
return { clip: c, x, w, known };
|
|
3915
|
+
});
|
|
3916
|
+
}
|
|
3917
|
+
function Timeline({
|
|
3918
|
+
tracks = [],
|
|
3919
|
+
/** Seconds. Drives the playhead; pass it from whatever is playing. */
|
|
3920
|
+
currentTime = 0,
|
|
3921
|
+
/** Called with a time in seconds when the ruler or lane background is scrubbed. */
|
|
3922
|
+
onSeek,
|
|
3923
|
+
onSelectClip,
|
|
3924
|
+
selectedClipId = null,
|
|
3925
|
+
/** Rendered at the right of each clip on hover — e.g. remove, reorder. (clip, index) => node */
|
|
3926
|
+
clipActions,
|
|
3927
|
+
/** Rendered after the last clip of a lane, e.g. an add button. (track) => node */
|
|
3928
|
+
laneAppend,
|
|
3929
|
+
zoomStorageKey = null,
|
|
3930
|
+
emptyLabel = "Nothing here yet.",
|
|
3931
|
+
className = ""
|
|
3932
|
+
}) {
|
|
3933
|
+
const scroller = useRef12(null);
|
|
3934
|
+
const [pps, setPps] = useState15(() => {
|
|
3935
|
+
if (zoomStorageKey && typeof window !== "undefined") {
|
|
3936
|
+
const n = parseFloat(window.localStorage.getItem(zoomStorageKey) || "");
|
|
3937
|
+
if (Number.isFinite(n)) return clamp(n, TL_MIN_PPS, TL_MAX_PPS);
|
|
3938
|
+
}
|
|
3939
|
+
return TL_DEFAULT_PPS;
|
|
3940
|
+
});
|
|
3941
|
+
const anchor = useRef12(null);
|
|
3942
|
+
const rows = useMemo4(
|
|
3943
|
+
() => tracks.map((t) => ({ ...t, laid: layout(t.clips || [], pps, t.sequential !== false) })),
|
|
3944
|
+
[tracks, pps]
|
|
3945
|
+
);
|
|
3946
|
+
const contentSeconds = useMemo4(() => {
|
|
3947
|
+
let end = 0;
|
|
3948
|
+
for (const t of rows) {
|
|
3949
|
+
for (const { clip, x, w } of t.laid) {
|
|
3950
|
+
void clip;
|
|
3951
|
+
end = Math.max(end, (x + w) / pps);
|
|
3952
|
+
}
|
|
3953
|
+
}
|
|
3954
|
+
return end;
|
|
3955
|
+
}, [rows, pps]);
|
|
3956
|
+
const setZoom = useCallback9((next, clientX) => {
|
|
3957
|
+
const v = clamp(next, TL_MIN_PPS, TL_MAX_PPS);
|
|
3958
|
+
const el = scroller.current;
|
|
3959
|
+
if (el) {
|
|
3960
|
+
const rect = el.getBoundingClientRect();
|
|
3961
|
+
const vx = clientX === void 0 ? (rect.width + TL_HEAD_W) / 2 : clientX - rect.left;
|
|
3962
|
+
anchor.current = { t: Math.max(0, (el.scrollLeft + vx - TL_HEAD_W) / pps), vx };
|
|
3963
|
+
}
|
|
3964
|
+
setPps(v);
|
|
3965
|
+
if (zoomStorageKey && typeof window !== "undefined") {
|
|
3966
|
+
try {
|
|
3967
|
+
window.localStorage.setItem(zoomStorageKey, String(v));
|
|
3968
|
+
} catch {
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
}, [pps, zoomStorageKey]);
|
|
3972
|
+
useLayoutEffect2(() => {
|
|
3973
|
+
const a = anchor.current;
|
|
3974
|
+
if (!a || !scroller.current) return;
|
|
3975
|
+
anchor.current = null;
|
|
3976
|
+
scroller.current.scrollLeft = Math.max(0, TL_HEAD_W + a.t * pps - a.vx);
|
|
3977
|
+
}, [pps]);
|
|
3978
|
+
useEffect16(() => {
|
|
3979
|
+
const el = scroller.current;
|
|
3980
|
+
if (!el) return void 0;
|
|
3981
|
+
const onWheel = (e) => {
|
|
3982
|
+
if (!(e.ctrlKey || e.metaKey)) return;
|
|
3983
|
+
e.preventDefault();
|
|
3984
|
+
setZoom(pps * Math.exp(-e.deltaY * 22e-4), e.clientX);
|
|
3985
|
+
};
|
|
3986
|
+
el.addEventListener("wheel", onWheel, { passive: false });
|
|
3987
|
+
return () => el.removeEventListener("wheel", onWheel);
|
|
3988
|
+
}, [pps, setZoom]);
|
|
3989
|
+
const timeAt = useCallback9((clientX) => {
|
|
3990
|
+
const el = scroller.current;
|
|
3991
|
+
if (!el) return 0;
|
|
3992
|
+
const rect = el.getBoundingClientRect();
|
|
3993
|
+
return Math.max(0, (el.scrollLeft + (clientX - rect.left) - TL_HEAD_W) / pps);
|
|
3994
|
+
}, [pps]);
|
|
3995
|
+
const onScrub = useCallback9((e) => {
|
|
3996
|
+
if (!onSeek) return;
|
|
3997
|
+
e.currentTarget.setPointerCapture?.(e.pointerId);
|
|
3998
|
+
onSeek(timeAt(e.clientX));
|
|
3999
|
+
const move = (ev) => onSeek(timeAt(ev.clientX));
|
|
4000
|
+
const up = () => {
|
|
4001
|
+
window.removeEventListener("pointermove", move);
|
|
4002
|
+
window.removeEventListener("pointerup", up);
|
|
4003
|
+
};
|
|
4004
|
+
window.addEventListener("pointermove", move);
|
|
4005
|
+
window.addEventListener("pointerup", up);
|
|
4006
|
+
}, [onSeek, timeAt]);
|
|
4007
|
+
const onKeyDown = useCallback9((e) => {
|
|
4008
|
+
if (e.key === "+" || e.key === "=") {
|
|
4009
|
+
e.preventDefault();
|
|
4010
|
+
setZoom(pps * 1.35);
|
|
4011
|
+
}
|
|
4012
|
+
if (e.key === "-" || e.key === "_") {
|
|
4013
|
+
e.preventDefault();
|
|
4014
|
+
setZoom(pps / 1.35);
|
|
4015
|
+
}
|
|
4016
|
+
}, [pps, setZoom]);
|
|
4017
|
+
const major = majorTickStep(pps);
|
|
4018
|
+
const minor = major / 5;
|
|
4019
|
+
const laneW = Math.max(contentSeconds * pps + 120, 240);
|
|
4020
|
+
const ticks = [];
|
|
4021
|
+
for (let t = 0; t <= contentSeconds + major; t += major) ticks.push(t);
|
|
4022
|
+
return /* @__PURE__ */ jsxs22("div", { className: `rui-tl ${className}`, onKeyDown, tabIndex: -1, children: [
|
|
4023
|
+
/* @__PURE__ */ jsx25("div", { className: "rui-tl-scroll", ref: scroller, children: /* @__PURE__ */ jsxs22("div", { className: "rui-tl-inner", style: { width: TL_HEAD_W + laneW }, children: [
|
|
4024
|
+
/* @__PURE__ */ jsxs22("div", { className: "rui-tl-row rui-tl-rulerrow", children: [
|
|
4025
|
+
/* @__PURE__ */ jsx25("div", { className: "rui-tl-head rui-tl-rulerhead", "aria-hidden": "true" }),
|
|
4026
|
+
/* @__PURE__ */ jsx25(
|
|
4027
|
+
"div",
|
|
4028
|
+
{
|
|
4029
|
+
className: "rui-tl-ruler",
|
|
4030
|
+
style: {
|
|
4031
|
+
width: laneW,
|
|
4032
|
+
// Minor ticks are a repeating background rather than elements: at 600 s and a
|
|
4033
|
+
// fine zoom that is thousands of nodes, and they carry no information a stripe
|
|
4034
|
+
// does not.
|
|
4035
|
+
backgroundImage: "linear-gradient(90deg, var(--uic-line, #DDDFE6) 0 1px, transparent 1px),linear-gradient(90deg, var(--uic-line-soft, #EFF1F4) 0 1px, transparent 1px)",
|
|
4036
|
+
backgroundSize: `${major * pps}px 9px, ${minor * pps}px 5px`
|
|
4037
|
+
},
|
|
4038
|
+
onPointerDown: onScrub,
|
|
4039
|
+
role: onSeek ? "slider" : void 0,
|
|
4040
|
+
"aria-label": onSeek ? "Playhead" : void 0,
|
|
4041
|
+
"aria-valuemin": 0,
|
|
4042
|
+
"aria-valuemax": Math.round(contentSeconds),
|
|
4043
|
+
"aria-valuenow": Math.round(currentTime),
|
|
4044
|
+
tabIndex: onSeek ? 0 : void 0,
|
|
4045
|
+
onKeyDown: onSeek ? (e) => {
|
|
4046
|
+
const step = e.shiftKey ? 5 : 1;
|
|
4047
|
+
if (e.key === "ArrowLeft") {
|
|
4048
|
+
e.preventDefault();
|
|
4049
|
+
onSeek(Math.max(0, currentTime - step));
|
|
4050
|
+
}
|
|
4051
|
+
if (e.key === "ArrowRight") {
|
|
4052
|
+
e.preventDefault();
|
|
4053
|
+
onSeek(currentTime + step);
|
|
4054
|
+
}
|
|
4055
|
+
} : void 0,
|
|
4056
|
+
children: ticks.map((t) => /* @__PURE__ */ jsx25("span", { className: "rui-tl-ticklbl", style: { left: t * pps }, children: tickLabel(t, major) }, t))
|
|
4057
|
+
}
|
|
4058
|
+
)
|
|
4059
|
+
] }),
|
|
4060
|
+
rows.length === 0 && /* @__PURE__ */ jsx25("p", { className: "rui-tl-empty", children: emptyLabel }),
|
|
4061
|
+
rows.map((track) => /* @__PURE__ */ jsxs22("div", { className: "rui-tl-row", children: [
|
|
4062
|
+
/* @__PURE__ */ jsxs22("div", { className: "rui-tl-head", title: track.label, children: [
|
|
4063
|
+
track.icon,
|
|
4064
|
+
/* @__PURE__ */ jsx25("span", { className: "rui-tl-headlbl", children: track.label })
|
|
4065
|
+
] }),
|
|
4066
|
+
/* @__PURE__ */ jsxs22(
|
|
4067
|
+
"div",
|
|
4068
|
+
{
|
|
4069
|
+
className: "rui-tl-lane",
|
|
4070
|
+
style: { width: laneW, height: LANE_H },
|
|
4071
|
+
onPointerDown: (e) => {
|
|
4072
|
+
if (e.target === e.currentTarget) onScrub(e);
|
|
4073
|
+
},
|
|
4074
|
+
children: [
|
|
4075
|
+
track.laid.length === 0 && track.emptyLabel && /* @__PURE__ */ jsx25("p", { className: "rui-tl-laneempty", children: track.emptyLabel }),
|
|
4076
|
+
track.laid.map(({ clip, x, w, known }, i) => /* @__PURE__ */ jsxs22(
|
|
4077
|
+
"article",
|
|
4078
|
+
{
|
|
4079
|
+
className: "rui-tl-clip" + (clip.state ? ` is-${clip.state}` : "") + (known ? "" : " is-unmeasured") + (selectedClipId === clip.id ? " is-selected" : ""),
|
|
4080
|
+
style: { left: x, width: w, ...clip.accent ? { "--rui-tl-accent": clip.accent } : null },
|
|
4081
|
+
title: clip.title || clip.label,
|
|
4082
|
+
tabIndex: 0,
|
|
4083
|
+
onClick: () => onSelectClip?.(clip, i),
|
|
4084
|
+
onKeyDown: (e) => {
|
|
4085
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
4086
|
+
e.preventDefault();
|
|
4087
|
+
onSelectClip?.(clip, i);
|
|
4088
|
+
}
|
|
4089
|
+
},
|
|
4090
|
+
children: [
|
|
4091
|
+
clip.poster ? /* @__PURE__ */ jsx25("img", { className: "rui-tl-poster", src: clip.poster, alt: "", loading: "lazy" }) : /* @__PURE__ */ jsx25("span", { className: "rui-tl-blank", "aria-hidden": "true", children: clip.glyph }),
|
|
4092
|
+
clip.badge && /* @__PURE__ */ jsx25("span", { className: "rui-tl-badge", children: clip.badge }),
|
|
4093
|
+
known && w > 44 && /* @__PURE__ */ jsx25("span", { className: "rui-tl-dur", children: durationLabel(clip.duration) }),
|
|
4094
|
+
clip.label && w > 96 && /* @__PURE__ */ jsx25("span", { className: "rui-tl-name", children: clip.label }),
|
|
4095
|
+
clipActions && /* @__PURE__ */ jsx25("span", { className: "rui-tl-acts", children: clipActions(clip, i) })
|
|
4096
|
+
]
|
|
4097
|
+
},
|
|
4098
|
+
clip.id ?? i
|
|
4099
|
+
)),
|
|
4100
|
+
laneAppend && /* @__PURE__ */ jsx25(
|
|
4101
|
+
"span",
|
|
4102
|
+
{
|
|
4103
|
+
className: "rui-tl-append",
|
|
4104
|
+
style: { left: track.laid.reduce((n, l) => Math.max(n, l.x + l.w), 0) + 4 },
|
|
4105
|
+
children: laneAppend(track)
|
|
4106
|
+
}
|
|
4107
|
+
)
|
|
4108
|
+
]
|
|
4109
|
+
}
|
|
4110
|
+
)
|
|
4111
|
+
] }, track.id)),
|
|
4112
|
+
Number.isFinite(currentTime) && contentSeconds > 0 && /* @__PURE__ */ jsx25(
|
|
4113
|
+
"div",
|
|
4114
|
+
{
|
|
4115
|
+
className: "rui-tl-playhead",
|
|
4116
|
+
style: { left: TL_HEAD_W + currentTime * pps },
|
|
4117
|
+
"aria-hidden": "true",
|
|
4118
|
+
children: /* @__PURE__ */ jsx25("span", { className: "rui-tl-playhead-grip" })
|
|
4119
|
+
}
|
|
4120
|
+
)
|
|
4121
|
+
] }) }),
|
|
4122
|
+
/* @__PURE__ */ jsxs22("div", { className: "rui-tl-zoom", children: [
|
|
4123
|
+
/* @__PURE__ */ jsx25(
|
|
4124
|
+
"button",
|
|
4125
|
+
{
|
|
4126
|
+
type: "button",
|
|
4127
|
+
className: "rui-tl-zoombtn",
|
|
4128
|
+
"aria-label": "Zoom out",
|
|
4129
|
+
onClick: () => setZoom(pps / 1.35),
|
|
4130
|
+
disabled: pps <= TL_MIN_PPS + 1e-6,
|
|
4131
|
+
children: "\u2212"
|
|
4132
|
+
}
|
|
4133
|
+
),
|
|
4134
|
+
/* @__PURE__ */ jsx25(
|
|
4135
|
+
"button",
|
|
4136
|
+
{
|
|
4137
|
+
type: "button",
|
|
4138
|
+
className: "rui-tl-zoombtn",
|
|
4139
|
+
"aria-label": "Zoom in",
|
|
4140
|
+
onClick: () => setZoom(pps * 1.35),
|
|
4141
|
+
disabled: pps >= TL_MAX_PPS - 1e-6,
|
|
4142
|
+
children: "+"
|
|
4143
|
+
}
|
|
4144
|
+
)
|
|
4145
|
+
] })
|
|
4146
|
+
] });
|
|
3874
4147
|
}
|
|
3875
4148
|
export {
|
|
3876
4149
|
AssistantTurn,
|
|
@@ -3924,8 +4197,13 @@ export {
|
|
|
3924
4197
|
Select,
|
|
3925
4198
|
SheetGrid,
|
|
3926
4199
|
Svg,
|
|
4200
|
+
TL_DEFAULT_PPS,
|
|
4201
|
+
TL_HEAD_W,
|
|
4202
|
+
TL_MAX_PPS,
|
|
4203
|
+
TL_MIN_PPS,
|
|
3927
4204
|
TaskList,
|
|
3928
4205
|
Textarea,
|
|
4206
|
+
Timeline,
|
|
3929
4207
|
ToolGroup,
|
|
3930
4208
|
ToolRow,
|
|
3931
4209
|
UserTurn,
|
|
@@ -3950,6 +4228,7 @@ export {
|
|
|
3950
4228
|
isAuthed,
|
|
3951
4229
|
login,
|
|
3952
4230
|
logout,
|
|
4231
|
+
majorTickStep,
|
|
3953
4232
|
packLayout,
|
|
3954
4233
|
parseArgs,
|
|
3955
4234
|
prettyJson,
|
|
@@ -3963,6 +4242,8 @@ export {
|
|
|
3963
4242
|
summarizeSteps,
|
|
3964
4243
|
switchOrg,
|
|
3965
4244
|
taskStatusGroup,
|
|
4245
|
+
tickLabel,
|
|
4246
|
+
durationLabel as timelineDurationLabel,
|
|
3966
4247
|
toolMeta,
|
|
3967
4248
|
turnsToMessages,
|
|
3968
4249
|
useDialog,
|