react-chessboard-expandable
Version:
A fork of the react-chessboard library to support an expandable chessboard
85 lines (84 loc) • 4.61 kB
TypeScript
import { ReactNode } from "react";
import { BoardPosition, ChessboardProps, CustomPieces, Piece, Square, Arrow, Move } from "../types";
import { BoardStateInterface } from "../boardState";
interface ChessboardProviderProps extends ChessboardProps {
boardWidth: number;
children: ReactNode;
}
type Premove = {
sourceSq: Square;
targetSq: Square;
piece: Piece;
};
type RequiredChessboardProps = Required<ChessboardProps>;
interface ChessboardProviderContext {
allowDragOutsideBoard: RequiredChessboardProps["allowDragOutsideBoard"];
animationDuration: RequiredChessboardProps["animationDuration"];
arePiecesDraggable: RequiredChessboardProps["arePiecesDraggable"];
arePremovesAllowed: RequiredChessboardProps["arePremovesAllowed"];
autoPromoteToQueen: RequiredChessboardProps["autoPromoteToQueen"];
boardOrientation: RequiredChessboardProps["boardOrientation"];
boardWidth: RequiredChessboardProps["boardWidth"];
customArrowColor: RequiredChessboardProps["customArrowColor"];
customBoardStyle: ChessboardProps["customBoardStyle"];
customNotationStyle: ChessboardProps["customNotationStyle"];
customDarkSquareStyle: RequiredChessboardProps["customDarkSquareStyle"];
customDropSquareStyle: RequiredChessboardProps["customDropSquareStyle"];
customLightSquareStyle: RequiredChessboardProps["customLightSquareStyle"];
customPremoveDarkSquareStyle: RequiredChessboardProps["customPremoveDarkSquareStyle"];
customPremoveLightSquareStyle: RequiredChessboardProps["customPremoveLightSquareStyle"];
customSquare: RequiredChessboardProps["customSquare"];
customSquareStyles: ChessboardProps["customSquareStyles"];
dropOffBoardAction: ChessboardProps["dropOffBoardAction"];
id: RequiredChessboardProps["id"];
isDraggablePiece: RequiredChessboardProps["isDraggablePiece"];
onDragOverSquare: RequiredChessboardProps["onDragOverSquare"];
onMouseOutSquare: RequiredChessboardProps["onMouseOutSquare"];
onMouseOverSquare: RequiredChessboardProps["onMouseOverSquare"];
onPieceClick: RequiredChessboardProps["onPieceClick"];
onPieceDragBegin: RequiredChessboardProps["onPieceDragBegin"];
onPieceDragEnd: RequiredChessboardProps["onPieceDragEnd"];
onPieceDrop: RequiredChessboardProps["onPieceDrop"];
onPieceDropOffBoard: ChessboardProps["onPieceDropOffBoard"];
onPromotionCheck: RequiredChessboardProps["onPromotionCheck"];
onPromotionPieceSelect: RequiredChessboardProps["onPromotionPieceSelect"];
onSparePieceDrop: ChessboardProps["onSparePieceDrop"];
onSquareClick: RequiredChessboardProps["onSquareClick"];
promotionDialogVariant: RequiredChessboardProps["promotionDialogVariant"];
showBoardNotation: RequiredChessboardProps["showBoardNotation"];
snapToCursor: RequiredChessboardProps["snapToCursor"];
arrows: Arrow[];
chessPieces: CustomPieces | Record<string, ReactNode>;
clearArrows: () => void;
clearCurrentRightClickDown: () => void;
currentPosition: BoardPosition;
currentRightClickDown?: Square;
deletePieceFromSquare: (sq: Square) => void;
drawNewArrow: (from: Square, to: Square) => void;
handleSetPosition: (move: Move, wasManualDropOverride?: boolean) => void;
handleSparePieceDrop: (piece: Piece, targetSq: Square) => void;
isWaitingForAnimation: boolean;
lastPieceColour: string | undefined;
lastSquareDraggedOver: Square | null;
newArrow?: Arrow;
onArrowDrawEnd: (from: Square, to: Square) => void;
onRightClickDown: (square: Square) => void;
onRightClickUp: (square: Square) => void;
positionDifferences: {
added: BoardPosition;
removed: BoardPosition;
};
premoves: Premove[];
promoteFromSquare: Square | null;
promoteToSquare: Square | null;
setLastSquareDraggedOver: React.Dispatch<React.SetStateAction<Square | null>>;
setPromoteFromSquare: React.Dispatch<React.SetStateAction<Square | null>>;
setPromoteToSquare: React.Dispatch<React.SetStateAction<Square | null>>;
setShowPromoteDialog: React.Dispatch<React.SetStateAction<boolean>>;
showPromoteDialog: boolean;
boardState: BoardStateInterface;
}
export declare const ChessboardContext: import("react").Context<ChessboardProviderContext>;
export declare const useChessboard: () => ChessboardProviderContext;
export declare const ChessboardProvider: import("react").ForwardRefExoticComponent<Omit<ChessboardProviderProps, "ref"> & import("react").RefAttributes<unknown>>;
export {};