@zohodesk/i18n 1.0.0-beta.3 → 1.0.0-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +120 -2
  2. package/es/I18NContext.js +1 -2
  3. package/es/components/DateTimeDiffFormat.js +192 -200
  4. package/es/components/FormatText.js +4 -25
  5. package/es/components/HOCI18N.js +33 -45
  6. package/es/components/I18N.js +48 -63
  7. package/es/components/I18NProvider.js +60 -85
  8. package/es/components/PluralFormat.js +29 -48
  9. package/es/components/UserTimeDiffFormat.js +65 -74
  10. package/es/components/__tests__/DateTimeDiffFormat.spec.js +868 -657
  11. package/es/components/__tests__/FormatText.spec.js +20 -17
  12. package/es/components/__tests__/HOCI18N.spec.js +18 -22
  13. package/es/components/__tests__/I18N.spec.js +20 -19
  14. package/es/components/__tests__/I18NProvider.spec.js +36 -45
  15. package/es/components/__tests__/PluralFormat.spec.js +20 -17
  16. package/es/components/__tests__/UserTimeDiffFormat.spec.js +1343 -1095
  17. package/es/index.js +2 -6
  18. package/es/utils/__tests__/jsxTranslations.spec.js +174 -0
  19. package/es/utils/index.js +592 -0
  20. package/es/utils/jsxTranslations.js +193 -0
  21. package/lib/I18NContext.js +6 -6
  22. package/lib/components/DateTimeDiffFormat.js +151 -123
  23. package/lib/components/FormatText.js +32 -22
  24. package/lib/components/HOCI18N.js +47 -23
  25. package/lib/components/I18N.js +62 -36
  26. package/lib/components/I18NProvider.js +85 -72
  27. package/lib/components/PluralFormat.js +42 -32
  28. package/lib/components/UserTimeDiffFormat.js +79 -56
  29. package/lib/components/__tests__/DateTimeDiffFormat.spec.js +815 -629
  30. package/lib/components/__tests__/FormatText.spec.js +23 -25
  31. package/lib/components/__tests__/HOCI18N.spec.js +26 -34
  32. package/lib/components/__tests__/I18N.spec.js +21 -26
  33. package/lib/components/__tests__/I18NProvider.spec.js +43 -51
  34. package/lib/components/__tests__/PluralFormat.spec.js +24 -28
  35. package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1256 -1039
  36. package/lib/index.js +85 -110
  37. package/lib/utils/__tests__/jsxTranslations.spec.js +183 -0
  38. package/lib/utils/index.js +658 -0
  39. package/lib/utils/jsxTranslations.js +242 -0
  40. package/package.json +3 -2
  41. package/src/components/DateTimeDiffFormat.js +86 -55
  42. package/src/components/I18N.js +2 -0
  43. package/src/components/I18NProvider.js +44 -33
  44. package/src/components/UserTimeDiffFormat.js +24 -18
  45. package/src/index.js +7 -9
  46. package/src/utils/__tests__/jsxTranslations.spec.js +213 -0
  47. package/src/utils/index.js +632 -0
  48. package/src/utils/jsxTranslations.js +180 -0
  49. package/es/components/NewDateFormat.js +0 -50
  50. package/es/offset.js +0 -629
  51. package/es/timezones.js +0 -118
  52. package/es/utils.js +0 -621
  53. package/lib/components/NewDateFormat.js +0 -68
  54. package/lib/offset.js +0 -634
  55. package/lib/timezones.js +0 -129
  56. package/lib/utils.js +0 -651
  57. package/src/components/NewDateFormat.js +0 -60
  58. package/src/offset.js +0 -629
  59. package/src/timezones.js +0 -113
  60. package/src/utils.js +0 -648
@@ -1,54 +1,64 @@
1
- 'use strict';
1
+ "use strict";
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); }
2
4
 
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
8
+ exports["default"] = void 0;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
6
11
 
7
- var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
13
 
9
- var _react = require('react');
14
+ var _I18N = _interopRequireDefault(require("./I18N"));
10
15
 
