import { location, record } from '@synnaxlabs/x'; import { DragEvent, ReactElement } from 'react'; import { Flex } from '../flex'; /** * Where a drop landed within a {@link Leaf}: a drop on the leaf's body carries the * region it landed in (an edge splits, center inserts), while a drop on the leaf's * tab strip always lands in the center and carries the resolved insertion index. */ export type DropPosition = { /** The region of the leaf body the drop landed in. */ location: location.Location; index?: never; } | { /** Strip drops always insert into the center of the leaf. */ location: "center"; /** The insertion index within the leaf's tab strip. */ index: number; }; /** Passed to a Frame's onDrop handler when a tab lands on a {@link Leaf}. */ export type OnDropProps = DropPosition & { /** The key of the leaf the tab was dropped on. */ nodeKey: number; /** The key of the dropped tab. */ tabKey: string; /** The payload the drag source attached to the tab, if any. */ data?: record.Unknown; }; /** Passed to a Frame's onCreate handler when creation items land on a {@link Leaf}. */ export type OnCreateProps = DropPosition & { /** The key of the leaf the items were dropped on. */ nodeKey: number; /** The keys of the dropped creation items, e.g. ontology ID strings. */ tabKeys: string[]; }; /** Passed to a Frame's onFileDrop handler when OS files land on a {@link Leaf}. */ export interface OnFileDropProps { /** The key of the leaf the files were dropped on. */ nodeKey: number; /** Where the files landed relative to the leaf: an edge splits, center inserts. */ location: location.Location; /** The native drag event carrying the dropped files. */ event: DragEvent; } export interface ContextValue { /** onDrop is the Frame-level tab drop handler invoked by {@link Leaf} parts. */ onDrop?: (props: OnDropProps) => void; /** onCreate is the Frame-level creation drop handler invoked by {@link Leaf} parts. */ onCreate?: (props: OnCreateProps) => void; /** * onFileDrop is the Frame-level OS file drop handler invoked by {@link Leaf} * parts. Its presence enables file drops on every leaf in the frame. */ onFileDrop?: (props: OnFileDropProps) => void; /** onResize is the Frame-level resize handler invoked by {@link Split} parts. */ onResize?: (splitKey: number, size: number) => void; /** disabled turns every structural gesture off across the frame. */ disabled?: boolean; } declare const useContext: (hookOrComponentName: string) => ContextValue; export { useContext }; export interface FrameProps extends Omit { /** onDrop is called when a hauled tab lands on one of the frame's leaves. */ onDrop?: (props: OnDropProps) => void; /** onCreate is called when hauled creation items land on one of the frame's leaves. */ onCreate?: (props: OnCreateProps) => void; /** onFileDrop enables OS file drops on the frame's leaves and handles them. */ onFileDrop?: (props: OnFileDropProps) => void; /** onResize is called when a {@link Split} handle drag ends with the new ratio. */ onResize?: (splitKey: number, size: number) => void; /** * Rejects every drop and removes every resize handle in the frame, for a viewer who * cannot persist a new layout. The parts a consumer renders itself (close and add * buttons, tab dragging) are its own to suppress. */ disabled?: boolean; } /** * Frame is the root of a composed mosaic. It distributes drop, create, file drop, * and resize handlers to the Leaf and Split parts rendered within it. Consumers * render their own tree of Split and Leaf parts as children. */ export declare const Frame: ({ onDrop, onCreate, onFileDrop, onResize, className, children, empty, disabled, ...rest }: FrameProps) => ReactElement; //# sourceMappingURL=Frame.d.ts.map