@zohodesk/i18n 1.0.0-beta.2 → 1.0.0-beta.21

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 (67) hide show
  1. package/README.md +80 -0
  2. package/es/I18NContext.js +1 -2
  3. package/es/components/DateTimeDiffFormat.js +192 -184
  4. package/es/components/FormatText.js +4 -25
  5. package/es/components/HOCI18N.js +33 -45
  6. package/es/components/I18N.js +46 -63
  7. package/es/components/I18NProvider.js +54 -84
  8. package/es/components/PluralFormat.js +29 -48
  9. package/es/components/UserTimeDiffFormat.js +65 -70
  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.js +250 -385
  19. package/lib/I18NContext.js +6 -6
  20. package/lib/components/DateTimeDiffFormat.js +167 -123
  21. package/lib/components/FormatText.js +32 -22
  22. package/lib/components/HOCI18N.js +47 -23
  23. package/lib/components/I18N.js +60 -36
  24. package/lib/components/I18NProvider.js +76 -69
  25. package/lib/components/PluralFormat.js +42 -32
  26. package/lib/components/UserTimeDiffFormat.js +81 -54
  27. package/lib/components/__tests__/DateTimeDiffFormat.spec.js +815 -629
  28. package/lib/components/__tests__/FormatText.spec.js +23 -25
  29. package/lib/components/__tests__/HOCI18N.spec.js +26 -34
  30. package/lib/components/__tests__/I18N.spec.js +21 -26
  31. package/lib/components/__tests__/I18NProvider.spec.js +43 -51
  32. package/lib/components/__tests__/PluralFormat.spec.js +24 -28
  33. package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1256 -1039
  34. package/lib/index.js +73 -119
  35. package/lib/utils.js +222 -329
  36. package/package.json +2 -2
  37. package/src/I18NContext.js +3 -0
  38. package/src/components/DateTimeDiffFormat.js +256 -0
  39. package/src/components/FormatText.js +14 -0
  40. package/src/components/HOCI18N.js +37 -0
  41. package/src/components/I18N.js +72 -0
  42. package/src/components/I18NProvider.js +110 -0
  43. package/src/components/PluralFormat.js +37 -0
  44. package/src/components/UserTimeDiffFormat.js +97 -0
  45. package/src/components/__tests__/DateTimeDiffFormat.spec.js +618 -0
  46. package/src/components/__tests__/FormatText.spec.js +27 -0
  47. package/src/components/__tests__/HOCI18N.spec.js +33 -0
  48. package/src/components/__tests__/I18N.spec.js +30 -0
  49. package/src/components/__tests__/I18NProvider.spec.js +65 -0
  50. package/src/components/__tests__/PluralFormat.spec.js +28 -0
  51. package/src/components/__tests__/UserTimeDiffFormat.spec.js +1076 -0
  52. package/src/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -0
  53. package/src/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -0
  54. package/src/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -0
  55. package/src/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -0
  56. package/src/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -0
  57. package/src/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -0
  58. package/src/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -0
  59. package/src/index.js +33 -0
  60. package/src/utils.js +527 -0
  61. package/.DS_Store +0 -0
  62. package/es/components/NewDateFormat.js +0 -50
  63. package/es/offset.js +0 -629
  64. package/es/timezones.js +0 -112
  65. package/lib/components/NewDateFormat.js +0 -68
  66. package/lib/offset.js +0 -634
  67. package/lib/timezones.js +0 -120
@@ -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,41 @@ 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;
78
100
  }
101
+
79
102
  if (this.props.isHtml) {
80
103
  var dangerouslySetInnerHTML = {
81
104
  __html: _SecurityJS.HTMLPurifier.sanitize(this.getI18NValue())
82
105
  };
83
-
84
- return _react2.default.createElement(this.props.tag, Object.assign(props, { dangerouslySetInnerHTML: dangerouslySetInnerHTML }));
106
+ return /*#__PURE__*/_react["default"].createElement(this.props.tag, Object.assign(props, {
107
+ dangerouslySetInnerHTML: dangerouslySetInnerHTML
108
+ }));
85
109
  }
86
- return _react2.default.createElement(this.props.tag, props, this.getI18NValue());
110
+
111
+ return /*#__PURE__*/_react["default"].createElement(this.props.tag, props, this.getI18NValue());
87
112
  }
