react-chessboard-ui 1.3.0 → 1.4.1

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.
@@ -9,6 +9,7 @@ declare type ChessBoardProps = {
9
9
  reversed?: boolean;
10
10
  config?: Partial<ChessBoardConfig>;
11
11
  playerColor?: FigureColor;
12
+ viewOnly?: boolean;
12
13
  };
13
14
  export declare const ChessBoard: FC<ChessBoardProps>;
14
15
  export {};
@@ -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
@@ -2610,9 +2610,13 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2610
2610
  clearClickedPos();
2611
2611
  clearClickPossibleMoves();
2612
2612
  };
2613
- var handleClick = function handleClick(cellPos) {
2613
+ var handleClick = function handleClick(cellPos, viewOnly) {
2614
+ if (viewOnly === void 0) {
2615
+ viewOnly = false;
2616
+ }
2614
2617
  clearMarkedCells();
2615
2618
  clearArrows();
2619
+ if (viewOnly) return;
2616
2620
  if (clickedPos[0] === -1) {
2617
2621
  selectClickFrom(cellPos);
2618
2622
  return;
@@ -2889,7 +2893,8 @@ var ChessBoard = function ChessBoard(props) {
2889
2893
  change = props.change,
2890
2894
  reversed = props.reversed,
2891
2895
  config = props.config,
2892
- playerColor = props.playerColor;
2896
+ playerColor = props.playerColor,
2897
+ viewOnly = props.viewOnly;
2893
2898
  var _useChessBoardInterac = useChessBoardInteractive({
2894
2899
  onChange: onChange,
2895
2900
  onEndGame: onEndGame,
@@ -2972,12 +2977,14 @@ var ChessBoard = function ChessBoard(props) {
2972
2977
  boardConfig: boardConfig
2973
2978
  }), React__default.createElement(ChessBoardControlLayout, {
2974
2979
  boardConfig: boardConfig,
2975
- onClick: handleClick,
2976
- onGrabStart: selectHoverFrom,
2980
+ onClick: function onClick(pos) {
2981
+ return handleClick(pos, viewOnly);
2982
+ },
2983
+ onGrabStart: viewOnly ? function () {} : selectHoverFrom,
2977
2984
  onGrabStartRight: startRenderArrow,
2978
- onGrabEnd: handleGrabEnd,
2985
+ onGrabEnd: viewOnly ? function () {} : handleGrabEnd,
2979
2986
  onGrabEndRight: endRenderArrow,
2980
- onGrabbing: handleGrabbing,
2987
+ onGrabbing: viewOnly ? function () {} : handleGrabbing,
2981
2988
  onRightClick: markCell,
2982
2989
  onGrabbingCell: handleGrabbingCell
2983
2990
  }), showFigurePicker && React__default.createElement("div", {