kokopu-react 1.9.0 → 1.9.2

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.
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = SquareMarkerIcon;
7
-
8
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _util = require("./impl/util");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
11
  /******************************************************************************
17
12
  * *
18
13
  * This file is part of Kokopu-React, a JavaScript chess library. *
@@ -33,18 +28,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
33
28
  * <http://www.gnu.org/licenses/>. *
34
29
  * *
35
30
  ******************************************************************************/
31
+
36
32
  var SQUARE_MARGIN_FACTOR = 0.1;
33
+
37
34
  /**
38
35
  * SVG icon representing a square marker.
39
36
  */
40
-
41
37
  function SquareMarkerIcon(props) {
42
38
  var size = (0, _util.sanitizeInteger)(props.size, _util.MIN_SQUARE_SIZE, _util.MAX_SQUARE_SIZE);
43
-
44
39
  if (isNaN(size)) {
45
40
  return undefined;
46
41
  }
47
-
48
42
  var margin = Math.round(size * SQUARE_MARGIN_FACTOR);
49
43
  var viewBox = "0 0 ".concat(size, " ").concat(size);
50
44
  return /*#__PURE__*/_react["default"].createElement("svg", {
@@ -60,13 +54,11 @@ function SquareMarkerIcon(props) {
60
54
  fill: props.color
61
55
  }));
62
56
  }
