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.
Files changed (347) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/lib/chessboard/Chessboard.d.ts +27 -2
  3. package/dist/lib/chessboard/Chessboard.js +38 -18
  4. package/dist/lib/chessboard/Chessboard.js.map +1 -1
  5. package/dist/lib/chessboard/ChessboardImpl.js +1 -1
  6. package/dist/lib/chessboard/ChessboardImpl.js.map +1 -1
  7. package/dist/lib/chessboard/Motion.js +1 -1
  8. package/dist/lib/chessboard/Motion.js.map +1 -1
  9. package/dist/lib/i18n.js +2 -2
  10. package/dist/lib/i18n.js.map +1 -1
  11. package/dist/lib/icons/ArrowMarkerIcon.js.map +1 -1
  12. package/dist/lib/icons/ChessPieceIcon.d.ts +1 -4
  13. package/dist/lib/icons/ChessPieceIcon.js +1 -5
  14. package/dist/lib/icons/ChessPieceIcon.js.map +1 -1
  15. package/dist/lib/icons/SquareMarkerIcon.d.ts +1 -4
  16. package/dist/lib/icons/SquareMarkerIcon.js +1 -5
  17. package/dist/lib/icons/SquareMarkerIcon.js.map +1 -1
  18. package/dist/lib/icons/TextMarkerIcon.d.ts +1 -4
  19. package/dist/lib/icons/TextMarkerIcon.js +1 -5
  20. package/dist/lib/icons/TextMarkerIcon.js.map +1 -1
  21. package/dist/lib/index.d.ts +1 -1
  22. package/dist/lib/index.js +1 -1
  23. package/dist/lib/index.js.map +1 -1
  24. package/dist/lib/movetext/Movetext.js.map +1 -1
  25. package/dist/lib/movetext/MovetextImpl.js +4 -3
  26. package/dist/lib/movetext/MovetextImpl.js.map +1 -1
  27. package/dist/lib/movetext/htmlFilter.js +1 -1
  28. package/dist/lib/movetext/htmlFilter.js.map +1 -1
  29. package/dist/lib/navigationboard/NavigationBoard.d.ts +37 -8
  30. package/dist/lib/navigationboard/NavigationBoard.js +67 -22
  31. package/dist/lib/navigationboard/NavigationBoard.js.map +1 -1
  32. package/dist/lib/navigationboard/NavigationButton.d.ts +13 -1
  33. package/dist/lib/navigationboard/NavigationButton.js +32 -0
  34. package/dist/lib/navigationboard/NavigationButton.js.map +1 -1
  35. package/dist/lib/navigationboard/NavigationField.js +1 -1
  36. package/dist/lib/navigationboard/NavigationField.js.map +1 -1
  37. package/dist/lib/navigationboard/NavigationToolbar.d.ts +9 -2
  38. package/dist/lib/navigationboard/NavigationToolbar.js +34 -1
  39. package/dist/lib/navigationboard/NavigationToolbar.js.map +1 -1
  40. package/dist/lib/util.js +2 -2
  41. package/dist/lib/util.js.map +1 -1
  42. package/doc_src/demo/PageChessboardBase.tsx +57 -51
  43. package/doc_src/demo/PageChessboardInteraction.tsx +78 -63
  44. package/doc_src/demo/PageChessboardMove.tsx +35 -30
  45. package/doc_src/demo/PageChessboardSmallScreens.tsx +3 -3
  46. package/doc_src/demo/PageMovetextBase.tsx +91 -81
  47. package/doc_src/demo/PageMovetextInteraction.tsx +23 -21
  48. package/doc_src/demo/PageNavigationBoardBase.tsx +62 -54
  49. package/doc_src/demo/PageNavigationBoardUncontrolledVsControlled.tsx +24 -18
  50. package/doc_src/theming/LogoRenderer.js +8 -9
  51. package/package.json +30 -28
  52. package/scripts/docker-compose.yml +1 -3
  53. package/src/chessboard/BoardProperties.ts +13 -13
  54. package/src/chessboard/Chessboard.tsx +106 -46
  55. package/src/chessboard/ChessboardImpl.tsx +58 -41
  56. package/src/chessboard/Draggable.tsx +15 -15
  57. package/src/chessboard/Motion.tsx +4 -4
  58. package/src/errorbox/ErrorBox.tsx +5 -5
  59. package/src/errorbox/parsing.tsx +6 -6
  60. package/src/i18n.ts +2 -2
  61. package/src/icons/AnnotationSymbolShape.tsx +5 -5
  62. package/src/icons/ArrowMarkerIcon.tsx +8 -4
  63. package/src/icons/ArrowTip.tsx +2 -2
  64. package/src/icons/ChessPieceIcon.tsx +4 -11
  65. package/src/icons/SquareMarkerIcon.tsx +3 -10
  66. package/src/icons/TextMarkerIcon.tsx +4 -11
  67. package/src/index.ts +1 -1
  68. package/src/movetext/Movetext.tsx +11 -10
  69. package/src/movetext/MovetextImpl.tsx +34 -28
  70. package/src/movetext/htmlFilter.tsx +4 -4
  71. package/src/navigationboard/NavigationBoard.tsx +150 -58
  72. package/src/navigationboard/NavigationButton.ts +47 -5
  73. package/src/navigationboard/NavigationField.tsx +6 -6
  74. package/src/navigationboard/NavigationToolbar.tsx +62 -15
  75. package/src/types.ts +26 -26
  76. package/src/util.ts +2 -2
  77. package/test/01_types.js +83 -61
  78. package/test/02_chessboard_util.js +79 -1
  79. package/test/03_error_box_graphic.js +1 -1
  80. package/test/07_chessboard_interaction.js +1 -2
  81. package/test/13_navigation_board_graphic.js +3 -3
  82. package/test/common/graphic.js +11 -11
  83. package/test/graphic_references/03_error_box_graphic/base/cut_beginning_of_text.png +0 -0
  84. package/test/graphic_references/03_error_box_graphic/base/cut_end_of_text.png +0 -0
  85. package/test/graphic_references/03_error_box_graphic/base/cut_on_line_breaks.png +0 -0
  86. package/test/graphic_references/03_error_box_graphic/base/error_index_not_integer.png +0 -0
  87. package/test/graphic_references/03_error_box_graphic/base/full.png +0 -0
  88. package/test/graphic_references/03_error_box_graphic/base/minimal.png +0 -0
  89. package/test/graphic_references/03_error_box_graphic/base/missing_error_index.png +0 -0
  90. package/test/graphic_references/03_error_box_graphic/base/missing_error_text.png +0 -0
  91. package/test/graphic_references/03_error_box_graphic/base/negative_error_index.png +0 -0
  92. package/test/graphic_references/03_error_box_graphic/base/single_character_text.png +0 -0
  93. package/test/graphic_references/03_error_box_graphic/base/too_large_error_index.png +0 -0
  94. package/test/graphic_references/03_error_box_graphic/localization/default.png +0 -0
  95. package/test/graphic_references/04_icons_graphic/chess_piece/customized_pieceset.png +0 -0
  96. package/test/graphic_references/04_icons_graphic/chess_piece/invalid_multiple_pieces.png +0 -0
  97. package/test/graphic_references/04_icons_graphic/chess_piece/invalid_pieceset.png +0 -0
  98. package/test/graphic_references/04_icons_graphic/chess_piece/invalid_single_piece.png +0 -0
  99. package/test/graphic_references/04_icons_graphic/chess_piece/invalid_size.png +0 -0
  100. package/test/graphic_references/04_icons_graphic/chess_piece/multiple_pieces.png +0 -0
  101. package/test/graphic_references/04_icons_graphic/chess_piece/single_piece.png +0 -0
  102. package/test/graphic_references/04_icons_graphic/marker/colorized_arrow.png +0 -0
  103. package/test/graphic_references/04_icons_graphic/marker/colorized_square.png +0 -0
  104. package/test/graphic_references/04_icons_graphic/marker/colorized_symbol.png +0 -0
  105. package/test/graphic_references/04_icons_graphic/marker/colorized_text.png +0 -0
  106. package/test/graphic_references/04_icons_graphic/marker/default_arrow.png +0 -0
  107. package/test/graphic_references/04_icons_graphic/marker/default_square.png +0 -0
  108. package/test/graphic_references/04_icons_graphic/marker/default_text.png +0 -0
  109. package/test/graphic_references/04_icons_graphic/marker/invalid_arrow_size.png +0 -0
  110. package/test/graphic_references/04_icons_graphic/marker/invalid_square_size.png +0 -0
  111. package/test/graphic_references/04_icons_graphic/marker/invalid_symbol.png +0 -0
  112. package/test/graphic_references/04_icons_graphic/marker/invalid_text_size.png +0 -0
  113. package/test/graphic_references/04_icons_graphic/marker/wrapped_arrow.png +0 -0
  114. package/test/graphic_references/04_icons_graphic/marker/wrapped_square.png +0 -0
  115. package/test/graphic_references/04_icons_graphic/marker/wrapped_symbol.png +0 -0
  116. package/test/graphic_references/04_icons_graphic/marker/wrapped_text.png +0 -0
  117. package/test/graphic_references/05_chessboard_graphic/annotations/overlap.png +0 -0
  118. package/test/graphic_references/05_chessboard_graphic/annotations/overlap_and_flip.png +0 -0
  119. package/test/graphic_references/05_chessboard_graphic/annotations/with_coordinates.png +0 -0
  120. package/test/graphic_references/05_chessboard_graphic/annotations/with_coordinates_and_flip.png +0 -0
  121. package/test/graphic_references/05_chessboard_graphic/annotations/without_coordinates.png +0 -0
  122. package/test/graphic_references/05_chessboard_graphic/annotations/without_coordinates_and_flip.png +0 -0
  123. package/test/graphic_references/05_chessboard_graphic/base/default.png +0 -0
  124. package/test/graphic_references/05_chessboard_graphic/base/empty.png +0 -0
  125. package/test/graphic_references/05_chessboard_graphic/base/from_fen.png +0 -0
  126. package/test/graphic_references/05_chessboard_graphic/base/from_kokopu_object.png +0 -0
  127. package/test/graphic_references/05_chessboard_graphic/base/parsing_error.png +0 -0
  128. package/test/graphic_references/05_chessboard_graphic/base/wrong_position_type.png +0 -0
  129. package/test/graphic_references/05_chessboard_graphic/chess_variants/chess960.png +0 -0
  130. package/test/graphic_references/05_chessboard_graphic/chess_variants/chess960_with_move.png +0 -0
  131. package/test/graphic_references/05_chessboard_graphic/chess_variants/invalid_variant.png +0 -0
  132. package/test/graphic_references/05_chessboard_graphic/chess_variants/invalid_variant_with_fen.png +0 -0
  133. package/test/graphic_references/05_chessboard_graphic/chess_variants/special_code.png +0 -0
  134. package/test/graphic_references/05_chessboard_graphic/chess_variants/variant_with_std_initial_position.png +0 -0
  135. package/test/graphic_references/05_chessboard_graphic/chess_variants/variant_without_std_initial_position.png +0 -0
  136. package/test/graphic_references/05_chessboard_graphic/flipped/default.png +0 -0
  137. package/test/graphic_references/05_chessboard_graphic/flipped/empty.png +0 -0
  138. package/test/graphic_references/05_chessboard_graphic/flipped/from_fen.png +0 -0
  139. package/test/graphic_references/05_chessboard_graphic/flipped/from_kokopu_object.png +0 -0
  140. package/test/graphic_references/05_chessboard_graphic/flipped/parsing_error.png +0 -0
  141. package/test/graphic_references/05_chessboard_graphic/move/capture.png +0 -0
  142. package/test/graphic_references/05_chessboard_graphic/move/castling_move.png +0 -0
  143. package/test/graphic_references/05_chessboard_graphic/move/default.png +0 -0
  144. package/test/graphic_references/05_chessboard_graphic/move/en-passant.png +0 -0
  145. package/test/graphic_references/05_chessboard_graphic/move/illegal_null-move.png +0 -0
  146. package/test/graphic_references/05_chessboard_graphic/move/no_move_arrow.png +0 -0
  147. package/test/graphic_references/05_chessboard_graphic/move/null-move.png +0 -0
  148. package/test/graphic_references/05_chessboard_graphic/move/parsing_error.png +0 -0
  149. package/test/graphic_references/05_chessboard_graphic/move/promotion.png +0 -0
  150. package/test/graphic_references/05_chessboard_graphic/move/with_forced_move_arrow_and_flip.png +0 -0
  151. package/test/graphic_references/05_chessboard_graphic/move/wrong_move_arrow_color_type.png +0 -0
  152. package/test/graphic_references/05_chessboard_graphic/move/wrong_move_type.png +0 -0
  153. package/test/graphic_references/05_chessboard_graphic/theme/custom_1.png +0 -0
  154. package/test/graphic_references/05_chessboard_graphic/theme/custom_2.png +0 -0
  155. package/test/graphic_references/05_chessboard_graphic/theme/custom_3.png +0 -0
  156. package/test/graphic_references/05_chessboard_graphic/theme/custom_4.png +0 -0
  157. package/test/graphic_references/05_chessboard_graphic/theme/custom_5.png +0 -0
  158. package/test/graphic_references/05_chessboard_graphic/theme/custom_6.png +0 -0
  159. package/test/graphic_references/05_chessboard_graphic/theme/default.png +0 -0
  160. package/test/graphic_references/05_chessboard_graphic/theme/large.png +0 -0
  161. package/test/graphic_references/05_chessboard_graphic/theme/small.png +0 -0
  162. package/test/graphic_references/05_chessboard_graphic/theme/wrong_colorset.png +0 -0
  163. package/test/graphic_references/05_chessboard_graphic/theme/wrong_pieceset.png +0 -0
  164. package/test/graphic_references/05_chessboard_graphic/theme/wrong_square_size_type.png +0 -0
  165. package/test/graphic_references/06_chessboard_animation/base_1/capture.png +0 -0
  166. package/test/graphic_references/06_chessboard_animation/base_1/castling_move.png +0 -0
  167. package/test/graphic_references/06_chessboard_animation/base_1/en-passant.png +0 -0
  168. package/test/graphic_references/06_chessboard_animation/base_1/move_1.png +0 -0
  169. package/test/graphic_references/06_chessboard_animation/base_1/move_2.png +0 -0
  170. package/test/graphic_references/06_chessboard_animation/base_1/promotion.png +0 -0
  171. package/test/graphic_references/06_chessboard_animation/base_2/capture.png +0 -0
  172. package/test/graphic_references/06_chessboard_animation/base_2/castling_move.png +0 -0
  173. package/test/graphic_references/06_chessboard_animation/base_2/en-passant.png +0 -0
  174. package/test/graphic_references/06_chessboard_animation/base_2/move_1.png +0 -0
  175. package/test/graphic_references/06_chessboard_animation/base_2/move_2.png +0 -0
  176. package/test/graphic_references/06_chessboard_animation/base_2/promotion.png +0 -0
  177. package/test/graphic_references/06_chessboard_animation/base_3/capture.png +0 -0
  178. package/test/graphic_references/06_chessboard_animation/base_3/castling_move.png +0 -0
  179. package/test/graphic_references/06_chessboard_animation/base_3/en-passant.png +0 -0
  180. package/test/graphic_references/06_chessboard_animation/base_3/move_1.png +0 -0
  181. package/test/graphic_references/06_chessboard_animation/base_3/move_2.png +0 -0
  182. package/test/graphic_references/06_chessboard_animation/base_3/promotion.png +0 -0
  183. package/test/graphic_references/06_chessboard_animation/on_redraw/final_state.png +0 -0
  184. package/test/graphic_references/06_chessboard_animation/on_redraw/initial_state.png +0 -0
  185. package/test/graphic_references/07_chessboard_interaction/edit_arrows/base_1.png +0 -0
  186. package/test/graphic_references/07_chessboard_interaction/edit_arrows/base_2.png +0 -0
  187. package/test/graphic_references/07_chessboard_interaction/edit_arrows/from_==_to.png +0 -0
  188. package/test/graphic_references/07_chessboard_interaction/edit_arrows/out_of_board.png +0 -0
  189. package/test/graphic_references/07_chessboard_interaction/edit_arrows/over_arrow_marker.png +0 -0
  190. package/test/graphic_references/07_chessboard_interaction/edit_arrows/over_square_marker.png +0 -0
  191. package/test/graphic_references/07_chessboard_interaction/error/edit_color_not_set.png +0 -0
  192. package/test/graphic_references/07_chessboard_interaction/error/wrong_interaction_mode.png +0 -0
  193. package/test/graphic_references/07_chessboard_interaction/move_pieces/after_move.png +0 -0
  194. package/test/graphic_references/07_chessboard_interaction/move_pieces/from_==_to.png +0 -0
  195. package/test/graphic_references/07_chessboard_interaction/move_pieces/move_empty_square.png +0 -0
  196. package/test/graphic_references/07_chessboard_interaction/move_pieces/out_of_board.png +0 -0
  197. package/test/graphic_references/07_chessboard_interaction/move_pieces/over_arrow_marker.png +0 -0
  198. package/test/graphic_references/07_chessboard_interaction/move_pieces/over_empty.png +0 -0
  199. package/test/graphic_references/07_chessboard_interaction/move_pieces/over_non-empty_1.png +0 -0
  200. package/test/graphic_references/07_chessboard_interaction/move_pieces/over_non-empty_2.png +0 -0
  201. package/test/graphic_references/07_chessboard_interaction/move_pieces/over_square_marker.png +0 -0
  202. package/test/graphic_references/07_chessboard_interaction/move_pieces/over_text_marker.png +0 -0
  203. package/test/graphic_references/08_chessboard_play_moves/base/castling_move.png +0 -0
  204. package/test/graphic_references/08_chessboard_play_moves/base/chess960_ambiguous_king_move.png +0 -0
  205. package/test/graphic_references/08_chessboard_play_moves/base/chess960_castling_move_1.png +0 -0
  206. package/test/graphic_references/08_chessboard_play_moves/base/chess960_castling_move_2.png +0 -0
  207. package/test/graphic_references/08_chessboard_play_moves/base/chess960_non-kxr_castling.png +0 -0
  208. package/test/graphic_references/08_chessboard_play_moves/base/from_==_to.png +0 -0
  209. package/test/graphic_references/08_chessboard_play_moves/base/illegal_move.png +0 -0
  210. package/test/graphic_references/08_chessboard_play_moves/base/illegal_position.png +0 -0
  211. package/test/graphic_references/08_chessboard_play_moves/base/out_of_board.png +0 -0
  212. package/test/graphic_references/08_chessboard_play_moves/base/regular_move_1.png +0 -0
  213. package/test/graphic_references/08_chessboard_play_moves/base/regular_move_2.png +0 -0
  214. package/test/graphic_references/08_chessboard_play_moves/base/wrong_color_moved.png +0 -0
  215. package/test/graphic_references/08_chessboard_play_moves/promotions/antichess_promotion.png +0 -0
  216. package/test/graphic_references/08_chessboard_play_moves/promotions/cancel_promotion.png +0 -0
  217. package/test/graphic_references/08_chessboard_play_moves/promotions/regular_promotion_1.png +0 -0
  218. package/test/graphic_references/08_chessboard_play_moves/promotions/regular_promotion_2.png +0 -0
  219. package/test/graphic_references/09_chessboard_small_screens/base/default.png +0 -0
  220. package/test/graphic_references/09_chessboard_small_screens/base/invalid_limits.png +0 -0
  221. package/test/graphic_references/09_chessboard_small_screens/base/width_690.png +0 -0
  222. package/test/graphic_references/09_chessboard_small_screens/base/width_700.png +0 -0
  223. package/test/graphic_references/09_chessboard_small_screens/base/width_710.png +0 -0
  224. package/test/graphic_references/09_chessboard_small_screens/base/width_720.png +0 -0
  225. package/test/graphic_references/09_chessboard_small_screens/base/width_730.png +0 -0
  226. package/test/graphic_references/09_chessboard_small_screens/base/width_740.png +0 -0
  227. package/test/graphic_references/09_chessboard_small_screens/base/width_750.png +0 -0
  228. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_bottom_component.png +0 -0
  229. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_top_component.png +0 -0
  230. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_bottom_component.png +0 -0
  231. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_top_component.png +0 -0
  232. package/test/graphic_references/10_movetext_graphic/base/game_1.png +0 -0
  233. package/test/graphic_references/10_movetext_graphic/base/game_2.png +0 -0
  234. package/test/graphic_references/10_movetext_graphic/base/game_3.png +0 -0
  235. package/test/graphic_references/10_movetext_graphic/base/game_4.png +0 -0
  236. package/test/graphic_references/10_movetext_graphic/error/pgn_parsing_error_1.png +0 -0
  237. package/test/graphic_references/10_movetext_graphic/error/pgn_parsing_error_2.png +0 -0
  238. package/test/graphic_references/10_movetext_graphic/error/wrong_game_index_1.png +0 -0
  239. package/test/graphic_references/10_movetext_graphic/error/wrong_game_index_2.png +0 -0
  240. package/test/graphic_references/10_movetext_graphic/error/wrong_game_index_type.png +0 -0
  241. package/test/graphic_references/10_movetext_graphic/error/wrong_game_type.png +0 -0
  242. package/test/graphic_references/10_movetext_graphic/format_move/format_text.png +0 -0
  243. package/test/graphic_references/10_movetext_graphic/html/filtered_tags_and_attributes.png +0 -0
  244. package/test/graphic_references/10_movetext_graphic/html/html_in_comments.png +0 -0
  245. package/test/graphic_references/10_movetext_graphic/html/html_in_headers.png +0 -0
  246. package/test/graphic_references/10_movetext_graphic/options/custom_piece_symbols.png +0 -0
  247. package/test/graphic_references/10_movetext_graphic/options/figurine_piece_symbols_and_diagram_options.png +0 -0
  248. package/test/graphic_references/10_movetext_graphic/options/hidden_diagrams.png +0 -0
  249. package/test/graphic_references/10_movetext_graphic/options/localized_piece_symbols.png +0 -0
  250. package/test/graphic_references/10_movetext_graphic/options/other_diagram_options.png +0 -0
  251. package/test/graphic_references/10_movetext_graphic/options/wrong_diagram_options_1.png +0 -0
  252. package/test/graphic_references/10_movetext_graphic/options/wrong_diagram_options_2.png +0 -0
  253. package/test/graphic_references/10_movetext_graphic/options/wrong_piece_symbol_value.png +0 -0
  254. package/test/graphic_references/11_movetext_interaction/error/wrong_interaction_mode.png +0 -0
  255. package/test/graphic_references/11_movetext_interaction/select_moves/click_on_disabled.png +0 -0
  256. package/test/graphic_references/11_movetext_interaction/select_moves/click_on_unselected.png +0 -0
  257. package/test/graphic_references/11_movetext_interaction/select_moves/click_on_unselected_without_callback.png +0 -0
  258. package/test/graphic_references/11_movetext_interaction/select_moves/click_on_with_variations.png +0 -0
  259. package/test/graphic_references/12_navigation_board_base/controlled/default.png +0 -0
  260. package/test/graphic_references/12_navigation_board_base/controlled/forbidden_navigation_0.png +0 -0
  261. package/test/graphic_references/12_navigation_board_base/controlled/forbidden_navigation_1.png +0 -0
  262. package/test/graphic_references/12_navigation_board_base/controlled/invalid_node_id.png +0 -0
  263. package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_0.png +0 -0
  264. package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_1.png +0 -0
  265. package/test/graphic_references/12_navigation_board_base/controlled/overriding_initial_node_id.png +0 -0
  266. package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_0.png +0 -0
  267. package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_1.png +0 -0
  268. package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_2.png +0 -0
  269. package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_3.png +0 -0
  270. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_0.png +0 -0
  271. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_1.png +0 -0
  272. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_2.png +0 -0
  273. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_0.png +0 -0
  274. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_1.png +0 -0
  275. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_2.png +0 -0
  276. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_end.png +0 -0
  277. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_specific_id.png +0 -0
  278. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_default.png +0 -0
  279. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_default_with_game_index.png +0 -0
  280. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_on_null-move.png +0 -0
  281. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_0.png +0 -0
  282. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_1.png +0 -0
  283. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_2.png +0 -0
  284. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_3.png +0 -0
  285. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_4.png +0 -0
  286. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_flipping_0.png +0 -0
  287. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_flipping_1.png +0 -0
  288. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_0.png +0 -0
  289. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_1.png +0 -0
  290. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_2.png +0 -0
  291. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_3.png +0 -0
  292. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_4.png +0 -0
  293. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_5.png +0 -0
  294. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_1.png +0 -0
  295. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_2.png +0 -0
  296. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/multiple_buttons.png +0 -0
  297. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/single_button.png +0 -0
  298. package/test/graphic_references/13_navigation_board_graphic/error/pgn_parsing_error.png +0 -0
  299. package/test/graphic_references/13_navigation_board_graphic/error/wrong_game_type.png +0 -0
  300. package/test/graphic_references/13_navigation_board_graphic/theme/custom_1.png +0 -0
  301. package/test/graphic_references/13_navigation_board_graphic/theme/custom_2.png +0 -0
  302. package/test/graphic_references/13_navigation_board_graphic/theme/large.png +0 -0
  303. package/test/graphic_references/13_navigation_board_graphic/theme/small.png +0 -0
  304. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_acknowledging_is-playing_changes.png +0 -0
  305. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_not_acknowledging_is-playing_changes.png +0 -0
  306. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_acknowledging_node_changes.png +0 -0
  307. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_not_acknowledging_node_changes.png +0 -0
  308. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_reaching_the_end.png +0 -0
  309. package/test/graphic_references/14_navigation_board_autoplay/controlled/already_at_the_end.png +0 -0
  310. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_is-playing_changes.png +0 -0
  311. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_node_changes.png +0 -0
  312. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_at_the_end.png +0 -0
  313. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_close_to_end.png +0 -0
  314. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_is-playing_changes.png +0 -0
  315. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_node_changes.png +0 -0
  316. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_after_stop.png +0 -0
  317. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_before_stop.png +0 -0
  318. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_after_stop.png +0 -0
  319. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_before_stop.png +0 -0
  320. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_close_to_end.png +0 -0
  321. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_default.png +0 -0
  322. package/test/graphic_test_app/03_error_box_graphic/base.tsx +18 -6
  323. package/test/graphic_test_app/04_icons_graphic/chess_piece.tsx +12 -3
  324. package/test/graphic_test_app/04_icons_graphic/marker.tsx +14 -4
  325. package/test/graphic_test_app/05_chessboard_graphic/annotations.tsx +7 -3
  326. package/test/graphic_test_app/05_chessboard_graphic/base.tsx +1 -1
  327. package/test/graphic_test_app/05_chessboard_graphic/move.tsx +9 -2
  328. package/test/graphic_test_app/05_chessboard_graphic/theme.tsx +1 -1
  329. package/test/graphic_test_app/06_chessboard_animation/on_redraw.tsx +8 -6
  330. package/test/graphic_test_app/07_chessboard_interaction/click_squares.tsx +4 -2
  331. package/test/graphic_test_app/07_chessboard_interaction/edit_arrows.tsx +4 -2
  332. package/test/graphic_test_app/07_chessboard_interaction/error.tsx +3 -1
  333. package/test/graphic_test_app/07_chessboard_interaction/move_pieces.tsx +4 -2
  334. package/test/graphic_test_app/08_chessboard_play_moves/base.tsx +12 -6
  335. package/test/graphic_test_app/08_chessboard_play_moves/promotions.tsx +12 -3
  336. package/test/graphic_test_app/09_chessboard_small_screens/base.tsx +3 -1
  337. package/test/graphic_test_app/09_chessboard_small_screens/top_bottom_components.tsx +8 -6
  338. package/test/graphic_test_app/10_movetext_graphic/error.tsx +1 -1
  339. package/test/graphic_test_app/10_movetext_graphic/options.tsx +16 -6
  340. package/test/graphic_test_app/11_movetext_interaction/error.tsx +4 -1
  341. package/test/graphic_test_app/13_navigation_board_graphic/additional_buttons.tsx +24 -17
  342. package/test/graphic_test_app/13_navigation_board_graphic/error.tsx +1 -1
  343. package/test/graphic_test_app/14_navigation_board_autoplay/controlled.tsx +34 -18
  344. package/test/graphic_test_app/common/test_app.tsx +4 -4
  345. package/.eslintrc.yml +0 -83
  346. package/test/.eslintrc.yml +0 -8
  347. package/test/graphic_test_app/.eslintrc.yml +0 -3
