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.modern.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, useMemo, useCallback } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
4
|
function _arrayLikeToArray(r, a) {
|
|
@@ -1041,7 +1041,7 @@ JSChessEngine.getGameResult = function (state, linesWithCheck, activeColor, reve
|
|
|
1041
1041
|
});
|
|
1042
1042
|
var countsSumResult = countsNextMoves.reduce(function (prevValue, curentValue) {
|
|
1043
1043
|
return prevValue + curentValue;
|
|
1044
|
-
});
|
|
1044
|
+
}, 0);
|
|
1045
1045
|
if (linesWithCheck.length > 0 && countsSumResult === 0) return {
|
|
1046
1046
|
resultType: 'mat',
|
|
1047
1047
|
winColor: activeColor === 'white' ? 'black' : 'white'
|
|
@@ -2380,13 +2380,16 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
|
|
|
2380
2380
|
var clearArrows = function clearArrows() {
|
|
2381
2381
|
return setArrowsCoords([]);
|
|
2382
2382
|
};
|
|
2383
|
+
var firstRender = useRef(false);
|
|
2383
2384
|
useEffect(function () {
|
|
2384
2385
|
setBoardConfig(getChessBoardConfig(config));
|
|
2385
2386
|
}, []);
|
|
2386
2387
|
useEffect(function () {
|
|
2387
|
-
if (
|
|
2388
|
+
if (firstRender.current) {
|
|
2388
2389
|
var gameResult = JSChessEngine.getGameResult(actualState, linesWithCheck, currentColor, boardReversed);
|
|
2389
2390
|
if (gameResult) onEndGame(gameResult);
|
|
2391
|
+
} else {
|
|
2392
|
+
firstRender.current = true;
|
|
2390
2393
|
}
|
|
2391
2394
|
}, [actualState, linesWithCheck, boardReversed, currentColor]);
|
|
2392
2395
|
var cleanAllForFigure = function cleanAllForFigure() {
|
|
@@ -2725,11 +2728,14 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
|
|
|
2725
2728
|
var handleSelectFigurePicker = function handleSelectFigurePicker(figure) {
|
|
2726
2729
|
var startPos = fromPos[0] > -1 ? fromPos : clickedPos;
|
|
2727
2730
|
var updatedCells = JSChessEngine.transformPawnToFigure(actualState, startPos, targetPos, figure);
|
|
2731
|
+
var colorFEN = currentColor === 'white' ? 'black' : 'white';
|
|
2732
|
+
var FEN = stateToFEN(updatedCells, colorFEN);
|
|
2728
2733
|
var moveData = {
|
|
2729
2734
|
figure: figure,
|
|
2730
2735
|
from: startPos,
|
|
2731
2736
|
to: targetPos,
|
|
2732
|
-
type: 'transform'
|
|
2737
|
+
type: 'transform',
|
|
2738
|
+
FEN: FEN
|
|
2733
2739
|
};
|
|
2734
2740
|
onChange(moveData);
|
|
2735
2741
|
setActualState(updatedCells);
|