kokopu-react 3.3.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 +4 -0
- package/dist/lib/chessboard/Chessboard.js +3 -2
- 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/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 +1 -1
- package/dist/lib/navigationboard/NavigationBoard.js +2 -2
- package/dist/lib/navigationboard/NavigationBoard.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.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 +43 -39
- 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/movetext/Movetext.tsx +11 -10
- package/src/movetext/MovetextImpl.tsx +34 -28
- package/src/movetext/htmlFilter.tsx +4 -4
- package/src/navigationboard/NavigationBoard.tsx +55 -50
- package/src/navigationboard/NavigationButton.ts +4 -4
- package/src/navigationboard/NavigationField.tsx +6 -6
- package/src/navigationboard/NavigationToolbar.tsx +17 -13
- 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 +2 -0
- 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 +23 -16
- 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
|
@@ -41,12 +41,12 @@ export interface ArrowMarkerIconProps {
|
|
|
41
41
|
/**
|
|
42
42
|
* Width and height (in pixels) of the icon.
|
|
43
43
|
*/
|
|
44
|
-
size: number
|
|
44
|
+
size: number,
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) to use to colorize the icon (for example: `'green'`, `'#ff0000'`...).
|
|
48
48
|
*/
|
|
49
|
-
color: string
|
|
49
|
+
color: string,
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
|
|
@@ -75,8 +75,12 @@ export class ArrowMarkerIcon extends React.Component<ArrowMarkerIconProps> {
|
|
|
75
75
|
<defs>
|
|
76
76
|
<ArrowTip id={this.arrowTipId} color={this.props.color} />
|
|
77
77
|
</defs>
|
|
78
|
-
<line
|
|
79
|
-
|
|
78
|
+
<line
|
|
79
|
+
className="kokopu-arrow"
|
|
80
|
+
x1={halfThickness} y1={size / 2} x2={size - halfThickness * 3} y2={size / 2}
|
|
81
|
+
stroke={color} strokeWidth={halfThickness * 2}
|
|
82
|
+
markerEnd={`url(#${this.arrowTipId})`}
|
|
83
|
+
/>
|
|
80
84
|
</svg>
|
|
81
85
|
);
|
|
82
86
|
}
|
package/src/icons/ArrowTip.tsx
CHANGED
|
@@ -30,12 +30,12 @@ interface ArrowTipProps {
|
|
|
30
30
|
/**
|
|
31
31
|
* ID of the element.
|
|
32
32
|
*/
|
|
33
|
-
id: string
|
|
33
|
+
id: string,
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
|
|
37
37
|
*/
|
|
38
|
-
color: string
|
|
38
|
+
color: string,
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
|
|
@@ -35,29 +35,24 @@ export interface ChessPieceIconProps {
|
|
|
35
35
|
/**
|
|
36
36
|
* Width and height (in pixels) of each chess piece icon.
|
|
37
37
|
*/
|
|
38
|
-
size: number
|
|
38
|
+
size: number,
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Chess piece(s) to display.
|
|
42
42
|
*/
|
|
43
|
-
type: ChessPieceIconType | ChessPieceIconType[]
|
|
43
|
+
type: ChessPieceIconType | ChessPieceIconType[],
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Piece theme ID. Must be a property of `Chessboard.piecesets()`.
|
|
47
47
|
*/
|
|
48
|
-
pieceset
|
|
48
|
+
pieceset?: string,
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
const defaultProps: Partial<ChessPieceIconProps> = {
|
|
53
|
-
pieceset: DEFAULT_PIECESET,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
52
|
/**
|
|
58
53
|
* SVG icon representing a colored chess piece, or a list of colored chess pieces.
|
|
59
54
|
*/
|
|
60
|
-
export function ChessPieceIcon({ size, type, pieceset }: ChessPieceIconProps) {
|
|
55
|
+
export function ChessPieceIcon({ size, type, pieceset = DEFAULT_PIECESET }: ChessPieceIconProps) {
|
|
61
56
|
|
|
62
57
|
// Sanitize the inputs.
|
|
63
58
|
size = sanitizeBoundedInteger(size, MIN_SQUARE_SIZE, MAX_SQUARE_SIZE, () => new IllegalArgument('ChessPieceIcon', 'size'));
|
|
@@ -77,8 +72,6 @@ export function ChessPieceIcon({ size, type, pieceset }: ChessPieceIconProps) {
|
|
|
77
72
|
);
|
|
78
73
|
}
|
|
79
74
|
|
|
80
|
-
ChessPieceIcon.defaultProps = defaultProps;
|
|
81
|
-
|
|
82
75
|
|
|
83
76
|
/**
|
|
84
77
|
* Sanitization method for the small-screen limits parameter.
|
|
@@ -36,24 +36,19 @@ export interface SquareMarkerIconProps {
|
|
|
36
36
|
/**
|
|
37
37
|
* Width and height (in pixels) of the icon.
|
|
38
38
|
*/
|
|
39
|
-
size: number
|
|
39
|
+
size: number,
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) to use to colorize the icon (for example: `'green'`, `'#ff0000'`...).
|
|
43
43
|
*/
|
|
44
|
-
color
|
|
44
|
+
color?: string,
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
const defaultProps: Partial<SquareMarkerIconProps> = {
|
|
49
|
-
color: 'currentcolor',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
|
|
53
48
|
/**
|
|
54
49
|
* SVG icon representing a square marker.
|
|
55
50
|
*/
|
|
56
|
-
export function SquareMarkerIcon({ size, color }: SquareMarkerIconProps) {
|
|
51
|
+
export function SquareMarkerIcon({ size, color = 'currentcolor' }: SquareMarkerIconProps) {
|
|
57
52
|
|
|
58
53
|
// Sanitize the inputs.
|
|
59
54
|
size = sanitizeBoundedInteger(size, MIN_SQUARE_SIZE, MAX_SQUARE_SIZE, () => new IllegalArgument('SquareMarkerIcon', 'size'));
|
|
@@ -68,5 +63,3 @@ export function SquareMarkerIcon({ size, color }: SquareMarkerIconProps) {
|
|
|
68
63
|
</svg>
|
|
69
64
|
);
|
|
70
65
|
}
|
|
71
|
-
|
|
72
|
-
SquareMarkerIcon.defaultProps = defaultProps;
|
|
@@ -36,29 +36,24 @@ export interface TextMarkerIconProps {
|
|
|
36
36
|
/**
|
|
37
37
|
* Width and height (in pixels) of the icon.
|
|
38
38
|
*/
|
|
39
|
-
size: number
|
|
39
|
+
size: number,
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Symbol to represent on the icon.
|
|
43
43
|
*/
|
|
44
|
-
symbol: AnnotationSymbol
|
|
44
|
+
symbol: AnnotationSymbol,
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) to use to colorize the icon (for example: `'green'`, `'#ff0000'`...).
|
|
48
48
|
*/
|
|
49
|
-
color
|
|
49
|
+
color?: string,
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
const defaultProps: Partial<TextMarkerIconProps> = {
|
|
54
|
-
color: 'currentcolor',
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
53
|
/**
|
|
59
54
|
* SVG icon representing a text marker.
|
|
60
55
|
*/
|
|
61
|
-
export function TextMarkerIcon({ size, symbol, color }: TextMarkerIconProps) {
|
|
56
|
+
export function TextMarkerIcon({ size, symbol, color = 'currentcolor' }: TextMarkerIconProps) {
|
|
62
57
|
|
|
63
58
|
// Sanitize the inputs.
|
|
64
59
|
size = sanitizeBoundedInteger(size, MIN_SQUARE_SIZE, MAX_SQUARE_SIZE, () => new IllegalArgument('TextMarkerIcon', 'size'));
|
|
@@ -75,5 +70,3 @@ export function TextMarkerIcon({ size, symbol, color }: TextMarkerIconProps) {
|
|
|
75
70
|
</svg>
|
|
76
71
|
);
|
|
77
72
|
}
|
|
78
|
-
|
|
79
|
-
TextMarkerIcon.defaultProps = defaultProps;
|
|
@@ -52,49 +52,49 @@ export interface MovetextProps {
|
|
|
52
52
|
* a [kokopu.Database](https://kokopu.yo35.org/docs/current/classes/Database.html) object,
|
|
53
53
|
* or a [PGN string](https://en.wikipedia.org/wiki/Portable_Game_Notation).
|
|
54
54
|
*/
|
|
55
|
-
game: Game | Database | string
|
|
55
|
+
game: Game | Database | string,
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Index of the game to display (only if attribute `game` is a [kokopu.Database](https://kokopu.yo35.org/docs/current/classes/Database.html)
|
|
59
59
|
* or a [PGN string](https://en.wikipedia.org/wiki/Portable_Game_Notation)): `0` for the first game of the database/PGN, `1` for the second one, etc.
|
|
60
60
|
* If omitted, the first game of the database/PGN is displayed.
|
|
61
61
|
*/
|
|
62
|
-
gameIndex: number
|
|
62
|
+
gameIndex: number,
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Options applicable to the diagrams in the comments. See [Chessboard](#/Components/Chessboard) for more details about each option.
|
|
66
66
|
*/
|
|
67
67
|
diagramOptions: Partial<StaticBoardGraphicProps> & {
|
|
68
68
|
flipped?: boolean,
|
|
69
|
-
}
|
|
69
|
+
},
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Symbols to use for the chess pieces. See {@link moveFormatter}.
|
|
73
73
|
*/
|
|
74
|
-
pieceSymbols: 'native' | 'localized' | 'figurines' | PieceSymbolMapping
|
|
74
|
+
pieceSymbols: 'native' | 'localized' | 'figurines' | PieceSymbolMapping,
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Whether the diagrams within the comments (if any) are displayed or not.
|
|
78
78
|
*/
|
|
79
|
-
diagramVisible: boolean
|
|
79
|
+
diagramVisible: boolean,
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Whether the game headers (if any) are displayed or not.
|
|
83
83
|
*/
|
|
84
|
-
headerVisible: boolean
|
|
84
|
+
headerVisible: boolean,
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* ID of the selected move (or `'start'`/`'end'` for the beginning/end of the main variation).
|
|
88
88
|
* Use [kokopu.Node#id](https://kokopu.yo35.org/docs/current/classes/Node.html#id) to get the ID of a game move.
|
|
89
89
|
*/
|
|
90
|
-
selection?: string
|
|
90
|
+
selection?: string,
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* Type of action allowed with the mouse/keys on the component. If undefined, then the user cannot interact with the component.
|
|
94
94
|
*
|
|
95
95
|
* - `'selectMove'` allows the user to select a move.
|
|
96
96
|
*/
|
|
97
|
-
interactionMode?: 'selectMove'
|
|
97
|
+
interactionMode?: 'selectMove',
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Callback invoked when the user selects a move (only if `interactionMode` is set to `'selectMove'`).
|
|
@@ -109,7 +109,7 @@ export interface MovetextProps {
|
|
|
109
109
|
* - `'key-exit'`: the event has been triggered by the "unselect-move" key (aka. the escape key),
|
|
110
110
|
* - `'click'`: the event has been triggered by a mouse click on a move.
|
|
111
111
|
*/
|
|
112
|
-
onMoveSelected?: (nodeId: string | undefined, evtOrigin: MoveSelectEventOrigin) => void
|
|
112
|
+
onMoveSelected?: (nodeId: string | undefined, evtOrigin: MoveSelectEventOrigin) => void,
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
|
|
@@ -151,7 +151,8 @@ export class Movetext extends React.Component<MovetextProps> {
|
|
|
151
151
|
const { onMoveSelected } = this.props;
|
|
152
152
|
|
|
153
153
|
return (
|
|
154
|
-
<MovetextImpl
|
|
154
|
+
<MovetextImpl
|
|
155
|
+
ref={this.implRef}
|
|
155
156
|
game={info.game}
|
|
156
157
|
diagramOptions={this.props.diagramOptions} moveFormatter={formatter} diagramVisible={diagramVisible} headerVisible={headerVisible}
|
|
157
158
|
selection={selection} interactionMode={interactionMode} onMoveSelected={onMoveSelected}
|
|
@@ -39,19 +39,19 @@ import './Movetext.css';
|
|
|
39
39
|
|
|
40
40
|
interface MovetextImplProps {
|
|
41
41
|
|
|
42
|
-
game: Game
|
|
42
|
+
game: Game,
|
|
43
43
|
|
|
44
44
|
diagramOptions: Partial<StaticBoardGraphicProps> & {
|
|
45
45
|
flipped?: boolean,
|
|
46
|
-
}
|
|
47
|
-
moveFormatter: (notation: string) => React.ReactNode
|
|
48
|
-
diagramVisible: boolean
|
|
49
|
-
headerVisible: boolean
|
|
46
|
+
},
|
|
47
|
+
moveFormatter: (notation: string) => React.ReactNode,
|
|
48
|
+
diagramVisible: boolean,
|
|
49
|
+
headerVisible: boolean,
|
|
50
50
|
|
|
51
|
-
selection?: string
|
|
52
|
-
interactionMode?: 'selectMove'
|
|
51
|
+
selection?: string,
|
|
52
|
+
interactionMode?: 'selectMove',
|
|
53
53
|
|
|
54
|
-
onMoveSelected?: (nodeId: string | undefined, evtOrigin: 'key-first' | 'key-previous' | 'key-next' | 'key-last' | 'key-exit' | 'click') => void
|
|
54
|
+
onMoveSelected?: (nodeId: string | undefined, evtOrigin: 'key-first' | 'key-previous' | 'key-next' | 'key-last' | 'key-exit' | 'click') => void,
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
|
|
@@ -106,7 +106,8 @@ export class MovetextImpl extends React.Component<MovetextImplProps> {
|
|
|
106
106
|
const titleElement = title === undefined ? undefined : <span className="kokopu-header-playerTitle">{filter(title)}</span>;
|
|
107
107
|
const ratingElement = rating === undefined ? undefined : <span className="kokopu-header-playerRating">{rating}</span>;
|
|
108
108
|
const separator = title === undefined || rating === undefined ? undefined : '\u00a0'; // \u00a0 ==
|
|
109
|
-
const titleRatingGroup = title === undefined && rating === undefined ?
|
|
109
|
+
const titleRatingGroup = title === undefined && rating === undefined ?
|
|
110
|
+
undefined :
|
|
110
111
|
<span className="kokopu-headerGroup-titleRating">{titleElement}{separator}{ratingElement}</span>;
|
|
111
112
|
return <div className={classNames.join(' ')} key={'player-' + color}>{colorTag}{playerNameElement}{titleRatingGroup}</div>;
|
|
112
113
|
}
|
|
@@ -155,13 +156,16 @@ export class MovetextImpl extends React.Component<MovetextImplProps> {
|
|
|
155
156
|
if (this.props.interactionMode !== 'selectMove') {
|
|
156
157
|
return undefined;
|
|
157
158
|
}
|
|
158
|
-
return
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
return (
|
|
160
|
+
<NavigationField
|
|
161
|
+
ref={this.navigationFieldRef}
|
|
162
|
+
onFirstPressed={() => this.handleNavigationPressed(firstNodeId, 'key-first')}
|
|
163
|
+
onPreviousPressed={() => this.handleNavigationPressed(previousNodeId, 'key-previous')}
|
|
164
|
+
onNextPressed={() => this.handleNavigationPressed(nextNodeId, 'key-next')}
|
|
165
|
+
onLastPressed={() => this.handleNavigationPressed(lastNodeId, 'key-last')}
|
|
166
|
+
onExitPressed={() => this.handleExitPressed()}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
165
169
|
}
|
|
166
170
|
|
|
167
171
|
private renderBody() {
|
|
@@ -268,7 +272,7 @@ export class MovetextImpl extends React.Component<MovetextImplProps> {
|
|
|
268
272
|
// Move number
|
|
269
273
|
let moveNumber: React.ReactNode = undefined;
|
|
270
274
|
if (forcePrintMoveNumber || node.moveColor() === 'w') {
|
|
271
|
-
const moveNumberText
|
|
275
|
+
const moveNumberText = node.fullMoveNumber() + (node.moveColor() === 'w' ? '.' : '\u2026');
|
|
272
276
|
moveNumber = <span className="kokopu-moveNumber">{moveNumberText}</span>;
|
|
273
277
|
}
|
|
274
278
|
|
|
@@ -313,17 +317,19 @@ export class MovetextImpl extends React.Component<MovetextImplProps> {
|
|
|
313
317
|
for (let textSegment of comment.split('[#]')) {
|
|
314
318
|
if (!isFirstTextSegment) {
|
|
315
319
|
const position = node instanceof Variation ? node.initialPosition() : node.position();
|
|
316
|
-
const diagram =
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
320
|
+
const diagram = (
|
|
321
|
+
<Chessboard
|
|
322
|
+
position={position}
|
|
323
|
+
squareMarkers={node.tag('csl')} arrowMarkers={node.tag('cal')} textMarkers={node.tag('ctl')}
|
|
324
|
+
flipped={this.props.diagramOptions.flipped}
|
|
325
|
+
squareSize={this.props.diagramOptions.squareSize}
|
|
326
|
+
coordinateVisible={this.props.diagramOptions.coordinateVisible}
|
|
327
|
+
turnVisible={this.props.diagramOptions.turnVisible}
|
|
328
|
+
colorset={this.props.diagramOptions.colorset}
|
|
329
|
+
pieceset={this.props.diagramOptions.pieceset}
|
|
330
|
+
smallScreenLimits={this.props.diagramOptions.smallScreenLimits}
|
|
331
|
+
/>
|
|
332
|
+
);
|
|
327
333
|
segmentElements.push(<div className="kokopu-diagram" key={'diagram-' + (diagramIndex++)}>{diagram}</div>);
|
|
328
334
|
}
|
|
329
335
|
isFirstTextSegment = false;
|
|
@@ -72,7 +72,7 @@ export function htmlFilter(type: 'header' | 'comment'): (text: string) => React.
|
|
|
72
72
|
'ul', 'ol', 'li', // lists
|
|
73
73
|
]);
|
|
74
74
|
Object.assign(allowedAttributes, {
|
|
75
|
-
|
|
75
|
+
img: [ 'alt', 'src', 'height', 'width' ],
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -85,8 +85,8 @@ export function htmlFilter(type: 'header' | 'comment'): (text: string) => React.
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
interface HtmlSanitizerProps {
|
|
88
|
-
allowedTags?: string[]
|
|
89
|
-
allowedAttributes?: Record<string, string[]
|
|
88
|
+
allowedTags?: string[],
|
|
89
|
+
allowedAttributes?: Record<string, string[]>,
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
|
|
@@ -101,7 +101,7 @@ class HtmlSanitizer {
|
|
|
101
101
|
|
|
102
102
|
constructor({ allowedTags, allowedAttributes }: HtmlSanitizerProps) {
|
|
103
103
|
this.#allowedTags = allowedTags ? new Set(allowedTags) : new Set();
|
|
104
|
-
this.#allowedAttributes = allowedAttributes ? new Map(Object.entries(allowedAttributes).map(([k, v]) => [k, new Set(v)])) : new Map();
|
|
104
|
+
this.#allowedAttributes = allowedAttributes ? new Map(Object.entries(allowedAttributes).map(([ k, v ]) => [ k, new Set(v) ])) : new Map();
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
/**
|
|
@@ -49,28 +49,28 @@ export interface NavigationBoardProps extends DynamicBoardGraphicProps {
|
|
|
49
49
|
* a [kokopu.Database](https://kokopu.yo35.org/docs/current/classes/Database.html) object,
|
|
50
50
|
* or a [PGN string](https://en.wikipedia.org/wiki/Portable_Game_Notation).
|
|
51
51
|
*/
|
|
52
|
-
game: Game | Database | string
|
|
52
|
+
game: Game | Database | string,
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Index of the game to display (only if attribute `game` is a [kokopu.Database](https://kokopu.yo35.org/docs/current/classes/Database.html)
|
|
56
56
|
* or a [PGN string](https://en.wikipedia.org/wiki/Portable_Game_Notation)): `0` for the first game of the database/PGN, `1` for the second one, etc.
|
|
57
57
|
* If omitted, the first game of the database/PGN is displayed.
|
|
58
58
|
*/
|
|
59
|
-
gameIndex: number
|
|
59
|
+
gameIndex: number,
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* ID of the move initially selected (or `'start'`/`'end'` for the beginning/end of the main variation) when the component is uncontrolled.
|
|
63
63
|
* Use [kokopu.Node#id](https://kokopu.yo35.org/docs/current/classes/Node.html#id) to get the ID of a game move.
|
|
64
64
|
* Ignored if the `nodeId` attribute is provided.
|
|
65
65
|
*/
|
|
66
|
-
initialNodeId: string
|
|
66
|
+
initialNodeId: string,
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* ID of the selected move (or `'start'`/`'end'` for the beginning/end of the main variation).
|
|
70
70
|
* Use [kokopu.Node#id](https://kokopu.yo35.org/docs/current/classes/Node.html#id) to get the ID of a game move.
|
|
71
71
|
* If provided (i.e. if the component is controlled), the attribute `onNodeIdChanged` must be provided as well.
|
|
72
72
|
*/
|
|
73
|
-
nodeId?: string
|
|
73
|
+
nodeId?: string,
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Callback invoked in controlled-component mode, when the user changes the selected move.
|
|
@@ -78,60 +78,60 @@ export interface NavigationBoardProps extends DynamicBoardGraphicProps {
|
|
|
78
78
|
* @param nodeId - ID of the selected move (as returned by [kokopu.Node#id](https://kokopu.yo35.org/docs/current/classes/Node.html#id)),
|
|
79
79
|
* or `'start'` for the beginning of the main variation.
|
|
80
80
|
*/
|
|
81
|
-
onNodeIdChanged?: (nodeId: string) => void
|
|
81
|
+
onNodeIdChanged?: (nodeId: string) => void,
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Whether auto-play is initially enabled or not.
|
|
85
85
|
* Ignored if the `isPlaying` attribute is provided.
|
|
86
86
|
*/
|
|
87
|
-
initialIsPlaying: boolean
|
|
87
|
+
initialIsPlaying: boolean,
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Whether auto-play is enabled or not.
|
|
91
91
|
* If provided (i.e. if the is-playing state is controlled), the attribute `onIsPlayingChanged` must be provided as well.
|
|
92
92
|
*/
|
|
93
|
-
isPlaying?: boolean
|
|
93
|
+
isPlaying?: boolean,
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Callback invoked in controlled-is-playing-state mode, when the user clicks on the play/stop button.
|
|
97
97
|
*
|
|
98
98
|
* @param isPlaying - New is-playing state.
|
|
99
99
|
*/
|
|
100
|
-
onIsPlayingChanged?: (isPlaying: boolean) => void
|
|
100
|
+
onIsPlayingChanged?: (isPlaying: boolean) => void,
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
103
|
* Whether the board is initially flipped (i.e. seen from Black's point of view) or not, when the flip state is uncontrolled.
|
|
104
104
|
* Ignored if the `flipped` attribute is provided.
|
|
105
105
|
*/
|
|
106
|
-
initialFlipped: boolean
|
|
106
|
+
initialFlipped: boolean,
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Whether the board is flipped (i.e. seen from Black's point of view) or not.
|
|
110
110
|
* If provided (i.e. if the flip state is controlled), the attribute `onFlippedChanged` must be provided as well.
|
|
111
111
|
*/
|
|
112
|
-
flipped?: boolean
|
|
112
|
+
flipped?: boolean,
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Callback invoked in controlled-flip-state mode, when the user flips the board.
|
|
116
116
|
*
|
|
117
117
|
* @param flipped - New flip state.
|
|
118
118
|
*/
|
|
119
|
-
onFlippedChanged?: (flipped: boolean) => void
|
|
119
|
+
onFlippedChanged?: (flipped: boolean) => void,
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* Whether the play/stop button is visible or not in the toolbar.
|
|
123
123
|
*/
|
|
124
|
-
playButtonVisible: boolean
|
|
124
|
+
playButtonVisible: boolean,
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
127
|
* Whether the flip button is visible or not in the toolbar.
|
|
128
128
|
*/
|
|
129
|
-
flipButtonVisible: boolean
|
|
129
|
+
flipButtonVisible: boolean,
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* Additional buttons to be added to the toolbar.
|
|
133
133
|
*/
|
|
134
|
-
additionalButtons: NavigationBar
|
|
134
|
+
additionalButtons: NavigationBar,
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
|
|
@@ -139,13 +139,13 @@ export interface NavigationBoardProps extends DynamicBoardGraphicProps {
|
|
|
139
139
|
* Attributes for method `NavigationBoard.size()`.
|
|
140
140
|
*/
|
|
141
141
|
interface NavigationBoardSizeAttr {
|
|
142
|
-
squareSize?: NavigationBoardProps['squareSize']
|
|
143
|
-
coordinateVisible?: NavigationBoardProps['coordinateVisible']
|
|
144
|
-
turnVisible?: NavigationBoardProps['turnVisible']
|
|
145
|
-
smallScreenLimits?: NavigationBoardProps['smallScreenLimits']
|
|
146
|
-
playButtonVisible?: NavigationBoardProps['playButtonVisible']
|
|
147
|
-
flipButtonVisible?: NavigationBoardProps['flipButtonVisible']
|
|
148
|
-
additionalButtons?: NavigationBarScheme
|
|
142
|
+
squareSize?: NavigationBoardProps['squareSize'],
|
|
143
|
+
coordinateVisible?: NavigationBoardProps['coordinateVisible'],
|
|
144
|
+
turnVisible?: NavigationBoardProps['turnVisible'],
|
|
145
|
+
smallScreenLimits?: NavigationBoardProps['smallScreenLimits'],
|
|
146
|
+
playButtonVisible?: NavigationBoardProps['playButtonVisible'],
|
|
147
|
+
flipButtonVisible?: NavigationBoardProps['flipButtonVisible'],
|
|
148
|
+
additionalButtons?: NavigationBarScheme,
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
|
|
@@ -153,19 +153,19 @@ interface NavigationBoardSizeAttr {
|
|
|
153
153
|
* Attributes for method `NavigationBoard.adaptSquareSize()`.
|
|
154
154
|
*/
|
|
155
155
|
interface NavigationBoardAdaptSquareSizeAttr {
|
|
156
|
-
coordinateVisible?: NavigationBoardProps['coordinateVisible']
|
|
157
|
-
turnVisible?: NavigationBoardProps['turnVisible']
|
|
158
|
-
smallScreenLimits?: NavigationBoardProps['smallScreenLimits']
|
|
159
|
-
playButtonVisible?: NavigationBoardProps['playButtonVisible']
|
|
160
|
-
flipButtonVisible?: NavigationBoardProps['flipButtonVisible']
|
|
161
|
-
additionalButtons?: NavigationBarScheme
|
|
156
|
+
coordinateVisible?: NavigationBoardProps['coordinateVisible'],
|
|
157
|
+
turnVisible?: NavigationBoardProps['turnVisible'],
|
|
158
|
+
smallScreenLimits?: NavigationBoardProps['smallScreenLimits'],
|
|
159
|
+
playButtonVisible?: NavigationBoardProps['playButtonVisible'],
|
|
160
|
+
flipButtonVisible?: NavigationBoardProps['flipButtonVisible'],
|
|
161
|
+
additionalButtons?: NavigationBarScheme,
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
interface NavigationBoardState {
|
|
166
|
-
nodeIdAsUncontrolled: string
|
|
167
|
-
isPlayingAsUncontrolled: boolean
|
|
168
|
-
flippedAsUncontrolled: boolean
|
|
166
|
+
nodeIdAsUncontrolled: string,
|
|
167
|
+
isPlayingAsUncontrolled: boolean,
|
|
168
|
+
flippedAsUncontrolled: boolean,
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
|
|
@@ -230,29 +230,34 @@ export class NavigationBoard extends React.Component<NavigationBoardProps, Navig
|
|
|
230
230
|
private renderBoard(game: Game, node: GameNode | Variation, isPlaying: boolean, flipped: boolean) {
|
|
231
231
|
const position = node instanceof GameNode ? node.positionBefore() : node.initialPosition();
|
|
232
232
|
const move = node instanceof GameNode ? node.notation() : undefined;
|
|
233
|
-
return
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
233
|
+
return (
|
|
234
|
+
<Chessboard
|
|
235
|
+
position={position} move={move} flipped={flipped}
|
|
236
|
+
squareMarkers={node.tag('csl')} arrowMarkers={node.tag('cal')} textMarkers={node.tag('ctl')}
|
|
237
|
+
squareSize={this.props.squareSize}
|
|
238
|
+
coordinateVisible={this.props.coordinateVisible}
|
|
239
|
+
turnVisible={this.props.turnVisible}
|
|
240
|
+
colorset={this.props.colorset}
|
|
241
|
+
pieceset={this.props.pieceset}
|
|
242
|
+
smallScreenLimits={this.props.smallScreenLimits}
|
|
243
|
+
moveArrowVisible={this.props.moveArrowVisible}
|
|
244
|
+
moveArrowColor={this.props.moveArrowColor}
|
|
245
|
+
animated={this.props.animated}
|
|
246
|
+
bottomComponent={({ squareSize }) => this.renderToolbar(game, node, squareSize, isPlaying)}
|
|
247
|
+
/>
|
|
248
|
+
);
|
|
247
249
|
}
|
|
248
250
|
|
|
249
251
|
private renderNavigationField(game: Game, currentNodeId: string) {
|
|
250
|
-
return
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
252
|
+
return (
|
|
253
|
+
<NavigationField
|
|
254
|
+
ref={this.navigationFieldRef}
|
|
255
|
+
onFirstPressed={() => this.handleNavClicked(firstNodeId(game, currentNodeId))}
|
|
256
|
+
onPreviousPressed={() => this.handleNavClicked(previousNodeId(game, currentNodeId))}
|
|
257
|
+
onNextPressed={() => this.handleNavClicked(nextNodeId(game, currentNodeId))}
|
|
258
|
+
onLastPressed={() => this.handleNavClicked(lastNodeId(game, currentNodeId))}
|
|
259
|
+
/>
|
|
260
|
+
);
|
|
256
261
|
}
|
|
257
262
|
|
|
258
263
|
private renderToolbar(game: Game, node: GameNode | Variation, squareSize: number, isPlaying: boolean) {
|
|
@@ -33,22 +33,22 @@ export type NavigationButton = {
|
|
|
33
33
|
*
|
|
34
34
|
* The path is rendered within 32 x 32 viewbox (defined as `viewbox="0 0 32 32"`). It must be be a closed path, and must fit within the viewbox incircle.
|
|
35
35
|
*/
|
|
36
|
-
iconPath: string
|
|
36
|
+
iconPath: string,
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Human-readable tooltip.
|
|
40
40
|
*/
|
|
41
|
-
tooltip?: string
|
|
41
|
+
tooltip?: string,
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Whether or not the button is enabled (true by default).
|
|
45
45
|
*/
|
|
46
|
-
enabled?: boolean
|
|
46
|
+
enabled?: boolean,
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Callback invoked when the user clicks on the button.
|
|
50
50
|
*/
|
|
51
|
-
onClick?: () => void
|
|
51
|
+
onClick?: () => void,
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
|
|
@@ -30,11 +30,11 @@ import './NavigationField.css';
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
interface NavigationFieldProps {
|
|
33
|
-
onFirstPressed?: () => void
|
|
34
|
-
onPreviousPressed?: () => void
|
|
35
|
-
onNextPressed?: () => void
|
|
36
|
-
onLastPressed?: () => void
|
|
37
|
-
onExitPressed?: () => void
|
|
33
|
+
onFirstPressed?: () => void,
|
|
34
|
+
onPreviousPressed?: () => void,
|
|
35
|
+
onNextPressed?: () => void,
|
|
36
|
+
onLastPressed?: () => void,
|
|
37
|
+
onExitPressed?: () => void,
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
|
|
@@ -54,7 +54,7 @@ export class NavigationField extends React.Component<NavigationFieldProps> {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
private handleKeyDown(evt: React.KeyboardEvent<HTMLAnchorElement>) {
|
|
57
|
-
/* eslint-disable no-unused-expressions */
|
|
57
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
58
58
|
doHandleKeyDown(evt, 'Home', this.props.onFirstPressed) ||
|
|
59
59
|
doHandleKeyDown(evt, 'ArrowLeft', this.props.onPreviousPressed) ||
|
|
60
60
|
doHandleKeyDown(evt, 'ArrowRight', this.props.onNextPressed) ||
|