react-chessboard-ui 2.13.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.
@@ -11,7 +11,7 @@ export declare const DEFAULT_MARKED_CELL_COLOR = "#3697ce";
11
11
  export declare const DEFAULT_CHECKED_CELL_COLOR = "#e95b5c";
12
12
  export declare const DEFAULT_PIECES_MAP: import("./models").ChessPiecesMap;
13
13
  export declare const DEFAULT_SHOW_MOVES_TRAIL = true;
14
- export declare const DEFAULT_HIDE_PIECES_HANDLER: (figure: Piece) => void;
14
+ export declare const DEFAULT_HIDE_PIECES_HANDLER: (figure: Piece, boardSize?: number) => void;
15
15
  export declare const DEFAULT_SQUARE_SIZE = 92;
16
16
  export declare const DEFAULT_PIECE_SIZE_PERCENT = 80;
17
17
  export declare const DEFAULT_HIDE_PIECE_EFFECT_CLASS_NAME: string;
@@ -4,7 +4,7 @@ import { FigureColor, Cell } from './JSChessEngine';
4
4
  * @param positionFEN позиция из FEN вида e4
5
5
  * @returns координаты для определения клетки на доске
6
6
  */
7
- export declare const getPositionByFEN: (positionFEN: string) => number[];
7
+ export declare const getPositionByFEN: (positionFEN: string, boardSize?: number) => number[];
8
8
  /**
9
9
  * Проверяет по части FEN возможность рокировки
10
10
  * и обновляет состояние доски для рокировки
@@ -378,7 +378,7 @@ export declare class JSChessEngine {
378
378
  * length - 8
379
379
  * @param fenMoves история ходов в формате FEN
380
380
  */
