react-chessboard-ui 2.9.0 → 2.11.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/README.md CHANGED
@@ -3,9 +3,14 @@
3
3
  [![NPM](https://img.shields.io/npm/v/react-chessboard-ui.svg)](https://www.npmjs.com/package/react-chessboard-ui)
4
4
  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
5
5
 
6
- A lightweight and customizable React chessboard component built with modern UI in mind. Easily integrate chess functionality into your React apps with FEN support, game-end detection, and position handling.
6
+ <p align="center">
7
+ <img src="./blob/default.png?raw=true" width="23%" alt="Default react-chessboard-ui board" />
8
+ <img src="./blob/customization.png?raw=true" width="23%" alt="Customized react-chessboard-ui board" />
9
+ <img src="./blob/colorfull_arrows.png?raw=true" width="23%" alt="React chessboard with colorful arrows" />
10
+ <img src="./blob/all_queens.png?raw=true" width="23%" alt="React chessboard with custom pieces" />
11
+ </p>
7
12
 
8
- <img src="./blob/ChessBoard.png?raw=true" width="400px" alt="react-chessboard-ui preview" />
13
+ An all-in-one React chessboard component with both the chess engine and UI included. Drop it into your React app and get a ready-to-use chessboard without wiring up separate chess logic, move validation, or board state tools. Control the board position with simple FEN notation and react to moves or game-end events through callbacks.
9
14
 
10
15
  ## 📘 **Full documentation**: [https://react-chessboard-ui.dev/](https://react-chessboard-ui.dev/)
11
16
 
@@ -14,10 +19,18 @@ A lightweight and customizable React chessboard component built with modern UI i
14
19
  ## 🚀 Features
15
20
 
16
21
  - 🎯 Fully controlled via FEN strings
22
+ - ♟️ Built-in chess engine and ready-made board UI
23
+ - ✅ Move validation included
17
24
  - ♻️ React functional component with hooks support
18
25
  - 🎨 Customizable styles (via CSS or override)
19
26
  - ♟️ Game-end and move-change callbacks
20
- - 🧩 Easy integration into any React project
27
+ - 🧩 No extra chess packages or setup required
28
+
29
+ ---
30
+
31
+ ## Why react-chessboard-ui?
32
+
33
+ `react-chessboard-ui` is designed for developers who need a React chessboard, chess UI, and chess engine in one package. It is not just a board renderer: it provides drag-and-drop chess pieces, FEN-based position control, legal move handling, game-end detection, and customization options out of the box.
21
34
 
22
35
  ---
23
36
 
@@ -46,19 +59,16 @@ import 'react-chessboard-ui/dist/index.css'; // Required CSS
46
59
 
47
60
  export const App = () => {
48
61
  return (
49
- <div>
50
- <ChessBoard
51
- FEN="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
52
- onChange={handleChangePosition}
53
- onEndGame={handleEndGame}
54
- />
55
- </div>
62
+ <ChessBoard
63
+ FEN="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
64
+ onChange={handleChangePosition}
65
+ onEndGame={handleEndGame}
66
+ />
56
67
  );
57
68
  };
58
69
  ```
59
70
 
60
71
  ## Full customizable
61
- <img src="./blob/customization.png?raw=true" width="400px" alt="react-chessboard-ui preview" />
62
72
 
63
73
  ### 📘 **Documentation for customization**: [https://react-chessboard-ui.dev/properties/config/](https://react-chessboard-ui.dev/properties/config/)
64
74
 
@@ -82,4 +92,4 @@ MIT © [react-chessboard-ui](https://github.com/)
82
92
 
83
93
  ## 🧠 Keywords (for discoverability)
84
94
 
85
- `react` `chess` `chessboard` `react-chess` `chess ui` `react chess component` `fen` `chess game` `react board game`
95
+ `react` `react-chess` `react-chessboard` `react-chessboard-ui` `js-chess` `chess` `chessboard` `chessboard component` `chess engine`
@@ -16,6 +16,7 @@ declare type ChessBoardProps = {
16
16
  arrows?: (ArrowCoords & {
17
17
  color?: string;
18
18
  })[];
19
+ toggleTurn?: boolean;
19
20
  };
20
21
  export declare const ChessBoard: FC<ChessBoardProps>;
21
22
  export {};
@@ -6,12 +6,14 @@ declare type UseChessBoardInteractiveProps = {
6
6
  onChange: (moveData: MoveData) => void;
7
7
  onEndGame: (result: GameResult) => void;
8
8
  onClickByChessBoard?: (data: ClickData) => void;
9
+ toggleTurn?: boolean;
9
10
  };
10
11
  export declare const useChessBoardInteractive: (props: UseChessBoardInteractiveProps) => {
11
12
  fromPos: CellPos;
12
13
  newMove: ChangeMove;
13
14
  animated: boolean;
14
15
  movesTrail: [CellPos, CellPos];
16
+ invalidFEN: boolean;
15
17
  boardConfig: ChessBoardConfig;
16
18
  markedCells: CellPos[];
17
19
  grabbingPos: CellPos;
@@ -31,6 +33,7 @@ export declare const useChessBoardInteractive: (props: UseChessBoardInteractiveP
31
33
  handleClick: (cellPos: CellPos, viewOnly?: boolean) => void;
32
34
  clearFromPos: () => void;
33
35
  handleGrabEnd: (cellPos: CellPos, withTransition?: boolean) => void;
36
+ setInvalidFEN: import("react").Dispatch<import("react").SetStateAction<boolean>>;
34
37
  handleGrabbing: (x: number, y: number) => void;
35
38
  endRenderArrow: ([x, y]: CellPos) => void;
36
39
  setActualState: import("react").Dispatch<import("react").SetStateAction<Cell[][]>>;
@@ -27,6 +27,7 @@ export declare const partFENtoState: (notation: string) => Cell[][];
27
27
  export declare const FENtoGameState: (FEN: string, reversed?: boolean) => {
28
28
  boardState: Cell[][];
29
29
  currentColor: FigureColor;
30
+ invalidFEN?: boolean;
30
31
  };
31
32
  /**
32
33
  * Возвращает FEN битое поле из состояние доски
package/dist/index.css CHANGED
@@ -148,6 +148,47 @@
148
148
  align-items: center;
149
149
  }
150
150
 
151
+ ._jyC3- {
152
+ z-index: 102;
153
+ position: absolute;
154
+ top: 0;
155
+ right: 0;
156
+ bottom: 0;
157
+ left: 0;
158
+ -webkit-backdrop-filter: blur(4px);
159
+ backdrop-filter: blur(4px);
160
+ display: flex;
161
+ justify-content: center;
162
+ align-items: center;
163
+ }
164
+
165
+ ._8urIN {
166
+ padding: 12px 14px;
167
+ border: 1px solid #f4b8b8;
168
+ border-radius: 6px;
169
+ background: #fff1f1;
170
+ color: #8a1f1f;
171
+ font-size: 14px;
172
+ line-height: 1.5;
173
+ }
174
+
175
+ ._8urIN a {
176
+ color: #b42318;
177
+ font-weight: 600;
178
+ text-decoration: underline;
179
+ text-underline-offset: 2px;
180
+ cursor: pointer;
181
+ }
182
+
183
+ ._8urIN a:hover {
184
+ color: #7a1712;
185
+ }
186
+
187
+ ._3p5AF {
188
+ color: #6b6b6b !important;
189
+ font-size: 12px;
190
+ }
191
+
151
192
  ._1RqCc {
152
193
  width: 100%;
153
194
  height: 100%;
package/dist/index.js CHANGED
@@ -1491,6 +1491,8 @@ var prepareCastlingByFEN = function prepareCastlingByFEN(castlingNotation, state
1491
1491
  preparedState[preparedState.length - 1][preparedState.length - 1].figure = _extends({}, preparedState[preparedState.length - 1][preparedState.length - 1].figure, {
1492
1492
  touched: false
1493
1493
  });
1494
+ }
1495
+ if (!!preparedState[preparedState.length - 1][4].figure) {
1494
1496
  preparedState[preparedState.length - 1][4].figure = _extends({}, preparedState[preparedState.length - 1][4].figure, {
1495
1497
  touched: false
1496
1498
  });
@@ -1501,6 +1503,8 @@ var prepareCastlingByFEN = function prepareCastlingByFEN(castlingNotation, state
1501
1503
  preparedState[preparedState.length - 1][0].figure = _extends({}, preparedState[preparedState.length - 1][0].figure, {
1502
1504
  touched: false
1503
1505
  });
1506
+ }
1507
+ if (!!preparedState[preparedState.length - 1][4].figure) {
1504
1508
  preparedState[preparedState.length - 1][4].figure = _extends({}, preparedState[preparedState.length - 1][4].figure, {
1505
1509
  touched: false
1506
1510
  });
@@ -1511,6 +1515,8 @@ var prepareCastlingByFEN = function prepareCastlingByFEN(castlingNotation, state
1511
1515
  preparedState[0][preparedState.length - 1].figure = _extends({}, preparedState[0][preparedState.length - 1].figure, {
1512
1516
  touched: false
1513
1517
  });
1518
+ }
1519
+ if (!!preparedState[0][4].figure) {
1514
1520
  preparedState[0][4].figure = _extends({}, preparedState[0][4].figure, {
1515
1521
  touched: false
1516
1522
  });
@@ -1521,6 +1527,8 @@ var prepareCastlingByFEN = function prepareCastlingByFEN(castlingNotation, state
1521
1527
  preparedState[0][0].figure = _extends({}, preparedState[0][0].figure, {
1522
1528
  touched: false
1523
1529
  });
1530
+ }
1531
+ if (!!preparedState[0][4].figure) {
1524
1532
  preparedState[0][4].figure = _extends({}, preparedState[0][4].figure, {
1525
1533
  touched: false
1526
1534
  });
@@ -1555,39 +1563,47 @@ var partFENtoState = function partFENtoState(notation) {
1555
1563
  });
1556
1564
  };
1557
1565
  var FENtoGameState = function FENtoGameState(FEN, reversed) {
1558
- var gameState = {
1559
- boardState: [],
1560
- currentColor: 'white'
1561
- };
1562
- var _FEN$split = FEN.split(' '),
1563
- stateNotaion = _FEN$split[0],
1564
- currentColor = _FEN$split[1],
1565
- FENcastling = _FEN$split[2],
1566
- beatedField = _FEN$split[3],
1567
- _ = _FEN$split.slice(4);
1568
- var preparedStateNotation = '';
1569
- for (var i = 0; i < stateNotaion.length; i++) {
1570
- if (!isNaN(parseInt(stateNotaion[i]))) {
1571
- var dotsCount = parseInt(stateNotaion[i]);
1572
- for (var dotI = 0; dotI < dotsCount; dotI++) preparedStateNotation += '.';
1573
- continue;
1574
- }
1575
- preparedStateNotation += stateNotaion[i];
1576
- }
1577
- gameState.boardState = partFENtoState(preparedStateNotation);
1578
- gameState.currentColor = currentColor === 'w' ? 'white' : 'black';
1579
- gameState.boardState = prepareCastlingByFEN(FENcastling, gameState.boardState);
1580
- if (beatedField !== '-') {
1581
- var posBeatedCell = getPositionByFEN(beatedField);
1582
- gameState.boardState[posBeatedCell[0]][posBeatedCell[1]] = _extends({}, gameState.boardState[posBeatedCell[0]][posBeatedCell[1]], {
1583
- beated: true
1584
- });
1566
+ try {
1567
+ var gameState = {
1568
+ boardState: [],
1569
+ currentColor: 'white'
1570
+ };
1571
+ var _FEN$split = FEN.split(' '),
1572
+ stateNotaion = _FEN$split[0],
1573
+ currentColor = _FEN$split[1],
1574
+ FENcastling = _FEN$split[2],
1575
+ beatedField = _FEN$split[3],
1576
+ _ = _FEN$split.slice(4);
1577
+ var preparedStateNotation = '';
1578
+ for (var i = 0; i < stateNotaion.length; i++) {
1579
+ if (!isNaN(parseInt(stateNotaion[i]))) {
1580
+ var dotsCount = parseInt(stateNotaion[i]);
1581
+ for (var dotI = 0; dotI < dotsCount; dotI++) preparedStateNotation += '.';
1582
+ continue;
1583
+ }
1584
+ preparedStateNotation += stateNotaion[i];
1585
+ }
1586
+ gameState.boardState = partFENtoState(preparedStateNotation);
1587
+ gameState.currentColor = currentColor === 'w' ? 'white' : 'black';
1588
+ gameState.boardState = prepareCastlingByFEN(FENcastling, gameState.boardState);
1589
+ if (beatedField !== '-') {
1590
+ var posBeatedCell = getPositionByFEN(beatedField);
1591
+ gameState.boardState[posBeatedCell[0]][posBeatedCell[1]] = _extends({}, gameState.boardState[posBeatedCell[0]][posBeatedCell[1]], {
1592
+ beated: true
1593
+ });
1594
+ }
1595
+ if (reversed) return {
1596
+ boardState: JSChessEngine.reverseChessBoard(gameState.boardState),
1597
+ currentColor: gameState.currentColor
1598
+ };
1599
+ return gameState;
1600
+ } catch (_unused) {
1601
+ return {
1602
+ boardState: INITIAL_CELLS,
1603
+ currentColor: 'white',
1604
+ invalidFEN: true
1605
+ };
1585
1606
  }
1586
- if (reversed) return {
1587
- boardState: JSChessEngine.reverseChessBoard(gameState.boardState),
1588
- currentColor: gameState.currentColor
1589
- };
1590
- return gameState;
1591
1607
  };
1592
1608
  var getBeatedCellFENfromState = function getBeatedCellFENfromState(state) {
1593
1609
  var beatedFieldFEN = '-';
@@ -1679,7 +1695,7 @@ var stateToFEN = function stateToFEN(state, currentColor, countMoves) {
1679
1695
  return positionsFEN + " " + colorFEN + " " + casttlingFEN + " " + beatedFieldFEN + " " + blackMoves + " " + countMoves;
1680
1696
  };
1681
1697
 
1682
- 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"};
1698
+ 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","chessBoardInvalidFenMessage":"_jyC3-","fenErrorMessage":"_8urIN","fenErrorMessageClose":"_3p5AF","movesTrail":"_1RqCc","lightSquare":"_1B0qo","darkSquare":"_1NBqS"};
1683
1699
 
1684
1700
  var CHESS_PIECES_MAP = {
1685
1701
  'pawn-white': function pawnWhite(size) {
@@ -2312,7 +2328,9 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2312
2328
  var config = props.config,
2313
2329
  onChange = props.onChange,
2314
2330
  onEndGame = props.onEndGame,
2315
- onClickByChessBoard = props.onClickByChessBoard;
2331
+ onClickByChessBoard = props.onClickByChessBoard,
2332
+ _props$toggleTurn = props.toggleTurn,
2333
+ toggleTurn = _props$toggleTurn === void 0 ? true : _props$toggleTurn;
2316
2334
  var _useState = React.useState(DEFAULT_CHESSBORD_CONFIG),
2317
2335
  boardConfig = _useState[0],
2318
2336
  setBoardConfig = _useState[1];
@@ -2382,6 +2400,9 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2382
2400
  var _useState23 = React.useState(false),
2383
2401
  animated = _useState23[0],
2384
2402
  setAnimated = _useState23[1];
2403
+ var _useState24 = React.useState(false),
2404
+ invalidFEN = _useState24[0],
2405
+ setInvalidFEN = _useState24[1];
2385
2406
  var clearFromPos = function clearFromPos() {
2386
2407
  return setFromPos([-1, -1]);
2387
2408
  };
@@ -2395,7 +2416,7 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2395
2416
  return setClickPossibleMoves([]);
2396
2417
  };
2397
2418
  var toggleCurrentColor = function toggleCurrentColor() {
2398
- return setCurrentColor(function (prevColor) {
2419
+ if (toggleTurn) setCurrentColor(function (prevColor) {
2399
2420
  return prevColor === 'white' ? 'black' : 'white';
2400
2421
  });
2401
2422
  };
@@ -2444,7 +2465,8 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2444
2465
  if (!onClickByChessBoard) return;
2445
2466
  onClickByChessBoard({
2446
2467
  cellData: cellData,
2447
- pos: pos
2468
+ pos: pos,
2469
+ currentColor: currentColor
2448
2470
  });
2449
2471
  };
2450
2472
  var selectFigureFrom = function selectFigureFrom(cellPos, extActualState) {
@@ -2510,8 +2532,10 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2510
2532
  var _JSChessEngine$change = JSChessEngine.changeState(actualState, figure, to, from, boardReversed),
2511
2533
  updatedCells = _JSChessEngine$change.updatedCells,
2512
2534
  attackedPos = _JSChessEngine$change.attackedPos;
2513
- var linesCheck = JSChessEngine.getLinesWithCheck(updatedCells, currentColor, boardReversed);
2514
- setLinesWithCheck(linesCheck);
2535
+ if (toggleTurn) {
2536
+ var linesCheck = JSChessEngine.getLinesWithCheck(updatedCells, currentColor, boardReversed);
2537
+ setLinesWithCheck(linesCheck);
2538
+ }
2515
2539
  setActualState(updatedCells);
2516
2540
  if (figure.type === 'pawn' && (to[1] === 0 || to[1] === actualState.length - 1)) {
2517
2541
  setTargetPos(to);
@@ -2545,8 +2569,10 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2545
2569
  figure = _change$move.figure;
2546
2570
  var _JSChessEngine$change2 = JSChessEngine.changeState(actualState, figure, to, from, boardReversed),
2547
2571
  updatedCells = _JSChessEngine$change2.updatedCells;
2548
- var linesCheck = JSChessEngine.getLinesWithCheck(updatedCells, currentColor, boardReversed);
2549
- setLinesWithCheck(linesCheck);
2572
+ if (toggleTurn) {
2573
+ var linesCheck = JSChessEngine.getLinesWithCheck(updatedCells, currentColor, boardReversed);
2574
+ setLinesWithCheck(linesCheck);
2575
+ }
2550
2576
  var updatedChange = _extends({}, change, {
2551
2577
  move: boardReversed ? JSChessEngine.reverseMove(change.move) : change.move
2552
2578
  });
@@ -2567,8 +2593,10 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2567
2593
  var _JSChessEngine$change3 = JSChessEngine.changeState(actualState, figure, to, from, boardReversed),
2568
2594
  updatedCells = _JSChessEngine$change3.updatedCells,
2569
2595
  attackedPos = _JSChessEngine$change3.attackedPos;
2570
- var linesCheck = JSChessEngine.getLinesWithCheck(updatedCells, currentColor, boardReversed);
2571
- setLinesWithCheck(linesCheck);
2596
+ if (toggleTurn) {
2597
+ var linesCheck = JSChessEngine.getLinesWithCheck(updatedCells, currentColor, boardReversed);
2598
+ setLinesWithCheck(linesCheck);
2599
+ }
2572
2600
  setActualState(updatedCells);
2573
2601
  if (figure.type === 'pawn' && (to[1] === 0 || to[1] === actualState.length - 1)) {
2574
2602
  setTargetPos(to);
@@ -2599,8 +2627,11 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2599
2627
  var _JSChessEngine$change4 = JSChessEngine.changeState(actualState, figure, to, from, boardReversed),
2600
2628
  updatedCells = _JSChessEngine$change4.updatedCells,
2601
2629
  attackedPos = _JSChessEngine$change4.attackedPos;
2602
- var linesCheck = JSChessEngine.getLinesWithCheck(updatedCells, currentColor, boardReversed);
2603
- setLinesWithCheck(linesCheck);
2630
+ var linesCheck = [];
2631
+ if (toggleTurn) {
2632
+ linesCheck = JSChessEngine.getLinesWithCheck(updatedCells, currentColor, boardReversed);
2633
+ setLinesWithCheck(linesCheck);
2634
+ }
2604
2635
  if (fromPos[0] !== -1) {
2605
2636
  var figureFromPos = updatedCells[fromPos[1]][fromPos[0]].figure;
2606
2637
  if (!figureFromPos || figureFromPos.type !== holdedFigure.type || figureFromPos.color !== holdedFigure.color) {
@@ -2815,7 +2846,9 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2815
2846
  var handleUpdateFEN = function handleUpdateFEN(FEN, reversed) {
2816
2847
  var _FENtoGameState = FENtoGameState(FEN, reversed),
2817
2848
  boardState = _FENtoGameState.boardState,
2818
- currentColor = _FENtoGameState.currentColor;
2849
+ currentColor = _FENtoGameState.currentColor,
2850
+ invalidFEN = _FENtoGameState.invalidFEN;
2851
+ setInvalidFEN(invalidFEN);
2819
2852
  cleanAllForFigure();
2820
2853
  setAnimated(false);
2821
2854
  setInitialState(boardState);
@@ -2830,6 +2863,7 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2830
2863
  newMove: newMove,
2831
2864
  animated: animated,
2832
2865
  movesTrail: movesTrail,
2866
+ invalidFEN: invalidFEN,
2833
2867
  boardConfig: boardConfig,
2834
2868
  markedCells: markedCells,
2835
2869
  grabbingPos: grabbingPos,
@@ -2849,6 +2883,7 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2849
2883
  handleClick: handleClick,
2850
2884
  clearFromPos: clearFromPos,
2851
2885
  handleGrabEnd: handleGrabEnd,
2886
+ setInvalidFEN: setInvalidFEN,
2852
2887
  handleGrabbing: handleGrabbing,
2853
2888
  endRenderArrow: endRenderArrow,
2854
2889
  setActualState: setActualState,
@@ -3042,17 +3077,21 @@ var ChessBoard = function ChessBoard(props) {
3042
3077
  _props$moveArrows = props.moveArrows,
3043
3078
  moveArrows = _props$moveArrows === void 0 ? [] : _props$moveArrows,
3044
3079
  _props$arrows = props.arrows,
3045
- arrows = _props$arrows === void 0 ? [] : _props$arrows;
3080
+ arrows = _props$arrows === void 0 ? [] : _props$arrows,
3081
+ _props$toggleTurn = props.toggleTurn,
3082
+ toggleTurn = _props$toggleTurn === void 0 ? true : _props$toggleTurn;
3046
3083
  var _useChessBoardInterac = useChessBoardInteractive({
3047
3084
  onChange: onChange,
3048
3085
  onEndGame: onEndGame,
3049
3086
  onClickByChessBoard: onClick,
3050
- config: config
3087
+ config: config,
3088
+ toggleTurn: toggleTurn
3051
3089
  }),
3052
3090
  fromPos = _useChessBoardInterac.fromPos,
3053
3091
  newMove = _useChessBoardInterac.newMove,
3054
3092
  animated = _useChessBoardInterac.animated,
3055
3093
  movesTrail = _useChessBoardInterac.movesTrail,
3094
+ invalidFEN = _useChessBoardInterac.invalidFEN,
3056
3095
  boardConfig = _useChessBoardInterac.boardConfig,
3057
3096
  markedCells = _useChessBoardInterac.markedCells,
3058
3097
  grabbingPos = _useChessBoardInterac.grabbingPos,
@@ -3067,6 +3106,7 @@ var ChessBoard = function ChessBoard(props) {
3067
3106
  markCell = _useChessBoardInterac.markCell,
3068
3107
  handleClick = _useChessBoardInterac.handleClick,
3069
3108
  handleGrabEnd = _useChessBoardInterac.handleGrabEnd,
3109
+ setInvalidFEN = _useChessBoardInterac.setInvalidFEN,
3070
3110
  handleGrabbing = _useChessBoardInterac.handleGrabbing,
3071
3111
  endRenderArrow = _useChessBoardInterac.endRenderArrow,
3072
3112
  setPlayerColor = _useChessBoardInterac.setPlayerColor,
@@ -3105,6 +3145,10 @@ var ChessBoard = function ChessBoard(props) {
3105
3145
  color: arrow.color
3106
3146
  };
3107
3147
  });
3148
+ var handleHideInvalidFENmessage = function handleHideInvalidFENmessage(event) {
3149
+ event.preventDefault();
3150
+ setInvalidFEN(false);
3151
+ };
3108
3152
  return React__default.createElement("div", {
3109
3153
  className: styles.chessBoard
3110
3154
  }, React__default.createElement(ChessBoardCellsLayout, {
@@ -3150,7 +3194,17 @@ var ChessBoard = function ChessBoard(props) {
3150
3194
  color: currentColor,
3151
3195
  forPawnTransform: true,
3152
3196
  onSelect: handleSelectFigurePicker
3153
- })));
3197
+ })), invalidFEN && React__default.createElement("div", {
3198
+ className: styles.chessBoardInvalidFenMessage
3199
+ }, React__default.createElement("div", {
3200
+ className: styles.fenErrorMessage,
3201
+ role: "alert"
3202
+ }, React__default.createElement("div", null, "Invalid FEN notation. The default board position was used instead.", " ", React__default.createElement("a", {
3203
+ href: "/docs/fen-errors"
3204
+ }, "See common FEN problems"), "."), React__default.createElement("div", null, React__default.createElement("a", {
3205
+ className: styles.fenErrorMessageClose,
3206
+ onClick: handleHideInvalidFENmessage
3207
+ }, "Hide this message")))));
3154
3208
  };
3155
3209
 
3156
3210
  exports.ALL_FIGURES = ALL_FIGURES;