kokopu-react 3.0.2 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/.eslintrc.yml +1 -1
  2. package/CHANGELOG.md +13 -1
  3. package/dist/lib/chessboard/BoardProperties.d.ts +91 -0
  4. package/dist/lib/chessboard/BoardProperties.js +43 -0
  5. package/dist/lib/chessboard/BoardProperties.js.map +1 -0
  6. package/dist/lib/chessboard/Chessboard.css +13 -13
  7. package/dist/lib/chessboard/Chessboard.d.ts +14 -58
  8. package/dist/lib/chessboard/Chessboard.js +26 -92
  9. package/dist/lib/chessboard/Chessboard.js.map +1 -1
  10. package/dist/lib/chessboard/ChessboardImpl.js.map +1 -1
  11. package/dist/lib/chessboard/Draggable.js.map +1 -1
  12. package/dist/lib/chessboard/Motion.js.map +1 -1
  13. package/dist/lib/chessboard/colorsets.js.map +1 -1
  14. package/dist/lib/chessboard/piecesets.js.map +1 -1
  15. package/dist/lib/errorbox/ErrorBox.css +18 -18
  16. package/dist/lib/errorbox/ErrorBox.js.map +1 -1
  17. package/dist/lib/errorbox/parsing.d.ts +57 -0
  18. package/dist/lib/errorbox/parsing.js +140 -0
  19. package/dist/lib/errorbox/parsing.js.map +1 -0
  20. package/dist/lib/exception.js.map +1 -1
  21. package/dist/lib/i18n.d.ts +6 -0
  22. package/dist/lib/i18n.js +7 -0
  23. package/dist/lib/i18n.js.map +1 -1
  24. package/dist/lib/icons/AnnotationSymbolShape.css +6 -6
  25. package/dist/lib/icons/AnnotationSymbolShape.js.map +1 -1
  26. package/dist/lib/icons/ArrowMarkerIcon.js.map +1 -1
  27. package/dist/lib/icons/ArrowTip.js.map +1 -1
  28. package/dist/lib/icons/ChessPieceIcon.js.map +1 -1
  29. package/dist/lib/icons/SquareMarkerIcon.js.map +1 -1
  30. package/dist/lib/icons/TextMarkerIcon.js.map +1 -1
  31. package/dist/lib/icons/arrow.css +1 -1
  32. package/dist/lib/index.d.ts +5 -1
  33. package/dist/lib/index.js +3 -0
  34. package/dist/lib/index.js.map +1 -1
  35. package/dist/lib/movetext/Movetext.css +27 -40
  36. package/dist/lib/movetext/Movetext.d.ts +9 -43
  37. package/dist/lib/movetext/Movetext.js +15 -67
  38. package/dist/lib/movetext/Movetext.js.map +1 -1
  39. package/dist/lib/movetext/MovetextImpl.d.ts +7 -28
  40. package/dist/lib/movetext/MovetextImpl.js +15 -94
  41. package/dist/lib/movetext/MovetextImpl.js.map +1 -1
  42. package/dist/lib/movetext/fonts.css +7 -7
  43. package/dist/lib/movetext/htmlFilter.js.map +1 -1
  44. package/dist/lib/movetext/moveFormatter.js.map +1 -1
  45. package/dist/lib/navigationboard/NavigationBoard.d.ts +156 -0
  46. package/dist/lib/navigationboard/NavigationBoard.js +195 -0
  47. package/dist/lib/navigationboard/NavigationBoard.js.map +1 -0
  48. package/dist/lib/navigationboard/NavigationButton.d.ts +54 -0
  49. package/dist/lib/navigationboard/NavigationButton.js +35 -0
  50. package/dist/lib/navigationboard/NavigationButton.js.map +1 -0
  51. package/dist/lib/navigationboard/NavigationField.css +36 -0
  52. package/dist/lib/navigationboard/NavigationField.d.ts +81 -0
  53. package/dist/lib/navigationboard/NavigationField.js +154 -0
  54. package/dist/lib/navigationboard/NavigationField.js.map +1 -0
  55. package/dist/lib/navigationboard/NavigationToolbar.css +54 -0
  56. package/dist/lib/navigationboard/NavigationToolbar.d.ts +34 -0
  57. package/dist/lib/navigationboard/NavigationToolbar.js +73 -0
  58. package/dist/lib/navigationboard/NavigationToolbar.js.map +1 -0
  59. package/dist/lib/navigationboard/iconPaths.d.ts +29 -0
  60. package/dist/lib/navigationboard/iconPaths.js +91 -0
  61. package/dist/lib/navigationboard/iconPaths.js.map +1 -0
  62. package/dist/lib/sanitization.js.map +1 -1
  63. package/dist/lib/types.js.map +1 -1
  64. package/dist/lib/util.js.map +1 -1
  65. package/doc_src/demo/PageChessboardBase.tsx +115 -115
  66. package/doc_src/demo/PageChessboardInteraction.tsx +303 -303
  67. package/doc_src/demo/PageChessboardMove.tsx +173 -156
  68. package/doc_src/demo/PageChessboardSmallScreens.tsx +94 -94
  69. package/doc_src/demo/PageMovetextBase.tsx +180 -180
  70. package/doc_src/demo/PageMovetextInteraction.tsx +123 -123
  71. package/doc_src/demo/PageNavigationBoardBase.tsx +201 -0
  72. package/doc_src/demo/PageNavigationBoardUncontrolledVsControlled.tsx +114 -0
  73. package/doc_src/demo/decs.d.ts +4 -4
  74. package/doc_src/demo/demo.css +12 -12
  75. package/doc_src/demo/game-3.pgn +10 -0
  76. package/doc_src/demo/util.ts +1 -1
  77. package/doc_src/examples/Movetext.md +1 -1
  78. package/doc_src/examples/NavigationBoard.md +15 -0
  79. package/doc_src/theming/LogoRenderer.js +13 -13
  80. package/doc_src/theming/theming.css +5 -5
  81. package/package.json +95 -95
  82. package/scripts/doc.styleguide.config.js +133 -123
  83. package/scripts/doc.tsconfig.json +5 -5
  84. package/scripts/docker-compose.yml +1 -1
  85. package/scripts/test-graphic.tsconfig.json +5 -5
  86. package/scripts/test-graphic.webpack.config.js +57 -57
  87. package/scripts/test-headless.webpack.config.js +29 -29
  88. package/src/chessboard/BoardProperties.ts +131 -0
  89. package/src/chessboard/Chessboard.css +13 -13
  90. package/src/chessboard/Chessboard.tsx +389 -518
  91. package/src/chessboard/ChessboardImpl.tsx +557 -557
  92. package/src/chessboard/Draggable.tsx +185 -185
  93. package/src/chessboard/Motion.tsx +67 -67
  94. package/src/chessboard/colorsets.ts +66 -66
  95. package/src/chessboard/piecesets.ts +84 -84
  96. package/src/decs.d.ts +2 -2
  97. package/src/errorbox/ErrorBox.css +18 -18
  98. package/src/errorbox/ErrorBox.tsx +75 -75
  99. package/src/errorbox/parsing.tsx +158 -0
  100. package/src/exception.ts +17 -17
  101. package/src/i18n.ts +8 -0
  102. package/src/icons/AnnotationSymbolShape.css +6 -6
  103. package/src/icons/AnnotationSymbolShape.tsx +31 -31
  104. package/src/icons/ArrowMarkerIcon.tsx +34 -34
  105. package/src/icons/ArrowTip.tsx +14 -14
  106. package/src/icons/ChessPieceIcon.tsx +45 -45
  107. package/src/icons/SquareMarkerIcon.tsx +20 -20
  108. package/src/icons/TextMarkerIcon.tsx +29 -29
  109. package/src/icons/arrow.css +1 -1
  110. package/src/index.ts +8 -3
  111. package/src/movetext/Movetext.css +27 -40
  112. package/src/movetext/Movetext.tsx +163 -228
  113. package/src/movetext/MovetextImpl.tsx +351 -438
  114. package/src/movetext/fonts.css +7 -7
  115. package/src/movetext/htmlFilter.tsx +129 -129
  116. package/src/movetext/moveFormatter.tsx +37 -37
  117. package/src/navigationboard/NavigationBoard.tsx +350 -0
  118. package/src/navigationboard/NavigationButton.ts +72 -0
  119. package/src/navigationboard/NavigationField.css +36 -0
  120. package/src/navigationboard/NavigationField.tsx +185 -0
  121. package/src/navigationboard/NavigationToolbar.css +54 -0
  122. package/src/navigationboard/NavigationToolbar.tsx +117 -0
  123. package/src/navigationboard/iconPaths.ts +98 -0
  124. package/src/sanitization.ts +17 -17
  125. package/src/types.ts +116 -116
  126. package/src/util.ts +11 -11
  127. package/test/01_types.js +167 -167
  128. package/test/02_chessboard_util.js +114 -114
  129. package/test/03_error_box_graphic.js +16 -16
  130. package/test/04_icons_graphic.js +32 -32
  131. package/test/05_chessboard_graphic.js +60 -58
  132. package/test/06_chessboard_animation.js +36 -36
  133. package/test/07_chessboard_interaction.js +101 -101
  134. package/test/08_chessboard_play_moves.js +62 -62
  135. package/test/09_chessboard_small_screens.js +42 -21
  136. package/test/10_movetext_graphic.js +36 -31
  137. package/test/11_movetext_interaction.js +100 -96
  138. package/test/12_navigation_board_base.js +151 -0
  139. package/test/13_navigation_board_graphic.js +68 -0
  140. package/test/14_navigation_board_autoplay.js +100 -0
  141. package/test/common/graphic.js +106 -97
  142. package/test/graphic_references/05_chessboard_graphic/move/illegal_null-move.png +0 -0
  143. package/test/graphic_references/05_chessboard_graphic/move/null-move.png +0 -0
  144. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_bottom_component.png +0 -0
  145. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_top_component.png +0 -0
  146. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_bottom_component.png +0 -0
  147. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_top_component.png +0 -0
  148. package/test/graphic_references/10_movetext_graphic/format_move/format_text.png +0 -0
  149. package/test/graphic_references/10_movetext_graphic/options/wrong_piece_symbol_value.png +0 -0
  150. package/test/graphic_references/11_movetext_interaction/select_moves/click_on_unselected_without_callback.png +0 -0
  151. package/test/graphic_references/12_navigation_board_base/controlled/default.png +0 -0
  152. package/test/graphic_references/12_navigation_board_base/controlled/forbidden_navigation_0.png +0 -0
  153. package/test/graphic_references/12_navigation_board_base/controlled/forbidden_navigation_1.png +0 -0
  154. package/test/graphic_references/12_navigation_board_base/controlled/invalid_node_id.png +0 -0
  155. package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_0.png +0 -0
  156. package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_1.png +0 -0
  157. package/test/graphic_references/12_navigation_board_base/controlled/overriding_initial_node_id.png +0 -0
  158. package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_0.png +0 -0
  159. package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_1.png +0 -0
  160. package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_2.png +0 -0
  161. package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_3.png +0 -0
  162. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_0.png +0 -0
  163. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_1.png +0 -0
  164. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_2.png +0 -0
  165. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_0.png +0 -0
  166. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_1.png +0 -0
  167. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_2.png +0 -0
  168. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_end.png +0 -0
  169. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_specific_id.png +0 -0
  170. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_default.png +0 -0
  171. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_default_with_game_index.png +0 -0
  172. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_on_null-move.png +0 -0
  173. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_0.png +0 -0
  174. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_1.png +0 -0
  175. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_2.png +0 -0
  176. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_3.png +0 -0
  177. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_4.png +0 -0
  178. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_flipping_0.png +0 -0
  179. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_flipping_1.png +0 -0
  180. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_0.png +0 -0
  181. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_1.png +0 -0
  182. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_2.png +0 -0
  183. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_3.png +0 -0
  184. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_4.png +0 -0
  185. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_5.png +0 -0
  186. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_1.png +0 -0
  187. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_2.png +0 -0
  188. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/multiple_buttons.png +0 -0
  189. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/single_button.png +0 -0
  190. package/test/graphic_references/13_navigation_board_graphic/error/pgn_parsing_error.png +0 -0
  191. package/test/graphic_references/13_navigation_board_graphic/error/wrong_game_type.png +0 -0
  192. package/test/graphic_references/13_navigation_board_graphic/theme/custom_1.png +0 -0
  193. package/test/graphic_references/13_navigation_board_graphic/theme/custom_2.png +0 -0
  194. package/test/graphic_references/13_navigation_board_graphic/theme/large.png +0 -0
  195. package/test/graphic_references/13_navigation_board_graphic/theme/small.png +0 -0
  196. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_acknowledging_is-playing_changes.png +0 -0
  197. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_not_acknowledging_is-playing_changes.png +0 -0
  198. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_acknowledging_node_changes.png +0 -0
  199. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_not_acknowledging_node_changes.png +0 -0
  200. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_reaching_the_end.png +0 -0
  201. package/test/graphic_references/14_navigation_board_autoplay/controlled/already_at_the_end.png +0 -0
  202. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_is-playing_changes.png +0 -0
  203. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_node_changes.png +0 -0
  204. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_at_the_end.png +0 -0
  205. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_close_to_end.png +0 -0
  206. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_is-playing_changes.png +0 -0
  207. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_node_changes.png +0 -0
  208. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_after_stop.png +0 -0
  209. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_before_stop.png +0 -0
  210. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_after_stop.png +0 -0
  211. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_before_stop.png +0 -0
  212. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_close_to_end.png +0 -0
  213. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_default.png +0 -0
  214. package/test/graphic_test_app/03_error_box_graphic/base.tsx +14 -14
  215. package/test/graphic_test_app/03_error_box_graphic/localization.tsx +1 -1
  216. package/test/graphic_test_app/04_icons_graphic/chess_piece.tsx +7 -7
  217. package/test/graphic_test_app/04_icons_graphic/marker.tsx +15 -15
  218. package/test/graphic_test_app/05_chessboard_graphic/annotations.tsx +7 -7
  219. package/test/graphic_test_app/05_chessboard_graphic/base.tsx +6 -6
  220. package/test/graphic_test_app/05_chessboard_graphic/chess_variants.tsx +7 -7
  221. package/test/graphic_test_app/05_chessboard_graphic/flipped.tsx +5 -5
  222. package/test/graphic_test_app/05_chessboard_graphic/move.tsx +12 -10
  223. package/test/graphic_test_app/05_chessboard_graphic/theme.tsx +12 -12
  224. package/test/graphic_test_app/06_chessboard_animation/base_1.tsx +6 -6
  225. package/test/graphic_test_app/06_chessboard_animation/base_2.tsx +6 -6
  226. package/test/graphic_test_app/06_chessboard_animation/base_3.tsx +6 -6
  227. package/test/graphic_test_app/06_chessboard_animation/on_redraw.tsx +16 -16
  228. package/test/graphic_test_app/07_chessboard_interaction/click_squares.tsx +5 -5
  229. package/test/graphic_test_app/07_chessboard_interaction/edit_arrows.tsx +4 -4
  230. package/test/graphic_test_app/07_chessboard_interaction/error.tsx +2 -2
  231. package/test/graphic_test_app/07_chessboard_interaction/move_pieces.tsx +5 -5
  232. package/test/graphic_test_app/08_chessboard_play_moves/base.tsx +8 -8
  233. package/test/graphic_test_app/08_chessboard_play_moves/promotions.tsx +4 -4
  234. package/test/graphic_test_app/09_chessboard_small_screens/base.tsx +9 -9
  235. package/test/graphic_test_app/09_chessboard_small_screens/top_bottom_components.tsx +48 -0
  236. package/test/graphic_test_app/10_movetext_graphic/base.tsx +4 -4
  237. package/test/graphic_test_app/10_movetext_graphic/error.tsx +6 -6
  238. package/test/graphic_test_app/10_movetext_graphic/format_move.tsx +31 -0
  239. package/test/graphic_test_app/10_movetext_graphic/html.tsx +5 -5
  240. package/test/graphic_test_app/10_movetext_graphic/options.tsx +10 -9
  241. package/test/graphic_test_app/11_movetext_interaction/error.tsx +1 -1
  242. package/test/graphic_test_app/11_movetext_interaction/select_moves.tsx +11 -10
  243. package/test/graphic_test_app/12_navigation_board_base/controlled.tsx +43 -0
  244. package/test/graphic_test_app/12_navigation_board_base/uncontrolled.tsx +56 -0
  245. package/test/graphic_test_app/13_navigation_board_graphic/additional_buttons.tsx +49 -0
  246. package/test/graphic_test_app/13_navigation_board_graphic/error.tsx +34 -0
  247. package/test/graphic_test_app/13_navigation_board_graphic/theme.tsx +38 -0
  248. package/test/graphic_test_app/14_navigation_board_autoplay/controlled.tsx +73 -0
  249. package/test/graphic_test_app/14_navigation_board_autoplay/uncontrolled.tsx +34 -0
  250. package/test/graphic_test_app/common/decs.d.ts +2 -2
  251. package/test/graphic_test_app/common/test_app.css +15 -15
  252. package/test/graphic_test_app/common/test_app.tsx +48 -48
  253. package/tsconfig.json +13 -13
