react-chessboard-ui 1.4.8 → 1.4.10
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.
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +10 -4
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1044,7 +1044,7 @@ JSChessEngine.getGameResult = function (state, linesWithCheck, activeColor, reve
|
|
|
1044
1044
|
});
|
|
1045
1045
|
var countsSumResult = countsNextMoves.reduce(function (prevValue, curentValue) {
|
|
1046
1046
|
return prevValue + curentValue;
|
|
1047
|
-
});
|
|
1047
|
+
}, 0);
|
|
1048
1048
|
if (linesWithCheck.length > 0 && countsSumResult === 0) return {
|
|
1049
1049
|
resultType: 'mat',
|
|
1050
1050
|
winColor: activeColor === 'white' ? 'black' : 'white'
|
|
@@ -2383,13 +2383,16 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
|
|
|
2383
2383
|
var clearArrows = function clearArrows() {
|
|
2384
2384
|
return setArrowsCoords([]);
|
|
2385
2385
|
};
|
|
2386
|
+
var firstRender = React.useRef(false);
|
|
2386
2387
|
React.useEffect(function () {
|
|
2387
2388
|
setBoardConfig(getChessBoardConfig(config));
|
|
2388
2389
|
}, []);
|
|
2389
2390
|
React.useEffect(function () {
|
|
2390
|
-
if (
|
|
2391
|
+
if (firstRender.current) {
|
|
2391
2392
|
var gameResult = JSChessEngine.getGameResult(actualState, linesWithCheck, currentColor, boardReversed);
|
|
2392
2393
|
if (gameResult) onEndGame(gameResult);
|
|
2394
|
+
} else {
|
|
2395
|
+
firstRender.current = true;
|
|
2393
2396
|
}
|
|
2394
2397
|
}, [actualState, linesWithCheck, boardReversed, currentColor]);
|
|
2395
2398
|
var cleanAllForFigure = function cleanAllForFigure() {
|
|
@@ -2728,11 +2731,14 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
|
|
|
2728
2731
|
var handleSelectFigurePicker = function handleSelectFigurePicker(figure) {
|
|
2729
2732
|
var startPos = fromPos[0] > -1 ? fromPos : clickedPos;
|
|
2730
2733
|
var updatedCells = JSChessEngine.transformPawnToFigure(actualState, startPos, targetPos, figure);
|
|
2734
|
+
var colorFEN = currentColor === 'white' ? 'black' : 'white';
|
|
2735
|
+
var FEN = stateToFEN(updatedCells, colorFEN);
|
|
2731
2736
|
var moveData = {
|
|
2732
2737
|
figure: figure,
|
|
2733
2738
|
from: startPos,
|
|
2734
2739
|
to: targetPos,
|
|
2735
|
-
type: 'transform'
|
|
2740
|
+
type: 'transform',
|
|
2741
|
+
FEN: FEN
|
|
2736
2742
|
};
|
|
2737
2743
|
onChange(moveData);
|
|
2738
2744
|
setActualState(updatedCells);
|