/** * Everything about a board move that is arithmetic rather than * React — so it can be tested in Node, exhaustively, without a * browser and without a pointer. * * That split is not tidiness. The pointer path is the one part of * this component a test cannot drive convincingly: `userEvent` can * dispatch `pointermove`, but it cannot lay anything out, so every * rectangle it would reason about is `0x0` in a test environment * that has not painted. Pulling the geometry out means the *rule* — * which lane, which index, what happens on a tie — is red/green in * Node, and the browser test is left proving only the wiring. */ /** * A lane as the drop calculation sees it: a box, a key, and the * boxes of the cards inside it. * * Deliberately plain data rather than elements. `chooseDropTarget` * never touches the DOM, which is why it can be called with * fixtures. */ export type BoardDropLane = { cardRects: readonly BoardRect[]; key: string; rect: BoardRect; }; export type BoardPoint = { x: number; y: number; }; /** * The subset of `DOMRect` this needs. Named rather than reusing * `DOMRect`, because `DOMRect` is a browser global and this module * is imported by the Node test project. */ export type BoardRect = { height: number; left: number; top: number; width: number; }; export type BoardDropTarget = { index: number; laneKey: string; }; /** * Where in a lane a point lands: the number of cards whose midpoint * is above it. * * Midpoints rather than edges, so the insertion flips when the * pointer passes the *centre* of a card. Against edges, the top * half of every card is a dead zone that means "same place you * already were", and the indicator stutters. */ export declare const chooseDropIndex: (cardRects: readonly BoardRect[], point: BoardPoint) => number; /** * The lane and index a pointer is currently over. * * Hit test first, nearest-lane second, and `null` only when there * are no lanes at all — a drag that started has to end somewhere. */ export declare const chooseDropTarget: (lanes: readonly BoardDropLane[], point: BoardPoint) => BoardDropTarget | null; /** * Whether a move would actually change anything. * * The subtle half is `toIndex`. Taking a card out of its own lane * shifts every card below it up by one, so "drop it back where it * was" arrives as both `fromIndex` and `fromIndex + 1` depending on * which side of its own midpoint the pointer ended on. Both are * no-ops, and a board that fires `onMove` for them makes a consumer * re-render — and, if the consumer is optimistic, flash — for a * drag that went nowhere. */ export declare const getIsMoveMeaningful: ({ fromIndex, fromLaneKey, toIndex, toLaneKey, }: { fromIndex: number; fromLaneKey: string; toIndex: number; toLaneKey: string; }) => boolean; /** * Where a card ends up once it has been removed from its old * position. * * A within-lane move is quoted against the list *including* the * card being moved — that is what the pointer was over — but a * consumer splicing an array removes it first, so every index below * the origin is one too high. Folding that here means the consumer's * handler is `splice(from, 1)` then `splice(to, 0, item)` with no * arithmetic of its own, which is the version nobody gets wrong. */ export declare const toSettledIndex: ({ fromIndex, fromLaneKey, toIndex, toLaneKey, }: { fromIndex: number; fromLaneKey: string; toIndex: number; toLaneKey: string; }) => number; /** * What the live region says after a move. * * A sentence rather than a status word, and it names the * **destination position** as well as the lane, because "moved to In * Progress" leaves a screen-reader user with no idea whether the * card went to the top of the lane or the bottom of thirty. That is * the single piece of feedback a sighted user gets for free from * watching the card land, and it is the one every drag-and-drop * implementation forgets to say out loud. * * One-based, because it is read to a person. */ export declare const describeMove: ({ index, laneLabel, laneSize, title, }: { index: number; laneLabel: string; laneSize: number; title: string; }) => string; //# sourceMappingURL=boardMove.d.ts.map