UNPKG

@mitcsutt/kiln-dnd

Version:

Kiln drag and drop: sortable lists, boards, drop zones and grid layouts with one keyboard model and one announcer, rendered through kiln-ui

65 lines (64 loc) • 2.67 kB
/*! @license * Vendored from react-grid-layout 2.3.0 (src/core/compactors.ts), MIT licence. * Copyright (c) 2016 Samuel Reed. See ./LICENSE. * https://github.com/react-grid-layout/react-grid-layout/tree/2.3.0/src/core */ import type { Compactor, CompactType, Layout, LayoutItem } from './types.js'; /** * Resolve a compaction collision by moving items. * * Before moving an item to a position, checks if that movement would * cause collisions and recursively moves those items first. * * @param layout - Full layout (must be sorted for optimization) * @param item - Item being moved (will be mutated) * @param moveToCoord - Target coordinate * @param axis - Which axis to move on ('x' or 'y') * @param hasStatics - Whether layout contains static items (disables early break optimization) */ export declare function resolveCompactionCollision(layout: Layout, item: LayoutItem, moveToCoord: number, axis: 'x' | 'y', hasStatics?: boolean): void; /** * Compact a single item vertically (move up). * * Moves the item as far up as possible without colliding. * * @param compareWith - Items to check for collisions * @param l - Item to compact (will be mutated) * @param fullLayout - Full layout for collision resolution * @param maxY - Maximum Y to start from */ export declare function compactItemVertical(compareWith: Layout, l: LayoutItem, fullLayout: Layout, maxY: number): LayoutItem; /** * Compact a single item horizontally (move left). * * Moves the item as far left as possible without colliding. * Wraps to the next row if it overflows. * * @param compareWith - Items to check for collisions * @param l - Item to compact (will be mutated) * @param cols - Number of columns in the grid * @param fullLayout - Full layout for collision resolution */ export declare function compactItemHorizontal(compareWith: Layout, l: LayoutItem, cols: number, fullLayout: Layout): LayoutItem; /** * Vertical compactor - moves items up to fill gaps. * * Items are sorted by row then column, and each item is moved * as far up as possible without overlapping other items. */ export declare const verticalCompactor: Compactor; /** * Horizontal compactor - moves items left to fill gaps. * * Items are sorted by column then row, and each item is moved * as far left as possible without overlapping other items. */ export declare const horizontalCompactor: Compactor; /** * No compaction - items stay where placed. * * Use this for free-form layouts where items can be placed anywhere. */ export declare const noCompactor: Compactor; /** Get a compactor by type. */ export declare function getCompactor(compactType: CompactType): Compactor;