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 CHANGED
@@ -4188,6 +4188,15 @@ function Timeline({
4188
4188
  /** Sequential lane: (clip, toIndex, track). Placed lane: (clip, newStartSeconds, track). */
4189
4189
  onMoveClip,
4190
4190
  onDeleteClip,
4191
+ /** Something was dropped on a lane: (payload, {trackId, seconds, index}). `trackId` is null when
4192
+ * it landed on the NEW-LANE strip below the last lane, which is how a layer gets created by
4193
+ * dropping rather than by a button nobody finds. */
4194
+ onDropClip,
4195
+ /** Reads the drag's payload out of a DataTransfer. Return null to refuse the drop, which is
4196
+ * what turns the lane's highlight off for things this timeline cannot take. */
4197
+ readDrop,
4198
+ /** Text on the strip below the last lane. Omit and no such strip is drawn. */
4199
+ newLaneLabel,
4191
4200
  laneAppend,
4192
4201
  zoomStorageKey = null,
4193
4202
  snapStorageKey = null,
@@ -4207,6 +4216,7 @@ function Timeline({
4207
4216
  const gesture = (0, import_react26.useRef)(null);
4208
4217
  const [drag, setDrag] = (0, import_react26.useState)(null);
4209
4218
  const anchor = (0, import_react26.useRef)(null);
4219
+ const [dropAt, setDropAt] = (0, import_react26.useState)(null);
4210
4220
  const rows = (0, import_react26.useMemo)(
4211
4221
  () => tracks.map((t) => ({
4212
4222
  ...t,
@@ -4527,11 +4537,33 @@ function Timeline({
4527
4537
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4528
4538
  "div",
4529
4539
  {
4530
- className: "rui-tl-lane",
4540
+ className: "rui-tl-lane" + (dropAt?.trackId === track.id ? " is-dropping" : ""),
4531
4541
  style: { width: laneW, height: LANE_H },
4532
4542
  onPointerDown: (e) => {
4533
4543
  if (e.target === e.currentTarget) onScrub(e);
4534
4544
  },
4545
+ onDragOver: onDropClip ? (e) => {
4546
+ if (!readDrop || readDrop(e.dataTransfer) === null) return;
4547
+ e.preventDefault();
4548
+ e.dataTransfer.dropEffect = "copy";
4549
+ setDropAt({ trackId: track.id, t: timeAt(e.clientX) });
4550
+ } : void 0,
4551
+ onDragLeave: onDropClip ? (e) => {
4552
+ if (e.currentTarget.contains(e.relatedTarget)) return;
4553
+ setDropAt((d) => d?.trackId === track.id ? null : d);
4554
+ } : void 0,
4555
+ onDrop: onDropClip ? (e) => {
4556
+ const payload = readDrop?.(e.dataTransfer) ?? null;
4557
+ setDropAt(null);
4558
+ if (payload === null) return;
4559
+ e.preventDefault();
4560
+ const t = timeAt(e.clientX);
4561
+ let index = 0;
4562
+ for (const other of track.laid) {
4563
+ if (t > other.t0 + other.w / pps / 2) index += 1;
4564
+ }
4565
+ onDropClip(payload, { trackId: track.id, seconds: t, index });
4566
+ } : void 0,
4535
4567
  children: [
4536
4568
  track.laid.length === 0 && track.emptyLabel && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "rui-tl-laneempty", children: track.emptyLabel }),
4537
4569
  track.laid.map((l) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -4550,6 +4582,14 @@ function Timeline({
4550
4582
  },
4551
4583
  l.clip.id ?? l.i
4552
4584
  )),
4585
+ dropAt?.trackId === track.id && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4586
+ "span",
4587
+ {
4588
+ className: "rui-tl-dropmark",
4589
+ style: { left: dropAt.t * pps },
4590
+ "aria-hidden": "true"
4591
+ }
4592
+ ),
4553
4593
  laneAppend && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4554
4594
  "span",
4555
4595
  {
@@ -4562,6 +4602,34 @@ function Timeline({
4562
4602
  }
4563
4603
  )
4564
4604
  ] }, track.id)),
4605
+ onDropClip && newLaneLabel && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "rui-tl-row", children: [
4606
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "rui-tl-head rui-tl-newhead", "aria-hidden": "true" }),
4607
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4608
+ "div",
4609
+ {
4610
+ className: "rui-tl-newlane" + (dropAt?.trackId === null ? " is-dropping" : ""),
4611
+ style: { width: laneW },
4612
+ onDragOver: (e) => {
4613
+ if (!readDrop || readDrop(e.dataTransfer) === null) return;
4614
+ e.preventDefault();
4615
+ e.dataTransfer.dropEffect = "copy";
4616
+ setDropAt({ trackId: null, t: timeAt(e.clientX) });
4617
+ },
4618
+ onDragLeave: (e) => {
4619
+ if (e.currentTarget.contains(e.relatedTarget)) return;
4620
+ setDropAt((d) => d?.trackId === null ? null : d);
4621
+ },
4622
+ onDrop: (e) => {
4623
+ const payload = readDrop?.(e.dataTransfer) ?? null;
4624
+ setDropAt(null);
4625
+ if (payload === null) return;
4626
+ e.preventDefault();
4627
+ onDropClip(payload, { trackId: null, seconds: timeAt(e.clientX), index: 0 });
4628
+ },
4629
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "rui-tl-newlbl", children: newLaneLabel })
4630
+ }
4631
+ )
4632
+ ] }),
4565
4633
  drag?.guide != null && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4566
4634
  "div",
4567
4635
  {