kokopu-react 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/lib/chessboard/BoardProperties.d.ts +91 -0
  3. package/dist/lib/chessboard/BoardProperties.js +43 -0
  4. package/dist/lib/chessboard/BoardProperties.js.map +1 -0
  5. package/dist/lib/chessboard/Chessboard.d.ts +14 -58
  6. package/dist/lib/chessboard/Chessboard.js +26 -92
  7. package/dist/lib/chessboard/Chessboard.js.map +1 -1
  8. package/dist/lib/errorbox/parsing.d.ts +57 -0
  9. package/dist/lib/errorbox/parsing.js +140 -0
  10. package/dist/lib/errorbox/parsing.js.map +1 -0
  11. package/dist/lib/i18n.d.ts +5 -0
  12. package/dist/lib/i18n.js +6 -0
  13. package/dist/lib/i18n.js.map +1 -1
  14. package/dist/lib/index.d.ts +4 -1
  15. package/dist/lib/index.js +2 -0
  16. package/dist/lib/index.js.map +1 -1
  17. package/dist/lib/movetext/Movetext.css +0 -13
  18. package/dist/lib/movetext/Movetext.d.ts +9 -43
  19. package/dist/lib/movetext/Movetext.js +15 -67
  20. package/dist/lib/movetext/Movetext.js.map +1 -1
  21. package/dist/lib/movetext/MovetextImpl.d.ts +7 -28
  22. package/dist/lib/movetext/MovetextImpl.js +15 -94
  23. package/dist/lib/movetext/MovetextImpl.js.map +1 -1
  24. package/dist/lib/navigationboard/NavigationBoard.d.ts +118 -0
  25. package/dist/lib/navigationboard/NavigationBoard.js +112 -0
  26. package/dist/lib/navigationboard/NavigationBoard.js.map +1 -0
  27. package/dist/lib/navigationboard/NavigationField.css +36 -0
  28. package/dist/lib/navigationboard/NavigationField.d.ts +81 -0
  29. package/dist/lib/navigationboard/NavigationField.js +154 -0
  30. package/dist/lib/navigationboard/NavigationField.js.map +1 -0
  31. package/dist/lib/navigationboard/NavigationToolbar.css +51 -0
  32. package/dist/lib/navigationboard/NavigationToolbar.d.ts +41 -0
  33. package/dist/lib/navigationboard/NavigationToolbar.js +124 -0
  34. package/dist/lib/navigationboard/NavigationToolbar.js.map +1 -0
  35. package/doc_src/demo/PageChessboardMove.tsx +17 -0
  36. package/doc_src/demo/PageNavigationBoardBase.tsx +194 -0
  37. package/doc_src/demo/PageNavigationBoardUncontrolledVsControlled.tsx +114 -0
  38. package/doc_src/demo/game-3.pgn +10 -0
  39. package/doc_src/examples/Movetext.md +1 -1
  40. package/doc_src/examples/NavigationBoard.md +15 -0
  41. package/package.json +16 -16
  42. package/scripts/doc.styleguide.config.js +12 -2
  43. package/scripts/docker-compose.yml +1 -1
  44. package/src/chessboard/BoardProperties.ts +131 -0
  45. package/src/chessboard/Chessboard.tsx +41 -170
  46. package/src/errorbox/parsing.tsx +158 -0
  47. package/src/i18n.ts +7 -0
  48. package/src/index.ts +5 -1
  49. package/src/movetext/Movetext.css +0 -13
  50. package/src/movetext/Movetext.tsx +20 -85
  51. package/src/movetext/MovetextImpl.tsx +28 -115
  52. package/src/navigationboard/NavigationBoard.tsx +231 -0
  53. package/src/navigationboard/NavigationField.css +36 -0
  54. package/src/navigationboard/NavigationField.tsx +185 -0
  55. package/src/navigationboard/NavigationToolbar.css +51 -0
  56. package/src/navigationboard/NavigationToolbar.tsx +174 -0
  57. package/test/05_chessboard_graphic.js +2 -0
  58. package/test/09_chessboard_small_screens.js +21 -0
  59. package/test/10_movetext_graphic.js +5 -0
  60. package/test/11_movetext_interaction.js +12 -8
  61. package/test/12_navigation_board.js +168 -0
  62. package/test/graphic_references/05_chessboard_graphic/move/illegal_null-move.png +0 -0
  63. package/test/graphic_references/05_chessboard_graphic/move/null-move.png +0 -0
  64. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_bottom_component.png +0 -0
  65. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_top_component.png +0 -0
  66. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_bottom_component.png +0 -0
  67. package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_top_component.png +0 -0
  68. package/test/graphic_references/10_movetext_graphic/format_move/format_text.png +0 -0
  69. package/test/graphic_references/10_movetext_graphic/options/wrong_piece_symbol_value.png +0 -0
  70. package/test/graphic_references/11_movetext_interaction/select_moves/click_on_unselected_without_callback.png +0 -0
  71. package/test/graphic_references/12_navigation_board/controlled/default.png +0 -0
  72. package/test/graphic_references/12_navigation_board/controlled/forbidden_navigation_0.png +0 -0
  73. package/test/graphic_references/12_navigation_board/controlled/forbidden_navigation_1.png +0 -0
  74. package/test/graphic_references/12_navigation_board/controlled/invalid_node_id.png +0 -0
  75. package/test/graphic_references/12_navigation_board/controlled/no_callback_defined_0.png +0 -0
  76. package/test/graphic_references/12_navigation_board/controlled/no_callback_defined_1.png +0 -0
  77. package/test/graphic_references/12_navigation_board/controlled/overriding_initial_node_id.png +0 -0
  78. package/test/graphic_references/12_navigation_board/controlled/regular_navigation_0.png +0 -0
  79. package/test/graphic_references/12_navigation_board/controlled/regular_navigation_1.png +0 -0
  80. package/test/graphic_references/12_navigation_board/controlled/regular_navigation_2.png +0 -0
  81. package/test/graphic_references/12_navigation_board/controlled/regular_navigation_3.png +0 -0
  82. package/test/graphic_references/12_navigation_board/error/pgn_parsing_error.png +0 -0
  83. package/test/graphic_references/12_navigation_board/error/wrong_game_type.png +0 -0
  84. package/test/graphic_references/12_navigation_board/theme/custom_1.png +0 -0
  85. package/test/graphic_references/12_navigation_board/theme/custom_2.png +0 -0
  86. package/test/graphic_references/12_navigation_board/theme/large.png +0 -0
  87. package/test/graphic_references/12_navigation_board/theme/small.png +0 -0
  88. package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_0.png +0 -0
  89. package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_1.png +0 -0
  90. package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_2.png +0 -0
  91. package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_end_0.png +0 -0
  92. package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_end_1.png +0 -0
  93. package/test/graphic_references/12_navigation_board/uncontrolled/forbidden_navigation_at_end_2.png +0 -0
  94. package/test/graphic_references/12_navigation_board/uncontrolled/initial_state_at_end.png +0 -0
  95. package/test/graphic_references/12_navigation_board/uncontrolled/initial_state_at_specific_id.png +0 -0
  96. package/test/graphic_references/12_navigation_board/uncontrolled/initial_state_default.png +0 -0
  97. package/test/graphic_references/12_navigation_board/uncontrolled/initial_state_default_with_game_index.png +0 -0
  98. package/test/graphic_references/12_navigation_board/uncontrolled/initial_state_on_null-move.png +0 -0
  99. package/test/graphic_references/12_navigation_board/uncontrolled/navigation_with_keys_0.png +0 -0
  100. package/test/graphic_references/12_navigation_board/uncontrolled/navigation_with_keys_1.png +0 -0
  101. package/test/graphic_references/12_navigation_board/uncontrolled/navigation_with_keys_2.png +0 -0
  102. package/test/graphic_references/12_navigation_board/uncontrolled/navigation_with_keys_3.png +0 -0
  103. package/test/graphic_references/12_navigation_board/uncontrolled/navigation_with_keys_4.png +0 -0
  104. package/test/graphic_references/12_navigation_board/uncontrolled/regular_flipping_0.png +0 -0
  105. package/test/graphic_references/12_navigation_board/uncontrolled/regular_flipping_1.png +0 -0
  106. package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_0.png +0 -0
  107. package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_1.png +0 -0
  108. package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_2.png +0 -0
  109. package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_3.png +0 -0
  110. package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_4.png +0 -0
  111. package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_5.png +0 -0
  112. package/test/graphic_test_app/05_chessboard_graphic/move.tsx +2 -0
  113. package/test/graphic_test_app/09_chessboard_small_screens/top_bottom_components.tsx +48 -0
  114. package/test/graphic_test_app/10_movetext_graphic/format_move.tsx +31 -0
  115. package/test/graphic_test_app/10_movetext_graphic/options.tsx +1 -0
  116. package/test/graphic_test_app/11_movetext_interaction/select_moves.tsx +1 -0
  117. package/test/graphic_test_app/12_navigation_board/controlled.tsx +43 -0
  118. package/test/graphic_test_app/12_navigation_board/error.tsx +34 -0
  119. package/test/graphic_test_app/12_navigation_board/theme.tsx +38 -0
  120. package/test/graphic_test_app/12_navigation_board/uncontrolled.tsx +56 -0
