kokopu-react 3.1.0 → 3.3.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.
- package/.eslintrc.yml +1 -1
- package/CHANGELOG.md +10 -0
- package/dist/lib/chessboard/BoardProperties.js.map +1 -1
- package/dist/lib/chessboard/Chessboard.css +13 -13
- package/dist/lib/chessboard/Chessboard.d.ts +27 -2
- package/dist/lib/chessboard/Chessboard.js +36 -17
- package/dist/lib/chessboard/Chessboard.js.map +1 -1
- package/dist/lib/chessboard/ChessboardImpl.js.map +1 -1
- package/dist/lib/chessboard/Draggable.js.map +1 -1
- package/dist/lib/chessboard/Motion.js.map +1 -1
- package/dist/lib/chessboard/colorsets.js.map +1 -1
- package/dist/lib/chessboard/piecesets.js.map +1 -1
- package/dist/lib/errorbox/ErrorBox.css +18 -18
- package/dist/lib/errorbox/ErrorBox.js.map +1 -1
- package/dist/lib/errorbox/parsing.js.map +1 -1
- package/dist/lib/exception.js.map +1 -1
- package/dist/lib/i18n.d.ts +1 -0
- package/dist/lib/i18n.js +1 -0
- package/dist/lib/i18n.js.map +1 -1
- package/dist/lib/icons/AnnotationSymbolShape.css +6 -6
- package/dist/lib/icons/AnnotationSymbolShape.js.map +1 -1
- package/dist/lib/icons/ArrowMarkerIcon.js.map +1 -1
- package/dist/lib/icons/ArrowTip.js.map +1 -1
- package/dist/lib/icons/ChessPieceIcon.js.map +1 -1
- package/dist/lib/icons/SquareMarkerIcon.js.map +1 -1
- package/dist/lib/icons/TextMarkerIcon.js.map +1 -1
- package/dist/lib/icons/arrow.css +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/movetext/Movetext.css +27 -27
- package/dist/lib/movetext/Movetext.js.map +1 -1
- package/dist/lib/movetext/MovetextImpl.js.map +1 -1
- package/dist/lib/movetext/fonts.css +7 -7
- package/dist/lib/movetext/htmlFilter.js.map +1 -1
- package/dist/lib/movetext/moveFormatter.js.map +1 -1
- package/dist/lib/navigationboard/NavigationBoard.d.ts +68 -1
- package/dist/lib/navigationboard/NavigationBoard.js +141 -13
- package/dist/lib/navigationboard/NavigationBoard.js.map +1 -1
- package/dist/lib/navigationboard/NavigationButton.d.ts +66 -0
- package/dist/lib/navigationboard/NavigationButton.js +67 -0
- package/dist/lib/navigationboard/NavigationButton.js.map +1 -0
- package/dist/lib/navigationboard/NavigationField.css +7 -7
- package/dist/lib/navigationboard/NavigationField.js.map +1 -1
- package/dist/lib/navigationboard/NavigationToolbar.css +16 -13
- package/dist/lib/navigationboard/NavigationToolbar.d.ts +10 -10
- package/dist/lib/navigationboard/NavigationToolbar.js +61 -79
- package/dist/lib/navigationboard/NavigationToolbar.js.map +1 -1
- package/dist/lib/navigationboard/iconPaths.d.ts +29 -0
- package/dist/lib/navigationboard/iconPaths.js +91 -0
- package/dist/lib/navigationboard/iconPaths.js.map +1 -0
- package/dist/lib/sanitization.js.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/util.js.map +1 -1
- package/doc_src/demo/PageChessboardBase.tsx +115 -115
- package/doc_src/demo/PageChessboardInteraction.tsx +303 -303
- package/doc_src/demo/PageChessboardMove.tsx +173 -173
- package/doc_src/demo/PageChessboardSmallScreens.tsx +94 -94
- package/doc_src/demo/PageMovetextBase.tsx +180 -180
- package/doc_src/demo/PageMovetextInteraction.tsx +123 -123
- package/doc_src/demo/PageNavigationBoardBase.tsx +144 -137
- package/doc_src/demo/PageNavigationBoardUncontrolledVsControlled.tsx +69 -69
- package/doc_src/demo/decs.d.ts +4 -4
- package/doc_src/demo/demo.css +12 -12
- package/doc_src/demo/util.ts +1 -1
- package/doc_src/examples/NavigationBoard.md +1 -1
- package/doc_src/theming/LogoRenderer.js +13 -13
- package/doc_src/theming/theming.css +5 -5
- package/package.json +95 -95
- package/scripts/doc.styleguide.config.js +131 -131
- package/scripts/doc.tsconfig.json +5 -5
- package/scripts/docker-compose.yml +1 -1
- package/scripts/test-graphic.tsconfig.json +5 -5
- package/scripts/test-graphic.webpack.config.js +57 -57
- package/scripts/test-headless.webpack.config.js +29 -29
- package/src/chessboard/BoardProperties.ts +68 -68
- package/src/chessboard/Chessboard.css +13 -13
- package/src/chessboard/Chessboard.tsx +436 -380
- package/src/chessboard/ChessboardImpl.tsx +557 -557
- package/src/chessboard/Draggable.tsx +185 -185
- package/src/chessboard/Motion.tsx +67 -67
- package/src/chessboard/colorsets.ts +66 -66
- package/src/chessboard/piecesets.ts +84 -84
- package/src/decs.d.ts +2 -2
- package/src/errorbox/ErrorBox.css +18 -18
- package/src/errorbox/ErrorBox.tsx +75 -75
- package/src/errorbox/parsing.tsx +95 -95
- package/src/exception.ts +17 -17
- package/src/i18n.ts +1 -0
- package/src/icons/AnnotationSymbolShape.css +6 -6
- package/src/icons/AnnotationSymbolShape.tsx +31 -31
- package/src/icons/ArrowMarkerIcon.tsx +34 -34
- package/src/icons/ArrowTip.tsx +14 -14
- package/src/icons/ChessPieceIcon.tsx +45 -45
- package/src/icons/SquareMarkerIcon.tsx +20 -20
- package/src/icons/TextMarkerIcon.tsx +29 -29
- package/src/icons/arrow.css +1 -1
- package/src/index.ts +3 -2
- package/src/movetext/Movetext.css +27 -27
- package/src/movetext/Movetext.tsx +158 -158
- package/src/movetext/MovetextImpl.tsx +345 -345
- package/src/movetext/fonts.css +7 -7
- package/src/movetext/htmlFilter.tsx +129 -129
- package/src/movetext/moveFormatter.tsx +37 -37
- package/src/navigationboard/NavigationBoard.tsx +386 -180
- package/src/navigationboard/NavigationButton.ts +114 -0
- package/src/navigationboard/NavigationField.css +7 -7
- package/src/navigationboard/NavigationField.tsx +90 -90
- package/src/navigationboard/NavigationToolbar.css +16 -13
- package/src/navigationboard/NavigationToolbar.tsx +98 -112
- package/src/navigationboard/iconPaths.ts +98 -0
- package/src/sanitization.ts +17 -17
- package/src/types.ts +116 -116
- package/src/util.ts +11 -11
- package/test/01_types.js +167 -167
- package/test/02_chessboard_util.js +191 -115
- package/test/03_error_box_graphic.js +16 -16
- package/test/04_icons_graphic.js +32 -32
- package/test/05_chessboard_graphic.js +60 -60
- package/test/06_chessboard_animation.js +36 -36
- package/test/07_chessboard_interaction.js +101 -101
- package/test/08_chessboard_play_moves.js +62 -62
- package/test/09_chessboard_small_screens.js +32 -32
- package/test/10_movetext_graphic.js +32 -32
- package/test/11_movetext_interaction.js +100 -100
- package/test/12_navigation_board_base.js +151 -0
- package/test/13_navigation_board_graphic.js +68 -0
- package/test/14_navigation_board_autoplay.js +100 -0
- package/test/common/graphic.js +106 -97
- package/test/graphic_references/12_navigation_board_base/controlled/default.png +0 -0
- package/test/graphic_references/{12_navigation_board/controlled/forbidden_navigation_1.png → 12_navigation_board_base/controlled/forbidden_navigation_0.png} +0 -0
- package/test/graphic_references/{12_navigation_board/controlled/invalid_node_id.png → 12_navigation_board_base/controlled/forbidden_navigation_1.png} +0 -0
- package/test/graphic_references/{12_navigation_board/controlled/forbidden_navigation_0.png → 12_navigation_board_base/controlled/invalid_node_id.png} +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_0.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/controlled/no_callback_defined_1.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/controlled/overriding_initial_node_id.png +0 -0
- package/test/graphic_references/{12_navigation_board/controlled/regular_navigation_1.png → 12_navigation_board_base/controlled/regular_navigation_0.png} +0 -0
- package/test/graphic_references/{12_navigation_board/uncontrolled/initial_state_at_specific_id.png → 12_navigation_board_base/controlled/regular_navigation_1.png} +0 -0
- package/test/graphic_references/{12_navigation_board/controlled/regular_navigation_3.png → 12_navigation_board_base/controlled/regular_navigation_2.png} +0 -0
- package/test/graphic_references/{12_navigation_board/controlled/regular_navigation_0.png → 12_navigation_board_base/controlled/regular_navigation_3.png} +0 -0
- package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_2.png → 12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_0.png} +0 -0
- package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_0.png → 12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_1.png} +0 -0
- package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_1.png → 12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_2.png} +0 -0
- package/test/graphic_references/{12_navigation_board/controlled/no_callback_defined_0.png → 12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_0.png} +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_2.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/initial_state_at_end.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_specific_id.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/initial_state_default.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/initial_state_default_with_game_index.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/initial_state_on_null-move.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/navigation_with_keys_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_1.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/navigation_with_keys_2.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/navigation_with_keys_3.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/navigation_with_keys_4.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_flipping_0.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_flipping_1.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_navigation_0.png +0 -0
- package/test/graphic_references/{12_navigation_board/controlled/default.png → 12_navigation_board_base/uncontrolled/regular_navigation_1.png} +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_navigation_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_3.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_navigation_4.png +0 -0
- package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_navigation_5.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_1.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_2.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/multiple_buttons.png +0 -0
- package/test/graphic_references/{12_navigation_board/uncontrolled/regular_navigation_3.png → 13_navigation_board_graphic/additional_buttons/single_button.png} +0 -0
- package/test/graphic_references/{12_navigation_board → 13_navigation_board_graphic}/theme/custom_1.png +0 -0
- package/test/graphic_references/{12_navigation_board → 13_navigation_board_graphic}/theme/custom_2.png +0 -0
- package/test/graphic_references/{12_navigation_board → 13_navigation_board_graphic}/theme/large.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/small.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_not_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_not_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_end_1.png → 14_navigation_board_autoplay/controlled/after_reaching_the_end.png} +0 -0
- package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_end_2.png → 14_navigation_board_autoplay/controlled/already_at_the_end.png} +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_end_0.png → 14_navigation_board_autoplay/controlled/initial_state_at_the_end.png} +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_close_to_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_after_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_before_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_after_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_before_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_close_to_end.png +0 -0
- package/test/graphic_references/{12_navigation_board/uncontrolled/navigation_with_keys_1.png → 14_navigation_board_autoplay/uncontrolled/initial_state_default.png} +0 -0
- package/test/graphic_test_app/03_error_box_graphic/base.tsx +14 -14
- package/test/graphic_test_app/03_error_box_graphic/localization.tsx +1 -1
- package/test/graphic_test_app/04_icons_graphic/chess_piece.tsx +7 -7
- package/test/graphic_test_app/04_icons_graphic/marker.tsx +15 -15
- package/test/graphic_test_app/05_chessboard_graphic/annotations.tsx +7 -7
- package/test/graphic_test_app/05_chessboard_graphic/base.tsx +6 -6
- package/test/graphic_test_app/05_chessboard_graphic/chess_variants.tsx +7 -7
- package/test/graphic_test_app/05_chessboard_graphic/flipped.tsx +5 -5
- package/test/graphic_test_app/05_chessboard_graphic/move.tsx +12 -12
- package/test/graphic_test_app/05_chessboard_graphic/theme.tsx +12 -12
- package/test/graphic_test_app/06_chessboard_animation/base_1.tsx +6 -6
- package/test/graphic_test_app/06_chessboard_animation/base_2.tsx +6 -6
- package/test/graphic_test_app/06_chessboard_animation/base_3.tsx +6 -6
- package/test/graphic_test_app/06_chessboard_animation/on_redraw.tsx +16 -16
- package/test/graphic_test_app/07_chessboard_interaction/click_squares.tsx +5 -5
- package/test/graphic_test_app/07_chessboard_interaction/edit_arrows.tsx +4 -4
- package/test/graphic_test_app/07_chessboard_interaction/error.tsx +2 -2
- package/test/graphic_test_app/07_chessboard_interaction/move_pieces.tsx +5 -5
- package/test/graphic_test_app/08_chessboard_play_moves/base.tsx +8 -8
- package/test/graphic_test_app/08_chessboard_play_moves/promotions.tsx +4 -4
- package/test/graphic_test_app/09_chessboard_small_screens/base.tsx +9 -9
- package/test/graphic_test_app/09_chessboard_small_screens/top_bottom_components.tsx +9 -9
- package/test/graphic_test_app/10_movetext_graphic/base.tsx +4 -4
- package/test/graphic_test_app/10_movetext_graphic/error.tsx +6 -6
- package/test/graphic_test_app/10_movetext_graphic/format_move.tsx +1 -1
- package/test/graphic_test_app/10_movetext_graphic/html.tsx +5 -5
- package/test/graphic_test_app/10_movetext_graphic/options.tsx +10 -10
- package/test/graphic_test_app/11_movetext_interaction/error.tsx +1 -1
- package/test/graphic_test_app/11_movetext_interaction/select_moves.tsx +11 -11
- package/test/graphic_test_app/{12_navigation_board → 12_navigation_board_base}/controlled.tsx +5 -5
- package/test/graphic_test_app/{12_navigation_board → 12_navigation_board_base}/uncontrolled.tsx +7 -7
- package/test/graphic_test_app/13_navigation_board_graphic/additional_buttons.tsx +49 -0
- package/test/graphic_test_app/{12_navigation_board → 13_navigation_board_graphic}/error.tsx +2 -2
- package/test/graphic_test_app/{12_navigation_board → 13_navigation_board_graphic}/theme.tsx +4 -4
- package/test/graphic_test_app/14_navigation_board_autoplay/controlled.tsx +73 -0
- package/test/graphic_test_app/14_navigation_board_autoplay/uncontrolled.tsx +34 -0
- package/test/graphic_test_app/common/decs.d.ts +2 -2
- package/test/graphic_test_app/common/test_app.css +15 -15
- package/test/graphic_test_app/common/test_app.tsx +48 -48
- package/tsconfig.json +13 -13
- package/test/12_navigation_board.js +0 -168
- package/test/graphic_references/12_navigation_board/controlled/regular_navigation_2.png +0 -0
- package/test/graphic_references/12_navigation_board/theme/small.png +0 -0
- package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_1.png +0 -0
- /package/test/graphic_references/{12_navigation_board → 13_navigation_board_graphic}/error/pgn_parsing_error.png +0 -0
- /package/test/graphic_references/{12_navigation_board → 13_navigation_board_graphic}/error/wrong_game_type.png +0 -0
|
@@ -48,147 +48,154 @@ const COLOR_ICON_SIZE = 16;
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
interface PageState {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
squareSize: number;
|
|
52
|
+
coordinateVisible: boolean;
|
|
53
|
+
turnVisible: boolean;
|
|
54
|
+
colorset: string;
|
|
55
|
+
pieceset: string;
|
|
56
|
+
moveArrowVisible: boolean;
|
|
57
|
+
moveArrowColor: AnnotationColor;
|
|
58
|
+
animated: boolean;
|
|
59
|
+
playButtonVisible: boolean;
|
|
60
|
+
flipButtonVisible: boolean;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
|
|
63
64
|
export default class Page extends React.Component<object, PageState> {
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
66
|
+
constructor(props: object) {
|
|
67
|
+
super(props);
|
|
68
|
+
this.state = {
|
|
69
|
+
squareSize: 40,
|
|
70
|
+
coordinateVisible: true,
|
|
71
|
+
turnVisible: true,
|
|
72
|
+
colorset: 'original',
|
|
73
|
+
pieceset: 'cburnett',
|
|
74
|
+
moveArrowVisible: true,
|
|
75
|
+
moveArrowColor: 'b',
|
|
76
|
+
animated: true,
|
|
77
|
+
playButtonVisible: true,
|
|
78
|
+
flipButtonVisible: true,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
render() {
|
|
83
|
+
return (
|
|
84
|
+
<Stack spacing={2} mt={2}>
|
|
85
|
+
{this.renderControls()}
|
|
86
|
+
{this.renderNavigationBoard()}
|
|
87
|
+
{this.renderCode()}
|
|
88
|
+
</Stack>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private renderControls() {
|
|
93
|
+
return (<>
|
|
94
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
95
|
+
<FormControlLabel label="Show play/stop button"
|
|
96
|
+
control={<Switch checked={this.state.playButtonVisible} onChange={() => this.setState({ playButtonVisible: !this.state.playButtonVisible })} color="primary" />}
|
|
97
|
+
/>
|
|
98
|
+
<FormControlLabel label="Show flip button"
|
|
99
|
+
control={<Switch checked={this.state.flipButtonVisible} onChange={() => this.setState({ flipButtonVisible: !this.state.flipButtonVisible })} color="primary" />}
|
|
100
|
+
/>
|
|
101
|
+
<FormControlLabel label="Show coordinates"
|
|
102
|
+
control={<Switch checked={this.state.coordinateVisible} onChange={() => this.setState({ coordinateVisible: !this.state.coordinateVisible })} color="primary" />}
|
|
103
|
+
/>
|
|
104
|
+
<FormControlLabel label="Show turn"
|
|
105
|
+
control={<Switch checked={this.state.turnVisible} onChange={() => this.setState({ turnVisible: !this.state.turnVisible })} color="primary" />}
|
|
106
|
+
/>
|
|
107
|
+
<FormControlLabel label="Animated"
|
|
108
|
+
control={<Switch checked={this.state.animated} onChange={() => this.setState({ animated: !this.state.animated })} color="primary" />}
|
|
109
|
+
/>
|
|
110
|
+
</Stack>
|
|
111
|
+
<Box>
|
|
112
|
+
<Typography gutterBottom>Square size</Typography>
|
|
113
|
+
<Slider
|
|
114
|
+
value={this.state.squareSize} onChange={(_, newValue) => this.setState({ squareSize: newValue as number })}
|
|
115
|
+
min={Chessboard.minSquareSize()} max={Chessboard.maxSquareSize()} step={1} valueLabelDisplay="on" color="primary"
|
|
116
|
+
/>
|
|
117
|
+
</Box>
|
|
118
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
119
|
+
<FormControl variant="standard">
|
|
120
|
+
<InputLabel id="colorset-label">Colorset</InputLabel>
|
|
121
|
+
<Select labelId="colorset-label" sx={{ width: '8em' }} value={this.state.colorset} onChange={evt => this.setState({ colorset: evt.target.value })}>
|
|
122
|
+
{Object.keys(Chessboard.colorsets()).sort().map(colorset => <MenuItem key={colorset} value={colorset}>{colorset}</MenuItem>)}
|
|
123
|
+
</Select>
|
|
124
|
+
</FormControl>
|
|
125
|
+
<FormControl variant="standard">
|
|
126
|
+
<InputLabel id="pieceset-label">Pieceset</InputLabel>
|
|
127
|
+
<Select labelId="pieceset-label" sx={{ width: '8em' }} value={this.state.pieceset} onChange={evt => this.setState({ pieceset: evt.target.value })}>
|
|
128
|
+
{Object.keys(Chessboard.piecesets()).sort().map(pieceset => <MenuItem key={pieceset} value={pieceset}>{pieceset}</MenuItem>)}
|
|
129
|
+
</Select>
|
|
130
|
+
</FormControl>
|
|
131
|
+
<FormControlLabel label="Show move arrow"
|
|
132
|
+
control={<Switch checked={this.state.moveArrowVisible} onChange={() => this.setState({ moveArrowVisible: !this.state.moveArrowVisible })} color="primary" />}
|
|
133
|
+
/>
|
|
134
|
+
{this.renderMoveArrowColorSelector()}
|
|
135
|
+
</Stack>
|
|
136
|
+
</>);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private renderMoveArrowColorSelector() {
|
|
140
|
+
if (!this.state.moveArrowVisible) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
const colorset = Chessboard.colorsets()['original'];
|
|
144
|
+
return (
|
|
145
|
+
<ToggleButtonGroup value={this.state.moveArrowColor} exclusive size="small" onChange={(_, newColor) => this.handleMoveArrowColorChanged(newColor)}>
|
|
146
|
+
<ToggleButton value="b"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cb} /></ToggleButton>
|
|
147
|
+
<ToggleButton value="g"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cg} /></ToggleButton>
|
|
148
|
+
<ToggleButton value="r"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cr} /></ToggleButton>
|
|
149
|
+
<ToggleButton value="y"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cy} /></ToggleButton>
|
|
150
|
+
</ToggleButtonGroup>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private renderNavigationBoard() {
|
|
155
|
+
return (
|
|
156
|
+
<Box>
|
|
157
|
+
<NavigationBoard
|
|
158
|
+
game={pgn}
|
|
159
|
+
initialNodeId="end"
|
|
160
|
+
squareSize={this.state.squareSize}
|
|
161
|
+
coordinateVisible={this.state.coordinateVisible}
|
|
162
|
+
turnVisible={this.state.turnVisible}
|
|
163
|
+
colorset={this.state.colorset}
|
|
164
|
+
pieceset={this.state.pieceset}
|
|
165
|
+
moveArrowVisible={this.state.moveArrowVisible}
|
|
166
|
+
moveArrowColor={this.state.moveArrowColor}
|
|
167
|
+
animated={this.state.animated}
|
|
168
|
+
playButtonVisible={this.state.playButtonVisible}
|
|
169
|
+
flipButtonVisible={this.state.flipButtonVisible}
|
|
170
|
+
/>
|
|
171
|
+
</Box>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private renderCode() {
|
|
176
|
+
const attributes: string[] = [];
|
|
177
|
+
attributes.push('game={pgn}');
|
|
178
|
+
attributes.push('initialNodeId="end"');
|
|
179
|
+
attributes.push(`squareSize={${this.state.squareSize}}`);
|
|
180
|
+
attributes.push(`coordinateVisible={${this.state.coordinateVisible}}`);
|
|
181
|
+
attributes.push(`turnVisible={${this.state.turnVisible}}`);
|
|
182
|
+
attributes.push(`colorset="${this.state.colorset}"`);
|
|
183
|
+
attributes.push(`pieceset="${this.state.pieceset}"`);
|
|
184
|
+
attributes.push(`moveArrowVisible={${this.state.moveArrowVisible}}`);
|
|
185
|
+
if (this.state.moveArrowVisible) {
|
|
186
|
+
attributes.push(`moveArrowColor="${this.state.moveArrowColor}"`);
|
|
187
|
+
}
|
|
188
|
+
attributes.push(`animated={${this.state.animated}}`);
|
|
189
|
+
attributes.push(`playButtonVisible={${this.state.playButtonVisible}}`);
|
|
190
|
+
attributes.push(`flipButtonVisible={${this.state.flipButtonVisible}}`);
|
|
191
|
+
const pgnDeclaration = 'const pgn = `\n' + pgn.trim() + '`;\n\n';
|
|
192
|
+
return <pre className="kokopu-demoCode">{pgnDeclaration + buildComponentDemoCode('NavigationBoard', attributes)}</pre>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private handleMoveArrowColorChanged(newColor: AnnotationColor | null) {
|
|
196
|
+
if (newColor !== null) {
|
|
197
|
+
this.setState({ moveArrowColor: newColor });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
193
200
|
|
|
194
201
|
}
|
|
@@ -36,79 +36,79 @@ import pgn from './game-3.pgn';
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
interface PageState {
|
|
39
|
-
|
|
39
|
+
nodeId: string;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
export default class Page extends React.Component<object, PageState> {
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
45
|
+
constructor(props: object) {
|
|
46
|
+
super(props);
|
|
47
|
+
this.state = {
|
|
48
|
+
nodeId: '9b',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
return (
|
|
54
|
+
<Stack spacing={2} mt={2}>
|
|
55
|
+
{this.renderControls()}
|
|
56
|
+
{this.renderNavigationBoards()}
|
|
57
|
+
{this.renderCode()}
|
|
58
|
+
</Stack>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private renderControls() {
|
|
63
|
+
return (<>
|
|
64
|
+
<Typography>
|
|
65
|
+
In uncontrolled mode, the current node ID (aka. the current move) of the <code>NavigationBoard</code> component is managed internally.
|
|
66
|
+
No additional code is needed to make the navigation buttons work.
|
|
67
|
+
</Typography>
|
|
68
|
+
<Typography>
|
|
69
|
+
In controlled mode, the current node ID is defined by the <code>nodeId</code> attribute, and a callback must be set
|
|
70
|
+
on the <code>onNodeIdChanged</code> attribute to respond to clicks on the navigation buttons.
|
|
71
|
+
This mode requires more code, as a state variable holding the current node ID must be explicitely managed out of the component,
|
|
72
|
+
but it allows to define more complex behaviors (e.g. synchronizing the node ID on the <code>NavigationBoard</code> with another component).
|
|
73
|
+
</Typography>
|
|
74
|
+
<Typography>
|
|
75
|
+
Whether the component is in uncontrolled mode or controlled mode depends on the presence of the <code>nodeId</code> attribute.
|
|
76
|
+
</Typography>
|
|
77
|
+
</>);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private renderNavigationBoards() {
|
|
81
|
+
return (
|
|
82
|
+
<Box display="flex" alignItems="top" justifyContent="space-around">
|
|
83
|
+
<Box>
|
|
84
|
+
<NavigationBoard game={pgn} animated initialNodeId="9b" />
|
|
85
|
+
<Typography mt={2} textAlign="center">Uncontrolled</Typography>
|
|
86
|
+
</Box>
|
|
87
|
+
<Box>
|
|
88
|
+
<NavigationBoard game={pgn} animated nodeId={this.state.nodeId} onNodeIdChanged={nodeId => this.setState({ nodeId: nodeId })} />
|
|
89
|
+
<Typography mt={2} textAlign="center">Controlled</Typography>
|
|
90
|
+
<Typography textAlign="center">{`Current node ID: ${this.state.nodeId}`}</Typography>
|
|
91
|
+
</Box>
|
|
92
|
+
</Box>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private renderCode() {
|
|
97
|
+
|
|
98
|
+
const uncontrolledAttributes: string[] = [];
|
|
99
|
+
uncontrolledAttributes.push('game={pgn}');
|
|
100
|
+
uncontrolledAttributes.push('animated');
|
|
101
|
+
uncontrolledAttributes.push('initialNodeId="9b"');
|
|
102
|
+
|
|
103
|
+
const controlledAttributes: string[] = [];
|
|
104
|
+
controlledAttributes.push('game={pgn}');
|
|
105
|
+
controlledAttributes.push('animated');
|
|
106
|
+
controlledAttributes.push(`nodeId="${this.state.nodeId}"`);
|
|
107
|
+
controlledAttributes.push('onNodeIdChanged={nodeId => handleNodeIdChanged(nodeId)}');
|
|
108
|
+
|
|
109
|
+
const pgnDeclaration = 'const pgn = `\n' + pgn.trim() + '`;\n\n';
|
|
110
|
+
return <pre className="kokopu-demoCode">{pgnDeclaration + '// Uncontrolled\n' + buildComponentDemoCode('NavigationBoard', uncontrolledAttributes)
|
|
111
|
+
+ '\n\n// Controlled\n' + buildComponentDemoCode('NavigationBoard', controlledAttributes)}</pre>;
|
|
112
|
+
}
|
|
113
113
|
|
|
114
114
|
}
|
package/doc_src/demo/decs.d.ts
CHANGED
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
declare module '*.pgn' {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const pgnText: string;
|
|
27
|
+
export default pgnText;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
declare module '*.png' {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const path: string;
|
|
32
|
+
export default path;
|
|
33
33
|
}
|
package/doc_src/demo/demo.css
CHANGED
|
@@ -23,25 +23,25 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
.kokopu-demoCode {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
border: 1px solid rgb(232, 232, 232);
|
|
27
|
+
border-radius: 3px;
|
|
28
|
+
background-color: rgb(245, 245, 245);
|
|
29
|
+
font-size: 13px;
|
|
30
|
+
padding: 16px;
|
|
31
|
+
white-space: pre-wrap;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
.MuiToggleButton-root.kokopu-fixTextTransform {
|
|
35
|
-
|
|
35
|
+
text-transform: none;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
.MuiToggleButton-root.Mui-disabled.kokopu-fixOpacity .kokopu-arrowMarkerIcon {
|
|
39
|
-
|
|
39
|
+
opacity: 0.3;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
.kokopu-fixedPopup {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
position: fixed;
|
|
44
|
+
bottom: 20px;
|
|
45
|
+
right: 20px;
|
|
46
|
+
padding: 10px;
|
|
47
47
|
}
|
package/doc_src/demo/util.ts
CHANGED
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
export function buildComponentDemoCode(componentName: string, attributes: string[]) {
|
|
26
|
-
|
|
26
|
+
return attributes.length === 0 ? `<${componentName} />` : `<${componentName} ${attributes.join(' ')} />`;
|
|
27
27
|
}
|
|
@@ -31,22 +31,22 @@ import './theming.css';
|
|
|
31
31
|
/* eslint-disable react/prop-types */
|
|
32
32
|
|
|
33
33
|
const styles = ({ color, fontFamily, fontSize }) => ({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
logo: {
|
|
35
|
+
color: color.base,
|
|
36
|
+
margin: 0,
|
|
37
|
+
fontFamily: fontFamily.base,
|
|
38
|
+
fontSize: fontSize.h4,
|
|
39
|
+
fontWeight: 'normal',
|
|
40
|
+
},
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
function LogoRenderer({ classes, children }) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
return (<>
|
|
45
|
+
<div className="kokopu-logo">
|
|
46
|
+
<img src="kokopu-react-logo.png" />
|
|
47
|
+
</div>
|
|
48
|
+
<h1 className={classes.logo}>{children}</h1>
|
|
49
|
+
</>);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export default Styled(styles)(LogoRenderer);
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
.kokopu-logo {
|
|
26
|
-
|
|
26
|
+
text-align: center;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
footer {
|
|
30
|
-
|
|
30
|
+
display: none !important;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
#changelog h2 {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
font-size: inherit;
|
|
35
|
+
font-weight: bold;
|
|
36
|
+
margin-top: 24px;
|
|
37
37
|
}
|