63
-
64
57
  SquareMarkerIcon.propTypes = {
65
58
  /**
66
59
  * Width and height (in pixels) of the icon.
67
60
  */
68
61
  size: _propTypes["default"].number.isRequired,
69
-
70
62
  /**
71
63
  * Color to use to colorize the icon (for example: `'green'`, `'#ff0000'`...).
72
64
  */
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = TextMarkerIcon;
7
-
8
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _util = require("./impl/util");
13
-
14
10
  var _TextSymbol = _interopRequireDefault(require("./impl/TextSymbol"));
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
-
18
12
  /******************************************************************************
19
13
  * *
20
14
  * This file is part of Kokopu-React, a JavaScript chess library. *
@@ -41,11 +35,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
41
35
  */
42
36
  function TextMarkerIcon(props) {
43
37
  var size = (0, _util.sanitizeInteger)(props.size, _util.MIN_SQUARE_SIZE, _util.MAX_SQUARE_SIZE);
44
-
45
38
  if (isNaN(size) || !(0, _util.isValidSymbol)(props.symbol)) {
46
39
  return undefined;
47
40
  }
48
-
49
41
  var viewBox = "0 0 ".concat(size, " ").concat(size);
50
42
  return /*#__PURE__*/_react["default"].createElement("svg", {
51
43
  className: "kokopu-textMarkerIcon",
@@ -60,13 +52,11 @@ function TextMarkerIcon(props) {
60
52
  color: props.color
61
53
  }));
62
54
  }
63
-
64
55
  TextMarkerIcon.propTypes = {
65
56
  /**
66
57
  * Width and height (in pixels) of the icon.
67
58
  */
68
59
  size: _propTypes["default"].number.isRequired,
69
-
70
60
  /**
71
61
  * Symbol to represent on the icon. Must be one of:
72
62
  * - any letter from A to Z (either upper-case or lower-case),
@@ -74,7 +64,6 @@ TextMarkerIcon.propTypes = {
74
64
  * - any symbol code among `'plus'`, `'times'`, `'dot'`, or `'circle'`.
75
65
  */
76
66
  symbol: _propTypes["default"].string.isRequired,
77
-
78
67
  /**
79
68
  * Color to use to colorize the icon (for example: `'green'`, `'#ff0000'`...).
80
69
  */
@@ -115,3 +115,7 @@ div.kokopu-subVariation {
115
115
  height: 0px;
116
116
  overflow: hidden;
117
117
  }
118
+
119
+ .kokopu-focusField {
120
+ position: absolute; /* see #1 */
121
+ }
@@ -5,15 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.formatMove = formatMove;
7
7
  exports.moveFormatter = moveFormatter;
8
-
9
8
  var _react = _interopRequireDefault(require("react"));
10
-
11
9
  var _i18n = _interopRequireDefault(require("./i18n"));
12
-
13
10
  require("./css/fonts.css");
14
-
15
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
-
17
12
  /******************************************************************************
18
13
  * *
19
14
  * This file is part of Kokopu-React, a JavaScript chess library. *
@@ -46,6 +41,7 @@ function formatMove(pieceSymbols, notation) {
46
41
  var formatter = moveFormatter(pieceSymbols);
47
42
  return formatter(notation);
48
43
  }
44
+
49
45
  /**
50
46
  * Return a callback capable of rendering a SAN notation using the given piece symbol style.
51
47
  *
@@ -53,8 +49,6 @@ function formatMove(pieceSymbols, notation) {
53
49
  * for each English piece symbol.
54
50
  * @returns {function(string)} Callback returning either a string or a React fragment.
55
51
  */
56
-
57
-
58
52
  function moveFormatter(pieceSymbols) {
59
53
  if (pieceSymbols === 'localized') {
60
54
  var mapping = _i18n["default"].PIECE_SYMBOLS;
@@ -81,27 +75,23 @@ function moveFormatter(pieceSymbols) {
81
75
  };
82
76
  }
83
77
  }
78
+
84
79
  /**
85
80
  * Decompose the given string into piece symbol characters and sections of non piece symbol characters, and transform the piece symbols into
86
81
  * React objects represented with the given chess font.
87
82
  *
88
83
  * @ignore
89
84
  */
90
-
91
-
92
85
  function figurineNotation(fontName, text) {
93
86
  var result = [];
94
87
  var beginOfText = 0;
95
88
  var pieceSymbolIndex = 0;
96
-
97
89
  for (var pos = 0; pos < text.length; ++pos) {
98
90
  var currentChar = text.charAt(pos);
99
-
100
91
  if (currentChar === 'K' || currentChar === 'Q' || currentChar === 'R' || currentChar === 'B' || currentChar === 'N' || currentChar === 'P') {
101
92
  if (pos > beginOfText) {
102
93
  result.push(text.substring(beginOfText, pos));
103
94
  }
104
-
105
95
  beginOfText = pos + 1;
106
96
  var key = 'symbol-' + pieceSymbolIndex++;
107
97
  result.push( /*#__PURE__*/_react["default"].createElement("span", {
@@ -110,10 +100,8 @@ function figurineNotation(fontName, text) {
110
100
  }, currentChar));
111
101
  }
112
102
  }
113
-
114
103
  if (beginOfText < text.length) {
115
104
  result.push(text.substring(beginOfText));
116
105
  }
117
-
118
106
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, result);
119
107
  }
package/dist/lib/i18n.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  /******************************************************************************
9
8
  * *
10
9
  * This file is part of Kokopu-React, a JavaScript chess library. *
@@ -25,6 +24,7 @@ exports["default"] = void 0;
25
24
  * <http://www.gnu.org/licenses/>. *
26
25
  * *
27
26
  ******************************************************************************/
27
+
28
28
  var i18n = {
29
29
  // Error box
30
30
  LINE: 'line {0}',
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = ArrowTip;
7
-
8
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  /******************************************************************************
15
11
  * *
16
12
  * This file is part of Kokopu-React, a JavaScript chess library. *
@@ -48,13 +44,11 @@ function ArrowTip(props) {
48
44
  d: "M 4,2 L 0,4 L 1,2 L 0,0 Z"
49
45
  }));
50
46
  }
51
-
52
47
  ArrowTip.propTypes = {
53
48
  /**
54
49
  * ID of the element.
55
50
  */
56
51
  id: _propTypes["default"].string.isRequired,
57
-
58
52
  /**
59
53
  * Color to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
60
54
  */
@@ -1,93 +1,75 @@
1
1
  "use strict";
2
2
 
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
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports["default"] = void 0;
9
-
10
7
  var _react = _interopRequireDefault(require("react"));
11
-
12
8
  var htmlparser2 = _interopRequireWildcard(require("htmlparser2"));
13
-
14
9
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
10
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
18
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
-
12
+ 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); }
20
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
21
-
22
14
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
-
24
15
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
-
26
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
27
-
28
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
29
-
17
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) { ; } } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
30
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
31
-
32
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
-
34
- 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); } }
35
-
20
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
36
21
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
-
22
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
23
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
38
24
  /**
39
25
  * Those tags cannot have any children.
40
26
  */
