react-chessboard-ui 1.7.4 → 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 -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 +65 -68
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +65 -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
|
@@ -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;
|
|
@@ -2052,17 +2052,18 @@ var ChessBoardCellsLayout = function ChessBoardCellsLayout(_ref) {
|
|
|
2052
2052
|
className: styles.row,
|
|
2053
2053
|
key: "cells-layout-" + j
|
|
2054
2054
|
}, getFilledArrayBySize(size).map(function (_, i) {
|
|
2055
|
+
var _cn;
|
|
2055
2056
|
return React__default.createElement("div", {
|
|
2056
2057
|
style: {
|
|
2057
|
-
width: boardConfig.
|
|
2058
|
-
height: boardConfig.
|
|
2059
|
-
backgroundColor: getIsLightCell(j, i) ? boardConfig.whiteCellColor : boardConfig.blackCellColor
|
|
2058
|
+
width: boardConfig.squareSize,
|
|
2059
|
+
height: boardConfig.squareSize
|
|
2060
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)),
|
|
2061
2062
|
key: "cells-layout-" + i
|
|
2062
2063
|
}, 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
|
|
2064
|
+
className: cn(styles.movesTrail, boardConfig.squareHighlightClassName)
|
|
2064
2065
|
}), 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
|
|
2066
|
+
className: cn(styles.movesTrail, boardConfig.squareHighlightClassName)
|
|
2066
2067
|
}));
|
|
2067
2068
|
}));
|
|
2068
2069
|
}));
|
|
@@ -2199,20 +2200,20 @@ var ChessBoardFiguresLayout = function ChessBoardFiguresLayout(props) {
|
|
|
2199
2200
|
});
|
|
2200
2201
|
}, [reversed, initialState]);
|
|
2201
2202
|
return React__default.createElement("div", {
|
|
2202
|
-
className: styles.
|
|
2203
|
+
className: styles.piecesLayout
|
|
2203
2204
|
}, actualState.map(function (figure, i) {
|
|
2204
2205
|
var _cn;
|
|
2205
2206
|
return React__default.createElement("div", {
|
|
2206
2207
|
key: i,
|
|
2207
|
-
className: cn([styles.
|
|
2208
|
+
className: cn([styles.piece], (_cn = {}, _cn[boardConfig.hidePieceEffectClassName] = figure.beated, _cn)),
|
|
2208
2209
|
style: {
|
|
2209
|
-
top: boardConfig.
|
|
2210
|
-
left: boardConfig.
|
|
2210
|
+
top: boardConfig.squareSize * figure.position[1] + "px",
|
|
2211
|
+
left: boardConfig.squareSize * figure.position[0] + "px",
|
|
2211
2212
|
transition: !!change && animated ? 'all .15s ease-out' : 'none',
|
|
2212
|
-
width: boardConfig.
|
|
2213
|
-
height: boardConfig.
|
|
2213
|
+
width: boardConfig.squareSize,
|
|
2214
|
+
height: boardConfig.squareSize
|
|
2214
2215
|
}
|
|
2215
|
-
}, boardConfig.piecesMap[getFigureCSS(figure)] && boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.
|
|
2216
|
+
}, boardConfig.piecesMap[getFigureCSS(figure)] && boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.pieceSizePercent + "%"));
|
|
2216
2217
|
}));
|
|
2217
2218
|
};
|
|
2218
2219
|
|
|
@@ -2286,8 +2287,8 @@ var ChessBoardControlLayout = function ChessBoardControlLayout(props) {
|
|
|
2286
2287
|
key: "control-layout-" + i,
|
|
2287
2288
|
className: styles.controlCell,
|
|
2288
2289
|
style: {
|
|
2289
|
-
width: boardConfig.
|
|
2290
|
-
height: boardConfig.
|
|
2290
|
+
width: boardConfig.squareSize,
|
|
2291
|
+
height: boardConfig.squareSize
|
|
2291
2292
|
},
|
|
2292
2293
|
onClick: function onClick() {
|
|
2293
2294
|
return handleClick([i, j]);
|
|
@@ -2741,7 +2742,7 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
|
|
|
2741
2742
|
return hasCheck(cell, currentColor, linesWithCheck);
|
|
2742
2743
|
};
|
|
2743
2744
|
var startRenderArrow = function startRenderArrow(pos) {
|
|
2744
|
-
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];
|
|
2745
2746
|
setStartArrowCoord(startPos);
|
|
2746
2747
|
};
|
|
2747
2748
|
var endRenderArrow = function endRenderArrow(_ref3) {
|
|
@@ -2844,16 +2845,16 @@ var HoldedFigure = function HoldedFigure(props) {
|
|
|
2844
2845
|
boardConfig = props.boardConfig;
|
|
2845
2846
|
var isCanShowFigure = holdedFigure && grabbingPos[0] > -1 && grabbingPos[1] > -1;
|
|
2846
2847
|
return isCanShowFigure && React__default.createElement("div", {
|
|
2847
|
-
className: cn([styles.
|
|
2848
|
+
className: cn([styles.piece, styles.holdedPiece]),
|
|
2848
2849
|
style: {
|
|
2849
2850
|
position: 'fixed',
|
|
2850
2851
|
zIndex: 6,
|
|
2851
|
-
top: grabbingPos[1] - boardConfig.
|
|
2852
|
-
left: grabbingPos[0] - boardConfig.
|
|
2853
|
-
width: boardConfig.
|
|
2854
|
-
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
|
|
2855
2856
|
}
|
|
2856
|
-
}, " ", boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.
|
|
2857
|
+
}, " ", boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.pieceSizePercent + "%"));
|
|
2857
2858
|
};
|
|
2858
2859
|
|
|
2859
2860
|
var BASE_BOARD_SIZE$2 = 8;
|
|
@@ -2880,27 +2881,23 @@ var ChessBoardInteractiveLayout = function ChessBoardInteractiveLayout(props) {
|
|
|
2880
2881
|
}, getFilledArrayBySize(size).map(function (_, i) {
|
|
2881
2882
|
var _cn, _cn2;
|
|
2882
2883
|
return React__default.createElement("div", {
|
|
2883
|
-
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)),
|
|
2884
2885
|
key: "interactive-layout-" + i,
|
|
2885
2886
|
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'
|
|
2887
|
+
width: boardConfig.squareSize,
|
|
2888
|
+
height: boardConfig.squareSize
|
|
2891
2889
|
}
|
|
2892
2890
|
}, selectedPos[0] === i && selectedPos[1] === j && holdedFigure && React__default.createElement("div", {
|
|
2893
|
-
className: cn([styles.
|
|
2891
|
+
className: cn([styles.piece, styles.holdedPiece], (_cn2 = {}, _cn2[styles.bluredPiece] = grabbingPos[0] !== -1, _cn2)),
|
|
2894
2892
|
style: {
|
|
2895
|
-
width: boardConfig.
|
|
2896
|
-
height: boardConfig.
|
|
2893
|
+
width: boardConfig.squareSize,
|
|
2894
|
+
height: boardConfig.squareSize
|
|
2897
2895
|
}
|
|
2898
|
-
}, boardConfig.piecesMap[getFigureCSS(holdedFigure)](boardConfig.
|
|
2899
|
-
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]),
|
|
2900
2898
|
style: {
|
|
2901
|
-
width: boardConfig.
|
|
2902
|
-
height: boardConfig.
|
|
2903
|
-
backgroundColor: boardConfig.circleMarkColor
|
|
2899
|
+
width: boardConfig.squareSize / boardConfig.factorForSizeCircleMark,
|
|
2900
|
+
height: boardConfig.squareSize / boardConfig.factorForSizeCircleMark
|
|
2904
2901
|
}
|
|
2905
2902
|
}));
|
|
2906
2903
|
}));
|
|
@@ -2966,19 +2963,19 @@ var FigurePicker = function FigurePicker(props) {
|
|
|
2966
2963
|
onSelect(figure);
|
|
2967
2964
|
}, [onSelect]);
|
|
2968
2965
|
return React__default.createElement("div", {
|
|
2969
|
-
className: styles.
|
|
2966
|
+
className: styles.piecePicker
|
|
2970
2967
|
}, getFiguresByColor(color, forPawnTransform).map(function (figure) {
|
|
2971
2968
|
return React__default.createElement("div", {
|
|
2972
2969
|
key: figure.type,
|
|
2973
|
-
className: styles.
|
|
2970
|
+
className: styles.piecePickerItem,
|
|
2974
2971
|
style: {
|
|
2975
|
-
width: boardConfig.
|
|
2976
|
-
height: boardConfig.
|
|
2972
|
+
width: boardConfig.squareSize,
|
|
2973
|
+
height: boardConfig.squareSize
|
|
2977
2974
|
},
|
|
2978
2975
|
onClick: function onClick() {
|
|
2979
2976
|
return handleChange(figure);
|
|
2980
2977
|
}
|
|
2981
|
-
}, boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.
|
|
2978
|
+
}, boardConfig.piecesMap[getFigureCSS(figure)](boardConfig.pieceSizePercent + "%"));
|
|
2982
2979
|
}));
|
|
2983
2980
|
};
|
|
2984
2981
|
|
|
@@ -3093,7 +3090,7 @@ var ChessBoard = function ChessBoard(props) {
|
|
|
3093
3090
|
onRightClick: markCell,
|
|
3094
3091
|
onGrabbingCell: handleGrabbingCell
|
|
3095
3092
|
}), showFigurePicker && React__default.createElement("div", {
|
|
3096
|
-
className: styles.
|
|
3093
|
+
className: styles.chessBoardPiecePicker
|
|
3097
3094
|
}, React__default.createElement(FigurePicker, {
|
|
3098
3095
|
boardConfig: boardConfig,
|
|
3099
3096
|
color: currentColor,
|