package/src/util.ts CHANGED
@@ -26,8 +26,8 @@ export function generateRandomId() {
26
26
  const buffer = new Uint32Array(8);
27
27
  crypto.getRandomValues(buffer);
28
28
  let result = '';
29
- for (let i = 0; i < buffer.length; ++i) {
30
- result += buffer[i].toString(16);
29
+ for (const c of buffer) {
30
+ result += c.toString(16);
31
31
  }
32
32
  return result;
33
33
  }
package/test/01_types.js CHANGED
@@ -35,7 +35,7 @@ describe('Is piece symbol mapping', () => {
35
35
  });
36
36
  }
37
37
 
38
- itIsPieceSymbolMapping('French localization', { K: 'R', Q: 'D', R: 'T', B: 'F', N: 'C', P: 'P' } , true);
38
+ itIsPieceSymbolMapping('French localization', { K: 'R', Q: 'D', R: 'T', B: 'F', N: 'C', P: 'P' }, true);
39
39
  itIsPieceSymbolMapping('Additional fields', { K: 'Ki_', Q: 'Qu_', R: 'Rk_', B: 'Bi_', N: 'Kn_', P: 'Pw_', Z: 'whatever', val: 42 }, true);
40
40
  itIsPieceSymbolMapping('Missing fields', { K: 'Ki_', Q: 'Qu_', R: 'Rk_', B: 'Bi_', N: 'Kn_' }, false);