@@ -0,0 +1,140 @@
1
+ /*!
2
+ * -------------------------------------------------------------------------- *
3
+ * *
4
+ * Kokopu-React - A React-based library of chess-related components. *
5
+ * <https://www.npmjs.com/package/kokopu-react> *
6
+ * Copyright (C) 2021-2024 Yoann Le Montagner <yo35 -at- melix.net> *
7
+ * *
8
+ * Kokopu-React is free software: you can redistribute it and/or *
9
+ * modify it under the terms of the GNU Lesser General Public License *
10
+ * as published by the Free Software Foundation, either version 3 of *
11
+ * the License, or (at your option) any later version. *
12
+ * *
13
+ * Kokopu-React is distributed in the hope that it will be useful, *
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16
+ * GNU Lesser General Public License for more details. *
17
+ * *
18
+ * You should have received a copy of the GNU Lesser General *
19
+ * Public License along with this program. If not, see *
20
+ * <http://www.gnu.org/licenses/>. *
21
+ * *
22
+ * -------------------------------------------------------------------------- */
23
+ import * as React from 'react';
24
+ import { exception as kokopuException, i18n as kokopuI18n, Database, Game, MoveDescriptor, Position, isGameVariant, pgnRead } from 'kokopu';
25
+ import { IllegalArgument } from '../exception';
26
+ import { i18n } from '../i18n';
27
+ import { ErrorBox } from './ErrorBox';
28
+ /**
29
+ * Try to interpret the given object as a chess position.
30
+ */
31
+ export function parsePosition(position, componentName) {
32
+ if (position instanceof Position) {
33
+ return { error: false, position: position };
34
+ }
35
+ else if (position === 'start' || position === 'empty') {
36
+ return { error: false, position: new Position(position) };
37
+ }
38
+ else if (typeof position === 'string') {
39
+ try {
40
+ const { variant, fen } = splitGameVariantAndFEN(position);
41
+ const result = new Position(variant, 'empty');
42
+ result.fen(fen);
43
+ return { error: false, position: result };
44
+ }
45
+ catch (e) {
46
+ // istanbul ignore else
47
+ if (e instanceof kokopuException.InvalidFEN) {
48
+ return { error: true, errorBox: React.createElement(ErrorBox, { title: i18n.INVALID_FEN_ERROR_TITLE, message: e.message }) };
49
+ }
50
+ else {
51
+ throw e;
52
+ }
53
+ }
54
+ }
55
+ else {
56
+ throw new IllegalArgument(componentName, 'position');
57
+ }
58
+ }
59
+ /**
60
+ * Look for an optional 'chess-variant:' prefix in the position attribute.
61
+ */
62
+ function splitGameVariantAndFEN(position) {
63
+ const separatorIndex = position.indexOf(':');
64
+ if (separatorIndex < 0) {
65
+ return { variant: 'regular', fen: position };
66
+ }
67
+ const variant = position.substring(0, separatorIndex);
68
+ return isGameVariant(variant) ? { variant: variant, fen: position.substring(separatorIndex + 1) } : { variant: 'regular', fen: position };
69
+ }
70
+ /**
71
+ * Try to interpret the given object `move` as a move descriptor based on the given position.
72
+ */
73
+ export function parseMove(position, move, componentName) {
74
+ if (move === undefined || move === null) {
75
+ return { error: false, type: 'none' };
76
+ }
77
+ else if (move instanceof MoveDescriptor) {
78
+ return { error: false, type: 'regular', move: move };
79
+ }
80
+ else if (typeof move === 'string') {
81
+ if (move === '--') {
82
+ if (position.isNullMoveLegal()) {
83
+ return { error: false, type: 'null-move' };
84
+ }
85
+ else {
86
+ return { error: true, errorBox: React.createElement(ErrorBox, { title: i18n.INVALID_NOTATION_ERROR_TITLE, message: kokopuI18n.ILLEGAL_NULL_MOVE }) };
87
+ }
88
+ }
89
+ else {
90
+ try {
91
+ return { error: false, type: 'regular', move: position.notation(move) };
92
+ }
93
+ catch (e) {
94
+ // istanbul ignore else
95
+ if (e instanceof kokopuException.InvalidNotation) {
96
+ return { error: true, errorBox: React.createElement(ErrorBox, { title: i18n.INVALID_NOTATION_ERROR_TITLE, message: e.message }) };
97
+ }
98
+ else {
99
+ throw e;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ else {
105
+ throw new IllegalArgument(componentName, 'move');
106
+ }
107
+ }
108
+ /**
109
+ * Try to interpret the given object as a chess game.
110
+ */
111
+ export function parseGame(game, gameIndex, componentName) {
112
+ if (game instanceof Game) {
113
+ return { error: false, game: game };
114
+ }
115
+ else if (game instanceof Database || typeof game === 'string') {
116
+ if (!Number.isInteger(gameIndex) || gameIndex < 0) {
117
+ throw new IllegalArgument(componentName, 'gameIndex');
118
+ }
119
+ try {
120
+ const result = game instanceof Database ? game.game(gameIndex) : pgnRead(game, gameIndex);
121
+ return { error: false, game: result };
122
+ }
123
+ catch (e) {
124
+ // istanbul ignore else
125
+ if (e instanceof kokopuException.InvalidPGN) {
126
+ return {
127
+ error: true,
128
+ errorBox: React.createElement(ErrorBox, { title: i18n.INVALID_PGN_ERROR_TITLE, message: e.message, text: e.pgn, errorIndex: e.index, lineNumber: e.lineNumber }),
129
+ };
130
+ }
131
+ else {
132
+ throw e;
133
+ }
134
+ }
135
+ }
136
+ else {
137
+ throw new IllegalArgument(componentName, 'game');
138
+ }
139
+ }
140
+ //# sourceMappingURL=parsing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsing.js","sourceRoot":"","sources":["../../../src/errorbox/parsing.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAGhF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,IAAI,IAAI,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAe,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEzJ,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;GA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AS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YAC1F,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACvC,CAAC;QACD,OAAO,CAAC,EAAE,CAAC;YACV,uBAAuB;YACvB,IAAI,CAAC,YAAY,eAAe,CAAC,UAAU,EAAE,CAAC;gBAC7C,OAAO;oBACN,KAAK,EAAE,IAAI;oBACX,QAAQ,EAAE,oBAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,CAAC,uBAAuB,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,GAAI;iBAC3I,CAAC;YACH,CAAC;iBACI,CAAC;gBACL,MAAM,CAAC,CAAC;YACT,CAAC;QACF,CAAC;IACF,CAAC;SACI,CAAC;QACL,MAAM,IAAI,eAAe,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;AACF,CAAC"}
@@ -27,6 +27,11 @@ export declare namespace i18n {
27
27
  let LINE: string;
28
28
  let INVALID_FEN_ERROR_TITLE: string;
29
29
  let INVALID_NOTATION_ERROR_TITLE: string;
30
+ let TOOLTIP_GO_FIRST: string;
31
+ let TOOLTIP_GO_PREVIOUS: string;
32
+ let TOOLTIP_GO_NEXT: string;
33
+ let TOOLTIP_GO_LAST: string;
34
+ let TOOLTIP_FLIP: string;
30
35
  let PIECE_SYMBOLS: {
31
36
  K: string;
32
37
  Q: string;
package/dist/lib/i18n.js CHANGED
@@ -32,6 +32,12 @@ export var i18n;
32
32
  // Chessboard
33
33
  i18n.INVALID_FEN_ERROR_TITLE = 'Invalid FEN string.';
34
34
  i18n.INVALID_NOTATION_ERROR_TITLE = 'Invalid move notation.';
35
+ // Navigation board
36
+ i18n.TOOLTIP_GO_FIRST = 'Go to the beginning of the game';
37
+ i18n.TOOLTIP_GO_PREVIOUS = 'Go to the previous move';
38
+ i18n.TOOLTIP_GO_NEXT = 'Go to the next move';
39
+ i18n.TOOLTIP_GO_LAST = 'Go to the end of the game';
40
+ i18n.TOOLTIP_FLIP = 'Flip the board';
35
41
  // Movetext
36
42
  i18n.PIECE_SYMBOLS = { 'K': 'K', 'Q': 'Q', 'R': 'R', 'B': 'B', 'N': 'N', 'P': 'P' };
37
43
  i18n.ANNOTATED_BY = 'Annotated by {0}';
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAGhF;;GAEG;AACH,MAAM,KAAW,IAAI,CAiBpB;AAjBD,WAAiB,IAAI;IAErB,iCAAiC;IACjC,0HAA0H;IAE1H,YAAY;IACD,SAAI,GAAG,UAAU,CAAC;IAE7B,aAAa;IACF,4BAAuB,GAAG,qBAAqB,CAAC;IAChD,iCAA4B,GAAG,wBAAwB,CAAC;IAEnE,WAAW;IACA,kBAAa,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,CAAC;IACzE,iBAAY,GAAG,kBAAkB,CAAC;IAClC,4BAAuB,GAAG,qBAAqB,CAAC;AAE3D,CAAC,EAjBgB,IAAI,KAAJ,IAAI,QAiBpB"}
1
+ {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAGhF;;GAEG;AACH,MAAM,KAAW,IAAI,CAwBpB;AAxBD,WAAiB,IAAI;IAErB,iCAAiC;IACjC,0HAA0H;IAE1H,YAAY;IACD,SAAI,GAAG,UAAU,CAAC;IAE7B,aAAa;IACF,4BAAuB,GAAG,qBAAqB,CAAC;IAChD,iCAA4B,GAAG,wBAAwB,CAAC;IAEnE,mBAAmB;IACR,qBAAgB,GAAG,iCAAiC,CAAC;IACrD,wBAAmB,GAAG,yBAAyB,CAAC;IAChD,oBAAe,GAAG,qBAAqB,CAAC;IACxC,oBAAe,GAAG,2BAA2B,CAAC;IAC9C,iBAAY,GAAG,gBAAgB,CAAC;IAE3C,WAAW;IACA,kBAAa,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,GAAG,EAAC,GAAG,EAAE,CAAC;IACzE,iBAAY,GAAG,kBAAkB,CAAC;IAClC,4BAAuB,GAAG,qBAAqB,CAAC;AAE3D,CAAC,EAxBgB,IAAI,KAAJ,IAAI,QAwBpB"}
@@ -28,6 +28,9 @@ 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 { firstNodeId, previousNodeId, nextNodeId, lastNodeId } from './navigationboard/NavigationField';
36
+ export { NavigationBoard, NavigationBoardProps } from './navigationboard/NavigationBoard';
package/dist/lib/index.js CHANGED
@@ -31,4 +31,6 @@ 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 { firstNodeId, previousNodeId, nextNodeId, lastNodeId } from './navigationboard/NavigationField';
35
+ export { NavigationBoard } from './navigationboard/NavigationBoard';
34
36
  //# 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,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAqC,MAAM,yBAAyB,CAAC;AAExF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAwC,MAAM,qBAAqB,CAAC"}
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,CAAC;AAG7E,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAwC,MAAM,qBAAqB,CAAC;AAErF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACxG,OAAO,EAAE,eAAe,EAAwB,MAAM,mCAAmC,CAAC"}
@@ -108,16 +108,3 @@ div.kokopu-subVariation {
108
108
  text-decoration: underline;
109
109
  cursor: pointer;
110
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 */
123
- }
@@ -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;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAGhF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIpF,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEnH,OAAO,gBAAgB,CAAC;AAmFxB;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK,CAAC,SAAwB;IAA5D;;QAWS,YAAO,GAAkC,KAAK,CAAC,SAAS,EAAE,CAAC;IAmHpE,CAAC;IAjHA,MAAM;QAEL,+CAA+C;QAC/C,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC9D,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,CACN,oBAAC,Q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AC;IACzC,CAAC;IAED;;OAEG;IACH,uBAAuB;IACvB,MAAM,CAAC,cAAc,CAAC,IAAU,EAAE,SAAiB;QAClD,OAAO,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,uBAAuB;IACvB,MAAM,CAAC,UAAU,CAAC,IAAU,EAAE,SAAiB;QAC9C,OAAO,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,uBAAuB;IACvB,MAAM,CAAC,UAAU,CAAC,IAAU,EAAE,SAAiB;QAC9C,OAAO,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACxC,CAAC;;AA9FM,qBAAY,GAAG;IACrB,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;CACnB,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 {};