UNPKG

@react-chess-tools/react-chess-puzzle

Version:

A lightweight, customizable React component library for rendering and interacting with chess puzzles.

58 lines (48 loc) 1.63 kB
import * as React from 'react'; import React__default from 'react'; import { ChessGame } from '@react-chess-tools/react-chess-game'; type Status = "not-started" | "in-progress" | "solved" | "failed"; type Hint = "none" | "piece" | "move"; type Puzzle = { fen: string; moves: string[]; makeFirstMove?: boolean; }; interface HintProps { asChild?: boolean; showOn?: Status[]; } interface ResetProps { asChild?: boolean; puzzle?: Puzzle; onReset?: (puzzleContext: ChessPuzzleContextType) => void; showOn?: Status[]; } interface PuzzleBoardProps extends React__default.ComponentProps<typeof ChessGame.Board> { } type ChessPuzzleContextType = { status: Status; changePuzzle: (puzzle: Puzzle) => void; resetPuzzle: () => void; puzzle: Puzzle; hint: Hint; nextMove?: string | null; isPlayerTurn: boolean; onHint: () => void; puzzleState: Status; movesPlayed: number; totalMoves: number; }; interface RootProps { puzzle: Puzzle; onSolve?: (puzzleContext: ChessPuzzleContextType) => void; onFail?: (puzzleContext: ChessPuzzleContextType) => void; } declare const ChessPuzzle: { Root: React.FC<React.PropsWithChildren<RootProps>>; Board: React.FC<PuzzleBoardProps>; Reset: React.FC<React.PropsWithChildren<ResetProps>>; Hint: React.FC<React.PropsWithChildren<HintProps>>; }; declare const useChessPuzzleContext: () => ChessPuzzleContextType; export { ChessPuzzle, type ChessPuzzleContextType, type Hint, type HintProps, type Puzzle, type PuzzleBoardProps, type ResetProps, type RootProps, type Status, useChessPuzzleContext };