react-chessboard-ui 2.12.0 → 2.14.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.
@@ -52,9 +52,12 @@ var FIGURES_COUNTS = {
52
52
  };
53
53
  var JSChessEngine = /*#__PURE__*/function () {
54
54
  function JSChessEngine() {}
55
- JSChessEngine.detectDrawByRepeatMoves = function detectDrawByRepeatMoves(fenMoves) {
56
- if (fenMoves.length < 8) return false;
57
- var lastMoves = fenMoves.slice(fenMoves.length - 8);
55
+ JSChessEngine.detectDrawByRepeatMoves = function detectDrawByRepeatMoves(fenMoves, boardSize) {
56
+ if (boardSize === void 0) {
57
+ boardSize = 8;
58
+ }
59
+ if (fenMoves.length < boardSize) return false;
60
+ var lastMoves = fenMoves.slice(fenMoves.length - boardSize);
58
61
  var firstFromSelectedMoves = lastMoves.slice(0, 4);
59
62
  var lastFromSelectedMoves = lastMoves.slice(4);
60
63
  var firstResultsFENs = firstFromSelectedMoves.join('');
@@ -1481,8 +1484,11 @@ var INITIAL_CELLS = [[{
1481
1484
  }
1482
1485
  }]];
1483
1486
 
1484
- var getPositionByFEN = function getPositionByFEN(positionFEN) {
1485
- return [8 - parseInt(positionFEN[1]) + 1, LETTERS.findIndex(function (letter) {
1487
+ var getPositionByFEN = function getPositionByFEN(positionFEN, boardSize) {
1488
+ if (boardSize === void 0) {
1489
+ boardSize = 8;
1490
+ }
1491
+ return [boardSize - parseInt(positionFEN[1]) + 1, LETTERS.findIndex(function (letter) {
1486
1492
  return letter === positionFEN[0];
1487
1493
  })];
1488
1494
  };
@@ -1577,20 +1583,14 @@ var FENtoGameState = function FENtoGameState(FEN, reversed) {
1577
1583
  FENcastling = _FEN$split[2],
1578
1584
  beatedField = _FEN$split[3],
1579
1585
  _ = _FEN$split.slice(4);
1580
- var preparedStateNotation = '';
1581
- for (var i = 0; i < stateNotaion.length; i++) {
1582
- if (!isNaN(parseInt(stateNotaion[i]))) {
1583
- var dotsCount = parseInt(stateNotaion[i]);
1584
- for (var dotI = 0; dotI < dotsCount; dotI++) preparedStateNotation += '.';
1585
- continue;
1586
- }
1587
- preparedStateNotation += stateNotaion[i];
1588
- }
1586
+ var preparedStateNotation = stateNotaion.replace(/\d+/g, function (match) {
1587
+ return '.'.repeat(Number(match));
1588
+ });
1589
1589
  gameState.boardState = partFENtoState(preparedStateNotation);
1590
1590
  gameState.currentColor = currentColor === 'w' ? 'white' : 'black';
1591
1591
  gameState.boardState = prepareCastlingByFEN(FENcastling, gameState.boardState);
1592
1592
  if (beatedField !== '-') {
1593
- var posBeatedCell = getPositionByFEN(beatedField);
1593
+ var posBeatedCell = getPositionByFEN(beatedField, gameState.boardState.length);
1594
1594
  gameState.boardState[posBeatedCell[0]][posBeatedCell[1]] = _extends({}, gameState.boardState[posBeatedCell[0]][posBeatedCell[1]], {
1595
1595
  beated: true
1596
1596
  });
@@ -1905,8 +1905,11 @@ var DEFAULT_CIRCLE_MARK_COLOR = '#3697ce';
1905
1905
  var DEFAULT_ARROW_COLOR = '#6ac2fd';
1906
1906
  var DEFAULT_PIECES_MAP = CHESS_PIECES_MAP;
1907
1907
  var DEFAULT_SHOW_MOVES_TRAIL = true;
1908
- var DEFAULT_HIDE_PIECES_HANDLER = function DEFAULT_HIDE_PIECES_HANDLER(figure) {
1909
- figure.color === 'white' ? figure.position = [8, figure.position[1]] : figure.position = [-1, figure.position[1]];
1908
+ var DEFAULT_HIDE_PIECES_HANDLER = function DEFAULT_HIDE_PIECES_HANDLER(figure, boardSize) {
1909
+ if (boardSize === void 0) {
1910
+ boardSize = 8;
1911
+ }
1912
+ figure.color === 'white' ? figure.position = [boardSize, figure.position[1]] : figure.position = [-1, figure.position[1]];
1910
1913
  };
1911
1914
  var DEFAULT_SQUARE_SIZE = 92;
1912
1915
  var DEFAULT_PIECE_SIZE_PERCENT = 80;
@@ -3155,6 +3158,7 @@ var ChessBoard = function ChessBoard(props) {
3155
3158
  return React.createElement("div", {
3156
3159
  className: styles.chessBoard
3157
3160
  }, React.createElement(ChessBoardCellsLayout, {
3161
+ size: initialState.length,
3158
3162
  boardConfig: boardConfig,
3159
3163
  movesTrail: boardConfig.showMovesTrail && movesTrail,
3160
3164
  moveHighlight: moveHighlight
@@ -3164,6 +3168,7 @@ var ChessBoard = function ChessBoard(props) {
3164
3168
  boardConfig: boardConfig,
3165
3169
  animated: animated
3166
3170
  }), React.createElement(ChessBoardInteractiveLayout, {
3171
+ size: initialState.length,
3167
3172
  selectedPos: fromPos,
3168
3173
  possibleMoves: possibleMoves,
3169
3174
  holdedFigure: holdedFigure,
@@ -3179,6 +3184,7 @@ var ChessBoard = function ChessBoard(props) {
3179
3184
  grabbingPos: correctGrabbingPosForArrow(grabbingCell, boardConfig),
3180
3185
  boardConfig: boardConfig
3181
3186
  }), React.createElement(ChessBoardControlLayout, {
3187
+ size: initialState.length,
3182
3188
  boardConfig: boardConfig,
3183
3189
  onClick: function onClick(pos) {
3184
3190
  return handleClick(pos, viewOnly);
@@ -3203,7 +3209,7 @@ var ChessBoard = function ChessBoard(props) {
3203
3209
  className: styles.fenErrorMessage,
3204
3210
  role: "alert"
3205
3211
  }, React.createElement("div", null, "Invalid FEN notation. The default board position was used instead.", " ", React.createElement("a", {
3206
- href: "/docs/fen-errors"
3212
+ href: "https://react-chessboard-ui.dev/docs/fen-errors"
3207
3213
  }, "See common FEN problems"), "."), React.createElement("div", null, React.createElement("a", {
3208
3214
  className: styles.fenErrorMessageClose,
3209
3215
  onClick: handleHideInvalidFENmessage