kokopu-react 3.2.0 → 3.3.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.
- package/CHANGELOG.md +8 -0
- package/dist/lib/chessboard/Chessboard.d.ts +27 -2
- package/dist/lib/chessboard/Chessboard.js +38 -18
- package/dist/lib/chessboard/Chessboard.js.map +1 -1
- package/dist/lib/chessboard/ChessboardImpl.js +1 -1
- package/dist/lib/chessboard/ChessboardImpl.js.map +1 -1
- package/dist/lib/chessboard/Motion.js +1 -1
- package/dist/lib/chessboard/Motion.js.map +1 -1
- package/dist/lib/i18n.js +2 -2
- package/dist/lib/i18n.js.map +1 -1
- package/dist/lib/icons/ArrowMarkerIcon.js.map +1 -1
- package/dist/lib/icons/ChessPieceIcon.d.ts +1 -4
- package/dist/lib/icons/ChessPieceIcon.js +1 -5
- package/dist/lib/icons/ChessPieceIcon.js.map +1 -1
- package/dist/lib/icons/SquareMarkerIcon.d.ts +1 -4
- package/dist/lib/icons/SquareMarkerIcon.js +1 -5
- package/dist/lib/icons/SquareMarkerIcon.js.map +1 -1
- package/dist/lib/icons/TextMarkerIcon.d.ts +1 -4
- package/dist/lib/icons/TextMarkerIcon.js +1 -5
- package/dist/lib/icons/TextMarkerIcon.js.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/movetext/Movetext.js.map +1 -1
- package/dist/lib/movetext/MovetextImpl.js +4 -3
- package/dist/lib/movetext/MovetextImpl.js.map +1 -1
- package/dist/lib/movetext/htmlFilter.js +1 -1
- package/dist/lib/movetext/htmlFilter.js.map +1 -1
- package/dist/lib/navigationboard/NavigationBoard.d.ts +37 -8
- package/dist/lib/navigationboard/NavigationBoard.js +67 -22
- package/dist/lib/navigationboard/NavigationBoard.js.map +1 -1
- package/dist/lib/navigationboard/NavigationButton.d.ts +13 -1
- package/dist/lib/navigationboard/NavigationButton.js +32 -0
- package/dist/lib/navigationboard/NavigationButton.js.map +1 -1
- package/dist/lib/navigationboard/NavigationField.js +1 -1
- package/dist/lib/navigationboard/NavigationField.js.map +1 -1
- package/dist/lib/navigationboard/NavigationToolbar.d.ts +9 -2
- package/dist/lib/navigationboard/NavigationToolbar.js +34 -1
- package/dist/lib/navigationboard/NavigationToolbar.js.map +1 -1
- package/dist/lib/util.js +2 -2
- package/dist/lib/util.js.map +1 -1
- package/doc_src/demo/PageChessboardBase.tsx +57 -51
- package/doc_src/demo/PageChessboardInteraction.tsx +78 -63
- package/doc_src/demo/PageChessboardMove.tsx +35 -30
- package/doc_src/demo/PageChessboardSmallScreens.tsx +3 -3
- package/doc_src/demo/PageMovetextBase.tsx +91 -81
- package/doc_src/demo/PageMovetextInteraction.tsx +23 -21
- package/doc_src/demo/PageNavigationBoardBase.tsx +62 -54
- package/doc_src/demo/PageNavigationBoardUncontrolledVsControlled.tsx +24 -18
- package/doc_src/theming/LogoRenderer.js +8 -9
- package/package.json +30 -28
- package/scripts/docker-compose.yml +1 -3
- package/src/chessboard/BoardProperties.ts +13 -13
- package/src/chessboard/Chessboard.tsx +106 -46
- package/src/chessboard/ChessboardImpl.tsx +58 -41
- package/src/chessboard/Draggable.tsx +15 -15
- package/src/chessboard/Motion.tsx +4 -4
- package/src/errorbox/ErrorBox.tsx +5 -5
- package/src/errorbox/parsing.tsx +6 -6
- package/src/i18n.ts +2 -2
- package/src/icons/AnnotationSymbolShape.tsx +5 -5
- package/src/icons/ArrowMarkerIcon.tsx +8 -4
- package/src/icons/ArrowTip.tsx +2 -2
- package/src/icons/ChessPieceIcon.tsx +4 -11
- package/src/icons/SquareMarkerIcon.tsx +3 -10
- package/src/icons/TextMarkerIcon.tsx +4 -11
- package/src/index.ts +1 -1
- package/src/movetext/Movetext.tsx +11 -10
- package/src/movetext/MovetextImpl.tsx +34 -28
- package/src/movetext/htmlFilter.tsx +4 -4
- package/src/navigationboard/NavigationBoard.tsx +150 -58
- package/src/navigationboard/NavigationButton.ts +47 -5
- package/src/navigationboard/NavigationField.tsx +6 -6
- package/src/navigationboard/NavigationToolbar.tsx +62 -15
- package/src/types.ts +26 -26
- package/src/util.ts +2 -2
- package/test/01_types.js +83 -61
- package/test/02_chessboard_util.js +79 -1
- package/test/03_error_box_graphic.js +1 -1
- package/test/07_chessboard_interaction.js +1 -2
- package/test/13_navigation_board_graphic.js +3 -3
- package/test/common/graphic.js +11 -11
- package/test/graphic_references/03_error_box_graphic/base/cut_beginning_of_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/cut_end_of_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/cut_on_line_breaks.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/error_index_not_integer.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/full.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/minimal.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/missing_error_index.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/missing_error_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/negative_error_index.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/single_character_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/too_large_error_index.png +0 -0
- package/test/graphic_references/03_error_box_graphic/localization/default.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/customized_pieceset.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/invalid_multiple_pieces.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/invalid_pieceset.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/invalid_single_piece.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/invalid_size.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/multiple_pieces.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/single_piece.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/colorized_arrow.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/colorized_square.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/colorized_symbol.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/colorized_text.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/default_arrow.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/default_square.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/default_text.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/invalid_arrow_size.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/invalid_square_size.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/invalid_symbol.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/invalid_text_size.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/wrapped_arrow.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/wrapped_square.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/wrapped_symbol.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/wrapped_text.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/overlap.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/overlap_and_flip.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/with_coordinates.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/with_coordinates_and_flip.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/without_coordinates.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/without_coordinates_and_flip.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/default.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/empty.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/from_fen.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/from_kokopu_object.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/parsing_error.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/wrong_position_type.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/chess960.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/chess960_with_move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/invalid_variant.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/invalid_variant_with_fen.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/special_code.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/variant_with_std_initial_position.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/variant_without_std_initial_position.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/default.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/empty.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/from_fen.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/from_kokopu_object.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/parsing_error.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/capture.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/castling_move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/default.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/en-passant.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/illegal_null-move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/no_move_arrow.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/null-move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/parsing_error.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/promotion.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/with_forced_move_arrow_and_flip.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/wrong_move_arrow_color_type.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/wrong_move_type.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_1.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_2.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_3.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_4.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_5.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_6.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/default.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/large.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/small.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/wrong_colorset.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/wrong_pieceset.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/wrong_square_size_type.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/capture.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/castling_move.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/en-passant.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/move_1.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/move_2.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/promotion.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/capture.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/castling_move.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/en-passant.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/move_1.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/move_2.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/promotion.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/capture.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/castling_move.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/en-passant.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/move_1.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/move_2.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/promotion.png +0 -0
- package/test/graphic_references/06_chessboard_animation/on_redraw/final_state.png +0 -0
- package/test/graphic_references/06_chessboard_animation/on_redraw/initial_state.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/base_1.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/base_2.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/from_==_to.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/out_of_board.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/over_arrow_marker.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/over_square_marker.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/error/edit_color_not_set.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/error/wrong_interaction_mode.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/after_move.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/from_==_to.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/move_empty_square.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/out_of_board.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_arrow_marker.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_empty.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_non-empty_1.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_non-empty_2.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_square_marker.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_text_marker.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/castling_move.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/chess960_ambiguous_king_move.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/chess960_castling_move_1.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/chess960_castling_move_2.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/chess960_non-kxr_castling.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/from_==_to.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/illegal_move.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/illegal_position.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/out_of_board.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/regular_move_1.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/regular_move_2.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/wrong_color_moved.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/promotions/antichess_promotion.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/promotions/cancel_promotion.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/promotions/regular_promotion_1.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/promotions/regular_promotion_2.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/default.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/invalid_limits.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_690.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_700.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_710.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_720.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_730.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_740.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_750.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/base/game_1.png +0 -0
- package/test/graphic_references/10_movetext_graphic/base/game_2.png +0 -0
- package/test/graphic_references/10_movetext_graphic/base/game_3.png +0 -0
- package/test/graphic_references/10_movetext_graphic/base/game_4.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/pgn_parsing_error_1.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/pgn_parsing_error_2.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/wrong_game_index_1.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/wrong_game_index_2.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/wrong_game_index_type.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/wrong_game_type.png +0 -0
- package/test/graphic_references/10_movetext_graphic/format_move/format_text.png +0 -0
- package/test/graphic_references/10_movetext_graphic/html/filtered_tags_and_attributes.png +0 -0
- package/test/graphic_references/10_movetext_graphic/html/html_in_comments.png +0 -0
- package/test/graphic_references/10_movetext_graphic/html/html_in_headers.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/custom_piece_symbols.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/figurine_piece_symbols_and_diagram_options.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/hidden_diagrams.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/localized_piece_symbols.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/other_diagram_options.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/wrong_diagram_options_1.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/wrong_diagram_options_2.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/error/wrong_interaction_mode.png +0 -0
- package/test/graphic_references/11_movetext_interaction/select_moves/click_on_disabled.png +0 -0
- package/test/graphic_references/11_movetext_interaction/select_moves/click_on_unselected.png +0 -0
- package/test/graphic_references/11_movetext_interaction/select_moves/click_on_unselected_without_callback.png +0 -0
- package/test/graphic_references/11_movetext_interaction/select_moves/click_on_with_variations.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/default.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/forbidden_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/forbidden_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/invalid_node_id.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/overriding_initial_node_id.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_3.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_end.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_specific_id.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_default.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_default_with_game_index.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_on_null-move.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_3.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_4.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_flipping_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_flipping_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_3.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_4.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_5.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_1.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_2.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/multiple_buttons.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/single_button.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/error/pgn_parsing_error.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/error/wrong_game_type.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/custom_1.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/custom_2.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/large.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/small.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_not_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_not_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_reaching_the_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/already_at_the_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_at_the_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_close_to_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_after_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_before_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_after_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_before_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_close_to_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_default.png +0 -0
- package/test/graphic_test_app/03_error_box_graphic/base.tsx +18 -6
- package/test/graphic_test_app/04_icons_graphic/chess_piece.tsx +12 -3
- package/test/graphic_test_app/04_icons_graphic/marker.tsx +14 -4
- package/test/graphic_test_app/05_chessboard_graphic/annotations.tsx +7 -3
- package/test/graphic_test_app/05_chessboard_graphic/base.tsx +1 -1
- package/test/graphic_test_app/05_chessboard_graphic/move.tsx +9 -2
- package/test/graphic_test_app/05_chessboard_graphic/theme.tsx +1 -1
- package/test/graphic_test_app/06_chessboard_animation/on_redraw.tsx +8 -6
- package/test/graphic_test_app/07_chessboard_interaction/click_squares.tsx +4 -2
- package/test/graphic_test_app/07_chessboard_interaction/edit_arrows.tsx +4 -2
- package/test/graphic_test_app/07_chessboard_interaction/error.tsx +3 -1
- package/test/graphic_test_app/07_chessboard_interaction/move_pieces.tsx +4 -2
- package/test/graphic_test_app/08_chessboard_play_moves/base.tsx +12 -6
- package/test/graphic_test_app/08_chessboard_play_moves/promotions.tsx +12 -3
- package/test/graphic_test_app/09_chessboard_small_screens/base.tsx +3 -1
- package/test/graphic_test_app/09_chessboard_small_screens/top_bottom_components.tsx +8 -6
- package/test/graphic_test_app/10_movetext_graphic/error.tsx +1 -1
- package/test/graphic_test_app/10_movetext_graphic/options.tsx +16 -6
- package/test/graphic_test_app/11_movetext_interaction/error.tsx +4 -1
- package/test/graphic_test_app/13_navigation_board_graphic/additional_buttons.tsx +24 -17
- package/test/graphic_test_app/13_navigation_board_graphic/error.tsx +1 -1
- package/test/graphic_test_app/14_navigation_board_autoplay/controlled.tsx +34 -18
- package/test/graphic_test_app/common/test_app.tsx +4 -4
- package/.eslintrc.yml +0 -83
- package/test/.eslintrc.yml +0 -8
- package/test/graphic_test_app/.eslintrc.yml +0 -3
|
@@ -31,10 +31,10 @@ import { DEFAULT_PIECESET } from './piecesets';
|
|
|
31
31
|
* Define a limit applicable to the parameters of a {@link Chessboard} on small-screen devices.
|
|
32
32
|
*/
|
|
33
33
|
export interface SmallScreenLimit {
|
|
34
|
-
width: number
|
|
35
|
-
squareSize?: number
|
|
36
|
-
coordinateVisible?: boolean
|
|
37
|
-
turnVisible?: boolean
|
|
34
|
+
width: number,
|
|
35
|
+
squareSize?: number,
|
|
36
|
+
coordinateVisible?: boolean,
|
|
37
|
+
turnVisible?: boolean,
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
|
|
@@ -46,27 +46,27 @@ export interface StaticBoardGraphicProps {
|
|
|
46
46
|
/**
|
|
47
47
|
* Size of the squares (in pixels). Must be an integer between `Chessboard.minSquareSize()` and `Chessboard.maxSquareSize()`.
|
|
48
48
|
*/
|
|
49
|
-
squareSize: number
|
|
49
|
+
squareSize: number,
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Whether the row and column coordinates are visible or not.
|
|
53
53
|
*/
|
|
54
|
-
coordinateVisible: boolean
|
|
54
|
+
coordinateVisible: boolean,
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Whether the turn flag is visible or not.
|
|
58
58
|
*/
|
|
59
|
-
turnVisible: boolean
|
|
59
|
+
turnVisible: boolean,
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Color theme ID. Must be a property of `Chessboard.colorsets()`.
|
|
63
63
|
*/
|
|
64
|
-
colorset: string
|
|
64
|
+
colorset: string,
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* Piece theme ID. Must be a property of `Chessboard.piecesets()`.
|
|
68
68
|
*/
|
|
69
|
-
pieceset: string
|
|
69
|
+
pieceset: string,
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Limits applicable on small-screen devices. For instance, if set to
|
|
@@ -81,7 +81,7 @@ export interface StaticBoardGraphicProps {
|
|
|
81
81
|
* will be limited to 24 and the row and column coordinates will always be hidden (whatever the value of the
|
|
82
82
|
* `coordinateVisible` attribute).
|
|
83
83
|
*/
|
|
84
|
-
smallScreenLimits?: SmallScreenLimit[]
|
|
84
|
+
smallScreenLimits?: SmallScreenLimit[],
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
|
|
@@ -93,17 +93,17 @@ export interface DynamicBoardGraphicProps extends StaticBoardGraphicProps {
|
|
|
93
93
|
/**
|
|
94
94
|
* Whether moves are highlighted with an arrow or not.
|
|
95
95
|
*/
|
|
96
|
-
moveArrowVisible: boolean
|
|
96
|
+
moveArrowVisible: boolean,
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Color of the move arrow.
|
|
100
100
|
*/
|
|
101
|
-
moveArrowColor: AnnotationColor
|
|
101
|
+
moveArrowColor: AnnotationColor,
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Whether moves are animated or not.
|
|
105
105
|
*/
|
|
106
|
-
animated: boolean
|
|
106
|
+
animated: boolean,
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
|
|
@@ -49,36 +49,36 @@ export interface ChessboardProps extends DynamicBoardGraphicProps {
|
|
|
49
49
|
* [game variant](https://kokopu.yo35.org/docs/current/types/GameVariant.html) supported by Kokopu. For instance:
|
|
50
50
|
* `'chess960:nrkbqrbn/pppppppp/8/8/8/8/PPPPPPPP/NRKBQRBN w KQkq - 0 1'`.
|
|
51
51
|
*/
|
|
52
|
-
position: Position | string
|
|
52
|
+
position: Position | string,
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Displayed move (optional), defined either as a [kokopu.MoveDescriptor](https://kokopu.yo35.org/docs/current/classes/MoveDescriptor.html) object
|
|
56
56
|
* or as a [SAN string](https://en.wikipedia.org/wiki/Algebraic_notation_(chess)) (e.g. `'Nf3'`). Use `'--'` for a null-move.
|
|
57
57
|
* In all cases, the move must be a legal move in position defined in attribute `position`.
|
|
58
58
|
*/
|
|
59
|
-
move?: MoveDescriptor | string
|
|
59
|
+
move?: MoveDescriptor | string,
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Square markers, defined as a {@link SquareMarkerSet} (e.g. `{ e4: 'g', d5: 'r' }`) or as a comma-separated CSL string (e.g. `'Rd5,Ge4'`).
|
|
63
63
|
*/
|
|
64
|
-
squareMarkers?: SquareMarkerSet | string
|
|
64
|
+
squareMarkers?: SquareMarkerSet | string,
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* Text markers, defined as a {@link TextMarkerSet} (e.g. `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }}`)
|
|
68
68
|
* or as a comma-separated CTL string (e.g. `'Rzd5,GAe4'`).
|
|
69
69
|
*/
|
|
70
|
-
textMarkers?: TextMarkerSet | string
|
|
70
|
+
textMarkers?: TextMarkerSet | string,
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Arrow markers, defined as a {@link ArrowMarkerSet} (e.g. `{ e2e4: 'g', g8f6: 'r', g8h6: 'y' }`)
|
|
74
74
|
* or as a comma-separated CAL string (e.g. `'Ge2e4,Rg8f6,Yg8h6'`).
|
|
75
75
|
*/
|
|
76
|
-
arrowMarkers?: ArrowMarkerSet | string
|
|
76
|
+
arrowMarkers?: ArrowMarkerSet | string,
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Whether the board is flipped (i.e. seen from Black's point of view) or not.
|
|
80
80
|
*/
|
|
81
|
-
flipped: boolean
|
|
81
|
+
flipped: boolean,
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Type of action allowed with the mouse on the chessboard. If undefined, then the user cannot interact with the component.
|
|
@@ -93,44 +93,72 @@ export interface ChessboardProps extends DynamicBoardGraphicProps {
|
|
|
93
93
|
/**
|
|
94
94
|
* Color of the edited arrow. Mandatory if `interactionMode === 'editArrows'`, ignored otherwise.
|
|
95
95
|
*/
|
|
96
|
-
editedArrowColor?: AnnotationColor
|
|
96
|
+
editedArrowColor?: AnnotationColor,
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Callback invoked when a piece is moved through drag&drop (only if `interactionMode` is set to `'movePieces'`).
|
|
100
100
|
*/
|
|
101
|
-
onPieceMoved?: (from: Square, to: Square) => void
|
|
101
|
+
onPieceMoved?: (from: Square, to: Square) => void,
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Callback invoked when the user clicks on a square (only if `interactionMode` is set to `'clickSquares'`).
|
|
105
105
|
*/
|
|
106
|
-
onSquareClicked?: (square: Square) => void
|
|
106
|
+
onSquareClicked?: (square: Square) => void,
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Callback invoked when an arrow is dragged (only if `interactionMode` is set to `'editArrows'`).
|
|
110
110
|
*/
|
|
111
|
-
onArrowEdited?: (from: Square, to: Square) => void
|
|
111
|
+
onArrowEdited?: (from: Square, to: Square) => void,
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
114
|
* Callback invoked when a move is played (only if `interactionMode` is set to `'playMoves'`).
|
|
115
115
|
*/
|
|
116
|
-
onMovePlayed?: (move: string) => void
|
|
116
|
+
onMovePlayed?: (move: string) => void,
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Optional component, to be rendered above the chessboard, and customized with the same square-size / coordinate-visible / turn-visible
|
|
120
120
|
* parameter values as actually used for the chessboard (which may be different from what is defined in props because of small-screen limits).
|
|
121
121
|
*/
|
|
122
|
-
topComponent?: (attr: Pick<StaticBoardGraphicProps, 'squareSize' | 'coordinateVisible' | 'turnVisible'>) => JSX.Element
|
|
122
|
+
topComponent?: (attr: Pick<StaticBoardGraphicProps, 'squareSize' | 'coordinateVisible' | 'turnVisible'>) => JSX.Element,
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Optional component, to be rendered below the chessboard, and customized with the same square-size / coordinate-visible / turn-visible
|
|
126
126
|
* parameter values as actually used for the chessboard (which may be different from what is defined in props because of small-screen limits).
|
|
127
127
|
*/
|
|
128
|
-
bottomComponent?: (attr: Pick<StaticBoardGraphicProps, 'squareSize' | 'coordinateVisible' | 'turnVisible'>) => JSX.Element
|
|
128
|
+
bottomComponent?: (attr: Pick<StaticBoardGraphicProps, 'squareSize' | 'coordinateVisible' | 'turnVisible'>) => JSX.Element,
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
type AuxilliaryComponentSizeFunction = (attr: Pick<StaticBoardGraphicProps, 'squareSize' | 'coordinateVisible' | 'turnVisible'>) => { width: number, height: number };
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Attributes for method `Chessboard.size()`.
|
|
137
|
+
*/
|
|
138
|
+
export interface ChessboardSizeAttr {
|
|
139
|
+
squareSize?: ChessboardProps['squareSize'],
|
|
140
|
+
coordinateVisible?: ChessboardProps['coordinateVisible'],
|
|
141
|
+
turnVisible?: ChessboardProps['turnVisible'],
|
|
142
|
+
smallScreenLimits?: ChessboardProps['smallScreenLimits'],
|
|
143
|
+
topComponent?: AuxilliaryComponentSizeFunction,
|
|
144
|
+
bottomComponent?: AuxilliaryComponentSizeFunction,
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Attributes for method `Chessboard.adaptSquareSize()`.
|
|
150
|
+
*/
|
|
151
|
+
export interface ChessboardAdaptSquareSizeAttr {
|
|
152
|
+
coordinateVisible?: ChessboardProps['coordinateVisible'],
|
|
153
|
+
turnVisible?: ChessboardProps['turnVisible'],
|
|
154
|
+
smallScreenLimits?: ChessboardProps['smallScreenLimits'],
|
|
155
|
+
topComponent?: AuxilliaryComponentSizeFunction,
|
|
156
|
+
bottomComponent?: AuxilliaryComponentSizeFunction,
|
|
129
157
|
}
|
|
130
158
|
|
|
131
159
|
|
|
132
160
|
interface ChessboardState {
|
|
133
|
-
windowWidth: number
|
|
161
|
+
windowWidth: number,
|
|
134
162
|
}
|
|
135
163
|
|
|
136
164
|
|
|
@@ -228,18 +256,21 @@ export class Chessboard extends React.Component<ChessboardProps, ChessboardState
|
|
|
228
256
|
// (mandatory to ensure that the move animation works properly and that the internal state of the component remains consistent).
|
|
229
257
|
const key = `${position.variant()}|${position.fen()}|${move ? position.notation(move) : ''}`;
|
|
230
258
|
|
|
231
|
-
return (
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
259
|
+
return (
|
|
260
|
+
<>
|
|
261
|
+
{this.props.topComponent ? this.props.topComponent(auxilliaryComponentAttr) : undefined}
|
|
262
|
+
<ChessboardImpl
|
|
263
|
+
key={key}
|
|
264
|
+
position={position} move={move} squareMarkers={sqm} textMarkers={txtm} arrowMarkers={arm} flipped={flipped}
|
|
265
|
+
squareSize={actualSquareSize} coordinateVisible={actualCoordinateVisible} turnVisible={actualTurnVisible}
|
|
266
|
+
moveArrowVisible={moveArrowVisible} moveArrowColor={this.props.moveArrowColor} animated={animated}
|
|
267
|
+
colorset={colorset} pieceset={pieceset}
|
|
268
|
+
interactionMode={interactionMode} editedArrowColor={this.props.editedArrowColor}
|
|
269
|
+
onPieceMoved={onPieceMoved} onSquareClicked={onSquareClicked} onArrowEdited={onArrowEdited} onMovePlayed={onMovePlayed}
|
|
270
|
+
/>
|
|
271
|
+
{this.props.bottomComponent ? this.props.bottomComponent(auxilliaryComponentAttr) : undefined}
|
|
272
|
+
</>
|
|
273
|
+
);
|
|
243
274
|
}
|
|
244
275
|
|
|
245
276
|
private getInteractionModeAndValidateEditedArrowColor() {
|
|
@@ -261,50 +292,54 @@ export class Chessboard extends React.Component<ChessboardProps, ChessboardState
|
|
|
261
292
|
/**
|
|
262
293
|
* Return the size of the chessboard, assuming it is built with the given attributes.
|
|
263
294
|
*/
|
|
264
|
-
static size(attr?:
|
|
265
|
-
|
|
295
|
+
static size(attr?: ChessboardSizeAttr): { width: number, height: number } {
|
|
296
|
+
const { squareSize, coordinateVisible, turnVisible, smallScreenLimits, topComponent, bottomComponent } = sanitizePartialObject(attr,
|
|
297
|
+
() => new IllegalArgument('Chessboard.size()', 'attr'));
|
|
266
298
|
|
|
267
299
|
// Sanitize the arguments.
|
|
268
|
-
|
|
300
|
+
let actualSquareSize = squareSize === undefined ?
|
|
301
|
+
DEFAULT_SQUARE_SIZE :
|
|
269
302
|
sanitizeBoundedInteger(squareSize, MIN_SQUARE_SIZE, MAX_SQUARE_SIZE, () => new IllegalArgument('Chessboard.size()', 'squareSize'));
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
303
|
+
let actualCoordinateVisible = coordinateVisible === undefined ? true : sanitizeBoolean(coordinateVisible);
|
|
304
|
+
let actualTurnVisible = turnVisible === undefined ? true : sanitizeBoolean(turnVisible);
|
|
305
|
+
const actualLimits = sanitizeSmallScreenLimits(smallScreenLimits, () => new IllegalArgument('Chessboard.size()', 'smallScreenLimits'));
|
|
273
306
|
|
|
274
307
|
// Enforce small-screen limits, if any.
|
|
275
308
|
if (typeof window !== 'undefined') {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
309
|
+
actualSquareSize = computeSquareSizeForSmallScreens(actualSquareSize, actualLimits, window.innerWidth);
|
|
310
|
+
actualCoordinateVisible = computeCoordinateVisibleForSmallScreens(actualCoordinateVisible, actualLimits, window.innerWidth);
|
|
311
|
+
actualTurnVisible = computeTurnVisibleForSmallScreens(actualTurnVisible, actualLimits, window.innerWidth);
|
|
279
312
|
}
|
|
280
313
|
|
|
281
314
|
// Compute the dimensions.
|
|
282
|
-
return
|
|
315
|
+
return chessBoardWithAuxilliaryComponentSize(actualSquareSize, actualCoordinateVisible, actualTurnVisible, topComponent, bottomComponent);
|
|
283
316
|
}
|
|
284
317
|
|
|
285
318
|
/**
|
|
286
319
|
* Return the maximum square size that would allow the chessboard to fit in a rectangle of size `width x height`.
|
|
287
320
|
*/
|
|
288
|
-
static adaptSquareSize(width: number, height: number, attr?:
|
|
289
|
-
|
|
321
|
+
static adaptSquareSize(width: number, height: number, attr?: ChessboardAdaptSquareSizeAttr): number {
|
|
322
|
+
const { coordinateVisible, turnVisible, smallScreenLimits, topComponent, bottomComponent } = sanitizePartialObject(attr,
|
|
323
|
+
() => new IllegalArgument('Chessboard.adaptSquareSize()', 'attr'));
|
|
290
324
|
|
|
291
325
|
// Sanitize the arguments.
|
|
292
326
|
width = sanitizeInteger(width, () => new IllegalArgument('Chessboard.adaptSquareSize()', 'width'));
|
|
293
327
|
height = sanitizeInteger(height, () => new IllegalArgument('Chessboard.adaptSquareSize()', 'height'));
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
328
|
+
let actualCoordinateVisible = coordinateVisible === undefined ? true : sanitizeBoolean(coordinateVisible);
|
|
329
|
+
let actualTurnVisible = turnVisible === undefined ? true : sanitizeBoolean(turnVisible);
|
|
330
|
+
const actualLimits = sanitizeSmallScreenLimits(smallScreenLimits, () => new IllegalArgument('Chessboard.adaptSquareSize()', 'smallScreenLimits'));
|
|
297
331
|
|
|
298
332
|
// Enforce small-screen limits, if any.
|
|
299
333
|
let maxSquareSize = MAX_SQUARE_SIZE;
|
|
300
334
|
if (typeof window !== 'undefined') {
|
|
301
|
-
maxSquareSize = computeSquareSizeForSmallScreens(maxSquareSize,
|
|
302
|
-
|
|
303
|
-
|
|
335
|
+
maxSquareSize = computeSquareSizeForSmallScreens(maxSquareSize, actualLimits, window.innerWidth);
|
|
336
|
+
actualCoordinateVisible = computeCoordinateVisibleForSmallScreens(actualCoordinateVisible, actualLimits, window.innerWidth);
|
|
337
|
+
actualTurnVisible = computeTurnVisibleForSmallScreens(actualTurnVisible, actualLimits, window.innerWidth);
|
|
304
338
|
}
|
|
305
339
|
|
|
306
340
|
function isAdapted(squareSize: number) {
|
|
307
|
-
const { width: actualWidth, height: actualHeight } =
|
|
341
|
+
const { width: actualWidth, height: actualHeight } = chessBoardWithAuxilliaryComponentSize(squareSize, actualCoordinateVisible, actualTurnVisible,
|
|
342
|
+
topComponent, bottomComponent);
|
|
308
343
|
return actualWidth <= width && actualHeight <= height;
|
|
309
344
|
}
|
|
310
345
|
|
|
@@ -369,6 +404,31 @@ export class Chessboard extends React.Component<ChessboardProps, ChessboardState
|
|
|
369
404
|
}
|
|
370
405
|
|
|
371
406
|
|
|
407
|
+
function chessBoardWithAuxilliaryComponentSize(squareSize: number, coordinateVisible: boolean, turnVisible: boolean,
|
|
408
|
+
topComponent: AuxilliaryComponentSizeFunction | undefined, bottomComponent: AuxilliaryComponentSizeFunction | undefined): { width: number, height: number } {
|
|
409
|
+
|
|
410
|
+
let { width, height } = chessboardSize(squareSize, coordinateVisible, turnVisible);
|
|
411
|
+
const auxilliaryComponentAttr = {
|
|
412
|
+
squareSize: squareSize,
|
|
413
|
+
coordinateVisible: coordinateVisible,
|
|
414
|
+
turnVisible: turnVisible,
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
if (topComponent) {
|
|
418
|
+
const { width: auxilliaryWidth, height: auxilliaryHeight } = topComponent(auxilliaryComponentAttr);
|
|
419
|
+
width = Math.max(width, auxilliaryWidth);
|
|
420
|
+
height += auxilliaryHeight;
|
|
421
|
+
}
|
|
422
|
+
if (bottomComponent) {
|
|
423
|
+
const { width: auxilliaryWidth, height: auxilliaryHeight } = bottomComponent(auxilliaryComponentAttr);
|
|
424
|
+
width = Math.max(width, auxilliaryWidth);
|
|
425
|
+
height += auxilliaryHeight;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return { width: width, height: height };
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
|
|
372
432
|
/**
|
|
373
433
|
* Compute the actual square size taking into account the given small-screen limits and window width.
|
|
374
434
|
*/
|
|
@@ -474,7 +534,7 @@ function sanitizeSmallScreenLimits(smallScreenLimits: SmallScreenLimit[] | undef
|
|
|
474
534
|
width: sanitizeInteger(smallScreenLimit.width, exceptionBuilder),
|
|
475
535
|
squareSize: sanitizeOptional(smallScreenLimit.squareSize, val => sanitizeBoundedInteger(val, MIN_SQUARE_SIZE, MAX_SQUARE_SIZE, exceptionBuilder)),
|
|
476
536
|
coordinateVisible: sanitizeOptional(smallScreenLimit.coordinateVisible, sanitizeBoolean),
|
|
477
|
-
turnVisible: sanitizeOptional(smallScreenLimit.turnVisible, sanitizeBoolean)
|
|
537
|
+
turnVisible: sanitizeOptional(smallScreenLimit.turnVisible, sanitizeBoolean),
|
|
478
538
|
};
|
|
479
539
|
});
|
|
480
540
|
}
|
|
@@ -52,44 +52,44 @@ const FILE_LABELS = 'abcdefgh';
|
|
|
52
52
|
|
|
53
53
|
interface ChessboardImplProps {
|
|
54
54
|
|
|
55
|
-
position: Position
|
|
56
|
-
move?: MoveDescriptor
|
|
57
|
-
|
|
58
|
-
squareMarkers?: SquareMarkerSet
|
|
59
|
-
textMarkers?: TextMarkerSet
|
|
60
|
-
arrowMarkers?: ArrowMarkerSet
|
|
61
|
-
|
|
62
|
-
flipped: boolean
|
|
63
|
-
squareSize: number
|
|
64
|
-
coordinateVisible: boolean
|
|
65
|
-
turnVisible: boolean
|
|
66
|
-
moveArrowVisible: boolean
|
|
67
|
-
moveArrowColor: AnnotationColor
|
|
68
|
-
animated: boolean
|
|
69
|
-
colorset: Colorset
|
|
70
|
-
pieceset: Pieceset
|
|
55
|
+
position: Position,
|
|
56
|
+
move?: MoveDescriptor,
|
|
57
|
+
|
|
58
|
+
squareMarkers?: SquareMarkerSet,
|
|
59
|
+
textMarkers?: TextMarkerSet,
|
|
60
|
+
arrowMarkers?: ArrowMarkerSet,
|
|
61
|
+
|
|
62
|
+
flipped: boolean,
|
|
63
|
+
squareSize: number,
|
|
64
|
+
coordinateVisible: boolean,
|
|
65
|
+
turnVisible: boolean,
|
|
66
|
+
moveArrowVisible: boolean,
|
|
67
|
+
moveArrowColor: AnnotationColor,
|
|
68
|
+
animated: boolean,
|
|
69
|
+
colorset: Colorset,
|
|
70
|
+
pieceset: Pieceset,
|
|
71
71
|
|
|
72
72
|
interactionMode?: 'movePieces' | 'clickSquares' | 'editArrows' | 'playMoves',
|
|
73
|
-
editedArrowColor?: AnnotationColor
|
|
73
|
+
editedArrowColor?: AnnotationColor, // mandatory if `interactionMode === 'editArrows'`
|
|
74
74
|
|
|
75
|
-
onPieceMoved?: (from: Square, to: Square) => void
|
|
76
|
-
onSquareClicked?: (square: Square) => void
|
|
77
|
-
onArrowEdited?: (from: Square, to: Square) => void
|
|
78
|
-
onMovePlayed?: (move: string) => void
|
|
75
|
+
onPieceMoved?: (from: Square, to: Square) => void,
|
|
76
|
+
onSquareClicked?: (square: Square) => void,
|
|
77
|
+
onArrowEdited?: (from: Square, to: Square) => void,
|
|
78
|
+
onMovePlayed?: (move: string) => void,
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
interface ChessboardImplState {
|
|
83
|
-
inhibitedSquare?: Square
|
|
84
|
-
draggedSquare?: Square
|
|
85
|
-
hoveredSquare?: Square
|
|
86
|
-
dragPosition?: { x: number, y: number }
|
|
87
|
-
cursorOffset?: { x: number, y: number }
|
|
83
|
+
inhibitedSquare?: Square,
|
|
84
|
+
draggedSquare?: Square,
|
|
85
|
+
hoveredSquare?: Square,
|
|
86
|
+
dragPosition?: { x: number, y: number }, // mandatory if `dragged` is defined
|
|
87
|
+
cursorOffset?: { x: number, y: number }, // mandatory if `dragged` is defined
|
|
88
88
|
promotionDrawer?: {
|
|
89
89
|
origin: Square,
|
|
90
90
|
buttons: Piece[],
|
|
91
91
|
builder: (promotion: Piece) => string,
|
|
92
|
-
}
|
|
92
|
+
},
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
|
|
@@ -309,12 +309,20 @@ export class ChessboardImpl extends React.Component<ChessboardImplProps, Chessbo
|
|
|
309
309
|
});
|
|
310
310
|
return (
|
|
311
311
|
<>
|
|
312
|
-
<rect
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
312
|
+
<rect
|
|
313
|
+
className="kokopu-handle"
|
|
314
|
+
x={0} y={0} width={this.props.squareSize * 8} height={this.props.squareSize * 8}
|
|
315
|
+
onClick={() => this.handleDrawerCancelButtonClicked()}
|
|
316
|
+
/>
|
|
317
|
+
<rect
|
|
318
|
+
x={x} y={y0} width={this.props.squareSize} height={this.props.squareSize * this.state.promotionDrawer.buttons.length}
|
|
319
|
+
fill={this.props.colorset.b}
|
|
320
|
+
/>
|
|
321
|
+
<rect
|
|
322
|
+
className="kokopu-drawerMask"
|
|
323
|
+
x={x} y={y0} width={this.props.squareSize} height={this.props.squareSize * this.state.promotionDrawer.buttons.length}
|
|
324
|
+
fill={this.props.colorset.w}
|
|
325
|
+
/>
|
|
318
326
|
{buttons}
|
|
319
327
|
</>
|
|
320
328
|
);
|
|
@@ -329,7 +337,9 @@ export class ChessboardImpl extends React.Component<ChessboardImplProps, Chessbo
|
|
|
329
337
|
if (dragEnabledForMovePieces || dragEnabledForEditArrows || dragEnabledForPlayMoves) {
|
|
330
338
|
return (
|
|
331
339
|
<Draggable
|
|
332
|
-
key={'handle-' + sq}
|
|
340
|
+
key={'handle-' + sq}
|
|
341
|
+
x={x} y={y} width={this.props.squareSize} height={this.props.squareSize}
|
|
342
|
+
isArrowHandle={dragEnabledForEditArrows}
|
|
333
343
|
onDragStart={(x0, y0) => this.handleDragStart(sq, x0, y0)}
|
|
334
344
|
onDrag={(dx, dy) => this.handleDrag(sq, dx, dy)}
|
|
335
345
|
onDragStop={(dx, dy) => this.handleDragStop(sq, dx, dy)}
|
|
@@ -340,7 +350,8 @@ export class ChessboardImpl extends React.Component<ChessboardImplProps, Chessbo
|
|
|
340
350
|
else if (this.props.interactionMode === 'clickSquares') {
|
|
341
351
|
return (
|
|
342
352
|
<rect
|
|
343
|
-
key={'handle-' + sq} className="kokopu-handle kokopu-clickable"
|
|
353
|
+
key={'handle-' + sq} className="kokopu-handle kokopu-clickable"
|
|
354
|
+
x={x} y={y} width={this.props.squareSize} height={this.props.squareSize}
|
|
344
355
|
onClick={() => this.handleSquareClicked(sq)}
|
|
345
356
|
/>
|
|
346
357
|
);
|
|
@@ -357,7 +368,9 @@ export class ChessboardImpl extends React.Component<ChessboardImplProps, Chessbo
|
|
|
357
368
|
return Object.entries(this.props.squareMarkers).map(([ sq, color ]) => {
|
|
358
369
|
const { x, y } = this.getSquareCoordinates(sq as Square);
|
|
359
370
|
return (
|
|
360
|
-
<rect
|
|
371
|
+
<rect
|
|
372
|
+
key={'sqm-' + sq} className="kokopu-annotation"
|
|
373
|
+
x={x} y={y} width={this.props.squareSize} height={this.props.squareSize}
|
|
361
374
|
fill={this.getColorForAnnotation(color)}
|
|
362
375
|
/>
|
|
363
376
|
);
|
|
@@ -401,8 +414,10 @@ export class ChessboardImpl extends React.Component<ChessboardImplProps, Chessbo
|
|
|
401
414
|
yTo += Math.sign(yFrom - yTo) * ARROW_TIP_OFFSET_FACTOR * this.props.squareSize;
|
|
402
415
|
return (
|
|
403
416
|
<line
|
|
404
|
-
key={'arm-' + vect} className="kokopu-annotation kokopu-arrow"
|
|
405
|
-
|
|
417
|
+
key={'arm-' + vect} className="kokopu-annotation kokopu-arrow"
|
|
418
|
+
x1={xFrom} y1={yFrom} x2={xTo} y2={yTo}
|
|
419
|
+
strokeWidth={strokeWidth} stroke={this.getColorForAnnotation(color)}
|
|
420
|
+
markerEnd={`url(#${this.getArrowTipId(color)})`}
|
|
406
421
|
/>
|
|
407
422
|
);
|
|
408
423
|
});
|
|
@@ -425,8 +440,10 @@ export class ChessboardImpl extends React.Component<ChessboardImplProps, Chessbo
|
|
|
425
440
|
const y = yTo * motionCursor + yFrom * (1 - motionCursor);
|
|
426
441
|
return (
|
|
427
442
|
<line
|
|
428
|
-
className="kokopu-annotation kokopu-arrow"
|
|
429
|
-
|
|
443
|
+
className="kokopu-annotation kokopu-arrow"
|
|
444
|
+
x1={xFrom} y1={yFrom} x2={x} y2={y}
|
|
445
|
+
strokeWidth={strokeWidth} stroke={this.getColorForAnnotation(this.props.moveArrowColor)}
|
|
446
|
+
markerEnd={`url(#${this.getArrowTipId(this.props.moveArrowColor)})`}
|
|
430
447
|
/>
|
|
431
448
|
);
|
|
432
449
|
}
|
|
@@ -478,7 +495,7 @@ export class ChessboardImpl extends React.Component<ChessboardImplProps, Chessbo
|
|
|
478
495
|
}
|
|
479
496
|
|
|
480
497
|
private handleDragStop(sq: Square, dx: number, dy: number) {
|
|
481
|
-
const { x, y } = this.getSquareCoordinates(
|
|
498
|
+
const { x, y } = this.getSquareCoordinates(sq);
|
|
482
499
|
const targetSq = this.getSquareAt(x + dx + this.state.cursorOffset!.x, y + dy + this.state.cursorOffset!.y);
|
|
483
500
|
this.setState({
|
|
484
501
|
inhibitedSquare: undefined,
|
|
@@ -30,65 +30,65 @@ interface DraggableProps {
|
|
|
30
30
|
/**
|
|
31
31
|
* Initial X coordinate of the handle.
|
|
32
32
|
*/
|
|
33
|
-
x: number
|
|
33
|
+
x: number,
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Initial Y coordinate of the handle.
|
|
37
37
|
*/
|
|
38
|
-
y: number
|
|
38
|
+
y: number,
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Width of the handle.
|
|
42
42
|
*/
|
|
43
|
-
width: number
|
|
43
|
+
width: number,
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Height of the handle.
|
|
47
47
|
*/
|
|
48
|
-
height: number
|
|
48
|
+
height: number,
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* `true` if the handle corresponds to a draggable arrow, `false` if it corresponds to a draggable piece.
|
|
52
52
|
*/
|
|
53
|
-
isArrowHandle: boolean
|
|
53
|
+
isArrowHandle: boolean,
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Callback invoked when the drag starts. `x0` and `y0` correspond to the coordinates (relative to the hande) at which the drag has been initiated.
|
|
57
57
|
*/
|
|
58
|
-
onDragStart?: (x0: number, y0: number) => void
|
|
58
|
+
onDragStart?: (x0: number, y0: number) => void,
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Callback invoked during the drag. `dx` and `dy` correspond to the coordinates of the drag translation vector.
|
|
62
62
|
*/
|
|
63
|
-
onDrag?: (dx: number, dy: number) => void
|
|
63
|
+
onDrag?: (dx: number, dy: number) => void,
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Callback invoked when the drag stops. `dx` and `dy` correspond to the coordinates of the drag translation vector.
|
|
67
67
|
*/
|
|
68
|
-
onDragStop?: (dx: number, dy: number) => void
|
|
68
|
+
onDragStop?: (dx: number, dy: number) => void,
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Callback invoked when the drag is canceled.
|
|
72
72
|
*/
|
|
73
|
-
onDragCanceled?: () => void
|
|
73
|
+
onDragCanceled?: () => void,
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
interface DragData {
|
|
78
|
-
originX: number
|
|
79
|
-
originY: number
|
|
78
|
+
originX: number,
|
|
79
|
+
originY: number,
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
interface PageCoordinates {
|
|
84
|
-
pageX: number
|
|
85
|
-
pageY: number
|
|
84
|
+
pageX: number,
|
|
85
|
+
pageY: number,
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
interface ClientCoordinates {
|
|
90
|
-
clientX: number
|
|
91
|
-
clientY: number
|
|
90
|
+
clientX: number,
|
|
91
|
+
clientY: number,
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
|
|
@@ -32,17 +32,17 @@ interface MotionProps {
|
|
|
32
32
|
/**
|
|
33
33
|
* Duration of the animation. Must be > 0.
|
|
34
34
|
*/
|
|
35
|
-
duration: number
|
|
35
|
+
duration: number,
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Factory for the content being animated. The animation cursor is guaranteed to be valued between 0 and 1 inclusive.
|
|
39
39
|
*/
|
|
40
|
-
children: (cursor: number) => React.ReactNode
|
|
40
|
+
children: (cursor: number) => React.ReactNode,
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
interface MotionState {
|
|
45
|
-
cursor: number
|
|
45
|
+
cursor: number,
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
|
|
@@ -63,7 +63,7 @@ export class Motion extends React.Component<MotionProps, MotionState> {
|
|
|
63
63
|
this.cursorStop = 1;
|
|
64
64
|
|
|
65
65
|
// WARNING: this hack exists only for testing purposes. DO NOT USE IT IN PRODUCTION.
|
|
66
|
-
const debugCursorStop = window[
|
|
66
|
+
const debugCursorStop = window[/* eslint-disable @typescript-eslint/no-explicit-any */ DEBUG_KEY as any /* eslint-enable */];
|
|
67
67
|
if (typeof debugCursorStop === 'number' && debugCursorStop >= 0 && debugCursorStop <= 1) {
|
|
68
68
|
this.cursorStop = debugCursorStop;
|
|
69
69
|
}
|
|
@@ -40,27 +40,27 @@ export interface ErrorBoxProps {
|
|
|
40
40
|
/**
|
|
41
41
|
* Title of the error box.
|
|
42
42
|
*/
|
|
43
|
-
title: string
|
|
43
|
+
title: string,
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Additional message providing details about the error.
|
|
47
47
|
*/
|
|
48
|
-
message: string
|
|
48
|
+
message: string,
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Raw text whose processing results in the error.
|
|
52
52
|
*/
|
|
53
|
-
text?: string
|
|
53
|
+
text?: string,
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Index of the character within `text` that results in the error.
|
|
57
57
|
*/
|
|
58
|
-
errorIndex?: number
|
|
58
|
+
errorIndex?: number,
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Index (1-based) of the line in which is the character that results in the error.
|
|
62
62
|
*/
|
|
63
|
-
lineNumber?: number
|
|
63
|
+
lineNumber?: number,
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
|