@@ -28,6 +28,10 @@ export { SquareMarkerIcon, SquareMarkerIconProps } from './icons/SquareMarkerIco
28
28
  export { TextMarkerIcon, TextMarkerIconProps } from './icons/TextMarkerIcon';
29
29
  export { ArrowMarkerIcon, ArrowMarkerIconProps } from './icons/ArrowMarkerIcon';
30
30
  export { ChessPieceIcon, ChessPieceIconProps } from './icons/ChessPieceIcon';
31
- export { Chessboard, ChessboardProps, SmallScreenLimit } from './chessboard/Chessboard';
31
+ export { SmallScreenLimit } from './chessboard/BoardProperties';
32
+ export { Chessboard, ChessboardProps } from './chessboard/Chessboard';
32
33
  export { formatMove, moveFormatter } from './movetext/moveFormatter';
33
34
  export { Movetext, MovetextProps, MoveSelectEventOrigin } from './movetext/Movetext';
35
+ export { NavigationButton, NavigationButtonList, isNavigationButton } from './navigationboard/NavigationButton';
36
+ export { firstNodeId, previousNodeId, nextNodeId, lastNodeId } from './navigationboard/NavigationField';
37
+ export { NavigationBoard, NavigationBoardProps } from './navigationboard/NavigationBoard';
package/dist/lib/index.js CHANGED
@@ -31,4 +31,7 @@ export { ChessPieceIcon } from './icons/ChessPieceIcon';
31
31
  export { Chessboard } from './chessboard/Chessboard';