381
- static detectDrawByRepeatMoves(fenMoves: string[]): boolean;
381
+ static detectDrawByRepeatMoves(fenMoves: string[], boardSize?: number): boolean;
382
382
  /**
383
383
  * Проверяет является ли ход рокеровкой
384
384
  * @param move данные хода
package/dist/index.js CHANGED
@@ -55,9 +55,12 @@ var FIGURES_COUNTS = {
55
55
  };
56
56
  var JSChessEngine = /*#__PURE__*/function () {
57
57
  function JSChessEngine() {}
58
- JSChessEngine.detectDrawByRepeatMoves = function detectDrawByRepeatMoves(fenMoves) {
59
- if (fenMoves.length < 8) return false;
60
- var lastMoves = fenMoves.slice(fenMoves.length - 8);
58
+ JSChessEngine.detectDrawByRepeatMoves = function detectDrawByRepeatMoves(fenMoves, boardSize) {
59
+ if (boardSize === void 0) {
60
+ boardSize = 8;
61
+ }
62
+ if (fenMoves.length < boardSize) return false;
63
+ var lastMoves = fenMoves.slice(fenMoves.length - boardSize);
61
64
  var firstFromSelectedMoves = lastMoves.slice(0, 4);
62
65
  var lastFromSelectedMoves = lastMoves.slice(4);
63
66
  var firstResultsFENs = firstFromSelectedMoves.join('');
@@ -1484,8 +1487,11 @@ var INITIAL_CELLS = [[{
1484
1487
  }
1485
1488
  }]];
1486
1489
 
1487
- var getPositionByFEN = function getPositionByFEN(positionFEN) {
1488
- return [8 - parseInt(positionFEN[1]) + 1, LETTERS.findIndex(function (letter) {
1490
+ var getPositionByFEN = function getPositionByFEN(positionFEN, boardSize) {
1491
+ if (boardSize === void 0) {
1492
+ boardSize = 8;
1493
+ }
1494
+ return [boardSize - parseInt(positionFEN[1]) + 1, LETTERS.findIndex(function (letter) {
1489
1495
  return letter === positionFEN[0];
1490
1496
  })];
1491
1497
  };
@@ -1580,20 +1586,14 @@ var FENtoGameState = function FENtoGameState(FEN, reversed) {
1580
1586
  FENcastling = _FEN$split[2],
1581
1587
  beatedField = _FEN$split[3],
1582
1588
  _ = _FEN$split.slice(4);
1583
- var preparedStateNotation = '';
1584
- for (var i = 0; i < stateNotaion.length; i++) {
1585
- if (!isNaN(parseInt(stateNotaion[i]))) {
1586
- var dotsCount = parseInt(stateNotaion[i]);
1587
- for (var dotI = 0; dotI < dotsCount; dotI++) preparedStateNotation += '.';
1588
- continue;
1589
- }
1590
- preparedStateNotation += stateNotaion[i];
1591
- }
1589
+ var preparedStateNotation = stateNotaion.replace(/\d+/g, function (match) {
1590
+ return '.'.repeat(Number(match));
1591
+ });
1592
1592
  gameState.boardState = partFENtoState(preparedStateNotation);
1593
1593
  gameState.currentColor = currentColor === 'w' ? 'white' : 'black';
1594
1594
  gameState.boardState = prepareCastlingByFEN(FENcastling, gameState.boardState);
1595
1595
  if (beatedField !== '-') {
1596
- var posBeatedCell = getPositionByFEN(beatedField);
1596
+ var posBeatedCell = getPositionByFEN(beatedField, gameState.boardState.length);
1597
1597
  gameState.boardState[posBeatedCell[0]][posBeatedCell[1]] = _extends({}, gameState.boardState[posBeatedCell[0]][posBeatedCell[1]], {
1598
1598
  beated: true
1599
1599
  });
@@ -1908,8 +1908,11 @@ var DEFAULT_CIRCLE_MARK_COLOR = '#3697ce';
1908
1908
  var DEFAULT_ARROW_COLOR = '#6ac2fd';
1909
1909
  var DEFAULT_PIECES_MAP = CHESS_PIECES_MAP;
1910
1910
  var DEFAULT_SHOW_MOVES_TRAIL = true;
1911
- var DEFAULT_HIDE_PIECES_HANDLER = function DEFAULT_HIDE_PIECES_HANDLER(figure) {
1912
- figure.color === 'white' ? figure.position = [8, figure.position[1]] : figure.position = [-1, figure.position[1]];
1911
+ var DEFAULT_HIDE_PIECES_HANDLER = function DEFAULT_HIDE_PIECES_HANDLER(figure, boardSize) {
1912
+ if (boardSize === void 0) {
1913
+ boardSize = 8;
1914
+ }
1915
+ figure.color === 'white' ? figure.position = [boardSize, figure.position[1]] : figure.position = [-1, figure.position[1]];
1913
1916
  };
1914
1917
  var DEFAULT_SQUARE_SIZE = 92;
1915
1918
  var DEFAULT_PIECE_SIZE_PERCENT = 80;
@@ -3158,6 +3161,7 @@ var ChessBoard = function ChessBoard(props) {
3158
3161
  return React__default.createElement("div", {
3159
3162
  className: styles.chessBoard
3160
3163
  }, React__default.createElement(ChessBoardCellsLayout, {
3164
+ size: initialState.length,
3161
3165
  boardConfig: boardConfig,
3162
3166
  movesTrail: boardConfig.showMovesTrail && movesTrail,
3163
3167
  moveHighlight: moveHighlight
@@ -3167,6 +3171,7 @@ var ChessBoard = function ChessBoard(props) {
3167
3171
  boardConfig: boardConfig,
3168
3172
  animated: animated
3169
3173
  }), React__default.createElement(ChessBoardInteractiveLayout, {
3174
+ size: initialState.length,
3170
3175
  selectedPos: fromPos,
3171
3176
  possibleMoves: possibleMoves,
3172
3177
  holdedFigure: holdedFigure,
@@ -3182,6 +3187,7 @@ var ChessBoard = function ChessBoard(props) {
3182
3187
  grabbingPos: correctGrabbingPosForArrow(grabbingCell, boardConfig),
3183
3188
  boardConfig: boardConfig
3184
3189
  }), React__default.createElement(ChessBoardControlLayout, {
3190
+ size: initialState.length,
3185
3191
  boardConfig: boardConfig,
3186
3192
  onClick: function onClick(pos) {
3187
3193
  return handleClick(pos, viewOnly);