reifyui 0.10.2 → 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 +69 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +69 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.d.ts +10 -0
- package/src/timeline/Timeline.jsx +75 -2
- 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
|
@@ -724,6 +724,16 @@ export interface TimelineProps {
|
|
|
724
724
|
clipActions?: (clip: TimelineClip, index: number) => ReactNode;
|
|
725
725
|
/** Rendered just past the last clip of a lane — an add button, usually. */
|
|
726
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;
|
|
727
737
|
/** localStorage key for the zoom level, so it survives a reload. */
|
|
728
738
|
zoomStorageKey?: string | null;
|
|
729
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 }}
|
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; }
|