32
32
  export { formatMove, moveFormatter } from './movetext/moveFormatter';
33
33
  export { Movetext } from './movetext/Movetext';
34
+ export { isNavigationButton } from './navigationboard/NavigationButton';
35
+ export { firstNodeId, previousNodeId, nextNodeId, lastNodeId } from './navigationboard/NavigationField';
36
+ export { NavigationBoard } from './navigationboard/NavigationBoard';
34
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAGhF,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,OAAO,EACN,oBAAoB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,mBAAmB,EAChJ,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,QAAQ,EAAiB,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAyB,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,cAAc,EAAuB,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAwB,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAuB,MAAM,wBAAwB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-colorTag {
26
- width : 1.2em;
27
- height: 1.2em;
28
- vertical-align: middle;
29
- display: inline-block;
30
- border: 1px solid black;
31
- margin-right: 0.25em;
26
+ width : 1.2em;
27
+ height: 1.2em;
28
+ vertical-align: middle;
29
+ display: inline-block;
30
+ border: 1px solid black;
31
+ margin-right: 0.25em;
32
32
  }
33
33
 
34
34
  .kokopu-headerGroup-whitePlayer .kokopu-colorTag {
35
- background-color: white;
35
+ background-color: white;
36
36
  }
37
37
 
38
38
  .kokopu-headerGroup-blackPlayer .kokopu-colorTag {
39
- background-color: black;
39
+ background-color: black;
40
40
  }
