react-chessboard-ui 1.7.4 → 2.1.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 -3
- package/dist/ChessBoard/ChessBoardCellsLayout.d.ts +3 -3
- 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 +66 -68
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +66 -68
- 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,9 +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?: [
|
|
13
|
+
moveHighlight?: [SquarePos, SquarePos];
|
|
14
14
|
};
|
|
15
15
|
export declare const ChessBoard: FC<ChessBoardProps>;
|
|
16
16
|
export {};
|
|
@@ -1,11 +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?: [
|
|
8
|
-
moveHighlight?: [
|
|
7
|
+
movesTrail?: [SquarePos, SquarePos];
|
|
8
|
+
moveHighlight?: [SquarePos, SquarePos];
|
|
9
9
|
};
|
|
10
10
|
export declare const ChessBoardCellsLayout: FC<ChessBoardCellsLayoutProps>;
|
|
11
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
|
@@ -645,6 +645,7 @@ JSChessEngine.checkPossibleCastling = function (state, kingPos, castlingPath, re
|
|
|
645
645
|
});
|
|
646
646
|
if (castlinPathWithFigures.length > 0) return false;
|
|
647
647
|
var isPossibleCastling = true;
|
|
648
|
+
if (castlingPathWithoutRook.length > 2) castlingPathWithoutRook.pop();
|
|
648
649
|
for (var i = 0; i < allAttackedPositionsByEnemys.length; i++) {
|
|
649
650
|
var attackedPos = allAttackedPositionsByEnemys[i];
|
|
650
651
|
for (var j = 0; j < castlingPathWithoutRook.length; j++) {
|
|
@@ -1675,7 +1676,7 @@ var stateToFEN = function stateToFEN(state, currentColor, countMoves) {
|
|
|
1675
1676
|
return positionsFEN + " " + colorFEN + " " + casttlingFEN + " " + beatedFieldFEN + " " + blackMoves + " " + countMoves;
|
|
1676
1677
|
};
|
|
1677
1678
|
|
|
1678
|
-
var styles = {"chessBoard":"_3XI6H","figuresLayout":"_2SyRK","controlLayout":"_3OVc8","controlLayoutGrabbing":"_G0IIl","interactiveLayout":"_3THn5","
|
|
1679
|
+
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
1680
|
|
|
1680
1681
|
var CHESS_PIECES_MAP = {
|
|
1681
1682
|
'pawn-white': function pawnWhite(size) {
|
|
@@ -1877,36 +1878,41 @@ var CHESS_PIECES_MAP = {
|
|
|
1877
1878
|
}
|
|
1878
1879
|
};
|
|
1879
1880
|
|
|
1880
|
-
var
|
|
1881
|
-
var DEFAULT_FIGURE_SIZE_PERCENT = 80;
|
|
1882
|
-
var FACTOR_FOR_SIZE_CIRCLE_MARK = 4.6;
|
|
1881
|
+
var DEFAULT_FACTOR_FOR_SIZE_CIRCLE_MARK = 4.6;
|
|
1883
1882
|
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
1883
|
var DEFAULT_ARROW_COLOR = '#6ac2fd';
|
|
1889
|
-
var DEFAULT_MARKED_CELL_COLOR = '#3697ce';
|
|
1890
|
-
var DEFAULT_CHECKED_CELL_COLOR = '#e95b5c';
|
|
1891
1884
|
var DEFAULT_PIECES_MAP = CHESS_PIECES_MAP;
|
|
1892
|
-
var DEFAULT_CSS_HIDE_PIECES_EFFECT = styles.hiddenFigureEffect;
|
|
1893
1885
|
var DEFAULT_SHOW_MOVES_TRAIL = true;
|
|
1894
1886
|
var DEFAULT_HIDE_PIECES_HANDLER = function DEFAULT_HIDE_PIECES_HANDLER(figure) {
|
|
1895
1887
|
figure.color === 'white' ? figure.position = [8, figure.position[1]] : figure.position = [-1, figure.position[1]];
|
|
1896
1888
|
};
|
|
1889
|
+
var DEFAULT_SQUARE_SIZE = 92;
|
|
1890
|
+
var DEFAULT_PIECE_SIZE_PERCENT = 80;
|
|
1891
|
+
var DEFAULT_HIDE_PIECE_EFFECT_CLASS_NAME = styles.hiddenFigureEffect;
|
|
1892
|
+
var DEFAULT_LIGHT_SQUARE_CLASS_NAME = undefined;
|
|
1893
|
+
var DEFAULT_DARK_SQUARE_CLASS_NAME = undefined;
|
|
1894
|
+
var DEFAULT_PICKED_SQUARE_CLASS_NAME = undefined;
|
|
1895
|
+
var DEFAULT_CHECKED_SQUARE_CLASS_NAME = undefined;
|
|
1896
|
+
var DEFAULT_SQUARE_HIGLIGHT_CLASS_NAME = undefined;
|
|
1897
|
+
var DEFAULT_SELECTED_SQUARE_CLASS_NAME = undefined;
|
|
1898
|
+
var DEFAULT_HOLDED_PIECE_CLASS_NAME = undefined;
|
|
1899
|
+
var DEFAULT_POSSIBLE_MOVE_MARK_CLASS_NAME = undefined;
|
|
1897
1900
|
var DEFAULT_CHESSBORD_CONFIG = {
|
|
1898
|
-
|
|
1899
|
-
|
|
1901
|
+
squareSize: DEFAULT_SQUARE_SIZE,
|
|
1902
|
+
pieceSizePercent: DEFAULT_PIECE_SIZE_PERCENT,
|
|
1903
|
+
lightSquareClassName: DEFAULT_LIGHT_SQUARE_CLASS_NAME,
|
|
1904
|
+
darkSquareClassName: DEFAULT_DARK_SQUARE_CLASS_NAME,
|
|
1905
|
+
pickedSquareClassName: DEFAULT_PICKED_SQUARE_CLASS_NAME,
|
|
1906
|
+
selectedSquareClassName: DEFAULT_SELECTED_SQUARE_CLASS_NAME,
|
|
1907
|
+
holdedPieceClassName: DEFAULT_HOLDED_PIECE_CLASS_NAME,
|
|
1908
|
+
checkedSquareClassName: DEFAULT_CHECKED_SQUARE_CLASS_NAME,
|
|
1909
|
+
squareHighlightClassName: DEFAULT_SQUARE_HIGLIGHT_CLASS_NAME,
|
|
1900
1910
|
circleMarkColor: DEFAULT_CIRCLE_MARK_COLOR,
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
selectedCellColor: DEFAULT_SELECTED_CELL_COLOR,
|
|
1904
|
-
selectedCellBorder: DEFAULT_SELECTED_CELL_BORDER,
|
|
1911
|
+
factorForSizeCircleMark: DEFAULT_FACTOR_FOR_SIZE_CIRCLE_MARK,
|
|
1912
|
+
possibleMoveMarkClassName: DEFAULT_POSSIBLE_MOVE_MARK_CLASS_NAME,
|
|
1905
1913
|
arrowColor: DEFAULT_ARROW_COLOR,
|
|
1906
|
-
markedCellColor: DEFAULT_MARKED_CELL_COLOR,
|
|
1907
|
-
checkedCellColor: DEFAULT_CHECKED_CELL_COLOR,
|
|
1908
1914
|
piecesMap: DEFAULT_PIECES_MAP,
|
|
1909
|
-
|
|
1915
|
+
hidePieceEffectClassName: DEFAULT_HIDE_PIECE_EFFECT_CLASS_NAME,
|
|
1910
1916
|
showMovesTrail: DEFAULT_SHOW_MOVES_TRAIL,
|
|
1911
1917
|
onHidePieces: DEFAULT_HIDE_PIECES_HANDLER
|
|
1912
1918
|
};
|
|
@@ -1986,12 +1992,7 @@ var calcAngle = function calcAngle(start, end) {
|
|
|
1986
1992
|
};
|
|
1987
1993
|
var getChessBoardConfig = function getChessBoardConfig(config) {
|
|
1988
1994
|
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;
|
|
1995
|
+
return _extends({}, DEFAULT_CHESSBORD_CONFIG, config);
|
|
1995
1996
|
};
|
|
1996
1997
|
var getFiguresByColor = function getFiguresByColor(color, forPawnTransform) {
|
|
1997
1998
|
if (forPawnTransform === void 0) {
|
|
@@ -2021,7 +2022,7 @@ var correctGrabbingPosByScroll = function correctGrabbingPosByScroll(pos) {
|
|
|
2021
2022
|
return [pos[0] - window.scrollX, pos[1] - window.scrollY];
|
|
2022
2023
|
};
|
|
2023
2024
|
var correctGrabbingPosForArrow = function correctGrabbingPosForArrow(pos, boardConfig) {
|
|
2024
|
-
return [pos[0] * boardConfig.
|
|
2025
|
+
return [pos[0] * boardConfig.squareSize + (boardConfig.squareSize / 2 - 10), pos[1] * boardConfig.squareSize + boardConfig.squareSize / 2];
|
|
2025
2026
|
};
|
|
2026
2027
|
var createHtmlReversedStateHolder = function createHtmlReversedStateHolder() {
|
|
2027
2028
|
if (!window) return;
|
|
@@ -2052,17 +2053,18 @@ var ChessBoardCellsLayout = function ChessBoardCellsLayout(_ref) {
|
|
|
2052
2053
|
className: styles.row,
|
|
2053
2054
|
key: "cells-layout-" + j
|
|
2054
2055
|
}, getFilledArrayBySize(size).map(function (_, i) {
|
|
2056
|
+
var _cn;
|
|
2055
2057
|
return React__default.createElement("div", {
|
|
2056
2058
|
style: {
|
|
2057
|
-
width: boardConfig.
|
|
2058
|
-
height: boardConfig.
|
|
2059
|
-
backgroundColor: getIsLightCell(j, i) ? boardConfig.whiteCellColor : boardConfig.blackCellColor
|
|
2059
|
+
width: boardConfig.squareSize,
|
|
2060
|
+
height: boardConfig.squareSize
|
|
2060
2061
|
},
|
|
2062
|
+
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)),
|
|
2061
2063
|
key: "cells-layout-" + i
|
|
2062
2064
|
}, movesTrail && (movesTrail[0][0] === i && movesTrail[0][1] === j || movesTrail[1][0] === i && movesTrail[1][1] === j) && React__default.createElement("div", {
|
|
2063
|
-
className: styles.movesTrail
|
|
2065
|
+
className: cn(styles.movesTrail, boardConfig.squareHighlightClassName)
|
|
2064
2066
|
}), moveHighlight && (moveHighlight[0][0] === i && moveHighlight[0][1] === j || moveHighlight[1][0] === i && moveHighlight[1][1] === j) && React__default.createElement("div", {
|
|
2065
|
-
className: styles.movesTrail
|
|
2067
|
+
className: cn(styles.movesTrail, boardConfig.squareHighlightClassName)
|
|
2066
2068
|
}));
|
|
2067
2069
|
}));
|
|
2068
2070
|
}));
|
|
@@ -2199,20 +2201,20 @@ var ChessBoardFiguresLayout = function ChessBoardFiguresLayout(props) {
|
|
|
2199
2201
|
});
|
|
2200
2202
|
}, [reversed, initialState]);
|
|
2201
2203
|
return React__default.createElement("div", {
|
|
2202
|
-
className: styles.
|
|
2204
|
+
className: styles.piecesLayout
|
|
2203
2205
|
}, actualState.map(function (figure, i) {
|
|
2204
2206
|
var _cn;
|
|
2205
2207
|
return React__default.createElement("div", {
|
|
2206
2208
|
key: i,
|
|
2207
|
-
className: cn([styles.
|
|
2209
|
+
className: cn([styles.piece], (_cn = {}, _cn[boardConfig.hidePieceEffectClassName] = figure.beated, _cn)),
|
|
2208
2210
|
style: {
|
|
2209
|
-
top: boardConfig.
|
|
2210
|
-
left: boardConfig.
|
|
2211
|
+
top: boardConfig.squareSize * figure.position[1] + "px",
|
|
2212
|
+
left: boardConfig.squareSize * figure.position[0] + "px",
|
|
2211
2213
|
transition: !!change && animated ? 'all .15s ease-out' : 'none',
|
|
2212
|
-
width: boardConfig.
|
|
2213
|
-
height: boardConfig.
|
|
2214
|
+
width: boardConfig.squareSize,
|
|
2215
|
+
height: boardConfig.squareSize
|
|
2214
2216
|
}
|
|
2215
|
-
}, boardConfig.piecesMap[getFigureCSS(figure)] && boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.
|
|
2217
|
+
}, boardConfig.piecesMap[getFigureCSS(figure)] && boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.pieceSizePercent + "%"));
|
|
2216
2218
|
}));
|
|
2217
2219
|
};
|
|
2218
2220
|
|
|
@@ -2286,8 +2288,8 @@ var ChessBoardControlLayout = function ChessBoardControlLayout(props) {
|
|
|
2286
2288
|
key: "control-layout-" + i,
|
|
2287
2289
|
className: styles.controlCell,
|
|
2288
2290
|
style: {
|
|
2289
|
-
width: boardConfig.
|
|
2290
|
-
height: boardConfig.
|
|
2291
|
+
width: boardConfig.squareSize,
|
|
2292
|
+
height: boardConfig.squareSize
|
|
2291
2293
|
},
|
|
2292
2294
|
onClick: function onClick() {
|
|
2293
2295
|
return handleClick([i, j]);
|
|
@@ -2741,7 +2743,7 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
|
|
|
2741
2743
|
return hasCheck(cell, currentColor, linesWithCheck);
|
|
2742
2744
|
};
|
|
2743
2745
|
var startRenderArrow = function startRenderArrow(pos) {
|
|
2744
|
-
var startPos = [(pos[0] + 1) * boardConfig.
|
|
2746
|
+
var startPos = [(pos[0] + 1) * boardConfig.squareSize - boardConfig.squareSize / 2 - 10, (pos[1] + 1) * boardConfig.squareSize - boardConfig.squareSize / 2];
|
|
2745
2747
|
setStartArrowCoord(startPos);
|
|
2746
2748
|
};
|
|
2747
2749
|
var endRenderArrow = function endRenderArrow(_ref3) {
|
|
@@ -2844,16 +2846,16 @@ var HoldedFigure = function HoldedFigure(props) {
|
|
|
2844
2846
|
boardConfig = props.boardConfig;
|
|
2845
2847
|
var isCanShowFigure = holdedFigure && grabbingPos[0] > -1 && grabbingPos[1] > -1;
|
|
2846
2848
|
return isCanShowFigure && React__default.createElement("div", {
|
|
2847
|
-
className: cn([styles.
|
|
2849
|
+
className: cn([styles.piece, styles.holdedPiece]),
|
|
2848
2850
|
style: {
|
|
2849
2851
|
position: 'fixed',
|
|
2850
2852
|
zIndex: 6,
|
|
2851
|
-
top: grabbingPos[1] - boardConfig.
|
|
2852
|
-
left: grabbingPos[0] - boardConfig.
|
|
2853
|
-
width: boardConfig.
|
|
2854
|
-
height: boardConfig.
|
|
2853
|
+
top: grabbingPos[1] - boardConfig.squareSize / 2 + "px",
|
|
2854
|
+
left: grabbingPos[0] - boardConfig.squareSize / 2 + "px",
|
|
2855
|
+
width: boardConfig.squareSize,
|
|
2856
|
+
height: boardConfig.squareSize
|
|
2855
2857
|
}
|
|
2856
|
-
}, " ", boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.
|
|
2858
|
+
}, " ", boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.pieceSizePercent + "%"));
|
|
2857
2859
|
};
|
|
2858
2860
|
|
|
2859
2861
|
var BASE_BOARD_SIZE$2 = 8;
|
|
@@ -2880,27 +2882,23 @@ var ChessBoardInteractiveLayout = function ChessBoardInteractiveLayout(props) {
|
|
|
2880
2882
|
}, getFilledArrayBySize(size).map(function (_, i) {
|
|
2881
2883
|
var _cn, _cn2;
|
|
2882
2884
|
return React__default.createElement("div", {
|
|
2883
|
-
className: cn(styles.interactiveCell, (_cn = {}, _cn[styles.
|
|
2885
|
+
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)),
|
|
2884
2886
|
key: "interactive-layout-" + i,
|
|
2885
2887
|
style: {
|
|
2886
|
-
width: boardConfig.
|
|
2887
|
-
height: boardConfig.
|
|
2888
|
-
backgroundColor: selectedPos[0] === i && selectedPos[1] === j ? boardConfig.selectedCellColor : 'transparent',
|
|
2889
|
-
border: selectedPos[0] === i && selectedPos[1] === j ? boardConfig.selectedCellBorder : 'none',
|
|
2890
|
-
boxShadow: checkIsPossibleMove(markedCells, [i, j]) ? "inset 0 0 30px " + boardConfig.markedCellColor : onHasCheck([i, j]) ? "inset 0 0 30px " + boardConfig.checkedCellColor : 'none'
|
|
2888
|
+
width: boardConfig.squareSize,
|
|
2889
|
+
height: boardConfig.squareSize
|
|
2891
2890
|
}
|
|
2892
2891
|
}, selectedPos[0] === i && selectedPos[1] === j && holdedFigure && React__default.createElement("div", {
|
|
2893
|
-
className: cn([styles.
|
|
2892
|
+
className: cn([styles.piece, styles.holdedPiece], (_cn2 = {}, _cn2[styles.bluredPiece] = grabbingPos[0] !== -1, _cn2)),
|
|
2894
2893
|
style: {
|
|
2895
|
-
width: boardConfig.
|
|
2896
|
-
height: boardConfig.
|
|
2894
|
+
width: boardConfig.squareSize,
|
|
2895
|
+
height: boardConfig.squareSize
|
|
2897
2896
|
}
|
|
2898
|
-
}, boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.
|
|
2899
|
-
className: styles.possibleMoveMark,
|
|
2897
|
+
}, boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.pieceSizePercent + "%")), checkIsPossibleMove(possibleMoves, [i, j]) && React__default.createElement("div", {
|
|
2898
|
+
className: cn([styles.possibleMoveMark, boardConfig.possibleMoveMarkClassName]),
|
|
2900
2899
|
style: {
|
|
2901
|
-
width: boardConfig.
|
|
2902
|
-
height: boardConfig.
|
|
2903
|
-
backgroundColor: boardConfig.circleMarkColor
|
|
2900
|
+
width: boardConfig.squareSize / boardConfig.factorForSizeCircleMark,
|
|
2901
|
+
height: boardConfig.squareSize / boardConfig.factorForSizeCircleMark
|
|
2904
2902
|
}
|
|
2905
2903
|
}));
|
|
2906
2904
|
}));
|
|
@@ -2966,19 +2964,19 @@ var FigurePicker = function FigurePicker(props) {
|
|
|
2966
2964
|
onSelect(figure);
|
|
2967
2965
|
}, [onSelect]);
|
|
2968
2966
|
return React__default.createElement("div", {
|
|
2969
|
-
className: styles.
|
|
2967
|
+
className: styles.piecePicker
|
|
2970
2968
|
}, getFiguresByColor(color, forPawnTransform).map(function (figure) {
|
|
2971
2969
|
return React__default.createElement("div", {
|
|
2972
2970
|
key: figure.type,
|
|
2973
|
-
className: styles.
|
|
2971
|
+
className: styles.piecePickerItem,
|
|
2974
2972
|
style: {
|
|
2975
|
-
width: boardConfig.
|
|
2976
|
-
height: boardConfig.
|
|
2973
|
+
width: boardConfig.squareSize,
|
|
2974
|
+
height: boardConfig.squareSize
|
|
2977
2975
|
},
|
|
2978
2976
|
onClick: function onClick() {
|
|
2979
2977
|
return handleChange(figure);
|
|
2980
2978
|
}
|
|
2981
|
-
}, boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.
|
|
2979
|
+
}, boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.pieceSizePercent + "%"));
|
|
2982
2980
|
}));
|
|
2983
2981
|
};
|
|
2984
2982
|
|
|
@@ -3093,7 +3091,7 @@ var ChessBoard = function ChessBoard(props) {
|
|
|
3093
3091
|
onRightClick: markCell,
|
|
3094
3092
|
onGrabbingCell: handleGrabbingCell
|
|
3095
3093
|
}), showFigurePicker && React__default.createElement("div", {
|
|
3096
|
-
className: styles.
|
|
3094
|
+
className: styles.chessBoardPiecePicker
|
|
3097
3095
|
}, React__default.createElement(FigurePicker, {
|
|
3098
3096
|
boardConfig: boardConfig,
|
|
3099
3097
|
color: currentColor,
|