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/dist/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;
|
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
|
{
|