Skip to content

Commit

Permalink
1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Clariity committed Apr 23, 2022
1 parent 8f4913c commit 7bbd8ba
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 85 deletions.
2 changes: 1 addition & 1 deletion package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ For more advanced code usage examples, please see example boards shown in [`exam
| onPieceClick | function: (piece) => {} | | User function that is run when piece is clicked. |
| onPieceDragBegin | function: (piece, sourceSquare) => {} | | User function that is run when piece is grabbed to start dragging. |
| onPieceDragEnd | function: (piece, sourceSquare) => {} | | User function that is run when piece is let go after dragging. |
| onPieceDrop | function: (sourceSquare, targetSquare, piece) => true | returns [true, false] | User function that is run when piece is dropped on a square. Must return whether the move was successful or not. |
| onPieceDrop | function: (sourceSquare, targetSquare, piece) => true | returns [true, false] | User function that is run when piece is dropped on a square. Must return whether the move was successful or not. This return value does not control whether or not the piece was placed (as that is controlled by the `position` prop) but instead controls premove logic. |
| onSquareClick | function: (square) => {} | | User function that is run when a square is clicked. |
| onSquareRightClick | function: (square) => {} | | User function that is run when a square is right clicked. |
| position | string: 'start' | ['start', FEN string, { e5: 'wK', e4: 'wP', ... }] | FEN string or position object notating where the chess pieces are on the board. Start position can also be notated with the string: 'start'. |
Expand Down
16 changes: 8 additions & 8 deletions package/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReactElement, CSSProperties, RefObject } from 'react';
import { BackendFactory } from 'dnd-core';

export type Square =
type Square =
| 'a8'
| 'b8'
| 'c8'
Expand Down Expand Up @@ -67,31 +67,31 @@ export type Square =
| 'g1'
| 'h1';

export type Pieces = 'wP' | 'wB' | 'wN' | 'wR' | 'wQ' | 'wK' | 'bP' | 'bB' | 'bN' | 'bR' | 'bQ' | 'bK';
type Pieces = 'wP' | 'wB' | 'wN' | 'wR' | 'wQ' | 'wK' | 'bP' | 'bB' | 'bN' | 'bR' | 'bQ' | 'bK';

export interface CustomPieceFnArgs {
interface CustomPieceFnArgs {
isDragging: boolean;
squareWidth: number;
droppedPiece: Pieces;
targetSquare: Square;
sourceSquare: Square;
}

export type CustomPieceFn = (args: CustomPieceFnArgs) => ReactElement;
type CustomPieceFn = (args: CustomPieceFnArgs) => ReactElement;

export type CustomPieces = {
type CustomPieces = {
[key in Pieces]?: CustomPieceFn;
};

export type CustomSquareStyles = {
type CustomSquareStyles = {
[key in Square]?: CSSProperties;
};

type CurrentPosition = {
[key in Square]: Pieces;
};

export interface ChessBoardProps {
interface ChessBoardProps {
/**
* Time in milliseconds for piece to slide to target square. Only used when the position is programmatically changed. If a new position is set before the animation is complete, the board will cancel the current animation and snap to the new position.
*/
Expand Down Expand Up @@ -235,4 +235,4 @@ export interface ChessBoardProps {
}
declare function Chessboard(props: ChessBoardProps): ReactElement;

export { Chessboard };
export { ChessBoardProps, Chessboard, CurrentPosition, CustomPieceFn, CustomPieceFnArgs, CustomPieces, CustomSquareStyles, Pieces, Square };
2 changes: 1 addition & 1 deletion package/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-chessboard",
"version": "1.2.2",
"version": "1.2.3",
"repository": "https://github.com/Clariity/react-chessboard",
"author": "Ryan Gregory <ryangregory.dev@outlook.com>",
"license": "MIT",
Expand Down
81 changes: 74 additions & 7 deletions package/src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,97 @@
import { CSSProperties, ReactElement, RefObject } from 'react';
import { BackendFactory } from 'dnd-core';
import { Pieces, Square } from './options';

interface CustomPieceFnArgs {
export type Square =
| 'a8'
| 'b8'
| 'c8'
| 'd8'
| 'e8'
| 'f8'
| 'g8'
| 'h8'
| 'a7'
| 'b7'
| 'c7'
| 'd7'
| 'e7'
| 'f7'
| 'g7'
| 'h7'
| 'a6'
| 'b6'
| 'c6'
| 'd6'
| 'e6'
| 'f6'
| 'g6'
| 'h6'
| 'a5'
| 'b5'
| 'c5'
| 'd5'
| 'e5'
| 'f5'
| 'g5'
| 'h5'
| 'a4'
| 'b4'
| 'c4'
| 'd4'
| 'e4'
| 'f4'
| 'g4'
| 'h4'
| 'a3'
| 'b3'
| 'c3'
| 'd3'
| 'e3'
| 'f3'
| 'g3'
| 'h3'
| 'a2'
| 'b2'
| 'c2'
| 'd2'
| 'e2'
| 'f2'
| 'g2'
| 'h2'
| 'a1'
| 'b1'
| 'c1'
| 'd1'
| 'e1'
| 'f1'
| 'g1'
| 'h1';

export type Pieces = 'wP' | 'wB' | 'wN' | 'wR' | 'wQ' | 'wK' | 'bP' | 'bB' | 'bN' | 'bR' | 'bQ' | 'bK';

export interface CustomPieceFnArgs {
isDragging: boolean;
squareWidth: number;
droppedPiece: Pieces;
targetSquare: Square;
sourceSquare: Square;
}

type CustomPieceFn = (args: CustomPieceFnArgs) => ReactElement;
export type CustomPieceFn = (args: CustomPieceFnArgs) => ReactElement;

type CustomPieces = {
export type CustomPieces = {
[key in Pieces]?: CustomPieceFn;
};

type CustomSquareStyles = {
export type CustomSquareStyles = {
[key in Square]?: CSSProperties;
};

type CurrentPosition = {
export type CurrentPosition = {
[key in Square]: Pieces;
};

interface ChessBoardProps {
export interface ChessBoardProps {
/**
* Time in milliseconds for piece to slide to target square. Only used when the position is programmatically changed. If a new position is set before the animation is complete, the board will cancel the current animation and snap to the new position.
*/
Expand Down
67 changes: 0 additions & 67 deletions package/src/types/options.d.ts

This file was deleted.

1 comment on commit 7bbd8ba

@vercel
Copy link

@vercel vercel bot commented on 7bbd8ba Apr 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.