88
113
  }, {
89
- key: 'render',
114
+ key: "render",
90
115
  value: function render() {
91
116
  return this.createElement();
92
117
  }
93
118
  }]);
94
119
 
95
120
  return I18N;
96
- }(_react2.default.Component);
97
-
98
- exports.default = I18N;
121
+ }(_react["default"].Component);
99
122
 
123
+ exports["default"] = I18N;
100
124
  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])
125
+ i18NKey: _propTypes["default"].string.isRequired,
126
+ isHtml: _propTypes["default"].bool,
127
+ tag: _propTypes["default"].string,
128
+ values: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].array])
105
129
  };
106
130
  I18N.defaultProps = {
107
131
  tag: 'span',
@@ -1,85 +1,99 @@
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
  });
6
- exports.i18NProviderUtils = undefined;
8
+ exports.i18NProviderUtils = exports["default"] = void 0;
7
9
 
8
- 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 = _interopRequireDefault(require("react"));
9
11
 
10
- var _react = require('react');
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
13
 
12
- var _react2 = _interopRequireDefault(_react);
14
+ var _utils = require("../utils");
13
15
 
14
- var _propTypes = require('prop-types');
16
+ var _I18NContext = require("../I18NContext");
15
17
 
16
- var _propTypes2 = _interopRequireDefault(_propTypes);
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
19
 
18
- var _utils = require('../utils');
20
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
21
 
20
- var _timezones = require('../timezones');
22
+ 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); } }
21
23
 
22
- var _reselect = require('reselect');
24
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
25
 
24
- var _I18NContext = require('../I18NContext');
26
+ 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); }
25
27
 
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
27
29
 
28
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
30
+ 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); }; }
29
31
 
30
- 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; }
32
+ 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); }
31
33
 
32
- 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; }
34
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
35
+
36
+ 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; } }
37
+
38
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
33
39
 
34
40
  var emptyObj = {};
41
+
35
42
  var dummy = function dummy(key, values) {
36
43
  return key;
37
44
  };