41
41
 
42
42
  .kokopu-headerGroup-titleRating:before,
43
43
  .kokopu-header-round:before {
44
- content: "\a0("; /* \a0 ==   */
44
+ content: "\a0("; /* \a0 ==   */
45
45
  }
46
46
 
47
47
  .kokopu-headerGroup-titleRating:after,
48
48
  .kokopu-header-round:after {
49
- content: ")";
49
+ content: ")";
50
50
  }
51
51
 
52
52
  .kokopu-header-round,
53
53
  .kokopu-header-annotator {
54
- font-style: italic;
54
+ font-style: italic;
55
55
  }
56
56
 
57
57
  * + .kokopu-move:before,
58
58
  * + .kokopu-gameResult:before,
59
59
  * + span.kokopu-comment:before {
60
- content: " ";
60
+ content: " ";
61
61
  }
62
62
 
63
63
  span.kokopu-variation:before {
64
- content: " (";
64
+ content: " (";
65
65
  }
66
66
 
67
67
  span.kokopu-variation:after {
68
- content: ")";
68
+ content: ")";
69
69
  }
70
70
 
71
71
  * + .kokopu-nag:before {
72
- content: "\a0"; /* \a0 ==   */
72
+ content: "\a0"; /* \a0 ==   */
73
73
  }
74
74
 
75
75
  div.kokopu-subVariation {
76
- margin-left: 1.5em;
76
+ margin-left: 1.5em;
77
77
  }
78
78
 
79
79
  .kokopu-move,
80
80
  .kokopu-gameResult {
81
- font-weight: bold;
81
+ font-weight: bold;
82
82
  }
83
83
 
84
84
  .kokopu-subVariation .kokopu-move {
85
- font-weight: inherit;
85
+ font-weight: inherit;
86
86
  }
87
87
 
88
88
  .kokopu-diagram {
89
- text-align: center;
90
- line-height: 0px;
89
+ text-align: center;
90
+ line-height: 0px;
91
91
  }
92
92
 
93
93
  .kokopu-moveContent {
94
- display: inline-block;
95
- padding-left: 1px;
96
- padding-right: 1px;
94
+ display: inline-block;
95
+ padding-left: 1px;
96
+ padding-right: 1px;
97
97
  }
98
98
 
99
99
  .kokopu-selectedMove .kokopu-moveContent {
100
- background-color: currentcolor;
100
+ background-color: currentcolor;
101
101
  }
102
102
 
103
103
  .kokopu-selectedMove .kokopu-moveContent > * {
104
- filter: invert(1);
104
+ filter: invert(1);
105
105
  }
106
106
 
107
107
  .kokopu-clickableMove .kokopu-moveContent:hover {
108
- text-decoration: underline;
109
- cursor: pointer;
110
- }
111
-
112
- .kokopu-focusFieldContainer {
113
- position: fixed;
114
- bottom: 0px;
115
- right: 0px;
116
- width: 0px;
117
- height: 0px;
118
- overflow: hidden;
119
- }
120
-
121
- .kokopu-focusField {
122
- position: absolute; /* see #1 */
108
+ text-decoration: underline;
109
+ cursor: pointer;
123
110
  }