11
- var _react2 = _interopRequireDefault(_react);
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
17
 
13
- var _propTypes = require('prop-types');
18
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
19
 
15
- var _propTypes2 = _interopRequireDefault(_propTypes);
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, descriptor.key, descriptor); } }
16
21
 
17
- var _I18N = require('./I18N');
22
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
18
23
 
19
- var _I18N2 = _interopRequireDefault(_I18N);
24
+ 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); }
20
25
 
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22
27
 
23
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28
+ 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); }; }
24
29
 
25
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
30
+ 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); }
26
31
 
27
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
32
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
28
33
 
29
- var FormatText = function (_React$Component) {
34
+ 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; } }
35
+
36
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
37
+
38
+ var FormatText = /*#__PURE__*/function (_React$Component) {
30
39
  _inherits(FormatText, _React$Component);
31
40
 
41
+ var _super = _createSuper(FormatText);
42
+
32
43
  function FormatText() {
33
44
  _classCallCheck(this, FormatText);
34
45
 
35
- return _possibleConstructorReturn(this, (FormatText.__proto__ || Object.getPrototypeOf(FormatText)).apply(this, arguments));
46
+ return _super.apply(this, arguments);
36
47
  }
37
48
 
38
49
  _createClass(FormatText, [{
39
- key: 'render',
50
+ key: "render",
40
51
  value: function render() {
41
- return _react2.default.createElement(_I18N2.default, this.props);
52
+ return /*#__PURE__*/_react["default"].createElement(_I18N["default"], this.props);
42
53
  }
43
54
  }]);
44
55
 
45
56
  return FormatText;
46
- }(_react2.default.Component);
47
-
48
- exports.default = FormatText;
57
+ }(_react["default"].Component);
49
58
 
59
+ exports["default"] = FormatText;
50
60
  FormatText.propTypes = {
51
- i18NKey: _propTypes2.default.string.isRequired,
52
- isHtml: _propTypes2.default.bool,
53
- values: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.array])
61
+ i18NKey: _propTypes["default"].string.isRequired,
62
+ isHtml: _propTypes["default"].bool,
63
+ values: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].array])
54
64
  };
@@ -1,50 +1,68 @@
1
- 'use strict';
1
+ "use strict";
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); }
2
4
 
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
8
+ exports["default"] = void 0;
6
9
 
7
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
-
9
- var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10
+ var _react = _interopRequireWildcard(require("react"));
10
11
 
11
- var _react = require('react');
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
13
 
13
- var _react2 = _interopRequireDefault(_react);
14
+ var _utils = require("../utils");
14
15
 
15
- var _propTypes = require('prop-types');
16
+ var _I18NContext = require("../I18NContext");
16
17
 
17
- var _propTypes2 = _interopRequireDefault(_propTypes);
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
18
19
 
19
- var _utils = require('../utils');
20
+ 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); }
20
21
 
21
- var _I18NContext = require('../I18NContext');
22
+ 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; }
22
23
 
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
24
25
 
25
26
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26
27
 
27
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
28
+ 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); } }
29
+
30
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
31
+
32
+ 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); }
33
+
34
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
35
+
36
+ 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); }; }
37
+
38
+ 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); }
39
+
40
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
41
+
42
+ 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; } }
28
43
 
29
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
44
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
45
 
