react-chessboard-ui 1.7.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChessBoard/ChessBoard.d.ts +3 -2
- package/dist/ChessBoard/ChessBoardCellsLayout.d.ts +3 -2
- package/dist/ChessBoard/ChessBoardControlLayout.d.ts +8 -8
- package/dist/ChessBoard/ChessBoardInteractiveLayout.d.ts +7 -7
- package/dist/ChessBoard/FigurePicker.d.ts +3 -3
- package/dist/ChessBoard/constants.d.ts +16 -8
- package/dist/ChessBoard/utils.d.ts +9 -9
- package/dist/JSChessEngine/JSChessEngine.d.ts +4 -0
- package/dist/index.css +26 -16
- package/dist/index.js +72 -70
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +72 -70
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PieceColor, GameResult, MoveData, SquarePos } from "../JSChessEngine";
|
|
2
2
|
import { FC } from "react";
|
|
3
3
|
import { ChangeMove, ChessBoardConfig } from "./models";
|
|
4
4
|
declare type ChessBoardProps = {
|
|
@@ -8,8 +8,9 @@ declare type ChessBoardProps = {
|
|
|
8
8
|
change?: ChangeMove;
|
|
9
9
|
reversed?: boolean;
|
|
10
10
|
config?: Partial<ChessBoardConfig>;
|
|
11
|
-
playerColor?:
|
|
11
|
+
playerColor?: PieceColor;
|
|
12
12
|
viewOnly?: boolean;
|
|
13
|
+
moveHighlight?: [SquarePos, SquarePos];
|
|
13
14
|
};
|
|
14
15
|
export declare const ChessBoard: FC<ChessBoardProps>;
|
|
15
16
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { ChessBoardConfig } from "./models";
|
|
3
|
-
import {
|
|
3
|
+
import { SquarePos } from "../JSChessEngine";
|
|
4
4
|
declare type ChessBoardCellsLayoutProps = {
|
|
5
5
|
boardConfig: ChessBoardConfig;
|
|
6
6
|
size?: number;
|
|
7
|
-
movesTrail?: [
|
|
7
|
+
movesTrail?: [SquarePos, SquarePos];
|
|
8
|
+
moveHighlight?: [SquarePos, SquarePos];
|
|
8
9
|
};
|
|
9
10
|
export declare const ChessBoardCellsLayout: FC<ChessBoardCellsLayoutProps>;
|
|
10
11
|
export {};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { SquarePos } from "../JSChessEngine";
|
|
3
3
|
import { ChessBoardConfig } from "./models";
|
|
4
4
|
declare type ChessBoardControlLayoutProps = {
|
|
5
5
|
size?: number;
|
|
6
6
|
boardConfig: ChessBoardConfig;
|
|
7
|
-
onClick: (position:
|
|
8
|
-
onGrabStart: (position:
|
|
9
|
-
onGrabStartRight: (position:
|
|
10
|
-
onGrabEnd: (position:
|
|
11
|
-
onGrabEndRight: (position:
|
|
7
|
+
onClick: (position: SquarePos) => void;
|
|
8
|
+
onGrabStart: (position: SquarePos) => void;
|
|
9
|
+
onGrabStartRight: (position: SquarePos) => void;
|
|
10
|
+
onGrabEnd: (position: SquarePos) => void;
|
|
11
|
+
onGrabEndRight: (position: SquarePos) => void;
|
|
12
12
|
onGrabbing: (x: number, y: number) => void;
|
|
13
|
-
onRightClick: (position:
|
|
14
|
-
onGrabbingCell: (position:
|
|
13
|
+
onRightClick: (position: SquarePos) => void;
|
|
14
|
+
onGrabbingCell: (position: SquarePos) => void;
|
|
15
15
|
};
|
|
16
16
|
export declare const ChessBoardControlLayout: FC<ChessBoardControlLayoutProps>;
|
|
17
17
|
export {};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { SquarePos, Piece } from "../JSChessEngine";
|
|
3
3
|
import { ChessBoardConfig } from "./models";
|
|
4
4
|
declare type ChessBoardInteractiveLayoutProps = {
|
|
5
5
|
size?: number;
|
|
6
6
|
boardConfig: ChessBoardConfig;
|
|
7
|
-
selectedPos:
|
|
8
|
-
possibleMoves:
|
|
9
|
-
markedCells:
|
|
10
|
-
holdedFigure?:
|
|
11
|
-
grabbingPos:
|
|
12
|
-
onHasCheck: (cellPos:
|
|
7
|
+
selectedPos: SquarePos;
|
|
8
|
+
possibleMoves: SquarePos[];
|
|
9
|
+
markedCells: SquarePos[];
|
|
10
|
+
holdedFigure?: Piece;
|
|
11
|
+
grabbingPos: SquarePos;
|
|
12
|
+
onHasCheck: (cellPos: SquarePos) => boolean;
|
|
13
13
|
};
|
|
14
14
|
export declare const ChessBoardInteractiveLayout: FC<ChessBoardInteractiveLayoutProps>;
|
|
15
15
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Piece, PieceColor } from '../JSChessEngine';
|
|
3
3
|
import { ChessBoardConfig } from './models';
|
|
4
4
|
interface FigurePickerProps {
|
|
5
5
|
boardConfig: ChessBoardConfig;
|
|
6
|
-
color:
|
|
6
|
+
color: PieceColor;
|
|
7
7
|
forPawnTransform?: boolean;
|
|
8
|
-
onSelect: (figure:
|
|
8
|
+
onSelect: (figure: Piece) => void;
|
|
9
9
|
}
|
|
10
10
|
export declare const FigurePicker: FC<FigurePickerProps>;
|
|
11
11
|
export {};
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Piece } from "../JSChessEngine";
|
|
2
2
|
import { ChessBoardConfig } from "./models";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const DEFAULT_FIGURE_SIZE_PERCENT = 80;
|
|
5
|
-
export declare const FACTOR_FOR_SIZE_CIRCLE_MARK = 4.6;
|
|
3
|
+
export declare const DEFAULT_FACTOR_FOR_SIZE_CIRCLE_MARK = 4.6;
|
|
6
4
|
export declare const DEFAULT_CIRCLE_MARK_COLOR = "#3697ce";
|
|
7
|
-
export declare const DEFAULT_WHITE_CELL_COLOR
|
|
8
|
-
export declare const DEFAULT_BLACK_CELL_COLOR
|
|
5
|
+
export declare const DEFAULT_WHITE_CELL_COLOR: string;
|
|
6
|
+
export declare const DEFAULT_BLACK_CELL_COLOR: string;
|
|
9
7
|
export declare const DEFAULT_SELECTED_CELL_COLOR = "#e3f1fe";
|
|
10
8
|
export declare const DEFAULT_SELECTED_CELL_BORDER = "3px solid #6ac2fd";
|
|
11
9
|
export declare const DEFAULT_ARROW_COLOR = "#6ac2fd";
|
|
12
10
|
export declare const DEFAULT_MARKED_CELL_COLOR = "#3697ce";
|
|
13
11
|
export declare const DEFAULT_CHECKED_CELL_COLOR = "#e95b5c";
|
|
14
12
|
export declare const DEFAULT_PIECES_MAP: import("./models").ChessPiecesMap;
|
|
15
|
-
export declare const DEFAULT_CSS_HIDE_PIECES_EFFECT: string;
|
|
16
13
|
export declare const DEFAULT_SHOW_MOVES_TRAIL = true;
|
|
17
|
-
export declare const DEFAULT_HIDE_PIECES_HANDLER: (figure:
|
|
14
|
+
export declare const DEFAULT_HIDE_PIECES_HANDLER: (figure: Piece) => void;
|
|
15
|
+
export declare const DEFAULT_SQUARE_SIZE = 92;
|
|
16
|
+
export declare const DEFAULT_PIECE_SIZE_PERCENT = 80;
|
|
17
|
+
export declare const DEFAULT_HIDE_PIECE_EFFECT_CLASS_NAME: string;
|
|
18
|
+
export declare const DEFAULT_LIGHT_SQUARE_CLASS_NAME: string;
|
|
19
|
+
export declare const DEFAULT_DARK_SQUARE_CLASS_NAME: string;
|
|
20
|
+
export declare const DEFAULT_PICKED_SQUARE_CLASS_NAME: string;
|
|
21
|
+
export declare const DEFAULT_CHECKED_SQUARE_CLASS_NAME: string;
|
|
22
|
+
export declare const DEFAULT_SQUARE_HIGLIGHT_CLASS_NAME: string;
|
|
23
|
+
export declare const DEFAULT_SELECTED_SQUARE_CLASS_NAME: string;
|
|
24
|
+
export declare const DEFAULT_HOLDED_PIECE_CLASS_NAME: string;
|
|
25
|
+
export declare const DEFAULT_POSSIBLE_MOVE_MARK_CLASS_NAME: string;
|
|
18
26
|
export declare const DEFAULT_CHESSBORD_CONFIG: ChessBoardConfig;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Cell,
|
|
1
|
+
import { Cell, SquarePos, Piece, PieceColor, MoveData } from "../JSChessEngine";
|
|
2
2
|
import { ChessBoardConfig } from "./models";
|
|
3
3
|
/**
|
|
4
4
|
* Возвращает класс для фигуры в клетке
|
|
5
5
|
*/
|
|
6
|
-
export declare const getFigureCSS: (figure:
|
|
6
|
+
export declare const getFigureCSS: (figure: Piece) => string;
|
|
7
7
|
/**
|
|
8
8
|
* Возвращает белая ли клетка
|
|
9
9
|
*/
|
|
@@ -16,20 +16,20 @@ export declare const getFilledArrayBySize: (size: number) => number[];
|
|
|
16
16
|
* Возвращает только массив фигурам у которых
|
|
17
17
|
* есть поле position
|
|
18
18
|
*/
|
|
19
|
-
export declare const mapCellsToFiguresArray: (boardState: Cell[][]) =>
|
|
19
|
+
export declare const mapCellsToFiguresArray: (boardState: Cell[][]) => Piece[];
|
|
20
20
|
/**
|
|
21
21
|
*
|
|
22
22
|
* @param possibleMoves Список возможных ходов
|
|
23
23
|
* @param position позиция для проверки
|
|
24
24
|
*/
|
|
25
|
-
export declare const checkIsPossibleMove: (possibleMoves:
|
|
25
|
+
export declare const checkIsPossibleMove: (possibleMoves: SquarePos[], position: import("../JSChessEngine").CellPos) => boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Проверяет находится ли проверяемая позиция в
|
|
28
28
|
* наборе позиций
|
|
29
29
|
* @param positions набор позиций
|
|
30
30
|
* @param pos позиция
|
|
31
31
|
*/
|
|
32
|
-
export declare const checkPositionsHas: (positions:
|
|
32
|
+
export declare const checkPositionsHas: (positions: SquarePos[] | undefined, pos: import("../JSChessEngine").CellPos) => boolean;
|
|
33
33
|
/**
|
|
34
34
|
* Проверяет, является ли ход рокеровкой
|
|
35
35
|
* @param moveData
|
|
@@ -39,7 +39,7 @@ export declare const checkIsCastlingMove: (moveData: MoveData) => boolean;
|
|
|
39
39
|
/**
|
|
40
40
|
* Проверка клетки, на то есть ли шах
|
|
41
41
|
*/
|
|
42
|
-
export declare const hasCheck: (cell: Cell, currentColor:
|
|
42
|
+
export declare const hasCheck: (cell: Cell, currentColor: PieceColor, linesWithCheck: SquarePos[][]) => boolean;
|
|
43
43
|
export declare const degrees: (a: number, b: number) => number;
|
|
44
44
|
export declare const calcAngle: (start: number[], end: number[]) => number;
|
|
45
45
|
export declare const getChessBoardConfig: (config: Partial<ChessBoardConfig> | undefined) => ChessBoardConfig;
|
|
@@ -48,16 +48,16 @@ export declare const getChessBoardConfig: (config: Partial<ChessBoardConfig> | u
|
|
|
48
48
|
* @param color цвет фигур
|
|
49
49
|
* @param forPawnTransform только фигуры для превращения пешки
|
|
50
50
|
*/
|
|
51
|
-
export declare const getFiguresByColor: (color:
|
|
51
|
+
export declare const getFiguresByColor: (color: PieceColor, forPawnTransform?: boolean) => Piece[];
|
|
52
52
|
/**
|
|
53
53
|
* Корректирует позицию захвата курсором
|
|
54
54
|
* коррекция происходит по сроллу
|
|
55
55
|
*/
|
|
56
|
-
export declare const correctGrabbingPosByScroll: (pos: CellPos) => CellPos;
|
|
56
|
+
export declare const correctGrabbingPosByScroll: (pos: import("../JSChessEngine").CellPos) => import("../JSChessEngine").CellPos;
|
|
57
57
|
/**
|
|
58
58
|
* Корректирует указатели стрелки
|
|
59
59
|
*/
|
|
60
|
-
export declare const correctGrabbingPosForArrow: (pos: CellPos, boardConfig: ChessBoardConfig) => CellPos;
|
|
60
|
+
export declare const correctGrabbingPosForArrow: (pos: import("../JSChessEngine").CellPos, boardConfig: ChessBoardConfig) => import("../JSChessEngine").CellPos;
|
|
61
61
|
/**
|
|
62
62
|
* Создание тэга для хранение состояния
|
|
63
63
|
* разворота доски
|
|
@@ -7,6 +7,10 @@ export interface Figure {
|
|
|
7
7
|
touched?: boolean;
|
|
8
8
|
position?: CellPos;
|
|
9
9
|
}
|
|
10
|
+
export declare type Piece = Figure;
|
|
11
|
+
export declare type PieceColor = FigureColor;
|
|
12
|
+
export declare type SquarePos = CellPos;
|
|
13
|
+
export declare type PieceType = FigureType;
|
|
10
14
|
export declare type CellColor = 'white' | 'black';
|
|
11
15
|
export interface Cell {
|
|
12
16
|
figure?: Figure;
|
package/dist/index.css
CHANGED
|
@@ -44,11 +44,19 @@
|
|
|
44
44
|
z-index: 5;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.
|
|
47
|
+
._1YsOr {
|
|
48
48
|
box-sizing: border-box;
|
|
49
|
+
border: 3px solid #6ac2fd;
|
|
50
|
+
background-color: #e3f1fe;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
.
|
|
53
|
+
._3MMcp {
|
|
54
|
+
box-shadow: inset 0 0 30px #3697ce;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
._KLkVN {
|
|
58
|
+
box-shadow: inset 0 0 30px #e95b5c;
|
|
59
|
+
}
|
|
52
60
|
|
|
53
61
|
._27yHq {
|
|
54
62
|
display: flex;
|
|
@@ -59,17 +67,15 @@
|
|
|
59
67
|
._UYGA_ {
|
|
60
68
|
border-radius: 100%;
|
|
61
69
|
opacity: 0.8;
|
|
70
|
+
background-color: #3697ce;
|
|
71
|
+
pointer-events: all;
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
._2XKSc {
|
|
65
75
|
display: flex;
|
|
66
76
|
}
|
|
67
77
|
|
|
68
|
-
.
|
|
69
|
-
|
|
70
|
-
._1407I {}
|
|
71
|
-
|
|
72
|
-
._19mE- {
|
|
78
|
+
._2QHnf {
|
|
73
79
|
position: absolute;
|
|
74
80
|
display: flex;
|
|
75
81
|
justify-content: center;
|
|
@@ -84,11 +90,11 @@
|
|
|
84
90
|
-webkit-user-drag: none;
|
|
85
91
|
}
|
|
86
92
|
|
|
87
|
-
.
|
|
93
|
+
._3z25q {
|
|
88
94
|
transition: none;
|
|
89
95
|
}
|
|
90
96
|
|
|
91
|
-
.
|
|
97
|
+
._10meo {
|
|
92
98
|
opacity: .4;
|
|
93
99
|
}
|
|
94
100
|
|
|
@@ -97,10 +103,6 @@
|
|
|
97
103
|
transform: rotate(-90deg);
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
._Zly-L {}
|
|
101
|
-
|
|
102
|
-
._31pmr {}
|
|
103
|
-
|
|
104
106
|
._12Bbd {
|
|
105
107
|
position: absolute;
|
|
106
108
|
width: 20px;
|
|
@@ -121,18 +123,18 @@
|
|
|
121
123
|
transform: rotate(90deg);
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
.
|
|
126
|
+
._3gVhA {
|
|
125
127
|
display: flex;
|
|
126
128
|
justify-content: center;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
|
-
.
|
|
131
|
+
._3EtmA {
|
|
130
132
|
background-position: center;
|
|
131
133
|
background-size: cover;
|
|
132
134
|
cursor: pointer;
|
|
133
135
|
}
|
|
134
136
|
|
|
135
|
-
.
|
|
137
|
+
._2xZM1 {
|
|
136
138
|
z-index: 101;
|
|
137
139
|
position: absolute;
|
|
138
140
|
top: 0;
|
|
@@ -152,3 +154,11 @@
|
|
|
152
154
|
box-shadow: inset 0 0 11px #3697ce80 !important;
|
|
153
155
|
background-color: #B8E6FE;
|
|
154
156
|
}
|
|
157
|
+
|
|
158
|
+
._1B0qo {
|
|
159
|
+
background-color: #fafafc;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
._1NBqS {
|
|
163
|
+
background-color: #d8d9e6;
|
|
164
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1675,7 +1675,7 @@ var stateToFEN = function stateToFEN(state, currentColor, countMoves) {
|
|
|
1675
1675
|
return positionsFEN + " " + colorFEN + " " + casttlingFEN + " " + beatedFieldFEN + " " + blackMoves + " " + countMoves;
|
|
1676
1676
|
};
|
|
1677
1677
|
|
|
1678
|
-
var styles = {"chessBoard":"_3XI6H","figuresLayout":"_2SyRK","controlLayout":"_3OVc8","controlLayoutGrabbing":"_G0IIl","interactiveLayout":"_3THn5","
|
|
1678
|
+
var styles = {"chessBoard":"_3XI6H","figuresLayout":"_2SyRK","controlLayout":"_3OVc8","controlLayoutGrabbing":"_G0IIl","interactiveLayout":"_3THn5","selectedSquare":"_1YsOr","pickedSquare":"_3MMcp","checkedSquare":"_KLkVN","interactiveCell":"_27yHq","possibleMoveMark":"_UYGA_","row":"_2XKSc","piece":"_2QHnf","holdedPiece":"_3z25q","bluredPiece":"_10meo","hiddenFigureEffect":"_2YKzU","arrow":"_12Bbd","arrowEnd":"_1BC3I","piecePicker":"_3gVhA","piecePickerItem":"_3EtmA","chessBoardPiecePicker":"_2xZM1","movesTrail":"_1RqCc","lightSquare":"_1B0qo","darkSquare":"_1NBqS"};
|
|
1679
1679
|
|
|
1680
1680
|
var CHESS_PIECES_MAP = {
|
|
1681
1681
|
'pawn-white': function pawnWhite(size) {
|
|
@@ -1877,36 +1877,41 @@ var CHESS_PIECES_MAP = {
|
|
|
1877
1877
|
}
|
|
1878
1878
|
};
|
|
1879
1879
|
|
|
1880
|
-
var
|
|
1881
|
-
var DEFAULT_FIGURE_SIZE_PERCENT = 80;
|
|
1882
|
-
var FACTOR_FOR_SIZE_CIRCLE_MARK = 4.6;
|
|
1880
|
+
var DEFAULT_FACTOR_FOR_SIZE_CIRCLE_MARK = 4.6;
|
|
1883
1881
|
var DEFAULT_CIRCLE_MARK_COLOR = '#3697ce';
|
|
1884
|
-
var DEFAULT_WHITE_CELL_COLOR = '#fafafc';
|
|
1885
|
-
var DEFAULT_BLACK_CELL_COLOR = '#d8d9e6';
|
|
1886
|
-
var DEFAULT_SELECTED_CELL_COLOR = '#e3f1fe';
|
|
1887
|
-
var DEFAULT_SELECTED_CELL_BORDER = '3px solid #6ac2fd';
|
|
1888
1882
|
var DEFAULT_ARROW_COLOR = '#6ac2fd';
|
|
1889
|
-
var DEFAULT_MARKED_CELL_COLOR = '#3697ce';
|
|
1890
|
-
var DEFAULT_CHECKED_CELL_COLOR = '#e95b5c';
|
|
1891
1883
|
var DEFAULT_PIECES_MAP = CHESS_PIECES_MAP;
|
|
1892
|
-
var DEFAULT_CSS_HIDE_PIECES_EFFECT = styles.hiddenFigureEffect;
|
|
1893
1884
|
var DEFAULT_SHOW_MOVES_TRAIL = true;
|
|
1894
1885
|
var DEFAULT_HIDE_PIECES_HANDLER = function DEFAULT_HIDE_PIECES_HANDLER(figure) {
|
|
1895
1886
|
figure.color === 'white' ? figure.position = [8, figure.position[1]] : figure.position = [-1, figure.position[1]];
|
|
1896
1887
|
};
|
|
1888
|
+
var DEFAULT_SQUARE_SIZE = 92;
|
|
1889
|
+
var DEFAULT_PIECE_SIZE_PERCENT = 80;
|
|
1890
|
+
var DEFAULT_HIDE_PIECE_EFFECT_CLASS_NAME = styles.hiddenFigureEffect;
|
|
1891
|
+
var DEFAULT_LIGHT_SQUARE_CLASS_NAME = undefined;
|
|
1892
|
+
var DEFAULT_DARK_SQUARE_CLASS_NAME = undefined;
|
|
1893
|
+
var DEFAULT_PICKED_SQUARE_CLASS_NAME = undefined;
|
|
1894
|
+
var DEFAULT_CHECKED_SQUARE_CLASS_NAME = undefined;
|
|
1895
|
+
var DEFAULT_SQUARE_HIGLIGHT_CLASS_NAME = undefined;
|
|
1896
|
+
var DEFAULT_SELECTED_SQUARE_CLASS_NAME = undefined;
|
|
1897
|
+
var DEFAULT_HOLDED_PIECE_CLASS_NAME = undefined;
|
|
1898
|
+
var DEFAULT_POSSIBLE_MOVE_MARK_CLASS_NAME = undefined;
|
|
1897
1899
|
var DEFAULT_CHESSBORD_CONFIG = {
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
+
squareSize: DEFAULT_SQUARE_SIZE,
|
|
1901
|
+
pieceSizePercent: DEFAULT_PIECE_SIZE_PERCENT,
|
|
1902
|
+
lightSquareClassName: DEFAULT_LIGHT_SQUARE_CLASS_NAME,
|
|
1903
|
+
darkSquareClassName: DEFAULT_DARK_SQUARE_CLASS_NAME,
|
|
1904
|
+
pickedSquareClassName: DEFAULT_PICKED_SQUARE_CLASS_NAME,
|
|
1905
|
+
selectedSquareClassName: DEFAULT_SELECTED_SQUARE_CLASS_NAME,
|
|
1906
|
+
holdedPieceClassName: DEFAULT_HOLDED_PIECE_CLASS_NAME,
|
|
1907
|
+
checkedSquareClassName: DEFAULT_CHECKED_SQUARE_CLASS_NAME,
|
|
1908
|
+
squareHighlightClassName: DEFAULT_SQUARE_HIGLIGHT_CLASS_NAME,
|
|
1900
1909
|
circleMarkColor: DEFAULT_CIRCLE_MARK_COLOR,
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
selectedCellColor: DEFAULT_SELECTED_CELL_COLOR,
|
|
1904
|
-
selectedCellBorder: DEFAULT_SELECTED_CELL_BORDER,
|
|
1910
|
+
factorForSizeCircleMark: DEFAULT_FACTOR_FOR_SIZE_CIRCLE_MARK,
|
|
1911
|
+
possibleMoveMarkClassName: DEFAULT_POSSIBLE_MOVE_MARK_CLASS_NAME,
|
|
1905
1912
|
arrowColor: DEFAULT_ARROW_COLOR,
|
|
1906
|
-
markedCellColor: DEFAULT_MARKED_CELL_COLOR,
|
|
1907
|
-
checkedCellColor: DEFAULT_CHECKED_CELL_COLOR,
|
|
1908
1913
|
piecesMap: DEFAULT_PIECES_MAP,
|
|
1909
|
-
|
|
1914
|
+
hidePieceEffectClassName: DEFAULT_HIDE_PIECE_EFFECT_CLASS_NAME,
|
|
1910
1915
|
showMovesTrail: DEFAULT_SHOW_MOVES_TRAIL,
|
|
1911
1916
|
onHidePieces: DEFAULT_HIDE_PIECES_HANDLER
|
|
1912
1917
|
};
|
|
@@ -1986,12 +1991,7 @@ var calcAngle = function calcAngle(start, end) {
|
|
|
1986
1991
|
};
|
|
1987
1992
|
var getChessBoardConfig = function getChessBoardConfig(config) {
|
|
1988
1993
|
if (!config) return DEFAULT_CHESSBORD_CONFIG;
|
|
1989
|
-
|
|
1990
|
-
var buildedConfig = {};
|
|
1991
|
-
configKeyes.forEach(function (key) {
|
|
1992
|
-
buildedConfig[key] = config[key] || DEFAULT_CHESSBORD_CONFIG[key];
|
|
1993
|
-
});
|
|
1994
|
-
return buildedConfig;
|
|
1994
|
+
return _extends({}, DEFAULT_CHESSBORD_CONFIG, config);
|
|
1995
1995
|
};
|
|
1996
1996
|
var getFiguresByColor = function getFiguresByColor(color, forPawnTransform) {
|
|
1997
1997
|
if (forPawnTransform === void 0) {
|
|
@@ -2021,7 +2021,7 @@ var correctGrabbingPosByScroll = function correctGrabbingPosByScroll(pos) {
|
|
|
2021
2021
|
return [pos[0] - window.scrollX, pos[1] - window.scrollY];
|
|
2022
2022
|
};
|
|
2023
2023
|
var correctGrabbingPosForArrow = function correctGrabbingPosForArrow(pos, boardConfig) {
|
|
2024
|
-
return [pos[0] * boardConfig.
|
|
2024
|
+
return [pos[0] * boardConfig.squareSize + (boardConfig.squareSize / 2 - 10), pos[1] * boardConfig.squareSize + boardConfig.squareSize / 2];
|
|
2025
2025
|
};
|
|
2026
2026
|
var createHtmlReversedStateHolder = function createHtmlReversedStateHolder() {
|
|
2027
2027
|
if (!window) return;
|
|
@@ -2045,21 +2045,25 @@ var ChessBoardCellsLayout = function ChessBoardCellsLayout(_ref) {
|
|
|
2045
2045
|
var _ref$size = _ref.size,
|
|
2046
2046
|
size = _ref$size === void 0 ? BASE_BOARD_SIZE : _ref$size,
|
|
2047
2047
|
boardConfig = _ref.boardConfig,
|
|
2048
|
-
movesTrail = _ref.movesTrail
|
|
2048
|
+
movesTrail = _ref.movesTrail,
|
|
2049
|
+
moveHighlight = _ref.moveHighlight;
|
|
2049
2050
|
return React__default.createElement("div", null, getFilledArrayBySize(size).map(function (_, j) {
|
|
2050
2051
|
return React__default.createElement("div", {
|
|
2051
2052
|
className: styles.row,
|
|
2052
2053
|
key: "cells-layout-" + j
|
|
2053
2054
|
}, getFilledArrayBySize(size).map(function (_, i) {
|
|
2055
|
+
var _cn;
|
|
2054
2056
|
return React__default.createElement("div", {
|
|
2055
2057
|
style: {
|
|
2056
|
-
width: boardConfig.
|
|
2057
|
-
height: boardConfig.
|
|
2058
|
-
backgroundColor: getIsLightCell(j, i) ? boardConfig.whiteCellColor : boardConfig.blackCellColor
|
|
2058
|
+
width: boardConfig.squareSize,
|
|
2059
|
+
height: boardConfig.squareSize
|
|
2059
2060
|
},
|
|
2061
|
+
className: cn((_cn = {}, _cn[styles.lightSquare] = !boardConfig.lightSquareClassName && getIsLightCell(j, i), _cn[styles.darkSquare] = !boardConfig.darkSquareClassName && !getIsLightCell(j, i), _cn[boardConfig.lightSquareClassName] = !!boardConfig.lightSquareClassName && getIsLightCell(j, i), _cn[boardConfig.darkSquareClassName] = !!boardConfig.darkSquareClassName && !getIsLightCell(j, i), _cn)),
|
|
2060
2062
|
key: "cells-layout-" + i
|
|
2061
2063
|
}, movesTrail && (movesTrail[0][0] === i && movesTrail[0][1] === j || movesTrail[1][0] === i && movesTrail[1][1] === j) && React__default.createElement("div", {
|
|
2062
|
-
className: styles.movesTrail
|
|
2064
|
+
className: cn(styles.movesTrail, boardConfig.squareHighlightClassName)
|
|
2065
|
+
}), moveHighlight && (moveHighlight[0][0] === i && moveHighlight[0][1] === j || moveHighlight[1][0] === i && moveHighlight[1][1] === j) && React__default.createElement("div", {
|
|
2066
|
+
className: cn(styles.movesTrail, boardConfig.squareHighlightClassName)
|
|
2063
2067
|
}));
|
|
2064
2068
|
}));
|
|
2065
2069
|
}));
|
|
@@ -2196,20 +2200,20 @@ var ChessBoardFiguresLayout = function ChessBoardFiguresLayout(props) {
|
|
|
2196
2200
|
});
|
|
2197
2201
|
}, [reversed, initialState]);
|
|
2198
2202
|
return React__default.createElement("div", {
|
|
2199
|
-
className: styles.
|
|
2203
|
+
className: styles.piecesLayout
|
|
2200
2204
|
}, actualState.map(function (figure, i) {
|
|
2201
2205
|
var _cn;
|
|
2202
2206
|
return React__default.createElement("div", {
|
|
2203
2207
|
key: i,
|
|
2204
|
-
className: cn([styles.
|
|
2208
|
+
className: cn([styles.piece], (_cn = {}, _cn[boardConfig.hidePieceEffectClassName] = figure.beated, _cn)),
|
|
2205
2209
|
style: {
|
|
2206
|
-
top: boardConfig.
|
|
2207
|
-
left: boardConfig.
|
|
2210
|
+
top: boardConfig.squareSize * figure.position[1] + "px",
|
|
2211
|
+
left: boardConfig.squareSize * figure.position[0] + "px",
|
|
2208
2212
|
transition: !!change && animated ? 'all .15s ease-out' : 'none',
|
|
2209
|
-
width: boardConfig.
|
|
2210
|
-
height: boardConfig.
|
|
2213
|
+
width: boardConfig.squareSize,
|
|
2214
|
+
height: boardConfig.squareSize
|
|
2211
2215
|
}
|
|
2212
|
-
}, boardConfig.piecesMap[getFigureCSS(figure)] && boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.
|
|
2216
|
+
}, boardConfig.piecesMap[getFigureCSS(figure)] && boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.pieceSizePercent + "%"));
|
|
2213
2217
|
}));
|
|
2214
2218
|
};
|
|
2215
2219
|
|
|
@@ -2283,8 +2287,8 @@ var ChessBoardControlLayout = function ChessBoardControlLayout(props) {
|
|
|
2283
2287
|
key: "control-layout-" + i,
|
|
2284
2288
|
className: styles.controlCell,
|
|
2285
2289
|
style: {
|
|
2286
|
-
width: boardConfig.
|
|
2287
|
-
height: boardConfig.
|
|
2290
|
+
width: boardConfig.squareSize,
|
|
2291
|
+
height: boardConfig.squareSize
|
|
2288
2292
|
},
|
|
2289
2293
|
onClick: function onClick() {
|
|
2290
2294
|
return handleClick([i, j]);
|
|
@@ -2738,7 +2742,7 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
|
|
|
2738
2742
|
return hasCheck(cell, currentColor, linesWithCheck);
|
|
2739
2743
|
};
|
|
2740
2744
|
var startRenderArrow = function startRenderArrow(pos) {
|
|
2741
|
-
var startPos = [(pos[0] + 1) * boardConfig.
|
|
2745
|
+
var startPos = [(pos[0] + 1) * boardConfig.squareSize - boardConfig.squareSize / 2 - 10, (pos[1] + 1) * boardConfig.squareSize - boardConfig.squareSize / 2];
|
|
2742
2746
|
setStartArrowCoord(startPos);
|
|
2743
2747
|
};
|
|
2744
2748
|
var endRenderArrow = function endRenderArrow(_ref3) {
|
|
@@ -2841,16 +2845,16 @@ var HoldedFigure = function HoldedFigure(props) {
|
|
|
2841
2845
|
boardConfig = props.boardConfig;
|
|
2842
2846
|
var isCanShowFigure = holdedFigure && grabbingPos[0] > -1 && grabbingPos[1] > -1;
|
|
2843
2847
|
return isCanShowFigure && React__default.createElement("div", {
|
|
2844
|
-
className: cn([styles.
|
|
2848
|
+
className: cn([styles.piece, styles.holdedPiece]),
|
|
2845
2849
|
style: {
|
|
2846
2850
|
position: 'fixed',
|
|
2847
2851
|
zIndex: 6,
|
|
2848
|
-
top: grabbingPos[1] - boardConfig.
|
|
2849
|
-
left: grabbingPos[0] - boardConfig.
|
|
2850
|
-
width: boardConfig.
|
|
2851
|
-
height: boardConfig.
|
|
2852
|
+
top: grabbingPos[1] - boardConfig.squareSize / 2 + "px",
|
|
2853
|
+
left: grabbingPos[0] - boardConfig.squareSize / 2 + "px",
|
|
2854
|
+
width: boardConfig.squareSize,
|
|
2855
|
+
height: boardConfig.squareSize
|
|
2852
2856
|
}
|
|
2853
|
-
}, " ", boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.
|
|
2857
|
+
}, " ", boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.pieceSizePercent + "%"));
|
|
2854
2858
|
};
|
|
2855
2859
|
|
|
2856
2860
|
var BASE_BOARD_SIZE$2 = 8;
|
|
@@ -2877,27 +2881,23 @@ var ChessBoardInteractiveLayout = function ChessBoardInteractiveLayout(props) {
|
|
|
2877
2881
|
}, getFilledArrayBySize(size).map(function (_, i) {
|
|
2878
2882
|
var _cn, _cn2;
|
|
2879
2883
|
return React__default.createElement("div", {
|
|
2880
|
-
className: cn(styles.interactiveCell, (_cn = {}, _cn[styles.
|
|
2884
|
+
className: cn(styles.interactiveCell, (_cn = {}, _cn[styles.selectedSquare + " " + boardConfig.selectedSquareClassName] = selectedPos[0] === i && selectedPos[1] === j, _cn[styles.pickedSquare + " " + boardConfig.pickedSquareClassName] = checkIsPossibleMove(markedCells, [i, j]), _cn[styles.checkedSquare + " " + boardConfig.checkedSquareClassName] = onHasCheck([i, j]), _cn)),
|
|
2881
2885
|
key: "interactive-layout-" + i,
|
|
2882
2886
|
style: {
|
|
2883
|
-
width: boardConfig.
|
|
2884
|
-
height: boardConfig.
|
|
2885
|
-
backgroundColor: selectedPos[0] === i && selectedPos[1] === j ? boardConfig.selectedCellColor : 'transparent',
|
|
2886
|
-
border: selectedPos[0] === i && selectedPos[1] === j ? boardConfig.selectedCellBorder : 'none',
|
|
2887
|
-
boxShadow: checkIsPossibleMove(markedCells, [i, j]) ? "inset 0 0 30px " + boardConfig.markedCellColor : onHasCheck([i, j]) ? "inset 0 0 30px " + boardConfig.checkedCellColor : 'none'
|
|
2887
|
+
width: boardConfig.squareSize,
|
|
2888
|
+
height: boardConfig.squareSize
|
|
2888
2889
|
}
|
|
2889
2890
|
}, selectedPos[0] === i && selectedPos[1] === j && holdedFigure && React__default.createElement("div", {
|
|
2890
|
-
className: cn([styles.
|
|
2891
|
+
className: cn([styles.piece, styles.holdedPiece], (_cn2 = {}, _cn2[styles.bluredPiece] = grabbingPos[0] !== -1, _cn2)),
|
|
2891
2892
|
style: {
|
|
2892
|
-
width: boardConfig.
|
|
2893
|
-
height: boardConfig.
|
|
2893
|
+
width: boardConfig.squareSize,
|
|
2894
|
+
height: boardConfig.squareSize
|
|
2894
2895
|
}
|
|
2895
|
-
}, boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.
|
|
2896
|
-
className: styles.possibleMoveMark,
|
|
2896
|
+
}, boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.pieceSizePercent + "%")), checkIsPossibleMove(possibleMoves, [i, j]) && React__default.createElement("div", {
|
|
2897
|
+
className: cn([styles.possibleMoveMark, boardConfig.possibleMoveMarkClassName]),
|
|
2897
2898
|
style: {
|
|
2898
|
-
width: boardConfig.
|
|
2899
|
-
height: boardConfig.
|
|
2900
|
-
backgroundColor: boardConfig.circleMarkColor
|
|
2899
|
+
width: boardConfig.squareSize / boardConfig.factorForSizeCircleMark,
|
|
2900
|
+
height: boardConfig.squareSize / boardConfig.factorForSizeCircleMark
|
|
2901
2901
|
}
|
|
2902
2902
|
}));
|
|
2903
2903
|
}));
|
|
@@ -2963,19 +2963,19 @@ var FigurePicker = function FigurePicker(props) {
|
|
|
2963
2963
|
onSelect(figure);
|
|
2964
2964
|
}, [onSelect]);
|
|
2965
2965
|
return React__default.createElement("div", {
|
|
2966
|
-
className: styles.
|
|
2966
|
+
className: styles.piecePicker
|
|
2967
2967
|
}, getFiguresByColor(color, forPawnTransform).map(function (figure) {
|
|
2968
2968
|
return React__default.createElement("div", {
|
|
2969
2969
|
key: figure.type,
|
|
2970
|
-
className: styles.
|
|
2970
|
+
className: styles.piecePickerItem,
|
|
2971
2971
|
style: {
|
|
2972
|
-
width: boardConfig.
|
|
2973
|
-
height: boardConfig.
|
|
2972
|
+
width: boardConfig.squareSize,
|
|
2973
|
+
height: boardConfig.squareSize
|
|
2974
2974
|
},
|
|
2975
2975
|
onClick: function onClick() {
|
|
2976
2976
|
return handleChange(figure);
|
|
2977
2977
|
}
|
|
2978
|
-
}, boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.
|
|
2978
|
+
}, boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.pieceSizePercent + "%"));
|
|
2979
2979
|
}));
|
|
2980
2980
|
};
|
|
2981
2981
|
|
|
@@ -2987,7 +2987,8 @@ var ChessBoard = function ChessBoard(props) {
|
|
|
2987
2987
|
reversed = props.reversed,
|
|
2988
2988
|
config = props.config,
|
|
2989
2989
|
playerColor = props.playerColor,
|
|
2990
|
-
viewOnly = props.viewOnly
|
|
2990
|
+
viewOnly = props.viewOnly,
|
|
2991
|
+
moveHighlight = props.moveHighlight;
|
|
2991
2992
|
var _useChessBoardInterac = useChessBoardInteractive({
|
|
2992
2993
|
onChange: onChange,
|
|
2993
2994
|
onEndGame: onEndGame,
|
|
@@ -3056,7 +3057,8 @@ var ChessBoard = function ChessBoard(props) {
|
|
|
3056
3057
|
className: styles.chessBoard
|
|
3057
3058
|
}, React__default.createElement(ChessBoardCellsLayout, {
|
|
3058
3059
|
boardConfig: boardConfig,
|
|
3059
|
-
movesTrail: boardConfig.showMovesTrail && movesTrail
|
|
3060
|
+
movesTrail: boardConfig.showMovesTrail && movesTrail,
|
|
3061
|
+
moveHighlight: moveHighlight
|
|
3060
3062
|
}), React__default.createElement(ChessBoardFiguresLayout, {
|
|
3061
3063
|
initialState: initialState,
|
|
3062
3064
|
change: newMove,
|
|
@@ -3088,7 +3090,7 @@ var ChessBoard = function ChessBoard(props) {
|
|
|
3088
3090
|
onRightClick: markCell,
|
|
3089
3091
|
onGrabbingCell: handleGrabbingCell
|
|
3090
3092
|
}), showFigurePicker && React__default.createElement("div", {
|
|
3091
|
-
className: styles.
|
|
3093
|
+
className: styles.chessBoardPiecePicker
|
|
3092
3094
|
}, React__default.createElement(FigurePicker, {
|
|
3093
3095
|
boardConfig: boardConfig,
|
|
3094
3096
|
color: currentColor,
|