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.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;
package/dist/index.js CHANGED
@@ -3949,6 +3949,15 @@ function Timeline({
3949
3949
  /** Sequential lane: (clip, toIndex, track). Placed lane: (clip, newStartSeconds, track). */
3950
3950
  onMoveClip,
3951
3951
  onDeleteClip,
3952
+ /** Something was dropped on a lane: (payload, {trackId, seconds, index}). `trackId` is null when
3953
+ * it landed on the NEW-LANE strip below the last lane, which is how a layer gets created by
3954
+ * dropping rather than by a button nobody finds. */
3955
+ onDropClip,
3956
+ /** Reads the drag's payload out of a DataTransfer. Return null to refuse the drop, which is
3957
+ * what turns the lane's highlight off for things this timeline cannot take. */
3958
+ readDrop,
3959
+ /** Text on the strip below the last lane. Omit and no such strip is drawn. */
3960
+ newLaneLabel,
3952
3961
  laneAppend,
3953
3962
  zoomStorageKey = null,
3954
3963
  snapStorageKey = null,
@@ -3968,6 +3977,7 @@ function Timeline({
3968
3977
  const gesture = useRef12(null);
3969
3978
  const [drag, setDrag] = useState15(null);
3970
3979
  const anchor = useRef12(null);
3980
+ const [dropAt, setDropAt] = useState15(null);
3971
3981
  const rows = useMemo4(
3972
3982
  () => tracks.map((t) => ({
3973
3983
  ...t,
@@ -4288,11 +4298,33 @@ function Timeline({
4288
4298
  /* @__PURE__ */ jsxs22(
4289
4299
  "div",
4290
4300
  {
4291
- className: "rui-tl-lane",
4301
+ className: "rui-tl-lane" + (dropAt?.trackId === track.id ? " is-dropping" : ""),
4292
4302
  style: { width: laneW, height: LANE_H },
4293
4303
  onPointerDown: (e) => {
4294
4304
  if (e.target === e.currentTarget) onScrub(e);
4295
4305
  },
4306
+ onDragOver: onDropClip ? (e) => {
4307
+ if (!readDrop || readDrop(e.dataTransfer) === null) return;
4308
+ e.preventDefault();
4309
+ e.dataTransfer.dropEffect = "copy";
4310
+ setDropAt({ trackId: track.id, t: timeAt(e.clientX) });
4311
+ } : void 0,
4312
+ onDragLeave: onDropClip ? (e) => {
4313
+ if (e.currentTarget.contains(e.relatedTarget)) return;
4314
+ setDropAt((d) => d?.trackId === track.id ? null : d);
4315
+ } : void 0,
4316
+ onDrop: onDropClip ? (e) => {
4317
+ const payload = readDrop?.(e.dataTransfer) ?? null;
4318
+ setDropAt(null);
4319
+ if (payload === null) return;
4320
+ e.preventDefault();
4321
+ const t = timeAt(e.clientX);
4322
+ let index = 0;
4323
+ for (const other of track.laid) {
4324
+ if (t > other.t0 + other.w / pps / 2) index += 1;
4325
+ }
4326
+ onDropClip(payload, { trackId: track.id, seconds: t, index });
4327
+ } : void 0,
4296
4328
  children: [
4297
4329
  track.laid.length === 0 && track.emptyLabel && /* @__PURE__ */ jsx25("p", { className: "rui-tl-laneempty", children: track.emptyLabel }),
4298
4330
  track.laid.map((l) => /* @__PURE__ */ jsx25(
@@ -4311,6 +4343,14 @@ function Timeline({
4311
4343
  },
4312
4344
  l.clip.id ?? l.i
4313
4345
  )),
4346
+ dropAt?.trackId === track.id && /* @__PURE__ */ jsx25(
4347
+ "span",
4348
+ {
4349
+ className: "rui-tl-dropmark",
4350
+ style: { left: dropAt.t * pps },
4351
+ "aria-hidden": "true"
4352
+ }
4353
+ ),
4314
4354
  laneAppend && /* @__PURE__ */ jsx25(
4315
4355
  "span",
4316
4356
  {
@@ -4323,6 +4363,34 @@ function Timeline({
4323
4363
  }
4324
4364
  )
4325
4365
  ] }, track.id)),
4366
+ onDropClip && newLaneLabel && /* @__PURE__ */ jsxs22("div", { className: "rui-tl-row", children: [
4367
+ /* @__PURE__ */ jsx25("div", { className: "rui-tl-head rui-tl-newhead", "aria-hidden": "true" }),
4368
+ /* @__PURE__ */ jsx25(
4369
+ "div",
4370
+ {
4371
+ className: "rui-tl-newlane" + (dropAt?.trackId === null ? " is-dropping" : ""),
4372
+ style: { width: laneW },
4373
+ onDragOver: (e) => {
4374
+ if (!readDrop || readDrop(e.dataTransfer) === null) return;
4375
+ e.preventDefault();
4376
+ e.dataTransfer.dropEffect = "copy";
4377
+ setDropAt({ trackId: null, t: timeAt(e.clientX) });
4378
+ },
4379
+ onDragLeave: (e) => {
4380
+ if (e.currentTarget.contains(e.relatedTarget)) return;
4381
+ setDropAt((d) => d?.trackId === null ? null : d);
4382
+ },
4383
+ onDrop: (e) => {
4384
+ const payload = readDrop?.(e.dataTransfer) ?? null;
4385
+ setDropAt(null);
4386
+ if (payload === null) return;
4387
+ e.preventDefault();
4388
+ onDropClip(payload, { trackId: null, seconds: timeAt(e.clientX), index: 0 });
4389
+ },
4390
+ children: /* @__PURE__ */ jsx25("span", { className: "rui-tl-newlbl", children: newLaneLabel })
4391
+ }
4392
+ )
4393
+ ] }),
4326
4394
  drag?.guide != null && /* @__PURE__ */ jsx25(
4327
4395
  "div",
4328
4396
  {
@@ -4363,11 +4431,14 @@ function Clip({
4363
4431
  const tileW = Math.round((LANE_H - CLIP_INSET * 2) * (16 / 9));
4364
4432
  const startTrim = (e, edge) => {
4365
4433
  if (!onTrim || !known) return;
4434
+ const room = clip.headroom || {};
4435
+ const outward = Math.max(0, Number(edge === "end" ? room.end : room.start) || 0);
4436
+ const maxDur = clip.duration + outward;
4366
4437
  beginGesture(e, {
4367
4438
  kind: "trim",
4368
4439
  snapTimes,
4369
4440
  preview: (t) => {
4370
- const dur = edge === "end" ? clamp(t - t0, TL_MIN_CLIP_S, clip.duration) : clamp(t0 + clip.duration - t, TL_MIN_CLIP_S, clip.duration);
4441
+ const dur = edge === "end" ? clamp(t - t0, TL_MIN_CLIP_S, maxDur) : clamp(t0 + clip.duration - t, TL_MIN_CLIP_S, maxDur);
4371
4442
  const nextW = dur * pps;
4372
4443
  const nextLeft = edge === "end" ? x : x + (w - nextW);
4373
4444
  return {
@@ -4379,7 +4450,7 @@ function Clip({
4379
4450
  };
4380
4451
  },
4381
4452
  commit: (t) => {
4382
- const dur = edge === "end" ? clamp(t - t0, TL_MIN_CLIP_S, clip.duration) : clamp(t0 + clip.duration - t, TL_MIN_CLIP_S, clip.duration);
4453
+ const dur = edge === "end" ? clamp(t - t0, TL_MIN_CLIP_S, maxDur) : clamp(t0 + clip.duration - t, TL_MIN_CLIP_S, maxDur);
4383
4454
  if (Math.abs(dur - clip.duration) > 1e-3) onTrim(clip, edge, dur, track);
4384
4455
  }
4385
4456
  });