38
- var getTzData = (0, _reselect.createSelector)([function (tzStr) {
39
- return tzStr;
40
- }], function (tzStr) {
41
- return (0, _timezones.unpack)(tzStr);
42
- });
43
- var i18NProviderUtils = exports.i18NProviderUtils = {
45
+
46
+ var i18NProviderUtils = {
44
47
  getI18NValue: dummy,
45
48
  userDateFormat: dummy
46
49
  };
50
+ exports.i18NProviderUtils = i18NProviderUtils;
47
51
 
48
- var I18NProvider = function (_React$Component) {
52
+ var I18NProvider = /*#__PURE__*/function (_React$Component) {
49
53
  _inherits(I18NProvider, _React$Component);
50
54
 
55
+ var _super = _createSuper(I18NProvider);
56
+
51
57
  function I18NProvider(props, context) {
52
- _classCallCheck(this, I18NProvider);
58
+ var _this;
53
59
 
54
- var _this = _possibleConstructorReturn(this, (I18NProvider.__proto__ || Object.getPrototypeOf(I18NProvider)).call(this, props, context));
60
+ _classCallCheck(this, I18NProvider);
55
61
 
62
+ _this = _super.call(this, props, context);
56
63
  i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(props.i18n);
57
- i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, (0, _timezones.unpack)(props.tzData));
64
+
65
+ if (props.tzData) {
66
+ i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, props.isEnabledCurrentYear);
67
+ }
68
+
58
69
  return _this;
59
70
  }
60
71
 
61
72
  _createClass(I18NProvider, [{
62
- key: 'componentDidUpdate',
73
+ key: "componentDidUpdate",
63
74
  value: function componentDidUpdate(next) {
64
75
  var _this2 = this;
65
76
 
66
- var _props = this.props,
67
- i18n = _props.i18n,
68
- timeZone = _props.timeZone,
69
- datePattern = _props.datePattern,
70
- timeFormat = _props.timeFormat,
71
- dateTimeFormat = _props.dateTimeFormat,
72
- direction = _props.direction,
73
- onChange = _props.onChange,
74
- tzData = _props.tzData;
75
-
76
- if (i18n !== next.i18n || timeZone !== next.timeZone || datePattern !== next.datePattern || timeFormat !== next.timeFormat || dateTimeFormat !== next.dateTimeFormat || direction !== next.direction || tzData !== next.tzData) {
77
+ var _this$props = this.props,
78
+ i18n = _this$props.i18n,
79
+ timeZone = _this$props.timeZone,
80
+ datePattern = _this$props.datePattern,
81
+ timeFormat = _this$props.timeFormat,
82
+ direction = _this$props.direction,
83
+ onChange = _this$props.onChange,
84
+ tzData = _this$props.tzData;
85
+
86
+ if (i18n !== next.i18n || timeZone !== next.timeZone || datePattern !== next.datePattern || timeFormat !== next.timeFormat || direction !== next.direction || tzData !== next.tzData) {
77
87
  this.promise = new Promise(function (res, rej) {
78
88
  _this2.resolve = res;
79
89
  _this2.reject = rej;
80
90
  }).then(function () {
81
91
  i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(nextProps.i18n);
82
- i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, (0, _timezones.unpack)(tzData));
92
+
93
+ if (props.tzData) {
94
+ i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, _this2.props.isEnabledCurrentYear);
95
+ }
96
+
83
97
  _this2.promise = null;
84
98
  }, function () {
85
99
  _this2.promise = null;
@@ -88,49 +102,42 @@ var I18NProvider = function (_React$Component) {
88
102
  }
89
103
  }
90
104
  }, {
91
- key: 'render',
105
+ key: "render",
92
106
  value: function render() {
93
- return _react2.default.createElement(
94
- _I18NContext.I18NContext.Provider,
95
- {
96
- value: {
97
- i18n: this.props.i18n,
98
- direction: this.props.direction,
99
- timeZone: this.props.timeZone,
100
- tzData: getTzData(this.props.tzData),
101
- datePattern: this.props.datePattern,
102
- timeFormat: this.props.timeFormat,
103
- dateTimeFormat: this.props.dateTimeFormat
104
- }
105
- },
106
- this.props.children
107
- );
107
+ return /*#__PURE__*/_react["default"].createElement(_I18NContext.I18NContext.Provider, {
108
+ value: {
109
+ i18n: this.props.i18n,
110
+ direction: this.props.direction,
111
+ timeZone: this.props.timeZone,
112
+ datePattern: this.props.datePattern,
113
+ timeFormat: this.props.timeFormat,
114
+ isEnabledCurrentYear: this.props.isEnabledCurrentYear,
115
+ tzData: this.props.tzData
116
+ }
117
+ }, this.props.children);
108
118
  }
109
119
  }]);
110
120
 
111
121
  return I18NProvider;
112
- }(_react2.default.Component);
113
-
114
- exports.default = I18NProvider;
115
-
122
+ }(_react["default"].Component);
116
123
 
124
+ exports["default"] = I18NProvider;
117
125
  I18NProvider.defaultProps = {
118
126
  i18n: emptyObj,
119
127
  timeZone: '',
120
128
  datePattern: '',
121
129
  timeFormat: '',
122
- dateTimeFormat: '',
130
+ isEnabledCurrentYear: '',
123
131
  direction: 'ltr'
124
132
  };
125
-
126
133
  I18NProvider.propTypes = {
127
- children: _propTypes2.default.element.isRequired,
128
- datePattern: _propTypes2.default.string,
129
- dateTimeFormat: _propTypes2.default.string,
130
- direction: _propTypes2.default.string,
131
- i18n: _propTypes2.default.oneOfType([_propTypes2.default.object, _propTypes2.default.func]),
132
- onChange: _propTypes2.default.func,
133
- timeFormat: _propTypes2.default.string,
134
- timeZone: _propTypes2.default.string,
135
- tzData: _propTypes2.default.string
134
+ children: _propTypes["default"].element.isRequired,
135
+ datePattern: _propTypes["default"].string,
136
+ isEnabledCurrentYear: _propTypes["default"].string,
137
+ direction: _propTypes["default"].string,
138
+ i18n: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].func]),
139
+ onChange: _propTypes["default"].func,
140
+ timeFormat: _propTypes["default"].string,
141
+ timeZone: _propTypes["default"].string,
142
+ tzData: _propTypes["default"].object
136
143
  };