41
41
  itIsPieceSymbolMapping('Non-string valued fields', { K: 42, Q: 'Qu_', R: 'Rk_', B: 'Bi_', N: 'Kn_', P: 'Pw_' }, false);
@@ -125,46 +125,60 @@ describe('Parse square markers', () => {
125
125
  describe('Flatten text markers', () => {
126
126
 
127
127
  it('RAe4', () => { test.value(flattenTextMarkers({ e4: { symbol: 'A', color: 'r' } })).is('RAe4'); });
128
- it('Gzd3,Y1h8', () => { test.value(flattenTextMarkers({
129
- h8: { symbol: '1', color: 'y' },
130
- d3: { symbol: 'z', color: 'g' },
131
- })).is('Gzd3,Y1h8'); });
132
- it('G2a1,YMc5,RLd2,Rxh7,Bwh8', () => { test.value(flattenTextMarkers({
133
- c5: { symbol: 'M', color: 'y' },
134
- h8: { symbol: 'w', color: 'b' },
135
- a1: { symbol: '2', color: 'g' },
136
- h7: { symbol: 'x', color: 'r' },
137
- d2: { symbol: 'L', color: 'r' },
138
- })).is('G2a1,YMc5,RLd2,Rxh7,Bwh8'); });
139
- it('Multi-character symbols', () => { test.value(flattenTextMarkers({
140
- a1: { symbol: 'A', color: 'y' },
141
- a7: { symbol: 'plus', color: 'g' },
142
- b3: { symbol: 'times', color: 'r' },
143
- g5: { symbol: 'dot', color: 'y' },
144
- h3: { symbol: 'circle', color: 'g' },
145
- })).is('YAa1,G(plus)a7,R(times)b3,Y(dot)g5,G(circle)h3'); });
128
+ it('Gzd3,Y1h8', () => {
129
+ test.value(flattenTextMarkers({
130
+ h8: { symbol: '1', color: 'y' },
131
+ d3: { symbol: 'z', color: 'g' },
132
+ })).is('Gzd3,Y1h8');
133
+ });
134
+ it('G2a1,YMc5,RLd2,Rxh7,Bwh8', () => {
135
+ test.value(flattenTextMarkers({
136
+ c5: { symbol: 'M', color: 'y' },
137
+ h8: { symbol: 'w', color: 'b' },
138
+ a1: { symbol: '2', color: 'g' },
139
+ h7: { symbol: 'x', color: 'r' },
140
+ d2: { symbol: 'L', color: 'r' },
141
+ })).is('G2a1,YMc5,RLd2,Rxh7,Bwh8');
142
+ });
143
+ it('Multi-character symbols', () => {
144
+ test.value(flattenTextMarkers({
145
+ a1: { symbol: 'A', color: 'y' },
146
+ a7: { symbol: 'plus', color: 'g' },
147
+ b3: { symbol: 'times', color: 'r' },
148
+ g5: { symbol: 'dot', color: 'y' },
149
+ h3: { symbol: 'circle', color: 'g' },
150
+ })).is('YAa1,G(plus)a7,R(times)b3,Y(dot)g5,G(circle)h3');
151
+ });
146
152
  it('<empty>', () => { test.value(flattenTextMarkers({})).is(''); });
147
153
 
148
- it('Wrong square', () => { test.value(flattenTextMarkers({
149
- e1: { symbol: 'H', color: 'r' },
150
- j5: { symbol: 'A', color: 'g' },
151
- })).is('RHe1'); });
152
- it('Wrong color', () => { test.value(flattenTextMarkers({
153
- a2: { symbol: '0', color: 'g' },
154
- b5: { symbol: 'A', color: 'R' },
155
- h8: { symbol: 'A' },
156
- })).is('G0a2'); });
157
- it('Wrong symbol', () => { test.value(flattenTextMarkers({
158
- a2: { symbol: '0', color: 'g' },
159
- b5: { symbol: '', color: 'r' },
160
- h8: { color: 'g' },
161
- d8: { symbol: '-', color: 'r' },
162
- c1: { symbol: 'abcd', color: 'r' },
163
- })).is('G0a2'); });
164
- it('Wrong multi-character symbol', () => { test.value(flattenTextMarkers({
165
- a2: { symbol: '0', color: 'g' },
166
- b5: { symbol: 'whatever', color: 'r' },
167
- })).is('G0a2'); });
154
+ it('Wrong square', () => {
155
+ test.value(flattenTextMarkers({
156
+ e1: { symbol: 'H', color: 'r' },
157
+ j5: { symbol: 'A', color: 'g' },
158
+ })).is('RHe1');
159
+ });
160
+ it('Wrong color', () => {
161
+ test.value(flattenTextMarkers({
162
+ a2: { symbol: '0', color: 'g' },
163
+ b5: { symbol: 'A', color: 'R' },
164
+ h8: { symbol: 'A' },
165
+ })).is('G0a2');
166
+ });
167
+ it('Wrong symbol', () => {
168
+ test.value(flattenTextMarkers({
169
+ a2: { symbol: '0', color: 'g' },
170
+ b5: { symbol: '', color: 'r' },
171
+ h8: { color: 'g' },
172
+ d8: { symbol: '-', color: 'r' },
173
+ c1: { symbol: 'abcd', color: 'r' },
174
+ })).is('G0a2');
175
+ });
176
+ it('Wrong multi-character symbol', () => {
177
+ test.value(flattenTextMarkers({
178
+ a2: { symbol: '0', color: 'g' },
179
+ b5: { symbol: 'whatever', color: 'r' },
180
+ })).is('G0a2');
181
+ });
168
182
 
169
183
  it('Wrong type (not an object)', () => { test.exception(() => flattenTextMarkers('whatever')).isInstanceOf(exception.IllegalArgument); });
170
184
  it('Wrong type (null)', () => { test.exception(() => flattenTextMarkers(null)).isInstanceOf(exception.IllegalArgument); });
@@ -175,24 +189,30 @@ describe('Flatten text markers', () => {
175
189
  describe('Parse text markers', () => {
176
190
 
177
191
  it('RAe4', () => { test.value(parseTextMarkers('RAe4')).is({ e4: { symbol: 'A', color: 'r' } }); });
178
- it('Gzd3,Y1h8', () => { test.value(parseTextMarkers('Gzd3,Y1h8')).is({
179
- h8: { symbol: '1', color: 'y' },
180
- d3: { symbol: 'z', color: 'g' },
181
- }); });
182
- it('G2a1,YMc5,RLd2,Rxh7,Bwh8', () => { test.value(parseTextMarkers(' G2a1, Rxh7 ,YMc5 ,RLd2,Bwh8 ')).is({
183
- c5: { symbol: 'M', color: 'y' },
184
- h8: { symbol: 'w', color: 'b' },
185
- a1: { symbol: '2', color: 'g' },
186
- h7: { symbol: 'x', color: 'r' },
187
- d2: { symbol: 'L', color: 'r' },
188
- }); });
189
- it('Multi-character symbols', () => { test.value(parseTextMarkers('YAa1,G(plus)a7, R(times)b3 ,Y(dot)g5,G(circle)h3')).is({
190
- a1: { symbol: 'A', color: 'y' },
191
- a7: { symbol: 'plus', color: 'g' },
192
- b3: { symbol: 'times', color: 'r' },
193
- g5: { symbol: 'dot', color: 'y' },
194
- h3: { symbol: 'circle', color: 'g' },
195
- }); });
192
+ it('Gzd3,Y1h8', () => {
193
+ test.value(parseTextMarkers('Gzd3,Y1h8')).is({
194
+ h8: { symbol: '1', color: 'y' },
195
+ d3: { symbol: 'z', color: 'g' },
196
+ });
197
+ });
198
+ it('G2a1,YMc5,RLd2,Rxh7,Bwh8', () => {
199
+ test.value(parseTextMarkers(' G2a1, Rxh7 ,YMc5 ,RLd2,Bwh8 ')).is({
200
+ c5: { symbol: 'M', color: 'y' },
201
+ h8: { symbol: 'w', color: 'b' },
202
+ a1: { symbol: '2', color: 'g' },
203
+ h7: { symbol: 'x', color: 'r' },
204
+ d2: { symbol: 'L', color: 'r' },
205
+ });
206
+ });
207
+ it('Multi-character symbols', () => {
208
+ test.value(parseTextMarkers('YAa1,G(plus)a7, R(times)b3 ,Y(dot)g5,G(circle)h3')).is({
209
+ a1: { symbol: 'A', color: 'y' },
210
+ a7: { symbol: 'plus', color: 'g' },
211
+ b3: { symbol: 'times', color: 'r' },
212
+ g5: { symbol: 'dot', color: 'y' },
213
+ h3: { symbol: 'circle', color: 'g' },
214
+ });
215
+ });
196
216
  it('<empty>', () => { test.value(parseTextMarkers('')).is({}); });
197
217
  it('<blank>', () => { test.value(parseTextMarkers(' ')).is({}); });
198
218
 
@@ -213,8 +233,9 @@ describe('Flatten arrow markers', () => {
213
233
 
214
234
  it('Re4d6', () => { test.value(flattenArrowMarkers({ e4d6: 'r' })).is('Re4d6'); });
215
235
  it('Gd3b4,Yh8h7', () => { test.value(flattenArrowMarkers({ h8h7: 'y', d3b4: 'g' })).is('Gd3b4,Yh8h7'); });
216
- it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5', () => { test.value(flattenArrowMarkers({ c5a1: 'y', h8c5: 'b', a1h8: 'g', h7h8: 'r', d2d2: 'r' }))
217
- .is('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5'); });
236
+ it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5', () => {
237
+ test.value(flattenArrowMarkers({ c5a1: 'y', h8c5: 'b', a1h8: 'g', h7h8: 'r', d2d2: 'r' })).is('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5');
238
+ });
218
239
  it('<empty>', () => { test.value(flattenArrowMarkers({})).is(''); });
219
240
 
220
241
  it('Wrong vector', () => { test.value(flattenArrowMarkers({ e1c2: 'r', a1b9: 'g', c0d2: 'r', i3d4: 'r', f2k3: 'g', whatever: 'y' })).is('Re1c2'); });
@@ -230,8 +251,9 @@ describe('Parse arrow markers', () => {
230
251
 
231
252
  it('Re4d6', () => { test.value(parseArrowMarkers('Re4d6')).is({ e4d6: 'r' }); });
232
253
  it('Gd3b4,Yh8h7', () => { test.value(parseArrowMarkers('Gd3b4,Yh8h7')).is({ h8h7: 'y', d3b4: 'g' }); });
233
- it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5', () => { test.value(parseArrowMarkers(' Bh8c5,Ga1h8 , Yc5a1 , Rd2d2,Rh7h8 '))
234
- .is({ c5a1: 'y', h8c5: 'b', a1h8: 'g', h7h8: 'r', d2d2: 'r' }); });
254
+ it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5', () => {
255
+ test.value(parseArrowMarkers(' Bh8c5,Ga1h8 , Yc5a1 , Rd2d2,Rh7h8 ')).is({ c5a1: 'y', h8c5: 'b', a1h8: 'g', h7h8: 'r', d2d2: 'r' });
256
+ });
235
257
  it('<empty>', () => { test.value(parseArrowMarkers('')).is({}); });
236
258
  it('<blank>', () => { test.value(parseArrowMarkers(' ')).is({}); });
237
259
 
@@ -22,7 +22,7 @@
22
22
  * -------------------------------------------------------------------------- */
23
23
 
24
24
 
25
- const { exception, Chessboard } = require('../build/test_headless/index');
25
+ const { exception, Chessboard, NavigationBoard } = require('../build/test_headless/index');
26
26
  const test = require('unit.js');
27
27
 
28
28
 
@@ -45,6 +45,22 @@ describe('Chessboard.size()', () => {
45
45
  itChessboardSize('Default without turn', 330, 333, { turnVisible: false });
46
46
  itChessboardSize('Default board only', 320, 320, { coordinateVisible: false, turnVisible: false });
47
47
 
48
+ function topComponent({ squareSize, coordinateVisible, turnVisible }) {
49
+ const width = squareSize * 20;
50
+ const height = (coordinateVisible ? 11 : 0) + (turnVisible ? 107 : 0);
51
+ return { width: width, height: height };
52
+ }
53
+
54
+ function bottomComponent({ squareSize, coordinateVisible, turnVisible }) {
55
+ const width = squareSize * 19;
56
+ const height = (coordinateVisible ? 3 : 0) + (turnVisible ? 157 : 0);
57
+ return { width: width, height: height };
58
+ }
59
+
60
+ itChessboardSize('With top component', 800, 451, { topComponent: topComponent });
61
+ itChessboardSize('With bottom component', 760, 493, { bottomComponent: bottomComponent });
62
+ itChessboardSize('With top & bottom components', 800, 611, { topComponent: topComponent, bottomComponent: bottomComponent });
63
+
48
64
  itInvalidArgument('Attribute not an object', () => Chessboard.size('not-an-object'));
49
65
  itInvalidArgument('Square size not an integer', () => Chessboard.size({ squareSize: 'not-an-integer' }));
50
66
  itInvalidArgument('Small-screen limits not an array', () => Chessboard.size({ smallScreenLimits: 'not-an-array' }));
@@ -54,6 +70,38 @@ describe('Chessboard.size()', () => {
54
70
  });
55
71
 
56
72
 
73
+ describe('NavigationBoard.size()', () => {
74
+
75
+ function itNavigationBoardSize(label, expectedWidth, expectedHeight, attr) {
76
+ it(label, () => {
77
+ test.value(NavigationBoard.size(attr)).is({ width: expectedWidth, height: expectedHeight });
78
+ });
79
+ }
80
+
81
+ itNavigationBoardSize('Default', 374, 368);
82
+ itNavigationBoardSize('Minimal square size with all default buttons', 130, 121, {
83
+ squareSize: 12,
84
+ coordinateVisible: false,
85
+ turnVisible: false,
86
+ playButtonVisible: true,
87
+ flipButtonVisible: true,
88
+ });
89
+ itNavigationBoardSize('With additional buttons', 198, 188, {
90
+ squareSize: 20,
91
+ coordinateVisible: false,
92
+ turnVisible: false,
93
+ playButtonVisible: true,
94
+ flipButtonVisible: false,
95
+ additionalButtons: [ 'button', 'button', 'spacer', 'spacer', 'button' ],
96
+ });
97
+
98
+ itInvalidArgument('Attribute not an object', () => NavigationBoard.size('not-an-object'));
99
+ itInvalidArgument('Square size not an integer', () => NavigationBoard.size({ squareSize: 'not-an-integer' }));
100
+ itInvalidArgument('Additional buttons not an array', () => NavigationBoard.size({ additionalButtons: 'not-an-array' }));
101
+ itInvalidArgument('Additional buttons with invalid items', () => NavigationBoard.size({ additionalButtons: [ 'not-a-button-nor-a-spacer' ] }));
102
+ });
103
+
104
+
57
105
  function testAdaptSquareSize(expectedSquareSize, width, height, coordinateVisible, turnVisible, smallScreenLimits) {
58
106
 
59
107
  test.value(Chessboard.adaptSquareSize(width, height, {
@@ -119,6 +167,34 @@ describe('Adapt square-size', () => {
119
167
  });
120
168
 
121
169
 
170
+ describe('Adapt square-size (NavigationBoard)', () => {
171
+
172
+ function itAdaptSquareSize(label, width, height, attributes, expectedSquareSize) {
173
+ it(label, () => {
174
+ test.value(NavigationBoard.adaptSquareSize(width, height, attributes)).is(expectedSquareSize);
175
+
176
+ const actualSizeIncremented = NavigationBoard.size({
177
+ ...attributes,
178
+ squareSize: expectedSquareSize + 1,
179
+ });
180
+ test.value(actualSizeIncremented.width > width || actualSizeIncremented.height > height).isTrue();
181
+ });
182
+ }
183
+
184
+ itAdaptSquareSize('Size 300x300 (default)', 300, 300, {}, 32);
185
+ itAdaptSquareSize('Size 136x200 (with play button)', 136, 200, { coordinateVisible: false, turnVisible: false, playButtonVisible: true }, 15);
186
+ itAdaptSquareSize('Size 136x200 (with minimal buttons)', 136, 200, { coordinateVisible: false, turnVisible: false, flipButtonVisible: false }, 17);
187
+
188
+ itInvalidArgument('Width <null>', () => NavigationBoard.adaptSquareSize(null, 400));
189
+ itInvalidArgument('Width not-a-number', () => NavigationBoard.adaptSquareSize('500', 400));
190
+ itInvalidArgument('Height <undefined>', () => NavigationBoard.adaptSquareSize(500, undefined));
191
+ itInvalidArgument('Height object', () => NavigationBoard.adaptSquareSize(500, {}));
192
+ itInvalidArgument('Attribute not-an-object', () => NavigationBoard.adaptSquareSize(500, 400, 'not-an-object'));
193
+ itInvalidArgument('Additional buttons not an array', () => NavigationBoard.adaptSquareSize(500, 400, { additionalButtons: 'not-an-array' }));
194
+ itInvalidArgument('Small-screen limits not-an-array', () => NavigationBoard.adaptSquareSize(500, 400, { smallScreenLimits: 'not-an-array' }));
195
+ });
196
+
197
+
122
198
  describe('Adapt square-size with small-screen limits', () => {
123
199
 
124
200
  const limits = [
@@ -135,6 +211,8 @@ describe('Adapt square-size with small-screen limits', () => {
135
211
  delete global.window;
136
212
  });
137
213
 
214
+ /* global window */
215
+
138
216
  it('Window-limited', () => {
139
217
  window.innerWidth = 640;
140
218
  testAdaptSquareSize(32, 9999, 9999, true, true, limits);
@@ -42,7 +42,7 @@ describeWithBrowser('Error box graphic', browserContext => {
42
42
  ]);
43
43
 
44
44
  itChecksScreenshots(browserContext, '03_error_box_graphic/localization', [
45
- 'default'
45
+ 'default',
46
46
  ]);
47
47
 
48
48
  });
@@ -31,8 +31,7 @@ describeWithBrowser('Chessboard interaction', browserContext => {
31
31
  itCustom(browserContext, '07_chessboard_interaction/click_squares', itemIndex, label, async element => {
32
32
  const actions = browserContext.driver.actions({ async: true });
33
33
  const area = await element.getRect();
34
- for (let i = 0; i < targets.length; ++i) {
35
- const target = targets[i];
34
+ for (const target of targets) {
36
35
  await actions.move({ x: area.x + target.x, y: area.y + target.y }).click().perform();
37
36
  await compareSandbox(browserContext, target.expectedText);
38
37
  }
@@ -50,10 +50,10 @@ describeWithBrowser('Navigation board graphic', browserContext => {
50
50
  function itCheckClickButton(itemIndex, label, buttons) {
51
51
  itCustom(browserContext, '13_navigation_board_graphic/additional_buttons', itemIndex, label, async element => {
52
52
  await setSandbox(browserContext, '');
53
- for (let i = 0; i < buttons.length; ++i) {
54
- const buttonElement = await element.findElement(By.xpath(`.//div[@title='${buttons[i].title}']`));
53
+ for (const button of buttons) {
54
+ const buttonElement = await element.findElement(By.xpath(`.//div[@title='${button.title}']`));
55
55
  await buttonElement.click();
56
- await compareSandbox(browserContext, buttons[i].expectedSandbox ?? '');
56
+ await compareSandbox(browserContext, button.expectedSandbox ?? '');
57
57
  }
58
58
  });
59
59
  }
@@ -47,8 +47,8 @@ const AUTOPLAY_DELAY = 1000;
47
47
  /**
48
48
  * Create a Mocha test-suite that runs graphic tests in Dockerized Selenium webbrowser.
49
49
  */
50
- exports.describeWithBrowser = function(suiteLabel, testFactory) {
51
- describe(suiteLabel, function() {
50
+ exports.describeWithBrowser = function (suiteLabel, testFactory) {
51
+ describe(suiteLabel, function () {
52
52
 
53
53
  // Fetching a new page in the browser may take a while, thus increase the timeout threshold.
54
54
  this.timeout(10000);
@@ -147,7 +147,7 @@ async function fetchTestCase(browserContext, testCaseName) {
147
147
  /**
148
148
  * Wait until the end of the chessboard animations.
149
149
  */
150
- const waitForAnimation = exports.waitForAnimation = async function() {
150
+ const waitForAnimation = exports.waitForAnimation = async function () {
151
151
  await new Promise(resolve => setTimeout(resolve, ANIMATION_DELAY));
152
152
  };
153
153
 
@@ -155,7 +155,7 @@ const waitForAnimation = exports.waitForAnimation = async function() {
155
155
  /**
156
156
  * Wait until the given number of moves have been auto-played.
157
157
  */
158
- exports.waitForAutoplay = async function(nbMoves) {
158
+ exports.waitForAutoplay = async function (nbMoves) {
159
159
  await new Promise(resolve => setTimeout(resolve, (nbMoves + 0.5) * AUTOPLAY_DELAY));
160
160
  };
161
161
 
@@ -163,7 +163,7 @@ exports.waitForAutoplay = async function(nbMoves) {
163
163
  /**
164
164
  * Take a screenshot of the element identified by the given CSS target.
165
165
  */
166
- const takeScreenshot = exports.takeScreenshot = async function(browserContext, imageBaseName, element) {
166
+ const takeScreenshot = exports.takeScreenshot = async function (browserContext, imageBaseName, element) {
167
167
 
168
168
  imageBaseName = imageBaseName.replaceAll(' ', '_').toLowerCase();
169
169
  const actualFilename = `${outputDir}/${browserContext.latestTestCase}/${imageBaseName}.png`;
@@ -178,7 +178,7 @@ const takeScreenshot = exports.takeScreenshot = async function(browserContext, i
178
178
  /**
179
179
  * Compare a screenshot to its reference.
180
180
  */
181
- const compareScreenshot = exports.compareScreenshot = async function(browserContext, imageBaseName) {
181
+ const compareScreenshot = exports.compareScreenshot = async function (browserContext, imageBaseName) {
182
182
 
183
183
  imageBaseName = imageBaseName.replaceAll(' ', '_').toLowerCase();
184
184
  const actualFilename = `${outputDir}/${browserContext.latestTestCase}/${imageBaseName}.png`;
@@ -198,7 +198,7 @@ const compareScreenshot = exports.compareScreenshot = async function(browserCont
198
198
  /**
199
199
  * Compare content of the sandbox to the expected text.
200
200
  */
201
- exports.compareSandbox = async function(browserContext, expectedText) {
201
+ exports.compareSandbox = async function (browserContext, expectedText) {
202
202
  const actualText = await browserContext.driver.findElement(By.id('sandbox')).getText();
203
203
  test.value(actualText).is(expectedText);
204
204
  };
@@ -207,7 +207,7 @@ exports.compareSandbox = async function(browserContext, expectedText) {
207
207
  /**
208
208
  * Set the content of the sandbox to the given value.
209
209
  */
210
- exports.setSandbox = async function(browserContext, value) {
210
+ exports.setSandbox = async function (browserContext, value) {
211
211
  if (/[^\w \-=]/.test(value)) {
212
212
  throw new Error('Invalid characters found in the sandox message.');
213
213
  }
@@ -218,7 +218,7 @@ exports.setSandbox = async function(browserContext, value) {
218
218
  /**
219
219
  * Set the width of the browser.
220
220
  */
221
- exports.setWindowWidth = async function(browserContext, width) {
221
+ exports.setWindowWidth = async function (browserContext, width) {
222
222
  const { height } = await await browserContext.driver.manage().window().getRect();
223
223
  await browserContext.driver.manage().window().setRect({ width: width, height: height });
224
224
  };
@@ -227,7 +227,7 @@ exports.setWindowWidth = async function(browserContext, width) {
227
227
  /**
228
228
  * Open the page corresponding to the given test-case, and execute the given scenario.
229
229
  */
230
- const itCustom = exports.itCustom = function(browserContext, testCaseName, itemIndex, itemName, scenario) {
230
+ const itCustom = exports.itCustom = function (browserContext, testCaseName, itemIndex, itemName, scenario) {
231
231
  it(`${testCaseName} - ${itemName}`, async () => {
232
232
  await fetchTestCase(browserContext, testCaseName);
233
233
  const element = await browserContext.driver.findElement(By.id('test-item-' + itemIndex));
@@ -239,7 +239,7 @@ const itCustom = exports.itCustom = function(browserContext, testCaseName, itemI
239
239
  /**
240
240
  * Open the page corresponding to the given test-case, take a screenshot for each item, and compare them to the reference.
241
241
  */
242
- exports.itChecksScreenshots = function(browserContext, testCaseName, itemNames) {
242
+ exports.itChecksScreenshots = function (browserContext, testCaseName, itemNames) {
243
243
  for (let i = 0; i < itemNames.length; ++i) {
244
244
  const itemName = itemNames[i];
245
245
  itCustom(browserContext, testCaseName, i, itemName, async element => {