react-chessboard-ui 1.4.0 → 1.4.2

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.
@@ -26,7 +26,7 @@ export declare const useChessBoardInteractive: (props: UseChessBoardInteractiveP
26
26
  markCell: (cellPos: CellPos) => void;
27
27
  setNewMove: import("react").Dispatch<import("react").SetStateAction<ChangeMove>>;
28
28
  setAnimated: import("react").Dispatch<import("react").SetStateAction<boolean>>;
29
- handleClick: (cellPos: CellPos) => void;
29
+ handleClick: (cellPos: CellPos, viewOnly?: boolean) => void;
30
30
  clearFromPos: () => void;
31
31
  handleGrabEnd: (cellPos: CellPos, withTransition?: boolean) => void;
32
32
  handleGrabbing: (x: number, y: number) => void;
package/dist/index.js CHANGED
@@ -2574,7 +2574,6 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2574
2574
  var handleChangeFromExternal = function handleChangeFromExternal(moveData) {
2575
2575
  var _moveFigureByExternal = moveFigureByExternalChange(moveData.from, moveData.to, moveData.figure),
2576
2576
  attackedPos = _moveFigureByExternal.attackedPos;
2577
- onChange(moveData);
2578
2577
  setAnimated(true);
2579
2578
  var change = {
2580
2579
  move: moveData,
@@ -2610,9 +2609,13 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2610
2609
  clearClickedPos();
2611
2610
  clearClickPossibleMoves();
2612
2611
  };
2613
- var handleClick = function handleClick(cellPos) {
2612
+ var handleClick = function handleClick(cellPos, viewOnly) {
2613
+ if (viewOnly === void 0) {
2614
+ viewOnly = false;
2615
+ }
2614
2616
  clearMarkedCells();
2615
2617
  clearArrows();
2618
+ if (viewOnly) return;
2616
2619
  if (clickedPos[0] === -1) {
2617
2620
  selectClickFrom(cellPos);
2618
2621
  return;
@@ -2973,7 +2976,9 @@ var ChessBoard = function ChessBoard(props) {
2973
2976
  boardConfig: boardConfig
2974
2977
  }), React__default.createElement(ChessBoardControlLayout, {
2975
2978
  boardConfig: boardConfig,
2976
- onClick: handleClick,
2979
+ onClick: function onClick(pos) {
2980
+ return handleClick(pos, viewOnly);
2981
+ },
2977
2982
  onGrabStart: viewOnly ? function () {} : selectHoverFrom,
2978
2983
  onGrabStartRight: startRenderArrow,
2979
2984
  onGrabEnd: viewOnly ? function () {} : handleGrabEnd,