/* * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ import { KanbanCardData, KanbanColumnData } from "./types.js"; import { ReactNode } from "react"; import * as react_jsx_runtime105 from "react/jsx-runtime"; import { DragEndEvent } from "@dnd-kit/core"; //#region src/components/kanban/context.d.ts /** * Function signature for moving a card between columns or positions. */ type MoveCard = (cardId: string, targetColumnId: string, targetPosition: number, closestEdge?: 'top' | 'bottom') => void; /** * Context data for Kanban state and operations. */ interface KanbanContextData { /** Array of all columns. */ columns: KanbanColumnData[]; /** Callback to update column state. */ updateColumnState: (columns: KanbanColumnData[]) => void; /** Function to move a card. */ moveCard: MoveCard; /** Get a column by its ID. */ getColumnById: (id: string) => KanbanColumnData | undefined; /** Map of card IDs to their location info. */ cardMap: Map; } /** * Props for KanbanProvider component. */ interface KanbanProviderProps { /** Array of column data. */ columns: KanbanColumnData[]; /** Callback to update column state. */ updateColumnState: (columns: KanbanColumnData[]) => void; /** Child components. */ children: ReactNode; } /** * Result of parsing a drop target from a drag event */ interface DropTargetInfo { /** The ID of the column where the card should be dropped */ columnId: string; /** The position/index within the column */ position: number; /** The edge to drop relative to (undefined when dropping on empty column) */ edge: 'top' | 'bottom' | undefined; } /** * Parameters for validating a card move operation */ interface MoveCardValidationParams { cardId: string; targetColumnId: string; targetPosition: number; columns: KanbanColumnData[]; cardMap: Map; } /** * Result of validating a card move operation * Uses discriminated union to ensure type safety based on success/failure */ type MoveCardValidationResult = { /** Validation succeeded */ success: true; /** Adjusted target position (clamped to valid bounds) */ adjustedPosition: number; /** Source card information */ sourceInfo: { column: KanbanColumnData; card: KanbanCardData; index: number; }; /** Target column */ targetColumn: KanbanColumnData; /** Empty error array for success case */ errors: []; } | { /** Validation failed */ success: false; /** List of error messages describing validation failures */ errors: string[]; }; /** * Calculates which edge of a drop target is closest to the dragged item * @param over - The drop target from dnd-kit * @param active - The active dragged item from dnd-kit * @returns 'top' if the dragged item's center is above the midpoint, 'bottom' otherwise */ declare function calculateClosestEdge(over: DragEndEvent['over'], active: DragEndEvent['active']): 'top' | 'bottom'; /** * Parses a drag event to determine where a card should be dropped * @param event - The drag end event from dnd-kit * @returns Normalized drop target information or null if invalid drop */ declare function parseDropTarget(event: DragEndEvent): DropTargetInfo | null; /** * Calculates the insert index based on target position and drop edge. * @param targetPosition - The target position index. * @param closestEdge - The edge to drop relative to. * @returns The calculated insert index. */ declare const getInsertIndex: (targetPosition: number, closestEdge?: "top" | "bottom") => number; /** * Validates all parameters for a card move operation * @param params - Validation parameters * @returns Validation result with success flag, adjusted values, and errors */ declare function validateMoveCard({ cardId, targetColumnId, targetPosition, columns, cardMap }: MoveCardValidationParams): MoveCardValidationResult; /** * KanbanProvider - Context provider for Kanban state management * * Manages column and card state, handles drag-and-drop operations, * and provides the moveCard function for card movements. * * @param props - {@link KanbanProviderProps} * @param props.children - Child components. * @param props.columns - Array of column data. * @param props.updateColumnState - Callback to update column state. * @returns The rendered KanbanProvider component. * * @example * ```tsx * * ... * * ``` */ declare const KanbanProvider: ({ children, columns, updateColumnState }: KanbanProviderProps) => react_jsx_runtime105.JSX.Element; /** * Hook to access Kanban context values. * Must be used within a KanbanProvider. * @returns The Kanban context data. */ declare const useKanban: () => KanbanContextData; //#endregion export { DropTargetInfo, KanbanContextData, KanbanProvider, KanbanProviderProps, MoveCard, MoveCardValidationParams, MoveCardValidationResult, calculateClosestEdge, getInsertIndex, parseDropTarget, useKanban, validateMoveCard }; //# sourceMappingURL=context.d.ts.map