react-chessboard-ui 2.0.0 → 2.2.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.
@@ -4,6 +4,7 @@ import { ArrowCoords, ChessBoardConfig } from "./models";
4
4
  declare type ArrowLayoutType = {
5
5
  startArrowCoord: CellPos;
6
6
  arrowsCoords: ArrowCoords[];
7
+ externalArrowsCoords?: ArrowCoords[];
7
8
  grabbingPos: CellPos;
8
9
  boardConfig: ChessBoardConfig;
9
10
  };
@@ -1,6 +1,6 @@
1
1
  import { PieceColor, GameResult, MoveData, SquarePos } from "../JSChessEngine";
2
2
  import { FC } from "react";
3
- import { ChangeMove, ChessBoardConfig } from "./models";
3
+ import { ArrowCoords, ChangeMove, ChessBoardConfig } from "./models";
4
4
  declare type ChessBoardProps = {
5
5
  FEN: string;
6
6
  onChange: (moveData: MoveData) => void;
@@ -11,6 +11,7 @@ declare type ChessBoardProps = {
11
11
  playerColor?: PieceColor;
12
12
  viewOnly?: boolean;
13
13
  moveHighlight?: [SquarePos, SquarePos];
14
+ moveArrows?: ArrowCoords[];
14
15
  };
15
16
  export declare const ChessBoard: FC<ChessBoardProps>;
16
17
  export {};
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++) {
@@ -2937,7 +2938,9 @@ var ArrowLayout = function ArrowLayout(props) {
2937
2938
  var startArrowCoord = props.startArrowCoord,
2938
2939
  arrowsCoords = props.arrowsCoords,
2939
2940
  grabbingPos = props.grabbingPos,
2940
- boardConfig = props.boardConfig;
2941
+ boardConfig = props.boardConfig,
2942
+ _props$externalArrows = props.externalArrowsCoords,
2943
+ externalArrowsCoords = _props$externalArrows === void 0 ? [] : _props$externalArrows;
2941
2944
  return React__default.createElement("div", {
2942
2945
  className: styles.arrowsLayer
2943
2946
  }, startArrowCoord[0] > -1 && grabbingPos[0] > -1 && React__default.createElement(Arrow, {
@@ -2950,6 +2953,12 @@ var ArrowLayout = function ArrowLayout(props) {
2950
2953
  }, coords, {
2951
2954
  color: boardConfig.arrowColor
2952
2955
  }));
2956
+ }), externalArrowsCoords.map(function (coords, i) {
2957
+ return React__default.createElement(Arrow, Object.assign({
2958
+ key: "extArrow_" + i
2959
+ }, coords, {
2960
+ color: boardConfig.arrowColor
2961
+ }));
2953
2962
  }));
2954
2963
  };
2955
2964
 
@@ -2988,7 +2997,9 @@ var ChessBoard = function ChessBoard(props) {
2988
2997
  config = props.config,
2989
2998
  playerColor = props.playerColor,
2990
2999
  viewOnly = props.viewOnly,
2991
- moveHighlight = props.moveHighlight;
3000
+ moveHighlight = props.moveHighlight,
3001
+ _props$moveArrows = props.moveArrows,
3002
+ moveArrows = _props$moveArrows === void 0 ? [] : _props$moveArrows;
2992
3003
  var _useChessBoardInterac = useChessBoardInteractive({
2993
3004
  onChange: onChange,
2994
3005
  onEndGame: onEndGame,
@@ -3053,6 +3064,12 @@ var ChessBoard = function ChessBoard(props) {
3053
3064
  var reversedChange = reversed ? JSChessEngine.reverseMove(change.move) : change.move;
3054
3065
  handleChangeFromExternal(reversedChange, change.withTransition);
3055
3066
  }, [change]);
3067
+ var externalArrows = moveArrows.map(function (arrow) {
3068
+ return {
3069
+ start: correctGrabbingPosForArrow(arrow.start, boardConfig),
3070
+ end: correctGrabbingPosForArrow(arrow.end, boardConfig)
3071
+ };
3072
+ });
3056
3073
  return React__default.createElement("div", {
3057
3074
  className: styles.chessBoard
3058
3075
  }, React__default.createElement(ChessBoardCellsLayout, {
@@ -3074,6 +3091,7 @@ var ChessBoard = function ChessBoard(props) {
3074
3091
  onHasCheck: getHasCheckByCellPos
3075
3092
  }), React__default.createElement(ArrowLayout, {
3076
3093
  arrowsCoords: arrowsCoords,
3094
+ externalArrowsCoords: externalArrows,
3077
3095
  startArrowCoord: startArrowCoord,
3078
3096
  grabbingPos: correctGrabbingPosForArrow(grabbingCell, boardConfig),
3079
3097
  boardConfig: boardConfig