reifyui 0.10.1 → 0.11.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 +74 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.js +74 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.d.ts +14 -0
- package/src/timeline/Timeline.jsx +87 -6
- package/styles/timeline.css +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reifyui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "The open-source rendering & interaction layer for agentic applications. Stream and render any agent's output as polished, application-native UI \u2014 model-agnostic, framework-agnostic, design-system-native. The foundation for building generative-UI and agent products.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
package/src/index.d.ts
CHANGED
|
@@ -691,6 +691,10 @@ export interface TimelineClip {
|
|
|
691
691
|
badge?: ReactNode;
|
|
692
692
|
/** 'failed' tints the block; any other value is yours to style as `.rui-tl-clip.is-<state>`. */
|
|
693
693
|
state?: string;
|
|
694
|
+
/** Seconds still available BEYOND the current window on each side — how far a trim may pull the
|
|
695
|
+
* edge back OUT. Without it an edge can only come in, and one stray drag makes a clip
|
|
696
|
+
* unrecoverable even though the film is still in the file. */
|
|
697
|
+
headroom?: { start?: number; end?: number };
|
|
694
698
|
/** Border colour for this clip, as a CSS colour. */
|
|
695
699
|
accent?: string;
|
|
696
700
|
}
|
|
@@ -720,6 +724,16 @@ export interface TimelineProps {
|
|
|
720
724
|
clipActions?: (clip: TimelineClip, index: number) => ReactNode;
|
|
721
725
|
/** Rendered just past the last clip of a lane — an add button, usually. */
|
|
722
726
|
laneAppend?: (track: TimelineTrack) => ReactNode;
|
|
727
|
+
/** Something was dropped. `trackId` is null when it landed on the new-lane strip, which is how
|
|
728
|
+
* a layer is created by dropping rather than by a button nobody finds. `index` is the slot in
|
|
729
|
+
* a sequential lane; `seconds` is where in time it landed. */
|
|
730
|
+
onDropClip?: (payload: unknown,
|
|
731
|
+
at: { trackId: string | null; seconds: number; index: number }) => void;
|
|
732
|
+
/** Reads a drag's payload out of a DataTransfer. Return null to refuse — that is what keeps a
|
|
733
|
+
* lane from lighting up for something this timeline cannot take. */
|
|
734
|
+
readDrop?: (dt: DataTransfer) => unknown | null;
|
|
735
|
+
/** Text on the new-lane strip. Omit and no strip is drawn. */
|
|
736
|
+
newLaneLabel?: string;
|
|
723
737
|
/** localStorage key for the zoom level, so it survives a reload. */
|
|
724
738
|
zoomStorageKey?: string | null;
|
|
725
739
|
emptyLabel?: string;
|
|
@@ -119,6 +119,15 @@ export function Timeline({
|
|
|
119
119
|
/** Sequential lane: (clip, toIndex, track). Placed lane: (clip, newStartSeconds, track). */
|
|
120
120
|
onMoveClip,
|
|
121
121
|
onDeleteClip,
|
|
122
|
+
/** Something was dropped on a lane: (payload, {trackId, seconds, index}). `trackId` is null when
|
|
123
|
+
* it landed on the NEW-LANE strip below the last lane, which is how a layer gets created by
|
|
124
|
+
* dropping rather than by a button nobody finds. */
|
|
125
|
+
onDropClip,
|
|
126
|
+
/** Reads the drag's payload out of a DataTransfer. Return null to refuse the drop, which is
|
|
127
|
+
* what turns the lane's highlight off for things this timeline cannot take. */
|
|
128
|
+
readDrop,
|
|
129
|
+
/** Text on the strip below the last lane. Omit and no such strip is drawn. */
|
|
130
|
+
newLaneLabel,
|
|
122
131
|
laneAppend,
|
|
123
132
|
zoomStorageKey = null,
|
|
124
133
|
snapStorageKey = null,
|
|
@@ -142,6 +151,9 @@ export function Timeline({
|
|
|
142
151
|
/** What the gesture is doing right now: live preview geometry + annotation. */
|
|
143
152
|
const [drag, setDrag] = useState(null);
|
|
144
153
|
const anchor = useRef(null);
|
|
154
|
+
/** Which lane the pointer is over during a drag, and where in time. Drawn as a marker so a drop
|
|
155
|
+
* lands where it was aimed rather than wherever the list decides. */
|
|
156
|
+
const [dropAt, setDropAt] = useState(null);
|
|
145
157
|
|
|
146
158
|
const rows = useMemo(
|
|
147
159
|
() => tracks.map((t) => ({ ...t, sequential: t.sequential !== false,
|
|
@@ -418,8 +430,33 @@ export function Timeline({
|
|
|
418
430
|
{track.icon}
|
|
419
431
|
<span className="rui-tl-headlbl">{track.label}</span>
|
|
420
432
|
</div>
|
|
421
|
-
<div
|
|
422
|
-
|
|
433
|
+
<div
|
|
434
|
+
className={'rui-tl-lane' + (dropAt?.trackId === track.id ? ' is-dropping' : '')}
|
|
435
|
+
style={{ width: laneW, height: LANE_H }}
|
|
436
|
+
onPointerDown={(e) => { if (e.target === e.currentTarget) onScrub(e); }}
|
|
437
|
+
onDragOver={onDropClip ? (e) => {
|
|
438
|
+
if (!readDrop || readDrop(e.dataTransfer) === null) return;
|
|
439
|
+
e.preventDefault(); // preventDefault IS the "yes, drop here"
|
|
440
|
+
e.dataTransfer.dropEffect = 'copy';
|
|
441
|
+
setDropAt({ trackId: track.id, t: timeAt(e.clientX) });
|
|
442
|
+
} : undefined}
|
|
443
|
+
onDragLeave={onDropClip ? (e) => {
|
|
444
|
+
if (e.currentTarget.contains(e.relatedTarget)) return;
|
|
445
|
+
setDropAt((d) => (d?.trackId === track.id ? null : d));
|
|
446
|
+
} : undefined}
|
|
447
|
+
onDrop={onDropClip ? (e) => {
|
|
448
|
+
const payload = readDrop?.(e.dataTransfer) ?? null;
|
|
449
|
+
setDropAt(null);
|
|
450
|
+
if (payload === null) return;
|
|
451
|
+
e.preventDefault();
|
|
452
|
+
const t = timeAt(e.clientX);
|
|
453
|
+
// Where in the ORDER it landed, for a lane that is a sequence.
|
|
454
|
+
let index = 0;
|
|
455
|
+
for (const other of track.laid) {
|
|
456
|
+
if (t > other.t0 + (other.w / pps) / 2) index += 1;
|
|
457
|
+
}
|
|
458
|
+
onDropClip(payload, { trackId: track.id, seconds: t, index });
|
|
459
|
+
} : undefined}>
|
|
423
460
|
{track.laid.length === 0 && track.emptyLabel && (
|
|
424
461
|
<p className="rui-tl-laneempty">{track.emptyLabel}</p>
|
|
425
462
|
)}
|
|
@@ -435,6 +472,10 @@ export function Timeline({
|
|
|
435
472
|
snapTimes={snapTimes}
|
|
436
473
|
/>
|
|
437
474
|
))}
|
|
475
|
+
{dropAt?.trackId === track.id && (
|
|
476
|
+
<span className="rui-tl-dropmark" style={{ left: dropAt.t * pps }}
|
|
477
|
+
aria-hidden="true" />
|
|
478
|
+
)}
|
|
438
479
|
{laneAppend && (
|
|
439
480
|
<span className="rui-tl-append"
|
|
440
481
|
style={{ left: track.laid.reduce((n, x) => Math.max(n, x.x + x.w), 0) + 6 }}>
|
|
@@ -445,6 +486,38 @@ export function Timeline({
|
|
|
445
486
|
</div>
|
|
446
487
|
))}
|
|
447
488
|
|
|
489
|
+
{/* Drop here and a lane is created. It only exists when a drop is possible at all, and
|
|
490
|
+
it says what it does — a bare dashed rectangle is a thing people avoid rather than
|
|
491
|
+
aim at. */}
|
|
492
|
+
{onDropClip && newLaneLabel && (
|
|
493
|
+
<div className="rui-tl-row">
|
|
494
|
+
<div className="rui-tl-head rui-tl-newhead" aria-hidden="true" />
|
|
495
|
+
<div
|
|
496
|
+
className={'rui-tl-newlane' + (dropAt?.trackId === null ? ' is-dropping' : '')}
|
|
497
|
+
style={{ width: laneW }}
|
|
498
|
+
onDragOver={(e) => {
|
|
499
|
+
if (!readDrop || readDrop(e.dataTransfer) === null) return;
|
|
500
|
+
e.preventDefault();
|
|
501
|
+
e.dataTransfer.dropEffect = 'copy';
|
|
502
|
+
setDropAt({ trackId: null, t: timeAt(e.clientX) });
|
|
503
|
+
}}
|
|
504
|
+
onDragLeave={(e) => {
|
|
505
|
+
if (e.currentTarget.contains(e.relatedTarget)) return;
|
|
506
|
+
setDropAt((d) => (d?.trackId === null ? null : d));
|
|
507
|
+
}}
|
|
508
|
+
onDrop={(e) => {
|
|
509
|
+
const payload = readDrop?.(e.dataTransfer) ?? null;
|
|
510
|
+
setDropAt(null);
|
|
511
|
+
if (payload === null) return;
|
|
512
|
+
e.preventDefault();
|
|
513
|
+
onDropClip(payload, { trackId: null, seconds: timeAt(e.clientX), index: 0 });
|
|
514
|
+
}}
|
|
515
|
+
>
|
|
516
|
+
<span className="rui-tl-newlbl">{newLaneLabel}</span>
|
|
517
|
+
</div>
|
|
518
|
+
</div>
|
|
519
|
+
)}
|
|
520
|
+
|
|
448
521
|
{/* A snap guide, drawn only while a gesture is actually locked onto something. */}
|
|
449
522
|
{drag?.guide != null && (
|
|
450
523
|
<div className="rui-tl-guide" style={{ left: TL_HEAD_W + drag.guide * pps }}
|
|
@@ -485,13 +558,21 @@ function Clip({ l, track, pps, selected, drag, onSelect, beginGesture, onTrim, o
|
|
|
485
558
|
|
|
486
559
|
const startTrim = (e, edge) => {
|
|
487
560
|
if (!onTrim || !known) return;
|
|
561
|
+
// HOW FAR THIS EDGE CAN GO BACK OUT, not just in. A trim clamped to the clip's CURRENT length
|
|
562
|
+
// can only ever shorten, so one stray drag makes a shot unrecoverable — the film is still in
|
|
563
|
+
// the file and the UI will not give it back. `headroom` is what the host says is left on each
|
|
564
|
+
// side beyond the present window; absent, the edge can only come in, which is the old
|
|
565
|
+
// behaviour and the honest default when nobody has said otherwise.
|
|
566
|
+
const room = clip.headroom || {};
|
|
567
|
+
const outward = Math.max(0, Number(edge === 'end' ? room.end : room.start) || 0);
|
|
568
|
+
const maxDur = clip.duration + outward;
|
|
488
569
|
beginGesture(e, {
|
|
489
570
|
kind: 'trim',
|
|
490
571
|
snapTimes,
|
|
491
572
|
preview: (t) => {
|
|
492
573
|
const dur = edge === 'end'
|
|
493
|
-
? clamp(t - t0, TL_MIN_CLIP_S,
|
|
494
|
-
: clamp((t0 + clip.duration) - t, TL_MIN_CLIP_S,
|
|
574
|
+
? clamp(t - t0, TL_MIN_CLIP_S, maxDur)
|
|
575
|
+
: clamp((t0 + clip.duration) - t, TL_MIN_CLIP_S, maxDur);
|
|
495
576
|
const nextW = dur * pps;
|
|
496
577
|
const nextLeft = edge === 'end' ? x : x + (w - nextW);
|
|
497
578
|
return { clipId: clip.id, width: nextW, left: nextLeft,
|
|
@@ -500,8 +581,8 @@ function Clip({ l, track, pps, selected, drag, onSelect, beginGesture, onTrim, o
|
|
|
500
581
|
},
|
|
501
582
|
commit: (t) => {
|
|
502
583
|
const dur = edge === 'end'
|
|
503
|
-
? clamp(t - t0, TL_MIN_CLIP_S,
|
|
504
|
-
: clamp((t0 + clip.duration) - t, TL_MIN_CLIP_S,
|
|
584
|
+
? clamp(t - t0, TL_MIN_CLIP_S, maxDur)
|
|
585
|
+
: clamp((t0 + clip.duration) - t, TL_MIN_CLIP_S, maxDur);
|
|
505
586
|
if (Math.abs(dur - clip.duration) > 1e-3) onTrim(clip, edge, dur, track);
|
|
506
587
|
},
|
|
507
588
|
});
|
package/styles/timeline.css
CHANGED
|
@@ -198,3 +198,27 @@ body.rui-tl-gesturing { cursor: ew-resize !important; user-select: none !importa
|
|
|
198
198
|
.rui-tl-clip.is-live { box-shadow: 0 4px 14px rgba(17, 24, 39, .22); z-index: 4; }
|
|
199
199
|
.rui-tl-clip { cursor: grab; }
|
|
200
200
|
.rui-tl-clip.is-live { cursor: grabbing; }
|
|
201
|
+
|
|
202
|
+
/* ── dropping ──────────────────────────────────────────────────────────────────────────────────
|
|
203
|
+
A lane says it will take the drop by lighting up, and a marker shows WHERE it will land — a
|
|
204
|
+
highlight alone tells you the lane accepts it and nothing about the position, which is the half
|
|
205
|
+
people actually care about. */
|
|
206
|
+
.rui-tl-lane.is-dropping {
|
|
207
|
+
background-color: var(--uic-brand-50, #F3F0FF);
|
|
208
|
+
box-shadow: inset 0 0 0 1px var(--uic-brand-soft, #CFC6FF);
|
|
209
|
+
}
|
|
210
|
+
.rui-tl-dropmark {
|
|
211
|
+
position: absolute; top: 2px; bottom: 2px; width: 2px; border-radius: 1px;
|
|
212
|
+
background: var(--uic-brand, #6E55FF); pointer-events: none; z-index: 3;
|
|
213
|
+
}
|
|
214
|
+
.rui-tl-newlane {
|
|
215
|
+
position: relative; flex: 0 0 auto; height: 30px; margin: 4px 0 2px;
|
|
216
|
+
border: 1px dashed var(--uic-line, #DDDFE6); border-radius: 7px;
|
|
217
|
+
display: flex; align-items: center; padding-left: 10px;
|
|
218
|
+
}
|
|
219
|
+
.rui-tl-newlane.is-dropping {
|
|
220
|
+
border-color: var(--uic-brand, #6E55FF); background: var(--uic-brand-50, #F3F0FF);
|
|
221
|
+
}
|
|
222
|
+
.rui-tl-newlbl { font-size: 11px; color: var(--uic-mute-2, #8E9199); pointer-events: none; }
|
|
223
|
+
.rui-tl-newlane.is-dropping .rui-tl-newlbl { color: var(--uic-brand, #6E55FF); }
|
|
224
|
+
.rui-tl-newhead { border-right-color: transparent; background: transparent; }
|