/** * A single reorderable column participating in a drag, described purely by its * id and rendered width. No DOM node is referenced — the model is deliberately * platform-free so it can be unit-tested and reused by any renderer. */ export interface ColumnDragSlot { /** Stable column identifier. */ readonly colId: string; /** Rendered width in CSS pixels, as resolved by `ColumnStyleManager`. */ readonly width: number; } /** * Lowest `enterRatio` that cannot oscillate. * * A swap commits when the preview covers `enterRatio` of the neighbour; the * reverse swap becomes possible only once it covers `1 - enterRatio` of that * same neighbour from the other side. The two thresholds therefore only stay * disjoint while `enterRatio >= 0.5`. Anything lower would let a stationary * pointer satisfy both conditions at once and flip the order every frame. */ export declare const MIN_ENTER_RATIO = 0.5; /** Default coverage required before a swap commits — the neighbour's midpoint. */ export declare const DEFAULT_ENTER_RATIO = 0.5; /** * Order model for an AG Grid-style column drag. * * The dragged column is treated as a free-floating **preview rectangle** whose * left edge is driven by the pointer. Every frame the preview is compared with * its immediate neighbours in the *current preview order*; once it covers more * than `enterRatio` of a neighbour, the two exchange slots. Because a swap * displaces the neighbour by its own width, the inverse condition cannot * immediately hold — the hysteresis is structural rather than an epsilon, so a * pointer resting exactly on a boundary never flickers. * * All geometry is expressed in **panel-content space**: `0` is the left edge of * the panel's first column, and positions accumulate column widths from there. * The caller converts pointer coordinates into that space, which keeps the * model independent of scrolling, pinning and viewport offsets. * * Complexity: `update()` is O(1) in the common frame (no swap) and O(n) on the * frames where the order actually changes. No allocation occurs after * construction — the position maps are mutated in place. * * @example * ```ts * const model = new ColumnReorderModel( * [{ colId: 'a', width: 100 }, { colId: 'b', width: 120 }], * 'a', * 0.5, * ); * if (model.update(previewLeft)) applyTransforms(model); * ``` */ export declare class ColumnReorderModel { private readonly sourceColId; private readonly widthById; private readonly originLeftById; private readonly targetLeftById; private readonly previewOrder; private readonly enterRatio; private readonly sourceWidth; private readonly initialIndex; private sourceIdx; /** * @param slots - Panel columns in their current (pre-drag) display order. * @param sourceColId - Id of the grabbed column; must exist in `slots`. * @param enterRatio - Fraction of a neighbour the preview must cover before * the swap commits. Clamped to `[0.5, 1]`; see * {@link MIN_ENTER_RATIO}. */ constructor(slots: readonly ColumnDragSlot[], sourceColId: string, enterRatio?: number); /** `true` when the grabbed column was found in the supplied slots. */ get isValid(): boolean; /** The grabbed column's index in the pre-drag order. */ get originalIndex(): number; /** The grabbed column's index in the current preview order — its drop slot. */ get targetIndex(): number; /** The live preview order of column ids. Do not mutate. */ get order(): readonly string[]; /** `true` when the preview order differs from the pre-drag order. */ get hasMoved(): boolean; /** * Left edge of a column in its pre-drag position, in panel-content space. * * @param colId - Column to look up. * @returns The origin offset, or `0` for an unknown column. */ originLeftOf(colId: string): number; /** * Horizontal shift a column must render with to appear in its preview slot. * * This is the value written to the `--pg-drag-x` custom property. The grabbed * column is excluded — it follows the pointer instead and is positioned by * the caller. * * @param colId - Column to look up. * @returns `targetLeft - originLeft`, or `0` when nothing moved. */ offsetFor(colId: string): number; /** * Advances the preview order for the frame's pointer position. * * Swaps are applied in a loop so a fast drag across several narrow columns * resolves completely within the same frame instead of lagging one column * behind the pointer. * * @param previewLeft - Left edge of the preview rectangle, in panel-content * space (`pointerX - grabOffsetX`, scroll-corrected). * @returns `true` when the order changed and transforms must be re-applied. */ update(previewLeft: number): boolean; /** * Exchanges the source with its right-hand neighbour when the preview has * covered `enterRatio` of it. */ private trySwapRight; /** * Exchanges the source with its left-hand neighbour when the preview has * covered `enterRatio` of it. */ private trySwapLeft; /** * Applies one source ⇄ neighbour exchange. * * Only the two participants change position — every other column keeps its * slot — so the target map is patched in O(1) instead of re-accumulating the * whole panel. Keeping it exact matters inside {@link update}'s loop, where * the next iteration reads these positions to test the following neighbour. * * @param idx - Index the source moves to (the neighbour's current index). * @param neighbour - Column id being displaced. * @param nbrWidth - The neighbour's width, already resolved by the caller. */ private commitSwap; } //# sourceMappingURL=column-reorder-model.d.ts.map