@@ -23,7 +23,7 @@
23
23
  import * as React from 'react';
24
24
  import { Database, Game } from 'kokopu';
25
25
  import { PieceSymbolMapping } from '../types';
26
- import { ChessboardProps } from '../chessboard/Chessboard';
26
+ import { StaticBoardGraphicProps } from '../chessboard/BoardProperties';
27
27
  import './Movetext.css';
28
28
  /**
29
29
  * Origin of a "move-selected" event in {@link Movetext}. See {@link MovetextProps.onMoveSelected} for more details.
@@ -31,7 +31,7 @@ import './Movetext.css';
31
31
  export type MoveSelectEventOrigin = 'key-first' | 'key-previous' | 'key-next' | 'key-last' | 'key-exit' | 'click';
32
32
  export interface MovetextProps {
33
33
  /**
34
- * Displayed position. Can be a [kokopu.Game](https://kokopu.yo35.org/docs/current/classes/Game.html) object,
34
+ * Displayed game. Can be a [kokopu.Game](https://kokopu.yo35.org/docs/current/classes/Game.html) object,
35
35
  * a [kokopu.Database](https://kokopu.yo35.org/docs/current/classes/Database.html) object,
36
36
  * or a [PGN string](https://en.wikipedia.org/wiki/Portable_Game_Notation).
37
37
  */