31
- exports.default = function () {
46
+ var _default = function _default() {
32
47
  var i18NKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
33
48
  return function (Component) {
34
- var HOCI18N = function (_React$Component) {
49
+ var HOCI18N = /*#__PURE__*/function (_React$Component) {
35
50
  _inherits(HOCI18N, _React$Component);
36
51
 
52
+ var _super = _createSuper(HOCI18N);
53
+
37
54
  function HOCI18N(props) {
38
- _classCallCheck(this, HOCI18N);
55
+ var _this;
39
56
 
40
- var _this = _possibleConstructorReturn(this, (HOCI18N.__proto__ || Object.getPrototypeOf(HOCI18N)).call(this, props));
57
+ _classCallCheck(this, HOCI18N);
41
58
 
42
- _this.getI18NValue = _this.getI18NValue.bind(_this);
59
+ _this = _super.call(this, props);
60
+ _this.getI18NValue = _this.getI18NValue.bind(_assertThisInitialized(_this));
43
61
  return _this;
44
62
  }
45
63
 
46
64
  _createClass(HOCI18N, [{
47
- key: 'getI18NValue',
65
+ key: "getI18NValue",
48
66
  value: function getI18NValue(key) {
49
67
  var _ref = this.context || {},
50
68
  i18n = _ref.i18n;
@@ -52,14 +70,17 @@ exports.default = function () {
52
70
  if (typeof i18n === 'undefined') {
53
71
  return key;
54
72
  }
73
+
55
74
  var i18nStr = i18n[key];
75
+
56
76
  if (i18nStr === undefined) {
57
77
  return key;
58
78
  }
79
+
59
80
  return (0, _utils.unescapeUnicode)(i18nStr);
60
81
  }
61
82
  }, {
62
- key: 'render',
83
+ key: "render",
63
84
  value: function render() {
64
85
  var _this2 = this;
65
86
 
@@ -67,16 +88,19 @@ exports.default = function () {
67
88
  if (_this2.props[key]) {
68
89
  result[key] = _this2.getI18NValue(_this2.props[key]);
69
90
  }
91
+
70
92
  return result;
71
93
  }, {});
72
- return _react2.default.createElement(Component, _extends({}, this.props, i18nProps));
94
+ return /*#__PURE__*/_react["default"].createElement(Component, _extends({}, this.props, i18nProps));
73
95
  }
74
96
  }]);
75
97
 
76
98
  return HOCI18N;
77
- }(_react2.default.Component);
99
+ }(_react["default"].Component);
78
100
 
79
101
  HOCI18N.contextType = _I18NContext.I18NContext;
80
102
  return HOCI18N;
81
103
  };
82
- };
104
+ };
105
+
106
+ exports["default"] = _default;
@@ -1,52 +1,70 @@
1
- 'use strict';
1
+ "use strict";
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); }
2
4
 
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
8
+ exports["default"] = void 0;
6
9
 
7
- var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- var _react = require('react');
10
+ var _react = _interopRequireWildcard(require("react"));
10
11
 
11
- var _react2 = _interopRequireDefault(_react);
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
13
 
13
- var _propTypes = require('prop-types');
14
+ var _utils = require("../utils");
14
15
 
15
- var _propTypes2 = _interopRequireDefault(_propTypes);
16
+ var _SecurityJS = require("@zoho/SecurityJS");
16
17
 
17
- var _utils = require('../utils');
18
+ var _I18NContext = require("../I18NContext");
18
19
 
19
- var _SecurityJS = require('@zoho/SecurityJS');
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
20
21
 
21
- var _I18NContext = require('../I18NContext');
22
+ 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); }
22
23
 
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+ 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; }
24
25
 
25
26
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26
27
 
27
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
28
+ 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); } }
29
+
30
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
31
+
32
+ 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); }
33
+
34
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
35
+
36
+ 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); }; }
28
37
 
29
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
38
+ 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); }
30
39
 
