react-xiangqiboard
Version:
A simple Xiangqi Board for React. Inspired and adapted from the unmaintained Chessboard.jsx. A fork of react-chessboard.
64 lines (63 loc) • 3.54 kB
TypeScript
import { ReactNode } from "react";
import { BoardPosition, ChessboardProps, CustomPieces, Piece, Square, Arrow } from "../types";
interface ChessboardProviderProps extends ChessboardProps {
boardWidth: number;
children: ReactNode;
}
type RequiredChessboardProps = Required<ChessboardProps>;
interface ChessboardProviderContext {
allowDragOutsideBoard: RequiredChessboardProps["allowDragOutsideBoard"];
animationDuration: RequiredChessboardProps["animationDuration"];
arePiecesDraggable: RequiredChessboardProps["arePiecesDraggable"];
boardOrientation: RequiredChessboardProps["boardOrientation"];
boardWidth: RequiredChessboardProps["boardWidth"];
customArrowColor: RequiredChessboardProps["customArrowColor"];
customBoardStyle: ChessboardProps["customBoardStyle"];
customNotationStyle: ChessboardProps["customNotationStyle"];
customDarkSquareStyle: RequiredChessboardProps["customDarkSquareStyle"];
customDropSquareStyle: RequiredChessboardProps["customDropSquareStyle"];
customLightSquareStyle: RequiredChessboardProps["customLightSquareStyle"];
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"];
onSparePieceDrop: ChessboardProps["onSparePieceDrop"];
onSquareClick: RequiredChessboardProps["onSquareClick"];
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: (sourceSq: Square, targetSq: Square, piece: Piece, 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;
};
setLastSquareDraggedOver: React.Dispatch<React.SetStateAction<Square | null>>;
}
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 {};