@@ -45,14 +45,8 @@ export interface MovetextProps {
45
45
  /**
46
46
  * Options applicable to the diagrams in the comments. See [Chessboard](#/Components/Chessboard) for more details about each option.
47
47
  */
48
- diagramOptions: {
49
- flipped?: ChessboardProps['flipped'];
50
- squareSize?: ChessboardProps['squareSize'];
51
- coordinateVisible?: ChessboardProps['coordinateVisible'];
52
- turnVisible?: ChessboardProps['turnVisible'];
53
- colorset?: ChessboardProps['colorset'];
54
- pieceset?: ChessboardProps['pieceset'];
55
- smallScreenLimits?: ChessboardProps['smallScreenLimits'];
48
+ diagramOptions: Partial<StaticBoardGraphicProps> & {
49
+ flipped?: boolean;
56
50
  };
57
51
  /**
58
52
  * Symbols to use for the chess pieces. See {@link moveFormatter}.
@@ -67,7 +61,7 @@ export interface MovetextProps {
67
61
  */
68
62
  headerVisible: boolean;
69
63
  /**
70
- * ID of the selected move (or `'start'` for the beginning of the main variation).
64
+ * ID of the selected move (or `'start'`/`'end'` for the beginning/end of the main variation).
71
65
  * Use [kokopu.Node#id](https://kokopu.yo35.org/docs/current/classes/Node.html#id) to get the ID of a game move.
72
66
  */
73
67
  selection?: string;
@@ -114,47 +108,19 @@ export declare class Movetext extends React.Component<MovetextProps> {
114
108
  */
115
109
  focus(): void;
116
110
  /**
117
- * Return the ID of the main variation in the given chess game.
118
- * If the given selection corresponds already at the main variation, `undefined` is returned.
119
- *
120
- * This corresponds to the operation performed when the user presses key "home" on a `Movetext` component.
121
- *
122
- * @param game - Considered chess game.
123
- * @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
124
- * @public
111
+ * @deprecated
125
112
  */
126
113
  static firstNodeId(game: Game, selection: string): string | undefined;
127
114
  /**
128
- * Return the ID of the node immediately preceding the given selection in the given chess game.
129
- * If no such node exists, `undefined` is returned.
130
- *
131
- * This corresponds to the operation performed when the user presses key "arrow left" on a `Movetext` component.
132
- *
133
- * @param game - Considered chess game.
134
- * @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
135
- * @public
115
+ * @deprecated
136
116
  */
137
117
  static previousNodeId(game: Game, selection: string): string | undefined;
138
118
  /**
139
- * Return the ID of the node immediately following the given selection in the given chess game.
140
- * If no such node exists, `undefined` is returned.
141
- *
142
- * This corresponds to the operation performed when the user presses key "arrow right" on a `Movetext` component.
143
- *
144
- * @param game - Considered chess game.
145
- * @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
146
- * @public
119
+ * @deprecated
147
120
  */
148
121
  static nextNodeId(game: Game, selection: string): string | undefined;
149
122
  /**
150
- * Return the ID of the node at then end of the variation in which lies the given selection in the given chess game.
151
- * If the selection is already at the end its variation, `undefined` is returned.
152
- *
153
- * This corresponds to the operation performed when the user presses key "end" on a `Movetext` component.
154
- *
155
- * @param game - Considered chess game.
156
- * @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
157
- * @public
123
+ * @deprecated
158
124
  */
159
125
  static lastNodeId(game: Game, selection: string): string | undefined;
160
126
  }
@@ -21,13 +21,13 @@
21
21
  * *
22
22
  * -------------------------------------------------------------------------- */
23
23
  import * as React from 'react';
24
- import { exception as kokopuException, Database, Game, pgnRead } from 'kokopu';
24
+ import { Game } from 'kokopu';
25
25
  import { IllegalArgument } from '../exception';
26
- import { i18n } from '../i18n';
27
26
  import { sanitizeString, sanitizeBoolean, sanitizeOptional } from '../sanitization';
28
- import { ErrorBox } from '../errorbox/ErrorBox';
27
+ import { parseGame } from '../errorbox/parsing';
28
+ import { firstNodeId as firstNodeIdImpl, previousNodeId as previousNodeIdImpl, nextNodeId as nextNodeIdImpl, lastNodeId as lastNodeIdImpl } from '../navigationboard/NavigationField';
29
29
  import { moveFormatter } from './moveFormatter';
30
- import { MovetextImpl, firstNodeIdImpl, previousNodeIdImpl, nextNodeIdImpl, lastNodeIdImpl } from './MovetextImpl';
30
+ import { MovetextImpl } from './MovetextImpl';
31
31
  import './Movetext.css';
32
32
  /**
33
33
  * Display a chess game, i.e. the headers (name of the players, event, etc.), the moves, and all the related annotations if any (comments, variations, NAGs...).
@@ -39,9 +39,9 @@ export class Movetext extends React.Component {
39
39
  }
40
40
  render() {
41
41
  // Validate the game and game-index attributes.
42
- const info = parseGame(this.props.game, this.props.gameIndex);
42
+ const info = parseGame(this.props.game, this.props.gameIndex, 'Movetext');
43
43
  if (info.error) {
44
- return (React.createElement(ErrorBox, { title: i18n.INVALID_PGN_ERROR_TITLE, message: info.pgnException.message, text: info.pgnException.pgn, errorIndex: info.pgnException.index, lineNumber: info.pgnException.lineNumber }));
44
+ return info.errorBox;
45
45
  }
46
46
  // Validate the appearance attributes.
47
47
  if (typeof this.props.diagramOptions !== 'object' || this.props.diagramOptions === null) {
@@ -72,59 +72,36 @@ export class Movetext extends React.Component {
72
72
  */
73
73
  focus() {
74
74
  const movetextImpl = this.implRef.current;
75
+ // istanbul ignore else
75
76
  if (movetextImpl) {
76
77
  movetextImpl.focus();
77
78
  }
78
79
  }
79
80
  /**
80
- * Return the ID of the main variation in the given chess game.
81
- * If the given selection corresponds already at the main variation, `undefined` is returned.
82
- *
83
- * This corresponds to the operation performed when the user presses key "home" on a `Movetext` component.
84
- *
85
- * @param game - Considered chess game.
86
- * @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
87
- * @public
81
+ * @deprecated
88
82
  */
83
+ // istanbul ignore next
89
84
  static firstNodeId(game, selection) {
90
85
  return firstNodeIdImpl(game, selection);
91
86
  }
92
87
  /**
93
- * Return the ID of the node immediately preceding the given selection in the given chess game.
94
- * If no such node exists, `undefined` is returned.
95
- *
96
- * This corresponds to the operation performed when the user presses key "arrow left" on a `Movetext` component.
97
- *
98
- * @param game - Considered chess game.
99
- * @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
100
- * @public
88
+ * @deprecated
101
89
  */
90
+ // istanbul ignore next
102
91
  static previousNodeId(game, selection) {
103
92
  return previousNodeIdImpl(game, selection);
104
93
  }
105
94
  /**
106
- * Return the ID of the node immediately following the given selection in the given chess game.
107
- * If no such node exists, `undefined` is returned.
108
- *
109
- * This corresponds to the operation performed when the user presses key "arrow right" on a `Movetext` component.
110
- *
111
- * @param game - Considered chess game.
112
- * @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
113
- * @public
95
+ * @deprecated
114
96
  */
97
+ // istanbul ignore next
115
98
  static nextNodeId(game, selection) {
116
99
  return nextNodeIdImpl(game, selection);
117
100
  }
118
101
  /**
119
- * Return the ID of the node at then end of the variation in which lies the given selection in the given chess game.
120
- * If the selection is already at the end its variation, `undefined` is returned.
121
- *
122
- * This corresponds to the operation performed when the user presses key "end" on a `Movetext` component.
123
- *
124
- * @param game - Considered chess game.
125
- * @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
126
- * @public
102
+ * @deprecated
127
103
  */
104
+ // istanbul ignore next
128
105
  static lastNodeId(game, selection) {
129
106
  return lastNodeIdImpl(game, selection);
130
107
  }
@@ -137,33 +114,4 @@ Movetext.defaultProps = {
137
114
  diagramVisible: true,
138
115
  headerVisible: true,
139
116
  };
140
- /**
141
- * Try to interpret the given object as a chess game.
142
- */
143
- function parseGame(game, gameIndex) {
144
- if (game instanceof Game) {
145
- return { error: false, game: game };
146
- }
147
- else if (game instanceof Database || typeof game === 'string') {
148
- if (!Number.isInteger(gameIndex) || gameIndex < 0) {
149
- throw new IllegalArgument('Movetext', 'gameIndex');
150
- }
151
- try {
152
- const result = game instanceof Database ? game.game(gameIndex) : pgnRead(game, gameIndex);
153
- return { error: false, game: result };
154
- }
155
- catch (e) {
156
- // istanbul ignore else
157
- if (e instanceof kokopuException.InvalidPGN) {
158
- return { error: true, pgnException: e };
159
- }
160
- else {
161
- throw e;
162
- }
163
- }
164
- }
165
- else {
166
- throw new IllegalArgument('Movetext', 'game');
167
- }
168
- }
169
117
  //# sourceMappingURL=Movetext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Movetext.js","sourceRoot":"","sources":["../../../src/movetext/Movetext.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;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OAEG;IACH,uBAAuB;IACvB,MAAM,CAAC,UAAU,CAAC,IAAU,EAAE,SAAiB;QAC3C,OAAO,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC;;AA9FM,qBAAY,GAAG;IAClB,IAAI,EAAE,IAAI,IAAI,EAAE;IAChB,SAAS,EAAE,CAAC;IACZ,cAAc,EAAE,EAAE;IAClB,YAAY,EAAE,QAAQ;IACtB,cAAc,EAAE,IAAI;IACpB,aAAa,EAAE,IAAI;CACtB,AAPkB,CAOjB"}
@@ -22,18 +22,12 @@
22
22
  * -------------------------------------------------------------------------- */
23
23
  import * as React from 'react';
24
24
  import { Game } from 'kokopu';
25
- import { ChessboardProps } from '../chessboard/Chessboard';
25
+ import { StaticBoardGraphicProps } from '../chessboard/BoardProperties';
26
26
  import './Movetext.css';
27
27
  interface MovetextImplProps {
28
28
  game: Game;
29
- diagramOptions: {
30
- flipped?: ChessboardProps['flipped'];
31
- squareSize?: ChessboardProps['squareSize'];
32
- coordinateVisible?: ChessboardProps['coordinateVisible'];
33
- turnVisible?: ChessboardProps['turnVisible'];
34
- colorset?: ChessboardProps['colorset'];
35
- pieceset?: ChessboardProps['pieceset'];
36
- smallScreenLimits?: ChessboardProps['smallScreenLimits'];
29
+ diagramOptions: Partial<StaticBoardGraphicProps> & {
30
+ flipped?: boolean;
37
31
  };
38
32
  moveFormatter: (notation: string) => React.ReactNode;
39
33
  diagramVisible: boolean;
@@ -48,7 +42,7 @@ interface MovetextImplProps {
48
42
  * This implementation assumes that all the parameter sanitization has been performed beforehand.
49
43
  */
50
44
  export declare class MovetextImpl extends React.Component<MovetextImplProps> {
51
- private focusFieldRef;
45
+ private navigationFieldRef;
52
46
  render(): React.JSX.Element;
53
47
  private renderHeaders;
54
48
  /**
@@ -67,7 +61,7 @@ export declare class MovetextImpl extends React.Component<MovetextImplProps> {
67
61
  * Header containing the annotator information.
68
62
  */
69
63
  private renderAnnotatorHeader;
70
- private renderFocusField;
64
+ private renderNavigationField;
71
65
  private renderBody;
72
66
  /**
73
67
  * Render the given variation and its sub-variations, recursively.
@@ -82,7 +76,8 @@ export declare class MovetextImpl extends React.Component<MovetextImplProps> {
82
76
  */
83
77
  private renderComment;
84
78
  private extractComment;
85
- private handleKeyDownInFocusField;
79
+ private handleNavigationPressed;
80
+ private handleExitPressed;
86
81
  private fireMoveSelected;
87
82
  private handleNodeClicked;
88
83
  /**
@@ -90,20 +85,4 @@ export declare class MovetextImpl extends React.Component<MovetextImplProps> {
90
85
  */
91
86
  focus(): void;
92
87
  }
93
- /**
94
- * See {@link Movetext.firstNodeId}.
95
- */
96
- export declare function firstNodeIdImpl(game: Game, selection: string): string | undefined;
97
- /**
98
- * See {@link Movetext.previousNodeId}.
99
- */
100
- export declare function previousNodeIdImpl(game: Game, selection: string): string | undefined;
101
- /**
102
- * See {@link Movetext.nextNodeId}.
103
- */
104
- export declare function nextNodeIdImpl(game: Game, selection: string): string | undefined;
105
- /**
106
- * See {@link Movetext.lastNodeId}.
107
- */
108
- export declare function lastNodeIdImpl(game: Game, selection: string): string | undefined;
109
88
  export {};
@@ -25,6 +25,7 @@ import { Variation, nagSymbol } from 'kokopu';
25
25
  import { i18n } from '../i18n';
26
26
  import { fillPlaceholder } from '../util';
27
27
  import { Chessboard } from '../chessboard/Chessboard';
28
+ import { NavigationField, firstNodeId, previousNodeId, nextNodeId, lastNodeId } from '../navigationboard/NavigationField';
28
29
  import { htmlFilter } from './htmlFilter';
29
30
  import './Movetext.css';
30
31
  /**
@@ -35,13 +36,13 @@ import './Movetext.css';
35
36
  export class MovetextImpl extends React.Component {
36
37
  constructor() {
37
38
  super(...arguments);
38
- this.focusFieldRef = React.createRef();
39
+ this.navigationFieldRef = React.createRef();
39
40
  }
40
41
  render() {
41
42
  return (React.createElement("div", { className: "kokopu-movetext" },
42
43
  this.renderHeaders(),
43
44
  this.renderBody(),
44
- this.renderFocusField()));
45
+ this.renderNavigationField()));
45
46
  }
46
47
  renderHeaders() {
47
48
  if (!this.props.headerVisible) {
@@ -124,12 +125,11 @@ export class MovetextImpl extends React.Component {
124
125
  }
125
126
  return React.createElement("div", { className: "kokopu-header-annotator", key: "annotator" }, filter(fillPlaceholder(i18n.ANNOTATED_BY, annotator)));
126
127
  }
127
- renderFocusField() {
128
+ renderNavigationField() {
128
129
  if (this.props.interactionMode !== 'selectMove') {
129
130
  return undefined;
130
131
  }
131
- return (React.createElement("div", { className: "kokopu-focusFieldContainer" },
132
- React.createElement("a", { className: "kokopu-focusField", href: "#", ref: this.focusFieldRef, onKeyDown: evt => this.handleKeyDownInFocusField(evt) })));
132
+ return React.createElement(NavigationField, { ref: this.navigationFieldRef, onFirstPressed: () => this.handleNavigationPressed(firstNodeId, 'key-first'), onPreviousPressed: () => this.handleNavigationPressed(previousNodeId, 'key-previous'), onNextPressed: () => this.handleNavigationPressed(nextNodeId, 'key-next'), onLastPressed: () => this.handleNavigationPressed(lastNodeId, 'key-last'), onExitPressed: () => this.handleExitPressed() });
133
133
  }
134
134
  renderBody() {
135
135
  const filter = htmlFilter('comment');
@@ -258,7 +258,7 @@ export class MovetextImpl extends React.Component {
258
258
  for (let textSegment of comment.split('[#]')) {
259
259
  if (!isFirstTextSegment) {
260
260
  const position = node instanceof Variation ? node.initialPosition() : node.position();
261
- const diagram = React.createElement(Chessboard, { position: position, squareMarkers: node.tag('csl'), arrowMarkers: node.tag('cal'), textMarkers: node.tag('ctl'), flipped: this.props.diagramOptions.flipped, squareSize: this.props.diagramOptions.squareSize, coordinateVisible: this.props.diagramOptions.coordinateVisible, turnVisible: this.props.diagramOptions.turnVisible, smallScreenLimits: this.props.diagramOptions.smallScreenLimits, colorset: this.props.diagramOptions.colorset, pieceset: this.props.diagramOptions.pieceset });
261
+ const diagram = React.createElement(Chessboard, { position: position, squareMarkers: node.tag('csl'), arrowMarkers: node.tag('cal'), textMarkers: node.tag('ctl'), flipped: this.props.diagramOptions.flipped, squareSize: this.props.diagramOptions.squareSize, coordinateVisible: this.props.diagramOptions.coordinateVisible, turnVisible: this.props.diagramOptions.turnVisible, colorset: this.props.diagramOptions.colorset, pieceset: this.props.diagramOptions.pieceset, smallScreenLimits: this.props.diagramOptions.smallScreenLimits });
262
262
  segmentElements.push(React.createElement("div", { className: "kokopu-diagram", key: 'diagram-' + (diagramIndex++) }, diagram));
263
263
  }
264
264
  isFirstTextSegment = false;
@@ -287,30 +287,14 @@ export class MovetextImpl extends React.Component {
287
287
  }
288
288
  return comment ? comment : undefined;
289
289
  }
290
- handleKeyDownInFocusField(evt) {
291
- if (evt.key !== 'Home' && evt.key !== 'ArrowLeft' && evt.key !== 'ArrowRight' && evt.key !== 'End' && evt.key !== 'Escape') {
292
- return;
290
+ handleNavigationPressed(transition, evtOrigin) {
291
+ if (this.props.selection) {
292
+ this.fireMoveSelected(transition(this.props.game, this.props.selection), evtOrigin);
293
293
  }
294
- evt.preventDefault();
295
- if (!this.props.selection) {
296
- return;
297
- }
298
- if (evt.key === 'Home') {
299
- this.fireMoveSelected(firstNodeIdImpl(this.props.game, this.props.selection), 'key-first');
300
- }
301
- else if (evt.key === 'ArrowLeft') {
302
- this.fireMoveSelected(previousNodeIdImpl(this.props.game, this.props.selection), 'key-previous');
303
- }
304
- else if (evt.key === 'ArrowRight') {
305
- this.fireMoveSelected(nextNodeIdImpl(this.props.game, this.props.selection), 'key-next');
306
- }
307
- else if (evt.key === 'End') {
308
- this.fireMoveSelected(lastNodeIdImpl(this.props.game, this.props.selection), 'key-last');
309
- }
310
- else { // evt.key === 'Escape'
311
- if (this.props.game.findById(this.props.selection)) {
312
- this.fireMoveSelected(undefined, 'key-exit');
313
- }
294
+ }
295
+ handleExitPressed() {
296
+ if (this.props.selection && this.props.game.findById(this.props.selection)) {
297
+ this.fireMoveSelected(undefined, 'key-exit');
314
298
  }
315
299
  }
316
300
  fireMoveSelected(nodeId, evtOrigin) {
@@ -328,76 +312,13 @@ export class MovetextImpl extends React.Component {
328
312
  * Set the focus to the current component.
329
313
  */
330
314
  focus() {
331
- const target = this.focusFieldRef.current;
315
+ const target = this.navigationFieldRef.current;
316
+ // istanbul ignore else
332
317
  if (target) {
333
318
  target.focus();
334
319
  }
335
320
  }
336
321
  }
337
- /**
338
- * See {@link Movetext.firstNodeId}.
339
- */
340
- export function firstNodeIdImpl(game, selection) {
341
- if (!game.findById(selection)) {
342
- return undefined;
343
- }
344
- return selection === 'start' ? undefined : 'start';
345
- }
346
- /**
347
- * See {@link Movetext.previousNodeId}.
348
- */
349
- export function previousNodeIdImpl(game, selection) {
350
- let currentNode = game.findById(selection);
351
- if (!currentNode) {
352
- return undefined;
353
- }
354
- if (currentNode instanceof Variation) {
355
- currentNode = currentNode.parentNode();
356
- if (!currentNode) {
357
- return undefined; // This case corresponds to the first variation being selected initially.
358
- }
359
- }
360
- while (currentNode) {
361
- const previousNode = currentNode.previous();
362
- if (previousNode) {
363
- return previousNode.id();
364
- }
365
- currentNode = currentNode.parentVariation().parentNode();
366
- }
367
- return 'start';
368
- }
369
- /**
370
- * See {@link Movetext.nextNodeId}.
371
- */
372
- export function nextNodeIdImpl(game, selection) {
373
- const currentNode = game.findById(selection);
374
- if (!currentNode) {
375
- return undefined;
376
- }
377
- const nextNode = currentNode instanceof Variation ? currentNode.first() : currentNode.next();
378
- return nextNode ? nextNode.id() : undefined;
379
- }
380
- /**
381
- * See {@link Movetext.lastNodeId}.
382
- */
383
- export function lastNodeIdImpl(game, selection) {
384
- let currentNode = game.findById(selection);
385
- if (!currentNode) {
386
- return undefined;
387
- }
388
- currentNode = currentNode instanceof Variation ? currentNode.first() : currentNode.next();
389
- if (!currentNode) { // Ensure that the input node is not already the last one.
390
- return undefined;
391
- }
392
- let currentNodeNotNull = currentNode;
393
- while (true) {
394
- const nextNode = currentNodeNotNull.next();
395
- if (!nextNode) {
396
- return currentNodeNotNull.id();
397
- }
398
- currentNodeNotNull = nextNode;
399
- }
400
- }
401
322
  /**
402
323
  * Example: `'hello world'` is turned into `'Hello world'`.
403
324
  */