kokopu-react 1.2.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/lib/ArrowMarkerIcon.js +5 -7
- package/dist/lib/Chessboard.js +27 -33
- package/dist/lib/{impl/ErrorBox.js → ErrorBox.js} +2 -2
- package/dist/lib/SquareMarkerIcon.js +1 -1
- package/dist/lib/TextMarkerIcon.js +12 -11
- package/dist/lib/css/arrow.css +1 -1
- package/dist/lib/css/chessboard.css +1 -1
- package/dist/lib/css/error_box.css +1 -1
- package/dist/lib/css/label.css +1 -1
- package/dist/lib/css/symbol.css +25 -0
- package/dist/lib/i18n.js +35 -0
- package/dist/lib/impl/ArrowTip.js +3 -8
- package/dist/lib/impl/TextSymbol.js +100 -0
- package/dist/lib/impl/colorsets.js +1 -1
- package/dist/lib/impl/piecesets.js +1 -1
- package/dist/lib/impl/util.js +6 -6
- package/dist/lib/index.js +34 -18
- package/dist/lib/markers.js +10 -10
- package/doc_src/{demo/.eslintrc.yml → .eslintrc.yml} +0 -0
- package/doc_src/demo/PageChessboardBase.js +36 -41
- package/doc_src/demo/PageChessboardEdition.js +59 -71
- package/doc_src/demo/PageChessboardMove.js +21 -28
- package/doc_src/demo/PageChessboardSmallScreens.js +16 -17
- package/doc_src/demo/demo.css +1 -1
- package/doc_src/demo/util.js +1 -1
- package/doc_src/examples/ErrorBox.md +3 -0
- package/doc_src/theming/LogoRenderer.js +50 -0
- package/doc_src/theming/kokopu-react-favicon.png +0 -0
- package/doc_src/theming/kokopu-react-logo.png +0 -0
- package/doc_src/theming/theming.css +29 -0
- package/graphic_test_app/01_marker_icons.js +6 -4
- package/graphic_test_app/02_chessboard_simple.js +1 -1
- package/graphic_test_app/03_chessboard_flipped.js +1 -1
- package/graphic_test_app/04_chessboard_annotations.js +2 -2
- package/graphic_test_app/05_chessboard_move.js +1 -1
- package/graphic_test_app/06_chessboard_theme.js +1 -1
- package/graphic_test_app/07_chessboard_click_squares.js +1 -1
- package/graphic_test_app/08_chessboard_move_pieces.js +1 -1
- package/graphic_test_app/09_chessboard_edit_arrows.js +1 -1
- package/graphic_test_app/10_chessboard_play_moves.js +1 -1
- package/graphic_test_app/11_chessboard_play_promotions.js +1 -1
- package/graphic_test_app/common/test_app.css +1 -1
- package/graphic_test_app/common/test_app.js +1 -1
- package/package.json +23 -22
- package/scripts/test_graphic/clean-graphic-output.js +1 -1
- package/scripts/test_graphic/docker-compose.yml +1 -1
- package/scripts/test_graphic/webpack-config.js +2 -1
- package/scripts/test_headless.webpack-config.js +2 -1
- package/src/ArrowMarkerIcon.js +2 -2
- package/src/Chessboard.js +16 -14
- package/src/{impl/ErrorBox.js → ErrorBox.js} +2 -2
- package/src/SquareMarkerIcon.js +1 -1
- package/src/TextMarkerIcon.js +7 -7
- package/src/css/arrow.css +1 -1
- package/src/css/chessboard.css +1 -1
- package/src/css/error_box.css +1 -1
- package/src/css/label.css +1 -1
- package/src/css/symbol.css +25 -0
- package/src/i18n.js +30 -0
- package/src/impl/ArrowTip.js +3 -7
- package/src/impl/TextSymbol.js +77 -0
- package/src/impl/colorsets.js +1 -1
- package/src/impl/piecesets.js +1 -1
- package/src/impl/util.js +2 -2
- package/src/index.js +3 -1
- package/src/markers.js +8 -7
- package/test/1_markers.js +20 -1
- package/test/2_chessboard_util.js +1 -1
- package/test/3_marker_icons_graphic.js +2 -2
- package/test/4_chessboard_graphic.js +1 -1
- package/test/5_chessboard_interaction.js +1 -1
- package/test/6_chessboard_play_moves.js +1 -1
- package/test/common/graphic.js +1 -1
- package/test/references/01_marker_icons/10.png +0 -0
- package/test/references/01_marker_icons/9.png +0 -0
- package/test/references/02_chessboard_simple/2.png +0 -0
- package/test/references/02_chessboard_simple/5.png +0 -0
- package/test/references/03_chessboard_flipped/2.png +0 -0
- package/test/references/04_chessboard_annotations/4.png +0 -0
- package/test/references/04_chessboard_annotations/5.png +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
ChangeLog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
1.4.1 (January 1, 2022)
|
|
5
|
+
-----------------------
|
|
6
|
+
* Upgrade dependencies.
|
|
7
|
+
|
|
8
|
+
1.4.0 (October 21, 2021)
|
|
9
|
+
------------------------
|
|
10
|
+
* Add support for plus/times/dot/circle in text markers.
|
|
11
|
+
|
|
12
|
+
1.3.1 (September 27, 2021)
|
|
13
|
+
--------------------------
|
|
14
|
+
* Fix missing export for `ErrorBox`.
|
|
15
|
+
|
|
16
|
+
1.3.0 (September 26, 2021)
|
|
17
|
+
--------------------------
|
|
18
|
+
* Expose component `ErrorBox`.
|
|
19
|
+
* Minor fixes in documentation.
|
|
20
|
+
|
|
4
21
|
1.2.0 (September 13, 2021)
|
|
5
22
|
--------------------------
|
|
6
23
|
* Fix ambiguous castling move issue at Chess960.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -23,9 +23,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
23
23
|
|
|
24
24
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
25
25
|
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
27
|
|
|
28
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
28
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
29
|
|
|
30
30
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
31
|
|
|
@@ -85,10 +85,8 @@ var ArrowMarkerIcon = /*#__PURE__*/function (_React$Component) {
|
|
|
85
85
|
x2: size - halfThickness * 3,
|
|
86
86
|
y2: size / 2,
|
|
87
87
|
stroke: this.props.color,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'markerEnd': "url(#".concat(this.arrowTipId, ")")
|
|
91
|
-
}
|
|
88
|
+
strokeWidth: halfThickness * 2,
|
|
89
|
+
markerEnd: "url(#".concat(this.arrowTipId, ")")
|
|
92
90
|
}));
|
|
93
91
|
}
|
|
94
92
|
}]);
|
package/dist/lib/Chessboard.js
CHANGED
|
@@ -21,7 +21,11 @@ var _piecesets2 = _interopRequireDefault(require("./impl/piecesets"));
|
|
|
21
21
|
|
|
22
22
|
var _ArrowTip = _interopRequireDefault(require("./impl/ArrowTip"));
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _TextSymbol = _interopRequireDefault(require("./impl/TextSymbol"));
|
|
25
|
+
|
|
26
|
+
var _ErrorBox = _interopRequireDefault(require("./ErrorBox"));
|
|
27
|
+
|
|
28
|
+
var _i18n = _interopRequireDefault(require("./i18n"));
|
|
25
29
|
|
|
26
30
|
var _markers = require("./markers");
|
|
27
31
|
|
|
@@ -35,7 +39,7 @@ require("./css/label.css");
|
|
|
35
39
|
|
|
36
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
37
41
|
|
|
38
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
42
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
39
43
|
|
|
40
44
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
41
45
|
|
|
@@ -53,9 +57,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
53
57
|
|
|
54
58
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
55
59
|
|
|
56
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
60
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
57
61
|
|
|
58
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
62
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
59
63
|
|
|
60
64
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
61
65
|
|
|
@@ -133,12 +137,12 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
133
137
|
|
|
134
138
|
if (info.positionError) {
|
|
135
139
|
return /*#__PURE__*/_react["default"].createElement(_ErrorBox["default"], {
|
|
136
|
-
title: "
|
|
140
|
+
title: _i18n["default"].INVALID_FEN_ERROR_TITLE,
|
|
137
141
|
message: info.message
|
|
138
142
|
});
|
|
139
143
|
} else if (info.moveError) {
|
|
140
144
|
return /*#__PURE__*/_react["default"].createElement(_ErrorBox["default"], {
|
|
141
|
-
title: "
|
|
145
|
+
title: _i18n["default"].INVALID_NOTATION_ERROR_TITLE,
|
|
142
146
|
message: info.message
|
|
143
147
|
});
|
|
144
148
|
}
|
|
@@ -406,10 +410,8 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
406
410
|
x2: xTo,
|
|
407
411
|
y2: yTo,
|
|
408
412
|
stroke: colorset[this.props.editedArrowColor],
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
'markerEnd': "url(#".concat(arrowTipId, ")")
|
|
412
|
-
}
|
|
413
|
+
strokeWidth: strokeWidth,
|
|
414
|
+
markerEnd: "url(#".concat(arrowTipId, ")")
|
|
413
415
|
});
|
|
414
416
|
}
|
|
415
417
|
}, {
|
|
@@ -565,16 +567,16 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
565
567
|
|
|
566
568
|
x += squareSize / 2;
|
|
567
569
|
y += squareSize / 2;
|
|
568
|
-
result.push( /*#__PURE__*/_react["default"].createElement("
|
|
570
|
+
result.push( /*#__PURE__*/_react["default"].createElement("g", {
|
|
569
571
|
key: 'txtm-' + sq,
|
|
570
|
-
className: "kokopu-annotation
|
|
572
|
+
className: "kokopu-annotation"
|
|
573
|
+
}, /*#__PURE__*/_react["default"].createElement(_TextSymbol["default"], {
|
|
571
574
|
x: x,
|
|
572
575
|
y: y,
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}, value.symbol));
|
|
576
|
+
size: squareSize,
|
|
577
|
+
symbol: value.symbol,
|
|
578
|
+
color: colorset[value.color]
|
|
579
|
+
})));
|
|
578
580
|
});
|
|
579
581
|
return result;
|
|
580
582
|
}
|
|
@@ -622,10 +624,8 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
622
624
|
x2: xTo,
|
|
623
625
|
y2: yTo,
|
|
624
626
|
stroke: colorset[color],
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
'markerEnd': "url(#".concat(arrowTipId, ")")
|
|
628
|
-
}
|
|
627
|
+
strokeWidth: strokeWidth,
|
|
628
|
+
markerEnd: "url(#".concat(arrowTipId, ")")
|
|
629
629
|
}));
|
|
630
630
|
});
|
|
631
631
|
return result;
|
|
@@ -661,10 +661,8 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
661
661
|
x2: x,
|
|
662
662
|
y2: y,
|
|
663
663
|
stroke: colorset['highlight'],
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
'markerEnd': "url(#".concat(this.getArrowTipId('highlight'), ")")
|
|
667
|
-
}
|
|
664
|
+
strokeWidth: squareSize * STROKE_THICKNESS_FACTOR,
|
|
665
|
+
markerEnd: "url(#".concat(this.getArrowTipId('highlight'), ")")
|
|
668
666
|
});
|
|
669
667
|
}
|
|
670
668
|
}, {
|
|
@@ -700,9 +698,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
700
698
|
className: "kokopu-coordinate kokopu-label",
|
|
701
699
|
x: x,
|
|
702
700
|
y: y,
|
|
703
|
-
|
|
704
|
-
'fontSize': fontSize
|
|
705
|
-
}
|
|
701
|
+
fontSize: fontSize
|
|
706
702
|
}, label);
|
|
707
703
|
}
|
|
708
704
|
}, {
|
|
@@ -716,9 +712,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
716
712
|
className: "kokopu-coordinate kokopu-label",
|
|
717
713
|
x: x,
|
|
718
714
|
y: y,
|
|
719
|
-
|
|
720
|
-
'fontSize': fontSize
|
|
721
|
-
}
|
|
715
|
+
fontSize: fontSize
|
|
722
716
|
}, label);
|
|
723
717
|
}
|
|
724
718
|
}, {
|
|
@@ -1317,7 +1311,7 @@ function parsePosition(position) {
|
|
|
1317
1311
|
} else {
|
|
1318
1312
|
return {
|
|
1319
1313
|
error: true,
|
|
1320
|
-
message:
|
|
1314
|
+
message: _i18n["default"].INVALID_POSITION_ATTRIBUTE_ERROR_MESSAGE
|
|
1321
1315
|
};
|
|
1322
1316
|
}
|
|
1323
1317
|
}
|
|
@@ -1352,7 +1346,7 @@ function parseMove(position, move) {
|
|
|
1352
1346
|
} else {
|
|
1353
1347
|
return {
|
|
1354
1348
|
error: true,
|
|
1355
|
-
message:
|
|
1349
|
+
message: _i18n["default"].INVALID_MOVE_ATTRIBUTE_ERROR_MESSAGE
|
|
1356
1350
|
};
|
|
1357
1351
|
}
|
|
1358
1352
|
}
|
|
@@ -9,14 +9,14 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
-
require("
|
|
12
|
+
require("./css/error_box.css");
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
15
|
|
|
16
16
|
/******************************************************************************
|
|
17
17
|
* *
|
|
18
18
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
19
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
19
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
20
20
|
* *
|
|
21
21
|
* This program is free software: you can redistribute it and/or *
|
|
22
22
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
16
16
|
/******************************************************************************
|
|
17
17
|
* *
|
|
18
18
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
19
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
19
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
20
20
|
* *
|
|
21
21
|
* This program is free software: you can redistribute it and/or *
|
|
22
22
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -9,16 +9,16 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
-
require("./css/label.css");
|
|
13
|
-
|
|
14
12
|
var _util = require("./impl/util");
|
|
15
13
|
|
|
14
|
+
var _TextSymbol = _interopRequireDefault(require("./impl/TextSymbol"));
|
|
15
|
+
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
17
|
|
|
18
18
|
/******************************************************************************
|
|
19
19
|
* *
|
|
20
20
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
21
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
21
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
22
22
|
* *
|
|
23
23
|
* This program is free software: you can redistribute it and/or *
|
|
24
24
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -52,15 +52,13 @@ function TextMarkerIcon(props) {
|
|
|
52
52
|
viewBox: viewBox,
|
|
53
53
|
width: size,
|
|
54
54
|
height: size
|
|
55
|
-
}, /*#__PURE__*/_react["default"].createElement("
|
|
56
|
-
className: "kokopu-label",
|
|
55
|
+
}, /*#__PURE__*/_react["default"].createElement(_TextSymbol["default"], {
|
|
57
56
|
x: size / 2,
|
|
58
57
|
y: size / 2,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, props.symbol));
|
|
58
|
+
size: size,
|
|
59
|
+
symbol: props.symbol,
|
|
60
|
+
color: props.color
|
|
61
|
+
}));
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
TextMarkerIcon.propTypes = {
|
|
@@ -70,7 +68,10 @@ TextMarkerIcon.propTypes = {
|
|
|
70
68
|
size: _propTypes["default"].number.isRequired,
|
|
71
69
|
|
|
72
70
|
/**
|
|
73
|
-
* Symbol to represent on the icon. Must be
|
|
71
|
+
* Symbol to represent on the icon. Must be one of:
|
|
72
|
+
* - any letter from A to Z (either upper-case or lower-case),
|
|
73
|
+
* - any digit from 0 to 9,
|
|
74
|
+
* - any symbol code among `'plus'`, `'times'`, `'dot'`, or `'circle'`.
|
|
74
75
|
*/
|
|
75
76
|
symbol: _propTypes["default"].string.isRequired,
|
|
76
77
|
|
package/dist/lib/css/arrow.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/******************************************************************************
|
|
2
2
|
* *
|
|
3
3
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
4
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
5
|
* *
|
|
6
6
|
* This program is free software: you can redistribute it and/or *
|
|
7
7
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/******************************************************************************
|
|
2
2
|
* *
|
|
3
3
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
4
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
5
|
* *
|
|
6
6
|
* This program is free software: you can redistribute it and/or *
|
|
7
7
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/******************************************************************************
|
|
2
2
|
* *
|
|
3
3
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
4
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
5
|
* *
|
|
6
6
|
* This program is free software: you can redistribute it and/or *
|
|
7
7
|
* modify it under the terms of the GNU Lesser General Public License *
|
package/dist/lib/css/label.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/******************************************************************************
|
|
2
2
|
* *
|
|
3
3
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
4
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
5
|
* *
|
|
6
6
|
* This program is free software: you can redistribute it and/or *
|
|
7
7
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* *
|
|
3
|
+
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
|
+
* *
|
|
6
|
+
* This program is free software: you can redistribute it and/or *
|
|
7
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
9
|
+
* the License, or (at your option) any later version. *
|
|
10
|
+
* *
|
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
|
+
* GNU Lesser General Public License for more details. *
|
|
15
|
+
* *
|
|
16
|
+
* You should have received a copy of the GNU Lesser General *
|
|
17
|
+
* Public License along with this program. If not, see *
|
|
18
|
+
* <http://www.gnu.org/licenses/>. *
|
|
19
|
+
* *
|
|
20
|
+
******************************************************************************/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
.kokopu-symbolCircle {
|
|
24
|
+
fill: transparent;
|
|
25
|
+
}
|
package/dist/lib/i18n.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
/******************************************************************************
|
|
9
|
+
* *
|
|
10
|
+
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
11
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
12
|
+
* *
|
|
13
|
+
* This program is free software: you can redistribute it and/or *
|
|
14
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
15
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
16
|
+
* the License, or (at your option) any later version. *
|
|
17
|
+
* *
|
|
18
|
+
* This program is distributed in the hope that it will be useful, *
|
|
19
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
20
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
21
|
+
* GNU Lesser General Public License for more details. *
|
|
22
|
+
* *
|
|
23
|
+
* You should have received a copy of the GNU Lesser General *
|
|
24
|
+
* Public License along with this program. If not, see *
|
|
25
|
+
* <http://www.gnu.org/licenses/>. *
|
|
26
|
+
* *
|
|
27
|
+
******************************************************************************/
|
|
28
|
+
var i18n = {
|
|
29
|
+
INVALID_FEN_ERROR_TITLE: 'Invalid FEN string.',
|
|
30
|
+
INVALID_NOTATION_ERROR_TITLE: 'Invalid move notation.',
|
|
31
|
+
INVALID_POSITION_ATTRIBUTE_ERROR_MESSAGE: 'Invalid "position" attribute.',
|
|
32
|
+
INVALID_MOVE_ATTRIBUTE_ERROR_MESSAGE: 'Invalid "move" attribute.'
|
|
33
|
+
};
|
|
34
|
+
var _default = i18n;
|
|
35
|
+
exports["default"] = _default;
|
|
@@ -14,7 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
14
14
|
/******************************************************************************
|
|
15
15
|
* *
|
|
16
16
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
17
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
17
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
18
18
|
* *
|
|
19
19
|
* This program is free software: you can redistribute it and/or *
|
|
20
20
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -43,9 +43,7 @@ function ArrowTip(props) {
|
|
|
43
43
|
refX: 2.5,
|
|
44
44
|
refY: 2,
|
|
45
45
|
orient: "auto",
|
|
46
|
-
|
|
47
|
-
fill: props.color
|
|
48
|
-
}
|
|
46
|
+
fill: props.color
|
|
49
47
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
50
48
|
d: "M 4,2 L 0,4 L 1,2 L 0,0 Z"
|
|
51
49
|
}));
|
|
@@ -60,8 +58,5 @@ ArrowTip.propTypes = {
|
|
|
60
58
|
/**
|
|
61
59
|
* Color to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
|
|
62
60
|
*/
|
|
63
|
-
color: _propTypes["default"].string
|
|
64
|
-
};
|
|
65
|
-
ArrowTip.defaultProps = {
|
|
66
|
-
color: 'currentcolor'
|
|
61
|
+
color: _propTypes["default"].string.isRequired
|
|
67
62
|
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = TextSymbol;
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
require("../css/label.css");
|
|
13
|
+
|
|
14
|
+
require("../css/symbol.css");
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
/******************************************************************************
|
|
19
|
+
* *
|
|
20
|
+
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
21
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
22
|
+
* *
|
|
23
|
+
* This program is free software: you can redistribute it and/or *
|
|
24
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
25
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
26
|
+
* the License, or (at your option) any later version. *
|
|
27
|
+
* *
|
|
28
|
+
* This program is distributed in the hope that it will be useful, *
|
|
29
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
30
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
31
|
+
* GNU Lesser General Public License for more details. *
|
|
32
|
+
* *
|
|
33
|
+
* You should have received a copy of the GNU Lesser General *
|
|
34
|
+
* Public License along with this program. If not, see *
|
|
35
|
+
* <http://www.gnu.org/licenses/>. *
|
|
36
|
+
* *
|
|
37
|
+
******************************************************************************/
|
|
38
|
+
var SHAPE_THICKNESS_FACTOR = 0.1;
|
|
39
|
+
var DOT_RADIUS_FACTOR = 0.15;
|
|
40
|
+
var CIRCLE_RADIUS_FACTOR = 0.425;
|
|
41
|
+
/**
|
|
42
|
+
* Symbol of a text marker.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
function TextSymbol(props) {
|
|
46
|
+
if (props.symbol === 'dot') {
|
|
47
|
+
return /*#__PURE__*/_react["default"].createElement("circle", {
|
|
48
|
+
cx: props.x,
|
|
49
|
+
cy: props.y,
|
|
50
|
+
r: props.size * DOT_RADIUS_FACTOR,
|
|
51
|
+
fill: props.color
|
|
52
|
+
});
|
|
53
|
+
} else if (props.symbol === 'circle') {
|
|
54
|
+
var thickness = props.size * SHAPE_THICKNESS_FACTOR;
|
|
55
|
+
return /*#__PURE__*/_react["default"].createElement("circle", {
|
|
56
|
+
className: "kokopu-symbolCircle",
|
|
57
|
+
cx: props.x,
|
|
58
|
+
cy: props.y,
|
|
59
|
+
r: props.size * CIRCLE_RADIUS_FACTOR,
|
|
60
|
+
stroke: props.color,
|
|
61
|
+
strokeWidth: thickness
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
var symbol = props.symbol === 'plus' ? '+' : props.symbol === 'times' ? "\xD7" : props.symbol;
|
|
65
|
+
return /*#__PURE__*/_react["default"].createElement("text", {
|
|
66
|
+
className: "kokopu-label",
|
|
67
|
+
x: props.x,
|
|
68
|
+
y: props.y,
|
|
69
|
+
fill: props.color,
|
|
70
|
+
fontSize: props.size
|
|
71
|
+
}, symbol);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
TextSymbol.propTypes = {
|
|
76
|
+
/**
|
|
77
|
+
* X-coordinate of the center of the symbol.
|
|
78
|
+
*/
|
|
79
|
+
x: _propTypes["default"].number.isRequired,
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Y-coordinate of the center of the symbol.
|
|
83
|
+
*/
|
|
84
|
+
y: _propTypes["default"].number.isRequired,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Size of the symbol (i.e. size of square in which the symbol is rendered).
|
|
88
|
+
*/
|
|
89
|
+
size: _propTypes["default"].number.isRequired,
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Symbol code.
|
|
93
|
+
*/
|
|
94
|
+
symbol: _propTypes["default"].string.isRequired,
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Color to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
|
|
98
|
+
*/
|
|
99
|
+
color: _propTypes["default"].string.isRequired
|
|
100
|
+
};
|
|
@@ -8,7 +8,7 @@ exports["default"] = void 0;
|
|
|
8
8
|
/******************************************************************************
|
|
9
9
|
* *
|
|
10
10
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
11
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
11
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
12
12
|
* *
|
|
13
13
|
* This program is free software: you can redistribute it and/or *
|
|
14
14
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -174,7 +174,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
174
174
|
/******************************************************************************
|
|
175
175
|
* *
|
|
176
176
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
177
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
177
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
178
178
|
* *
|
|
179
179
|
* This program is free software: you can redistribute it and/or *
|
|
180
180
|
* modify it under the terms of the GNU Lesser General Public License *
|
package/dist/lib/impl/util.js
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.MIN_SQUARE_SIZE = exports.MAX_SQUARE_SIZE = void 0;
|
|
6
7
|
exports.generateRandomId = generateRandomId;
|
|
7
|
-
exports.sanitizeInteger = sanitizeInteger;
|
|
8
|
-
exports.isValidSquare = isValidSquare;
|
|
9
|
-
exports.isValidVector = isValidVector;
|
|
10
8
|
exports.isValidColor = isValidColor;
|
|
9
|
+
exports.isValidSquare = isValidSquare;
|
|
11
10
|
exports.isValidSymbol = isValidSymbol;
|
|
12
|
-
exports.
|
|
11
|
+
exports.isValidVector = isValidVector;
|
|
12
|
+
exports.sanitizeInteger = sanitizeInteger;
|
|
13
13
|
|
|
14
14
|
/******************************************************************************
|
|
15
15
|
* *
|
|
16
16
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
17
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
17
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
18
18
|
* *
|
|
19
19
|
* This program is free software: you can redistribute it and/or *
|
|
20
20
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -65,5 +65,5 @@ function isValidColor(color) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function isValidSymbol(symbol) {
|
|
68
|
-
return /^[A-Za-z0-9]$/.test(symbol);
|
|
68
|
+
return /^(?:[A-Za-z0-9]|plus|times|dot|circle)$/.test(symbol);
|
|
69
69
|
}
|