kokopu-react 3.0.1 → 3.1.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.
- package/CHANGELOG.md +10 -0
- package/dist/lib/chessboard/BoardProperties.d.ts +91 -0
- package/dist/lib/chessboard/BoardProperties.js +43 -0
- package/dist/lib/chessboard/BoardProperties.js.map +1 -0
- package/dist/lib/chessboard/Chessboard.css +7 -5
- package/dist/lib/chessboard/Chessboard.d.ts +36 -58
- package/dist/lib/chessboard/Chessboard.js +33 -97
- package/dist/lib/chessboard/Chessboard.js.map +1 -1
- package/dist/lib/chessboard/ChessboardImpl.d.ts +22 -0
- package/dist/lib/chessboard/ChessboardImpl.js +8 -6
- package/dist/lib/chessboard/ChessboardImpl.js.map +1 -1
- package/dist/lib/chessboard/Draggable.d.ts +22 -0
- package/dist/lib/chessboard/Draggable.js +7 -5
- package/dist/lib/chessboard/Draggable.js.map +1 -1
- package/dist/lib/chessboard/Motion.d.ts +22 -0
- package/dist/lib/chessboard/Motion.js +7 -5
- package/dist/lib/chessboard/Motion.js.map +1 -1
- package/dist/lib/chessboard/colorsets.d.ts +22 -0
- package/dist/lib/chessboard/colorsets.js +7 -5
- package/dist/lib/chessboard/colorsets.js.map +1 -1
- package/dist/lib/chessboard/piecesets.d.ts +22 -0
- package/dist/lib/chessboard/piecesets.js +7 -5
- package/dist/lib/chessboard/piecesets.js.map +1 -1
- package/dist/lib/errorbox/ErrorBox.css +7 -5
- package/dist/lib/errorbox/ErrorBox.d.ts +22 -0
- package/dist/lib/errorbox/ErrorBox.js +7 -5
- package/dist/lib/errorbox/ErrorBox.js.map +1 -1
- package/dist/lib/errorbox/parsing.d.ts +57 -0
- package/dist/lib/errorbox/parsing.js +140 -0
- package/dist/lib/errorbox/parsing.js.map +1 -0
- package/dist/lib/exception.d.ts +22 -0
- package/dist/lib/exception.js +7 -5
- package/dist/lib/exception.js.map +1 -1
- package/dist/lib/i18n.d.ts +27 -0
- package/dist/lib/i18n.js +13 -5
- package/dist/lib/i18n.js.map +1 -1
- package/dist/lib/icons/AnnotationSymbolShape.css +7 -5
- package/dist/lib/icons/AnnotationSymbolShape.d.ts +22 -0
- package/dist/lib/icons/AnnotationSymbolShape.js +7 -5
- package/dist/lib/icons/AnnotationSymbolShape.js.map +1 -1
- package/dist/lib/icons/ArrowMarkerIcon.d.ts +22 -0
- package/dist/lib/icons/ArrowMarkerIcon.js +7 -5
- package/dist/lib/icons/ArrowMarkerIcon.js.map +1 -1
- package/dist/lib/icons/ArrowTip.d.ts +22 -0
- package/dist/lib/icons/ArrowTip.js +7 -5
- package/dist/lib/icons/ArrowTip.js.map +1 -1
- package/dist/lib/icons/ChessPieceIcon.d.ts +22 -0
- package/dist/lib/icons/ChessPieceIcon.js +7 -5
- package/dist/lib/icons/ChessPieceIcon.js.map +1 -1
- package/dist/lib/icons/SquareMarkerIcon.d.ts +22 -0
- package/dist/lib/icons/SquareMarkerIcon.js +7 -5
- package/dist/lib/icons/SquareMarkerIcon.js.map +1 -1
- package/dist/lib/icons/TextMarkerIcon.d.ts +22 -0
- package/dist/lib/icons/TextMarkerIcon.js +7 -5
- package/dist/lib/icons/TextMarkerIcon.js.map +1 -1
- package/dist/lib/icons/arrow.css +7 -5
- package/dist/lib/index.d.ts +26 -1
- package/dist/lib/index.js +9 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/movetext/Movetext.css +7 -18
- package/dist/lib/movetext/Movetext.d.ts +31 -43
- package/dist/lib/movetext/Movetext.js +22 -72
- package/dist/lib/movetext/Movetext.js.map +1 -1
- package/dist/lib/movetext/MovetextImpl.d.ts +29 -28
- package/dist/lib/movetext/MovetextImpl.js +22 -99
- package/dist/lib/movetext/MovetextImpl.js.map +1 -1
- package/dist/lib/movetext/fonts.css +7 -5
- package/dist/lib/movetext/htmlFilter.d.ts +22 -0
- package/dist/lib/movetext/htmlFilter.js +21 -19
- package/dist/lib/movetext/htmlFilter.js.map +1 -1
- package/dist/lib/movetext/moveFormatter.d.ts +22 -0
- package/dist/lib/movetext/moveFormatter.js +7 -5
- package/dist/lib/movetext/moveFormatter.js.map +1 -1
- package/dist/lib/navigationboard/NavigationBoard.d.ts +118 -0
- package/dist/lib/navigationboard/NavigationBoard.js +112 -0
- package/dist/lib/navigationboard/NavigationBoard.js.map +1 -0
- package/dist/lib/navigationboard/NavigationField.css +36 -0
- package/dist/lib/navigationboard/NavigationField.d.ts +81 -0
- package/dist/lib/navigationboard/NavigationField.js +154 -0
- package/dist/lib/navigationboard/NavigationField.js.map +1 -0
- package/dist/lib/navigationboard/NavigationToolbar.css +51 -0
- package/dist/lib/navigationboard/NavigationToolbar.d.ts +41 -0
- package/dist/lib/navigationboard/NavigationToolbar.js +124 -0
- package/dist/lib/navigationboard/NavigationToolbar.js.map +1 -0
- package/dist/lib/sanitization.d.ts +22 -0
- package/dist/lib/sanitization.js +7 -5
- package/dist/lib/sanitization.js.map +1 -1
- package/dist/lib/types.d.ts +22 -0
- package/dist/lib/types.js +7 -5
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/util.d.ts +22 -0
- package/dist/lib/util.js +7 -5
- package/dist/lib/util.js.map +1 -1
- package/doc_src/demo/PageChessboardBase.tsx +7 -5
- package/doc_src/demo/PageChessboardInteraction.tsx +32 -22
- package/doc_src/demo/PageChessboardMove.tsx +24 -5
- package/doc_src/demo/PageChessboardSmallScreens.tsx +7 -5
- package/doc_src/demo/PageMovetextBase.tsx +7 -5
- package/doc_src/demo/PageMovetextInteraction.tsx +7 -5
- package/doc_src/demo/PageNavigationBoardBase.tsx +194 -0
- package/doc_src/demo/PageNavigationBoardUncontrolledVsControlled.tsx +114 -0
- package/doc_src/demo/decs.d.ts +7 -5
- package/doc_src/demo/demo.css +7 -5
- package/doc_src/demo/game-3.pgn +10 -0
- package/doc_src/demo/util.ts +7 -5
- package/doc_src/examples/Movetext.md +1 -1
- package/doc_src/examples/NavigationBoard.md +15 -0
- package/doc_src/theming/LogoRenderer.js +7 -5
- package/doc_src/theming/theming.css +7 -5
- package/package.json +27 -26
- package/scripts/doc.styleguide.config.js +19 -7
- package/scripts/docker-compose.yml +3 -3
- package/scripts/test-graphic.webpack.config.js +7 -5
- package/scripts/test-headless.webpack.config.js +7 -5
- package/src/chessboard/BoardProperties.ts +131 -0
- package/src/chessboard/Chessboard.css +7 -5
- package/src/chessboard/Chessboard.tsx +48 -175
- package/src/chessboard/ChessboardImpl.tsx +7 -5
- package/src/chessboard/Draggable.tsx +7 -5
- package/src/chessboard/Motion.tsx +7 -5
- package/src/chessboard/colorsets.ts +7 -5
- package/src/chessboard/piecesets.ts +7 -5
- package/src/decs.d.ts +7 -5
- package/src/errorbox/ErrorBox.css +7 -5
- package/src/errorbox/ErrorBox.tsx +7 -5
- package/src/errorbox/parsing.tsx +158 -0
- package/src/exception.ts +7 -5
- package/src/i18n.ts +14 -5
- package/src/icons/AnnotationSymbolShape.css +7 -5
- package/src/icons/AnnotationSymbolShape.tsx +7 -5
- package/src/icons/ArrowMarkerIcon.tsx +7 -5
- package/src/icons/ArrowTip.tsx +7 -5
- package/src/icons/ChessPieceIcon.tsx +7 -5
- package/src/icons/SquareMarkerIcon.tsx +7 -5
- package/src/icons/TextMarkerIcon.tsx +7 -5
- package/src/icons/arrow.css +7 -5
- package/src/index.ts +12 -6
- package/src/movetext/Movetext.css +7 -18
- package/src/movetext/Movetext.tsx +27 -90
- package/src/movetext/MovetextImpl.tsx +35 -120
- package/src/movetext/fonts.css +7 -5
- package/src/movetext/htmlFilter.tsx +7 -5
- package/src/movetext/moveFormatter.tsx +7 -5
- package/src/navigationboard/NavigationBoard.tsx +231 -0
- package/src/navigationboard/NavigationField.css +36 -0
- package/src/navigationboard/NavigationField.tsx +185 -0
- package/src/navigationboard/NavigationToolbar.css +51 -0
- package/src/navigationboard/NavigationToolbar.tsx +174 -0
- package/src/sanitization.ts +7 -5
- package/src/types.ts +7 -5
- package/src/util.ts +7 -5
- package/test/01_types.js +7 -5
- package/test/02_chessboard_util.js +7 -5
- package/test/03_error_box_graphic.js +7 -5
- package/test/04_icons_graphic.js +7 -5
- package/test/05_chessboard_graphic.js +9 -5
- package/test/06_chessboard_animation.js +7 -5
- package/test/07_chessboard_interaction.js +7 -5
- package/test/08_chessboard_play_moves.js +7 -5
- package/test/09_chessboard_small_screens.js +28 -5
- package/test/10_movetext_graphic.js +12 -5
- package/test/11_movetext_interaction.js +19 -13
- package/test/12_navigation_board.js +168 -0
- package/test/common/graphic.js +7 -5
- package/test/graphic_references/05_chessboard_graphic/move/illegal_null-move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/null-move.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_bottom_component.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_top_component.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_bottom_component.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_top_component.png +0 -0
- package/test/graphic_references/10_movetext_graphic/format_move/format_text.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/wrong_piece_symbol_value.png +0 -0
- package/test/graphic_references/11_movetext_interaction/select_moves/click_on_unselected_without_callback.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/default.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/forbidden_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/forbidden_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/invalid_node_id.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/no_callback_defined_0.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/no_callback_defined_1.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/overriding_initial_node_id.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/regular_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/regular_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/regular_navigation_2.png +0 -0
- package/test/graphic_references/12_navigation_board/controlled/regular_navigation_3.png +0 -0
- package/test/graphic_references/12_navigation_board/error/pgn_parsing_error.png +0 -0
- package/test/graphic_references/12_navigation_board/error/wrong_game_type.png +0 -0
- package/test/graphic_references/12_navigation_board/theme/custom_1.png +0 -0
- package/test/graphic_references/12_navigation_board/theme/custom_2.png +0 -0
- package/test/graphic_references/12_navigation_board/theme/large.png +0 -0
- package/test/graphic_references/12_navigation_board/theme/small.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_0.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_1.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_2.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_end_0.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_end_1.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_end_2.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/initial_state_at_end.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/initial_state_at_specific_id.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/initial_state_default.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/initial_state_default_with_game_index.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/initial_state_on_null-move.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/navigation_with_keys_0.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/navigation_with_keys_1.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/navigation_with_keys_2.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/navigation_with_keys_3.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/navigation_with_keys_4.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/regular_flipping_0.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/regular_flipping_1.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_2.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_3.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_4.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_5.png +0 -0
- package/test/graphic_test_app/03_error_box_graphic/base.tsx +7 -5
- package/test/graphic_test_app/03_error_box_graphic/localization.tsx +7 -5
- package/test/graphic_test_app/04_icons_graphic/chess_piece.tsx +7 -5
- package/test/graphic_test_app/04_icons_graphic/marker.tsx +7 -5
- package/test/graphic_test_app/05_chessboard_graphic/annotations.tsx +7 -5
- package/test/graphic_test_app/05_chessboard_graphic/base.tsx +7 -5
- package/test/graphic_test_app/05_chessboard_graphic/chess_variants.tsx +7 -5
- package/test/graphic_test_app/05_chessboard_graphic/flipped.tsx +7 -5
- package/test/graphic_test_app/05_chessboard_graphic/move.tsx +9 -5
- package/test/graphic_test_app/05_chessboard_graphic/theme.tsx +7 -5
- package/test/graphic_test_app/06_chessboard_animation/base_1.tsx +7 -5
- package/test/graphic_test_app/06_chessboard_animation/base_2.tsx +7 -5
- package/test/graphic_test_app/06_chessboard_animation/base_3.tsx +7 -5
- package/test/graphic_test_app/06_chessboard_animation/on_redraw.tsx +7 -5
- package/test/graphic_test_app/07_chessboard_interaction/click_squares.tsx +7 -5
- package/test/graphic_test_app/07_chessboard_interaction/edit_arrows.tsx +7 -5
- package/test/graphic_test_app/07_chessboard_interaction/error.tsx +7 -5
- package/test/graphic_test_app/07_chessboard_interaction/move_pieces.tsx +7 -5
- package/test/graphic_test_app/08_chessboard_play_moves/base.tsx +7 -5
- package/test/graphic_test_app/08_chessboard_play_moves/promotions.tsx +7 -5
- package/test/graphic_test_app/09_chessboard_small_screens/base.tsx +7 -5
- package/test/graphic_test_app/09_chessboard_small_screens/top_bottom_components.tsx +48 -0
- package/test/graphic_test_app/10_movetext_graphic/base.tsx +7 -5
- package/test/graphic_test_app/10_movetext_graphic/error.tsx +7 -5
- package/test/graphic_test_app/10_movetext_graphic/format_move.tsx +31 -0
- package/test/graphic_test_app/10_movetext_graphic/html.tsx +7 -5
- package/test/graphic_test_app/10_movetext_graphic/options.tsx +8 -5
- package/test/graphic_test_app/11_movetext_interaction/error.tsx +7 -5
- package/test/graphic_test_app/11_movetext_interaction/select_moves.tsx +8 -5
- package/test/graphic_test_app/12_navigation_board/controlled.tsx +43 -0
- package/test/graphic_test_app/12_navigation_board/error.tsx +34 -0
- package/test/graphic_test_app/12_navigation_board/theme.tsx +38 -0
- package/test/graphic_test_app/12_navigation_board/uncontrolled.tsx +56 -0
- package/test/graphic_test_app/common/decs.d.ts +7 -5
- package/test/graphic_test_app/common/test_app.css +7 -5
- package/test/graphic_test_app/common/test_app.tsx +7 -5
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
3
|
+
* *
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
7
|
+
* *
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
9
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
10
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
11
|
+
* the License, or (at your option) any later version. *
|
|
12
|
+
* *
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
16
|
+
* GNU Lesser General Public License for more details. *
|
|
17
|
+
* *
|
|
18
|
+
* You should have received a copy of the GNU Lesser General *
|
|
19
|
+
* Public License along with this program. If not, see *
|
|
20
|
+
* <http://www.gnu.org/licenses/>. *
|
|
21
|
+
* *
|
|
22
|
+
* -------------------------------------------------------------------------- */
|
|
1
23
|
import { IllegalArgument } from './exception';
|
|
2
24
|
export declare function sanitizeString(input: string): string;
|
|
3
25
|
export declare function sanitizeBoolean(input: boolean): boolean;
|
package/dist/lib/sanitization.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
2
3
|
* *
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
7
|
* *
|
|
6
|
-
*
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
7
9
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
10
|
* as published by the Free Software Foundation, either version 3 of *
|
|
9
11
|
* the License, or (at your option) any later version. *
|
|
10
12
|
* *
|
|
11
|
-
*
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
12
14
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
15
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
16
|
* GNU Lesser General Public License for more details. *
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitization.js","sourceRoot":"","sources":["../../src/sanitization.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sanitization.js","sourceRoot":"","sources":["../../src/sanitization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAMhF,MAAM,UAAU,cAAc,CAAC,KAAa;IAC3C,OAAO,MAAM,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3
|
+
* *
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
7
|
+
* *
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
9
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
10
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
11
|
+
* the License, or (at your option) any later version. *
|
|
12
|
+
* *
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
16
|
+
* GNU Lesser General Public License for more details. *
|
|
17
|
+
* *
|
|
18
|
+
* You should have received a copy of the GNU Lesser General *
|
|
19
|
+
* Public License along with this program. If not, see *
|
|
20
|
+
* <http://www.gnu.org/licenses/>. *
|
|
21
|
+
* *
|
|
22
|
+
* -------------------------------------------------------------------------- */
|
|
1
23
|
import { ColoredPiece, Square, SquareCouple } from 'kokopu';
|
|
2
24
|
/**
|
|
3
25
|
* Minimum square size in a {@link Chessboard} component.
|
package/dist/lib/types.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
2
3
|
* *
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
7
|
* *
|
|
6
|
-
*
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
7
9
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
10
|
* as published by the Free Software Foundation, either version 3 of *
|
|
9
11
|
* the License, or (at your option) any later version. *
|
|
10
12
|
* *
|
|
11
|
-
*
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
12
14
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
15
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
16
|
* GNU Lesser General Public License for more details. *
|
package/dist/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAGhF,OAAO,EAAsC,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEtG,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAWlC;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAiB;IACrD,OAAO,cAAc,CAAC,QAAQ,CAAC,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,IAAI,CAAC;AAC3E,CAAC;AA8FD;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACpD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,OAAQ,OAA8B,CAAC,CAAC,KAAK,QAAQ;QAC3D,OAAQ,OAA8B,CAAC,CAAC,KAAK,QAAQ;QACrD,OAAQ,OAA8B,CAAC,CAAC,KAAK,QAAQ;QACrD,OAAQ,OAA8B,CAAC,CAAC,KAAK,QAAQ;QACrD,O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AClJ,SAAS,CAAC;IACZ,CAAC,CAAC,CAAC;AACJ,CAAC;AAGD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAChD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACjC,MAAM,IAAI,eAAe,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,YAAY,CAAgC,OAAO,EAAE,KAAK,CAAC,EAAE;QACnE,OAAO,kCAAkC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACtD,EAAE,GAAG,EAAE,MAAM,CAAC,EAAkB,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,WAAW,EAAqB,EAAE,CAAC,CAAC;YACvF,SAAS,CAAC;IACZ,CAAC,CAAC,CAAC;AACJ,CAAC;AAGD,SAAS,YAAY,CAAsB,OAAe,EAAE,WAAgE;IAC3H,MAAM,MAAM,GAA0B,EAAE,CAAC;IACzC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC3E,IAAI,MAAM,EAAE,CAAC;YACZ,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;QACnC,CAAC;IACF,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC"}
|
package/dist/lib/util.d.ts
CHANGED
|
@@ -1,2 +1,24 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
3
|
+
* *
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
7
|
+
* *
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
9
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
10
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
11
|
+
* the License, or (at your option) any later version. *
|
|
12
|
+
* *
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
16
|
+
* GNU Lesser General Public License for more details. *
|
|
17
|
+
* *
|
|
18
|
+
* You should have received a copy of the GNU Lesser General *
|
|
19
|
+
* Public License along with this program. If not, see *
|
|
20
|
+
* <http://www.gnu.org/licenses/>. *
|
|
21
|
+
* *
|
|
22
|
+
* -------------------------------------------------------------------------- */
|
|
1
23
|
export declare function generateRandomId(): string;
|
|
2
24
|
export declare function fillPlaceholder(message: string, ...placeholderValues: unknown[]): string;
|
package/dist/lib/util.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
2
3
|
* *
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
7
|
* *
|
|
6
|
-
*
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
7
9
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
10
|
* as published by the Free Software Foundation, either version 3 of *
|
|
9
11
|
* the License, or (at your option) any later version. *
|
|
10
12
|
* *
|
|
11
|
-
*
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
12
14
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
15
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
16
|
* GNU Lesser General Public License for more details. *
|
package/dist/lib/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAGhF,MAAM,UAAU,gBAAgB;IAC/B,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAGD,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,GAAG,iBAA4B;IAC/E,OAAO,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE;QACzD,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAC7C,OAAO,gBAAgB,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1G,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
2
3
|
* *
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
7
|
* *
|
|
6
|
-
*
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
7
9
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
10
|
* as published by the Free Software Foundation, either version 3 of *
|
|
9
11
|
* the License, or (at your option) any later version. *
|
|
10
12
|
* *
|
|
11
|
-
*
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
12
14
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
15
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
16
|
* GNU Lesser General Public License for more details. *
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
2
3
|
* *
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
7
|
* *
|
|
6
|
-
*
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
7
9
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
10
|
* as published by the Free Software Foundation, either version 3 of *
|
|
9
11
|
* the License, or (at your option) any later version. *
|
|
10
12
|
* *
|
|
11
|
-
*
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
12
14
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
15
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
16
|
* GNU Lesser General Public License for more details. *
|
|
@@ -111,25 +113,33 @@ export default class Page extends React.Component<object, PageState> {
|
|
|
111
113
|
<Typography gutterBottom>Interaction mode</Typography>
|
|
112
114
|
<RadioGroup value={this.state.interactionMode} onChange={evt => this.setState({ interactionMode: evt.target.value as PageState['interactionMode'] })}>
|
|
113
115
|
<FormControlLabel value="none" control={<Radio color="primary" />} label="None" />
|
|
114
|
-
<
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
<FormControlLabel value="addRemovePieces" control={<Radio color="primary" />} label={
|
|
117
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
118
|
+
<span>Add/remove pieces</span>
|
|
119
|
+
{this.renderPieceSelector()}
|
|
120
|
+
</Stack>
|
|
121
|
+
} />
|
|
118
122
|
<FormControlLabel value="movePieces" control={<Radio color="primary" />} label="Move pieces" />
|
|
119
123
|
<FormControlLabel value="playMoves" control={<Radio color="primary" />} label="Move pieces (obeying chess rules)" />
|
|
120
|
-
<
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
<FormControlLabel value="editSquareMarkers" control={<Radio color="primary" />} label={
|
|
125
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
126
|
+
<span>Edit square annotations</span>
|
|
127
|
+
{this.renderMarkerColorSelector('editSquareMarkers', this.state.squareMarkerColor, newColor => this.handleSquareMarkerColorChanged(newColor))}
|
|
128
|
+
</Stack>
|
|
129
|
+
} />
|
|
130
|
+
<FormControlLabel value="editTextMarkers" control={<Radio color="primary" />} label={
|
|
131
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
132
|
+
<span>Edit text annotations</span>
|
|
133
|
+
{this.renderMarkerColorSelector('editTextMarkers', this.state.textMarkerColor, newColor => this.handleTextMarkerColorChanged(newColor))}
|
|
134
|
+
{this.renderTextMarkerSymbolSelector()}
|
|
135
|
+
</Stack>
|
|
136
|
+
} />
|
|
137
|
+
<FormControlLabel value="editArrowMarkers" control={<Radio color="primary" />} label={
|
|
138
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
139
|
+
<span>Edit arrow annotations</span>
|
|
140
|
+
{this.renderMarkerColorSelector('editArrowMarkers', this.state.arrowMarkerColor, newColor => this.handleArrowMarkerColorChanged(newColor))}
|
|
141
|
+
</Stack>
|
|
142
|
+
} />
|
|
133
143
|
</RadioGroup>
|
|
134
144
|
</Box>
|
|
135
145
|
</>);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
2
3
|
* *
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
7
|
* *
|
|
6
|
-
*
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
7
9
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
10
|
* as published by the Free Software Foundation, either version 3 of *
|
|
9
11
|
* the License, or (at your option) any later version. *
|
|
10
12
|
* *
|
|
11
|
-
*
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
12
14
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
15
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
16
|
* GNU Lesser General Public License for more details. *
|
|
@@ -178,6 +180,23 @@ export default class Page extends React.Component<object, PageState> {
|
|
|
178
180
|
positionAfter: null,
|
|
179
181
|
});
|
|
180
182
|
}
|
|
183
|
+
else if (move === '--') {
|
|
184
|
+
const positionAfter = new Position(currentPosition);
|
|
185
|
+
if (positionAfter.playNullMove()) {
|
|
186
|
+
this.setState({
|
|
187
|
+
position: currentPosition,
|
|
188
|
+
playedMove: '--',
|
|
189
|
+
positionAfter: positionAfter,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
this.setState({
|
|
194
|
+
position: currentPosition,
|
|
195
|
+
playedMove: '',
|
|
196
|
+
positionAfter: null,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
181
200
|
else {
|
|
182
201
|
try {
|
|
183
202
|
const moveDescriptor = currentPosition.notation(move);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
2
3
|
* *
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
7
|
* *
|
|
6
|
-
*
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
7
9
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
10
|
* as published by the Free Software Foundation, either version 3 of *
|
|
9
11
|
* the License, or (at your option) any later version. *
|
|
10
12
|
* *
|
|
11
|
-
*
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
12
14
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
15
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
16
|
* GNU Lesser General Public License for more details. *
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
2
3
|
* *
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
7
|
* *
|
|
6
|
-
*
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
7
9
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
10
|
* as published by the Free Software Foundation, either version 3 of *
|
|
9
11
|
* the License, or (at your option) any later version. *
|
|
10
12
|
* *
|
|
11
|
-
*
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
12
14
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
15
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
16
|
* GNU Lesser General Public License for more details. *
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
2
3
|
* *
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
7
|
* *
|
|
6
|
-
*
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
7
9
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
10
|
* as published by the Free Software Foundation, either version 3 of *
|
|
9
11
|
* the License, or (at your option) any later version. *
|
|
10
12
|
* *
|
|
11
|
-
*
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
12
14
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
15
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
16
|
* GNU Lesser General Public License for more details. *
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* -------------------------------------------------------------------------- *
|
|
3
|
+
* *
|
|
4
|
+
* Kokopu-React - A React-based library of chess-related components. *
|
|
5
|
+
* <https://www.npmjs.com/package/kokopu-react> *
|
|
6
|
+
* Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
7
|
+
* *
|
|
8
|
+
* Kokopu-React is free software: you can redistribute it and/or *
|
|
9
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
10
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
11
|
+
* the License, or (at your option) any later version. *
|
|
12
|
+
* *
|
|
13
|
+
* Kokopu-React is distributed in the hope that it will be useful, *
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
16
|
+
* GNU Lesser General Public License for more details. *
|
|
17
|
+
* *
|
|
18
|
+
* You should have received a copy of the GNU Lesser General *
|
|
19
|
+
* Public License along with this program. If not, see *
|
|
20
|
+
* <http://www.gnu.org/licenses/>. *
|
|
21
|
+
* *
|
|
22
|
+
* -------------------------------------------------------------------------- */
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
import * as React from 'react';
|
|
26
|
+
|
|
27
|
+
import { AnnotationColor, ArrowMarkerIcon, Chessboard, NavigationBoard } from '../../src/index';
|
|
28
|
+
import { buildComponentDemoCode } from './util';
|
|
29
|
+
|
|
30
|
+
import Box from '@mui/material/Box';
|
|
31
|
+
import FormControl from '@mui/material/FormControl';
|
|
32
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
33
|
+
import InputLabel from '@mui/material/InputLabel';
|
|
34
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
35
|
+
import Select from '@mui/material/Select';
|
|
36
|
+
import Slider from '@mui/material/Slider';
|
|
37
|
+
import Stack from '@mui/material/Stack';
|
|
38
|
+
import Switch from '@mui/material/Switch';
|
|
39
|
+
import ToggleButton from '@mui/material/ToggleButton';
|
|
40
|
+
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
|
|
41
|
+
import Typography from '@mui/material/Typography';
|
|
42
|
+
|
|
43
|
+
import './demo.css';
|
|
44
|
+
import pgn from './game-3.pgn';
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const COLOR_ICON_SIZE = 16;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
interface PageState {
|
|
51
|
+
squareSize: number;
|
|
52
|
+
coordinateVisible: boolean;
|
|
53
|
+
turnVisible: boolean;
|
|
54
|
+
colorset: string;
|
|
55
|
+
pieceset: string;
|
|
56
|
+
moveArrowVisible: boolean;
|
|
57
|
+
moveArrowColor: AnnotationColor;
|
|
58
|
+
animated: boolean;
|
|
59
|
+
flipButtonVisible: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
export default class Page extends React.Component<object, PageState> {
|
|
64
|
+
|
|
65
|
+
constructor(props: object) {
|
|
66
|
+
super(props);
|
|
67
|
+
this.state = {
|
|
68
|
+
squareSize: 40,
|
|
69
|
+
coordinateVisible: true,
|
|
70
|
+
turnVisible: true,
|
|
71
|
+
colorset: 'original',
|
|
72
|
+
pieceset: 'cburnett',
|
|
73
|
+
moveArrowVisible: true,
|
|
74
|
+
moveArrowColor: 'b',
|
|
75
|
+
animated: true,
|
|
76
|
+
flipButtonVisible: true,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
render() {
|
|
81
|
+
return (
|
|
82
|
+
<Stack spacing={2} mt={2}>
|
|
83
|
+
{this.renderControls()}
|
|
84
|
+
{this.renderNavigationBoard()}
|
|
85
|
+
{this.renderCode()}
|
|
86
|
+
</Stack>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private renderControls() {
|
|
91
|
+
return (<>
|
|
92
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
93
|
+
<FormControlLabel label="Show flip button"
|
|
94
|
+
control={<Switch checked={this.state.flipButtonVisible} onChange={() => this.setState({ flipButtonVisible: !this.state.flipButtonVisible })} color="primary" />}
|
|
95
|
+
/>
|
|
96
|
+
<FormControlLabel label="Show coordinates"
|
|
97
|
+
control={<Switch checked={this.state.coordinateVisible} onChange={() => this.setState({ coordinateVisible: !this.state.coordinateVisible })} color="primary" />}
|
|
98
|
+
/>
|
|
99
|
+
<FormControlLabel label="Show turn"
|
|
100
|
+
control={<Switch checked={this.state.turnVisible} onChange={() => this.setState({ turnVisible: !this.state.turnVisible })} color="primary" />}
|
|
101
|
+
/>
|
|
102
|
+
<FormControlLabel label="Animated"
|
|
103
|
+
control={<Switch checked={this.state.animated} onChange={() => this.setState({ animated: !this.state.animated })} color="primary" />}
|
|
104
|
+
/>
|
|
105
|
+
</Stack>
|
|
106
|
+
<Box>
|
|
107
|
+
<Typography gutterBottom>Square size</Typography>
|
|
108
|
+
<Slider
|
|
109
|
+
value={this.state.squareSize} onChange={(_, newValue) => this.setState({ squareSize: newValue as number })}
|
|
110
|
+
min={Chessboard.minSquareSize()} max={Chessboard.maxSquareSize()} step={1} valueLabelDisplay="on" color="primary"
|
|
111
|
+
/>
|
|
112
|
+
</Box>
|
|
113
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
114
|
+
<FormControl variant="standard">
|
|
115
|
+
<InputLabel id="colorset-label">Colorset</InputLabel>
|
|
116
|
+
<Select labelId="colorset-label" sx={{ width: '8em' }} value={this.state.colorset} onChange={evt => this.setState({ colorset: evt.target.value })}>
|
|
117
|
+
{Object.keys(Chessboard.colorsets()).sort().map(colorset => <MenuItem key={colorset} value={colorset}>{colorset}</MenuItem>)}
|
|
118
|
+
</Select>
|
|
119
|
+
</FormControl>
|
|
120
|
+
<FormControl variant="standard">
|
|
121
|
+
<InputLabel id="pieceset-label">Pieceset</InputLabel>
|
|
122
|
+
<Select labelId="pieceset-label" sx={{ width: '8em' }} value={this.state.pieceset} onChange={evt => this.setState({ pieceset: evt.target.value })}>
|
|
123
|
+
{Object.keys(Chessboard.piecesets()).sort().map(pieceset => <MenuItem key={pieceset} value={pieceset}>{pieceset}</MenuItem>)}
|
|
124
|
+
</Select>
|
|
125
|
+
</FormControl>
|
|
126
|
+
<FormControlLabel label="Show move arrow"
|
|
127
|
+
control={<Switch checked={this.state.moveArrowVisible} onChange={() => this.setState({ moveArrowVisible: !this.state.moveArrowVisible })} color="primary" />}
|
|
128
|
+
/>
|
|
129
|
+
{this.renderMoveArrowColorSelector()}
|
|
130
|
+
</Stack>
|
|
131
|
+
</>);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private renderMoveArrowColorSelector() {
|
|
135
|
+
if (!this.state.moveArrowVisible) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
const colorset = Chessboard.colorsets()['original'];
|
|
139
|
+
return (
|
|
140
|
+
<ToggleButtonGroup value={this.state.moveArrowColor} exclusive size="small" onChange={(_, newColor) => this.handleMoveArrowColorChanged(newColor)}>
|
|
141
|
+
<ToggleButton value="b"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cb} /></ToggleButton>
|
|
142
|
+
<ToggleButton value="g"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cg} /></ToggleButton>
|
|
143
|
+
<ToggleButton value="r"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cr} /></ToggleButton>
|
|
144
|
+
<ToggleButton value="y"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cy} /></ToggleButton>
|
|
145
|
+
</ToggleButtonGroup>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private renderNavigationBoard() {
|
|
150
|
+
return (
|
|
151
|
+
<Box>
|
|
152
|
+
<NavigationBoard
|
|
153
|
+
game={pgn}
|
|
154
|
+
initialNodeId="end"
|
|
155
|
+
squareSize={this.state.squareSize}
|
|
156
|
+
coordinateVisible={this.state.coordinateVisible}
|
|
157
|
+
turnVisible={this.state.turnVisible}
|
|
158
|
+
colorset={this.state.colorset}
|
|
159
|
+
pieceset={this.state.pieceset}
|
|
160
|
+
moveArrowVisible={this.state.moveArrowVisible}
|
|
161
|
+
moveArrowColor={this.state.moveArrowColor}
|
|
162
|
+
animated={this.state.animated}
|
|
163
|
+
flipButtonVisible={this.state.flipButtonVisible}
|
|
164
|
+
/>
|
|
165
|
+
</Box>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private renderCode() {
|
|
170
|
+
const attributes: string[] = [];
|
|
171
|
+
attributes.push('game={pgn}');
|
|
172
|
+
attributes.push('initialNodeId="end"');
|
|
173
|
+
attributes.push(`squareSize={${this.state.squareSize}}`);
|
|
174
|
+
attributes.push(`coordinateVisible={${this.state.coordinateVisible}}`);
|
|
175
|
+
attributes.push(`turnVisible={${this.state.turnVisible}}`);
|
|
176
|
+
attributes.push(`colorset="${this.state.colorset}"`);
|
|
177
|
+
attributes.push(`pieceset="${this.state.pieceset}"`);
|
|
178
|
+
attributes.push(`moveArrowVisible={${this.state.moveArrowVisible}}`);
|
|
179
|
+
if (this.state.moveArrowVisible) {
|
|
180
|
+
attributes.push(`moveArrowColor="${this.state.moveArrowColor}"`);
|
|
181
|
+
}
|
|
182
|
+
attributes.push(`animated={${this.state.animated}}`);
|
|
183
|
+
attributes.push(`flipButtonVisible={${this.state.flipButtonVisible}}`);
|
|
184
|
+
const pgnDeclaration = 'const pgn = `\n' + pgn.trim() + '`;\n\n';
|
|
185
|
+
return <pre className="kokopu-demoCode">{pgnDeclaration + buildComponentDemoCode('NavigationBoard', attributes)}</pre>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private handleMoveArrowColorChanged(newColor: AnnotationColor | null) {
|
|
189
|
+
if (newColor !== null) {
|
|
190
|
+
this.setState({ moveArrowColor: newColor });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
}
|