41
27
  var NO_CHILDREN_TAGS = new Set(['br', 'hr', 'img']);
28
+
42
29
  /**
43
30
  * HTML sanitizer: parse HTML string, keeping only the allowed HTML nodes, and the corresponding React object.
44
31
  */
45
-
46
32
  var HtmlSanitizer = /*#__PURE__*/function () {
47
33
  function HtmlSanitizer(_ref) {
48
34
  var allowedTags = _ref.allowedTags,
49
- allowedAttributes = _ref.allowedAttributes;
50
-
35
+ allowedAttributes = _ref.allowedAttributes;
51
36
  _classCallCheck(this, HtmlSanitizer);
52
-
53
37
  this._allowedTags = allowedTags ? new Set(allowedTags) : new Set();
54
38
  this._allowedAttributes = allowedAttributes ? new Map(Object.entries(allowedAttributes).map(function (_ref2) {
55
39
  var _ref3 = _slicedToArray(_ref2, 2),
56
- k = _ref3[0],
57
- v = _ref3[1];
58
-
40
+ k = _ref3[0],
41
+ v = _ref3[1];
59
42
  return [k, new Set(v)];
60
43
  })) : new Map();
61
44
  this._keyCounter = 0;
62
45
  }
46
+
63
47
  /**
64
48
  * @param {string} text HTML string to be parsed.
65
49
  * @returns {*} React object corresponding to the given HTML string. Can also be a fragment, or just a simple string if the given HTML string
66
50
  * does not contain any HTML tag.
67
51
  */
68
-
69
-
70
52
  _createClass(HtmlSanitizer, [{
71
53
  key: "parse",
72
54
  value: function parse(text) {
73
55
  var _this = this;
56
+ var dom = htmlparser2.parseDocument(text);
74
57
 
75
- var dom = htmlparser2.parseDocument(text); // Ensure that the returned object is a non-empty node type.
76
-
58
+ // Ensure that the returned object is a non-empty node type.
77
59
  if (dom.type !== 'root') {
78
60
  return undefined;
79
- } // Process the children of the root node.
80
-
61
+ }
81
62
 
63
+ // Process the children of the root node.
82
64
  var result = [];
83
65
  dom.children.forEach(function (child) {
84
66
  var childElement = _this._processNode(child);
85
-
86
67
  if (childElement) {
87
68
  result.push(childElement);
88
69
  }
89
- }); // Return the result.
70
+ });
90
71
 
72
+ // Return the result.
91
73
  if (result.length === 0) {
92
74
  return undefined;
93
75
  } else if (result.length === 1) {
@@ -102,17 +84,14 @@ var HtmlSanitizer = /*#__PURE__*/function () {
102
84
  key: "_processNode",
103
85
  value: function _processNode(node) {
104
86
  var _this2 = this;
105
-
106
87
  if (node.type === 'text') {
107
88
  return node.data;
108
89
  } else if (node.type === 'tag') {
109
90
  var children = NO_CHILDREN_TAGS.has(node.name) ? undefined : node.children.map(function (child) {
110
91
  return _this2._processNode(child);
111
92
  });
112
-
113
93
  if (this._allowedTags.has(node.name)) {
114
94
  var attributes = this._filterAttributes(node.name, node.attribs);
115
-
116
95
  attributes['key'] = this._allocateKey();
117
96
  return /*#__PURE__*/_react["default"].createElement(node.name, attributes, children);
118
97
  } else {
@@ -128,17 +107,14 @@ var HtmlSanitizer = /*#__PURE__*/function () {
128
107
  key: "_filterAttributes",
129
108
  value: function _filterAttributes(nodeName, attributes) {
130
109
  var result = {};
131
-
132
110
  for (var _i2 = 0, _Object$entries = Object.entries(attributes); _i2 < _Object$entries.length; _i2++) {
133
111
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
134
- attribute = _Object$entries$_i[0],
135
- value = _Object$entries$_i[1];
136
-
112
+ attribute = _Object$entries$_i[0],
113
+ value = _Object$entries$_i[1];
137
114
  if (this._isAttributeAllowed(nodeName, attribute)) {
138
115
  result[attribute === 'class' ? 'className' : attribute] = value;
139
116
  }
140
117
  }
141
-
142
118
  return result;
143
119
  }
144
120
  }, {
@@ -148,19 +124,14 @@ var HtmlSanitizer = /*#__PURE__*/function () {
148
124
  // Those attributes are always forbidden.
149
125
  return false;
150
126
  }
151
-
152
127
  var allowedAttributesForCurrent = this._allowedAttributes.get(nodeName);
153
-
154
128
  if (allowedAttributesForCurrent && allowedAttributesForCurrent.has(attribute)) {
155
129
  return true;
156
130
  }
157
-
158
131
  var allowedAttributesForAll = this._allowedAttributes.get('*');
159
-
160
132
  if (allowedAttributesForAll && allowedAttributesForAll.has(attribute)) {
161
133
  return true;
162
134
  }
163
-
164
135
  return false;
165
136
  }
166
137
  }, {
@@ -169,8 +140,6 @@ var HtmlSanitizer = /*#__PURE__*/function () {
169
140
  return 'auto-' + this._keyCounter++;
170
141
  }
171
142
  }]);
172
-
173
143
  return HtmlSanitizer;
174
144
  }();
175
-
176
145
  exports["default"] = HtmlSanitizer;
@@ -1,72 +1,53 @@
1
1
  "use strict";
2
2
 
3
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
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
9
  var _react = _interopRequireDefault(require("react"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
11
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
-
18
- 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); } }
19
-
12
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
20
13
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
21
-
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
22
16
  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); }
