import { Clip, TimelineClipDropFailureReason, TimelineReadonly, TimelineTrackGeometryOptions, TimelineTrackHitTestResult, Track, TrackHitTestInput } from "@techsquidtv/canvas-timeline-core"; //#region src/hooks/tracks/useTimelineTrackDropTargets.d.ts /** * Context passed to custom clip track-drop guards. * * @remarks * * The context contains the clip being moved, the source row captured at drag * start, and the candidate target row currently under the pointer. Use it to * express app policy such as visual-only tracks, audio-only tracks, locked * groups, or modifier-key cross-kind moves. * * target tracks. */ interface TimelineTrackDropContext { /** Clip being moved. */ clip: TimelineReadonly; /** Track that contained the clip at drag start. */ sourceTrack: TimelineReadonly; /** Candidate destination track. */ targetTrack: TimelineReadonly; /** Source track index at drag start. */ sourceTrackIndex: number; /** Candidate destination track index. */ targetTrackIndex: number; } /** Result of resolving whether a clip may drop on a track. */ interface TimelineTrackDropResult { /** Whether the target track accepts the clip. */ canDrop: boolean; /** Machine-readable failure reason when `canDrop` is false. */ reason: TimelineClipDropFailureReason | null; /** Whether the engine should permit a cross-kind transfer. */ allowCrossKindTrackMove: boolean; } /** * Custom policy for accepting or rejecting track drop targets. * * target tracks. */ type TimelineTrackDropGuard = (context: TimelineTrackDropContext) => boolean | TimelineTrackDropResult; /** * Options accepted by `useTimelineTrackDropTargets`. * * @remarks * * Geometry options should match the renderer and interaction layer. The optional * guard runs after built-in checks for missing, locked, and same-kind tracks. * * * @see {@link TimelineTrackDropGuard} * @see {@link useTimelineClipDrag} */ interface UseTimelineTrackDropTargetsOptions extends TimelineTrackGeometryOptions { /** Optional app policy for accepting, rejecting, or expanding drop targets. */ canDropClipOnTrack?: TimelineTrackDropGuard; } /** * Result returned by `useTimelineTrackDropTargets`. * * @remarks * * Use this result to build custom track-row drop previews, or indirectly through * {@link useTimelineClipDrag}. `trackTargets` are viewport-space rows in * timeline order and `canDropClipOnTrack` applies both engine and app policy. * */ interface UseTimelineTrackDropTargetsResult { /** Viewport-space track rows in timeline order. */ trackTargets: TimelineTrackHitTestResult[]; /** Hit-tests timeline tracks in viewport coordinates. */ getTrackAtViewportPoint: (input: TrackHitTestInput) => TimelineTrackHitTestResult | null; /** Resolves whether one clip may drop on one candidate track. */ canDropClipOnTrack: (clipId: string, targetTrackId: string, sourceTrackId?: string) => TimelineTrackDropResult; } /** * Builds headless track drop targets for cross-track clip movement. * * @remarks * * This hook is a geometry and policy helper for custom clip drag layers. It * does not start pointer capture or mutate clips on its own; combine it with * {@link useTimelineClipDrag} or your own pointer lifecycle when building custom * interaction chrome. * * @param options - Track geometry and optional drop policy used to resolve compatible tracks. * @returns Track hit targets, viewport hit testing, and drop-policy resolution helpers. * * @example * ```tsx * import { useTimelineTrackDropTargets } from '@techsquidtv/canvas-timeline-react'; * * export function TrackDropOverlay({ clipId }: { clipId: string }) { * const targets = useTimelineTrackDropTargets({ * canDropClipOnTrack: ({ sourceTrack, targetTrack }) => sourceTrack.kind === targetTrack.kind, * }); * * return targets.trackTargets.map((target) => { * const result = targets.canDropClipOnTrack(clipId, target.track.id); * * return ( *
* {target.track.name ?? target.track.id} *
* ); * }); * } * ``` * * @see {@link TimelineTrackDropContext} * @see {@link useTimelineClipDrag} * @see {@link https://canvastimeline.com/docs/tracks-and-clips | Tracks and clips} */ declare function useTimelineTrackDropTargets(options?: UseTimelineTrackDropTargetsOptions): UseTimelineTrackDropTargetsResult; //#endregion export { TimelineTrackDropContext, TimelineTrackDropGuard, TimelineTrackDropResult, UseTimelineTrackDropTargetsOptions, UseTimelineTrackDropTargetsResult, useTimelineTrackDropTargets }; //# sourceMappingURL=useTimelineTrackDropTargets.d.mts.map