31
- var I18N = function (_React$Component) {
40
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
41
+
42
+ 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; } }
43
+
44
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
45
+
46
+ var I18N = /*#__PURE__*/function (_React$Component) {
32
47
  _inherits(I18N, _React$Component);
33
48
 
49
+ var _super = _createSuper(I18N);
50
+
34
51
  function I18N(props) {
35
- _classCallCheck(this, I18N);
52
+ var _this;
36
53
 
37
- var _this = _possibleConstructorReturn(this, (I18N.__proto__ || Object.getPrototypeOf(I18N)).call(this, props));
54
+ _classCallCheck(this, I18N);
38
55
 
39
- _this.getI18NValue = _this.getI18NValue.bind(_this);
40
- _this.createElement = _this.createElement.bind(_this);
56
+ _this = _super.call(this, props);
57
+ _this.getI18NValue = _this.getI18NValue.bind(_assertThisInitialized(_this));
58
+ _this.createElement = _this.createElement.bind(_assertThisInitialized(_this));
41
59
  return _this;
42
60
  }
43
61
 
44
62
  _createClass(I18N, [{
45
- key: 'getI18NValue',
63
+ key: "getI18NValue",
46
64
  value: function getI18NValue() {
47
- var _props = this.props,
48
- key = _props.i18NKey,
49
- values = _props.values;
65
+ var _this$props = this.props,
66
+ key = _this$props.i18NKey,
67
+ values = _this$props.values;
50
68
 
51
69
  var _ref = this.context || {},
52
70
  i18n = _ref.i18n;
@@ -54,15 +72,18 @@ var I18N = function (_React$Component) {
54
72
  if (typeof i18n === 'undefined') {
55
73
  return key;
56
74
  }
75
+
57
76
  var i18nStr = i18n[key];
77
+
58
78
  if (i18nStr === undefined) {
59
79
  return key;
60
80
  }
81
+
61
82
  i18nStr = (0, _utils.replaceI18NValuesWithRegex)(i18nStr, values);
62
83
  return (0, _utils.unescapeUnicode)(i18nStr);
63
84
  }
64
85
  }, {
65
- key: 'createElement',
86
+ key: "createElement",
66
87
  value: function createElement() {
67
88
  var _this2 = this;
68
89
 
@@ -70,38 +91,43 @@ var I18N = function (_React$Component) {
70
91
  if (nextKey != 'i18NKey' && nextKey != 'tag' && nextKey != 'values' && nextKey != 'isHtml' && nextKey != 'dataId') {
71
92
  result[nextKey] = _this2.props[nextKey];
72
93
  }
94
+
73
95
  return result;
74
- }, {});
75
- //const child=this.getI18NValue();
96
+ }, {}); //const child=this.getI18NValue();
97
+
76
98
  if (this.props.dataId) {
77
99
  props['data-id'] = this.props.dataId;
100
+ props['data-test-id'] = this.props.dataId;
78
101
  }
102
+
79
103
  if (this.props.isHtml) {
80
104
  var dangerouslySetInnerHTML = {
81
105
  __html: _SecurityJS.HTMLPurifier.sanitize(this.getI18NValue())
82
106
  };
83
-
84
- return _react2.default.createElement(this.props.tag, Object.assign(props, { dangerouslySetInnerHTML: dangerouslySetInnerHTML }));
107
+ return /*#__PURE__*/_react["default"].createElement(this.props.tag, Object.assign(props, {
108
+ dangerouslySetInnerHTML: dangerouslySetInnerHTML
109
+ }));
85
110
  }
86
- return _react2.default.createElement(this.props.tag, props, this.getI18NValue());
111
+
112
+ return /*#__PURE__*/_react["default"].createElement(this.props.tag, props, this.getI18NValue());
87
113
  }
88
114
  }, {
89
- key: 'render',
115
+ key: "render",
90
116
  value: function render() {
91
117
  return this.createElement();
92
118
  }
93
119
  }]);
94
120
 
95
121
  return I18N;
96
- }(_react2.default.Component);
97
-
98
- exports.default = I18N;
122
+ }(_react["default"].Component);
99
123
 
124
+ exports["default"] = I18N;
100
125
  I18N.propTypes = {
101
- i18NKey: _propTypes2.default.string.isRequired,
102
- isHtml: _propTypes2.default.bool,
103
- tag: _propTypes2.default.string,
104
- values: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.array])
126
+ i18NKey: _propTypes["default"].string.isRequired,
127
+ isHtml: _propTypes["default"].bool,
128
+ tag: _propTypes["default"].string,
129
+ dataId: _propTypes["default"].string,
130
+ values: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].array])
105
131
  };
106
132
  I18N.defaultProps = {
107
133
  tag: 'span',