23
-
24
17
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
25
-
26
18
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
27
-
28
19
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
29
-
30
20
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
31
-
32
21
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
33
-
34
22
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
-
36
23
  var DEBUG_KEY = '__kokopu_debug_freeze_motion';
24
+
37
25
  /**
38
26
  * Wrap some animated content.
39
27
  */
40
-
41
28
  var Motion = /*#__PURE__*/function (_React$Component) {
42
29
  _inherits(Motion, _React$Component);
43
-
44
30
  var _super = _createSuper(Motion);
45
-
46
31
  function Motion(props) {
47
32
  var _this;
48
-
49
33
  _classCallCheck(this, Motion);
50
-
51
34
  _this = _super.call(this, props);
52
35
  _this.state = {
53
36
  cursor: 0
54
37
  };
55
38
  _this.animationFrameId = null;
56
- _this.cursorStop = 1; // WARNING: this hack exists only for testing purposes. DO NOT USE IT IN PRODUCTION.
39
+ _this.cursorStop = 1;
57
40
 
41
+ // WARNING: this hack exists only for testing purposes. DO NOT USE IT IN PRODUCTION.
58
42
  if (typeof window[DEBUG_KEY] === 'number' && window[DEBUG_KEY] >= 0 && window[DEBUG_KEY] <= 1) {
59
43
  _this.cursorStop = window[DEBUG_KEY];
60
44
  }
61
-
62
45
  return _this;
63
46
  }
64
-
65
47
  _createClass(Motion, [{
66
48
  key: "componentDidMount",
67
49
  value: function componentDidMount() {
68
50
  var _this2 = this;
69
-
70
51
  this.animationFrameId = window.requestAnimationFrame(function (ts) {
71
52
  return _this2.handleAnimationStep(ts);
72
53
  });
@@ -83,24 +64,22 @@ var Motion = /*#__PURE__*/function (_React$Component) {
83
64
  key: "handleAnimationStep",
84
65
  value: function handleAnimationStep(timestamp) {
85
66
  var _this3 = this;
86
-
87
67
  if (this.initialTimestamp === undefined) {
88
68
  this.initialTimestamp = timestamp;
89
- } // Compute the animation cursor and update the state.
90
-
69
+ }
91
70
 
71
+ // Compute the animation cursor and update the state.
92
72
  var cursor = (timestamp - this.initialTimestamp) / this.props.duration;
93
-
94
73
  if (cursor < 0) {
95
74
  cursor = 0;
96
75
  } else if (cursor > this.cursorStop) {
97
76
  cursor = this.cursorStop;
98
77
  }
99
-
100
78
  this.setState({
101
79
  cursor: cursor
102
- }); // Schedule the next animation frame if necessary.
80
+ });
103
81
 
82
+ // Schedule the next animation frame if necessary.
104
83
  if (cursor === this.cursorStop) {
105
84
  this.animationFrameId = null;
106
85
  } else {
@@ -115,17 +94,14 @@ var Motion = /*#__PURE__*/function (_React$Component) {
115
94
  return this.props.children(this.state.cursor);
116
95
  }
117
96
  }]);
118
-
119
97
  return Motion;
120
98
  }(_react["default"].Component);
121
-
122
99
  exports["default"] = Motion;
123
100
  Motion.propTypes = {
124
101
  /**
125
102
  * Duration of the animation. Must be > 0.
126
103
  */
127
104
  duration: _propTypes["default"].number.isRequired,
128
-
129
105
  /**
130
106
  * Factory for the content being animated. The animation cursor is guaranteed to be valued between 0 and 1 inclusive.
131
107
  */
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = TextSymbol;
7
-
8
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  require("../css/symbol.css");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
11
  /******************************************************************************
17
12
  * *
18
13
  * This file is part of Kokopu-React, a JavaScript chess library. *
@@ -33,13 +28,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
33
28
  * <http://www.gnu.org/licenses/>. *
34
29
  * *
35
30
  ******************************************************************************/
31
+
36
32
  var SHAPE_THICKNESS_FACTOR = 0.1;
37
33
  var DOT_RADIUS_FACTOR = 0.15;
38
34
  var CIRCLE_RADIUS_FACTOR = 0.425;
35
+
39
36
  /**
40
37
  * Symbol of a text marker.
41
38
  */
42
-
43
39
  function TextSymbol(props) {
44
40
  if (props.symbol === 'dot') {
45
41
  return /*#__PURE__*/_react["default"].createElement("circle", {
@@ -69,28 +65,23 @@ function TextSymbol(props) {
69
65
  }, symbol);
70
66
  }
71
67
  }
72
-
73
68
  TextSymbol.propTypes = {
74
69
  /**
75
70
  * X-coordinate of the center of the symbol.
76
71
  */
77
72
  x: _propTypes["default"].number.isRequired,
78
-
79
73
  /**
80
74
  * Y-coordinate of the center of the symbol.
81
75
  */
82
76
  y: _propTypes["default"].number.isRequired,
83
-
84
77
  /**
85
78
  * Size of the symbol (i.e. size of square in which the symbol is rendered).
86
79
  */
87
80
  size: _propTypes["default"].number.isRequired,
88
-
89
81
  /**
90
82
  * Symbol code.
91
83
  */
92
84
  symbol: _propTypes["default"].string.isRequired,
93
-
94
85
  /**
95
86
  * Color to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
96
87
  */
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  /******************************************************************************
9
8
  * *
10
9
  * This file is part of Kokopu-React, a JavaScript chess library. *
@@ -66,7 +65,6 @@ var _default = {
66
65
  cr: '#d00',
67
66
  cy: '#ff0'
68
67
  },
69
-
70
68
  /*
71
69
  * Source: http://omgchess.blogspot.fr/2015/09/chess-board-color-schemes.html
72
70
  * Author: Gorgonian <http://omgchess.blogspot.fr/>