import { JSX } from 'react/jsx-runtime'; import type { default as React_2 } from 'react'; /** * Options to enable boundary constraints for specific sides of a container or window. * When set to true, the dragged item will be prevented from moving beyond that boundary. */ export declare type BoundedConstraintOption = { /** * Enable constraint on the top edge, default: true. */ top?: boolean; /** * Enable constraint on the right edge, default: true. */ right?: boolean; /** * Enable constraint on the bottom edge, default: true. */ bottom?: boolean; /** * Enable constraint on the left edge, default: true. */ left?: boolean; }; export declare interface ColumnLayoutConfig { /** * Total number of columns in the layout; must be a positive integer. */ columns: number; } export declare interface ColumnLayoutItem extends LayoutItem { /** * Zero-based start column index where the item is placed. */ column: number; /** * Number of columns the item spans; clamped to a valid range during layout. */ columnSpan: number; /** * Preferred item height in pixels (used when measured size is not available). */ height: number; } export declare interface Constraint { /** * Returns the constrained local position. * @param context * @returns The position of the currently dragged item relative to its container. */ constrain: (context: ConstraintContext) => Position; } export declare type ConstraintContext = { /** * The item currently being dragged */ item: LayoutItem; /** * Initial position of the dragged item relative to the container at the start of the drag. */ startLocalPosition: Position; /** * The position of the currently dragged item relative to its container. */ localPosition: Position; /** * The current position of the dragged item relative to the viewport. */ globalPosition: Position; /** * The bounding box of the current viewport. */ windowRect: Rectangle; /** * The bounding box of the current item relative to its container, * ignoring any scaling applied to the container or parent elements. */ itemLocalRect: Rectangle; /** * The bounding box of the current item relative to the viewport. */ itemGlobalRect: Rectangle; /** * The bounding box of the container relative to the viewport, * ignoring any scaling applied to the container or parent elements. */ containerLocalRect: Rectangle; /** * The bounding box of the container relative to the viewport. */ containerGlobalRect: Rectangle; /** * The current position of the pointer. */ pointer: Pick; /** * Converts a global position to container-local coordinates. * @param globalPosition A position relative to the viewport. * @returns */ globalPositionToLocalPosition: (globalPosition: Position) => Position; }; /** * Container constraint - ensures dragging items don't exceed container boundaries. */ export declare function containerConstraint(options?: BoundedConstraintOption): Constraint; /** * How the container should fit its content size. * - `"width"`: Container adjusts to fit content width * - `"height"`: Container adjusts to fit content height * - `"both"`: Container adjusts to fit both width and height * - `"none"`: Container does not adjust to fit content */ export declare type ContentFitMode = "width" | "height" | "both" | "none"; export declare function createColumnLayoutAlgorithm(config?: ColumnLayoutConfig): LayoutAlgorithm; export declare function createRowLayoutAlgorithm(config?: RowLayoutConfig): LayoutAlgorithm; export declare function DndLayout(props: DndLayoutProps): JSX.Element; export declare type DndLayoutProps = { /** * Layout store instance created by `useLayout`, used to update layout. */ layout: ILayoutStore; /** * Layout render options (e.g. `gap`, fit container width/height to content). */ layoutConfig?: LayoutConfig; /** * Drag behavior config. Set `enable=false` to disable dragging; use `draggableSelector` as a drag handle filter. */ dragConfig?: DragConfig; /** * Drag constraints applied during movement to clamp/adjust positions. */ constraints?: Constraint[]; /** * Renders a single item node. * @param item * @returns */ itemRender: (item: T) => React_2.ReactNode; /** * Custom placeholder renderer shown while dragging or external dropping. * @param item * @returns */ placeholderRender?: (item: T) => React_2.ReactNode; /** * Called after layout changes. * @param items Returns serialized items * @returns */ onLayoutChange?: (items: T[]) => void; /** * Called when external drag enters the container. Return a `T` to accept/insert a temporary item, or `false` to reject. * @param event * @param id * @returns */ onDragEnter?: (event: React_2.DragEvent, id: string) => T | false; /** * Called when external drop happens. Return final `T` to confirm, or `false` to cancel and remove the temporary item. * @param event * @param item * @returns */ onDrop?: (event: React_2.DragEvent, item: T) => T | false; /** * Class name for the root container. */ className?: string; /** * Style for the root container. */ style?: React_2.CSSProperties; }; export declare type DragConfig = { /** * Enable/disable dragging. Default: true. */ enable?: boolean; /** * CSS selector that defines valid drag handles. */ draggableSelector?: string; }; /** * Restricts movement to the horizontal axis only (left and right). * Prevents any vertical displacement. */ export declare function horizontalAxisConstraint(): Constraint; export declare interface ILayoutStore { /** * Replaces current layout algorithm. * @param layoutAlgorithm The layout algorithm to be used. * @returns */ setLayoutAlgorithm: (layoutAlgorithm: LayoutAlgorithm) => void; /** * Replaces current item list. * @param items Layout items. * @returns */ setItems: (items: T[]) => void; } export declare interface LayoutAlgorithm { /** * Class name applied to layout root for algorithm-specific styles. */ readonly className?: string; /** * Container resize trigger dimension(s). */ readonly containerTrigger: RelayoutTrigger; /** * Item resize trigger dimension(s). */ readonly itemTrigger: RelayoutTrigger; /** * How the container should fit its content size. */ readonly contentFitMode: ContentFitMode; /** * Computes positioned render items from source items and config. * @param items * @param config * @returns */ layout: (items: MeasuredLayoutItem[], config: LayoutRenderConfig) => RenderItem>[]; /** * Computes reordered items while moving; return `false` for no change. * @param items * @param config * @param context * @returns */ move: (items: RenderItem>[], config: LayoutRenderConfig, context: MoveContext>) => MeasuredLayoutItem[] | false; /** * Serializes a render item. * @param item * @returns */ serialize: (item: RenderItem>) => T; } export declare type LayoutConfig = { /** * Item gap: uniform number or `[horizontal, vertical]`. */ gap?: number | [horizontal: number, vertical: number]; }; export declare type LayoutInitializer = () => { /** * Initial items for layout. */ initialItems: T[]; /** * The layout algorithm to be used. * You can use the built-in `createColumnLayoutAlgorithm` or `createRowLayoutAlgorithm`, * or provide your own custom implementation. */ algorithm: LayoutAlgorithm; }; export declare type LayoutItem = { /** * Unique and stable item identifier used for rendering. */ id: string; }; export declare type LayoutRenderConfig = { layoutSize: LayoutSize; gap: [horizontal: number, vertical: number]; }; /** * The available size within the container for layout purposes. */ export declare type LayoutSize = { /** * The available width of the container. */ layoutWidth: number; /** * The available height of the container. */ layoutHeight: number; }; export declare type MeasuredLayoutItem = { /** * Runtime measured size, if available. */ size?: Size; } & T; export declare type MoveContext = { /** * Currently dragged render item. */ current: RenderItem; /** * Index of `current` in the render list. */ currentIndex: number; /** * The position of the currently dragged item relative to its container. */ localPosition: Position; }; /** * Represents the 2D coordinates (x-coordinate: left, y-coordinate: top). */ export declare type Position = Pick, "left" | "top">; /** * Represents a rectangular area, typically used for bounding boxes. */ export declare type Rectangle = { /** * The x-coordinate (left) relative to the reference container. */ left: number; /** * The y-coordinate (top) relative to the reference container. */ top: number; /** * The width of the rectangle. */ width: number; /** * The height of the rectangle. */ height: number; }; /** * Which dimension changes should trigger relayout. */ export declare type RelayoutTrigger = "width" | "height" | "both"; export declare type RenderItem = { /** * The x-coordinate (left) relative to the reference container. */ left: number; /** * The y-coordinate (top) relative to the reference container. */ top: number; /** * The width of the item. */ width: number; /** * The height of the item. */ height: number; /** * LayoutItem */ data: T; }; export declare interface RowLayoutConfig { /** * Total number of rows in the layout; must be a positive integer. */ rows: number; } export declare interface RowLayoutItem extends LayoutItem { /** * Zero-based start row index where the item is placed. */ row: number; /** * Number of rows the item spans; clamped to a valid range during layout. */ rowSpan: number; /** * Preferred item width in pixels (used when measured size is not available). */ width: number; } /** * Represents the dimensions of an element. */ export declare type Size = { /** * Width in pixels. */ width: number; /** * Height in pixels. */ height: number; }; /** * Initializes and manages the layout state. * @param initializer - A function that returns the initial layout configuration, * including the layout algorithm and the initial items. * @returns A layout controller object to be passed to the DndLayout component. */ export declare function useLayout(initializer: LayoutInitializer): ILayoutStore; /** * Restricts movement to the vertical axis only (up and down). * Prevents any horizontal displacement. */ export declare function verticalAxisConstraint(): Constraint; /** * Window constraint - ensures dragging items don't exceed window boundaries. */ export declare function windowConstraint(options?: BoundedConstraintOption): Constraint; export { }