@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,85 +1,105 @@
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 _jsxTranslations = require("../utils/jsxTranslations");
15
17
 
16
- var _propTypes2 = _interopRequireDefault(_propTypes);
18
+ var _I18NContext = require("../I18NContext");
17
19
 
18
- var _utils = require('../utils');
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
21
 
20
- var _timezones = require('../timezones');
22
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
23
 
22
- var _reselect = require('reselect');
24
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
23
25
 
24
- var _I18NContext = require('../I18NContext');
26
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
25
27
 
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
27
29
 
28
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
30
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
31
+
32
+ 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); }; }
33
+
34
+ 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); }
35
+
36
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
29
37
 
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; }
38
+ 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; } }
31
39
 
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; }
40
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
33
41
 
34
42
  var emptyObj = {};
43
+
35
44
  var dummy = function dummy(key, values) {
36
45
  return key;
37
46
  };
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 = {
47
+
48
+ var i18NProviderUtils = {
44
49
  getI18NValue: dummy,
45
- userDateFormat: dummy
50
+ userDateFormat: dummy,
51
+ getI18NComponent: dummy
46
52
  };
53
+ exports.i18NProviderUtils = i18NProviderUtils;
47
54
 
48
- var I18NProvider = function (_React$Component) {
55
+ var I18NProvider = /*#__PURE__*/function (_React$Component) {
49
56
  _inherits(I18NProvider, _React$Component);
50
57
 
58
+ var _super = _createSuper(I18NProvider);
59
+
51
60
  function I18NProvider(props, context) {
52
- _classCallCheck(this, I18NProvider);
61
+ var _this;
53
62
 
54
- var _this = _possibleConstructorReturn(this, (I18NProvider.__proto__ || Object.getPrototypeOf(I18NProvider)).call(this, props, context));
63
+ _classCallCheck(this, I18NProvider);
55
64
 
65
+ _this = _super.call(this, props, context);
56
66
  i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(props.i18n);
57
- i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, (0, _timezones.unpack)(props.tzData));
67
+ i18NProviderUtils.getI18NComponent = (0, _jsxTranslations.getI18NComponent)(props.i18n);
68
+
69
+ if (props.tzData) {
70
+ i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, props.isEnabledCurrentYear);
71
+ }
72
+
58
73
  return _this;
59
74
  }
60
75
 
61
76
  _createClass(I18NProvider, [{
62
- key: 'componentDidUpdate',
63
- value: function componentDidUpdate(next) {
77
+ key: "componentDidUpdate",
78
+ value: function componentDidUpdate(prevProps) {
64
79
  var _this2 = this;
65
80
 
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) {
81
+ var _this$props = this.props,
82
+ i18n = _this$props.i18n,
83
+ timeZone = _this$props.timeZone,
84
+ datePattern = _this$props.datePattern,
85
+ timeFormat = _this$props.timeFormat,
86
+ direction = _this$props.direction,
87
+ onChange = _this$props.onChange,
88
+ tzData = _this$props.tzData,
89
+ isEnabledCurrentYear = _this$props.isEnabledCurrentYear;
90
+
91
+ if (i18n !== prevProps.i18n || timeZone !== prevProps.timeZone || datePattern !== prevProps.datePattern || timeFormat !== prevProps.timeFormat || direction !== prevProps.direction || tzData !== prevProps.tzData || isEnabledCurrentYear !== prevProps.isEnabledCurrentYear) {
77
92
  this.promise = new Promise(function (res, rej) {
78
93
  _this2.resolve = res;
79
94
  _this2.reject = rej;
80
95
  }).then(function () {
81
- i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(nextProps.i18n);
82
- i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, (0, _timezones.unpack)(tzData));
96
+ i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(_this2.props.i18n);
97
+ i18NProviderUtils.getI18NComponent = (0, _jsxTranslations.getI18NComponent)(_this2.props.i18n);
98
+
99
+ if (_this2.props.tzData) {
100
+ i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, _this2.props.tzData, _this2.props.timeFormat, _this2.props.datePattern, _this2.props.isEnabledCurrentYear);
101
+ }
102
+
83
103
  _this2.promise = null;
84
104
  }, function () {
85
105
  _this2.promise = null;
@@ -88,49 +108,42 @@ var I18NProvider = function (_React$Component) {
88
108
  }
89
109
  }
90
110
  }, {
91
- key: 'render',
111
+ key: "render",
92
112
  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
- );
113
+ return /*#__PURE__*/_react["default"].createElement(_I18NContext.I18NContext.Provider, {
114
+ value: {
115
+ i18n: this.props.i18n,
116
+ direction: this.props.direction,
117
+ timeZone: this.props.timeZone,
118
+ datePattern: this.props.datePattern,
119
+ timeFormat: this.props.timeFormat,
120
+ isEnabledCurrentYear: this.props.isEnabledCurrentYear,
121
+ tzData: this.props.tzData
122
+ }
123
+ }, this.props.children);
108
124
  }
109
125
  }]);
110
126
 
111
127
  return I18NProvider;
112
- }(_react2.default.Component);
113
-
114
- exports.default = I18NProvider;
115
-
128
+ }(_react["default"].Component);
116
129
 
130
+ exports["default"] = I18NProvider;
117
131
  I18NProvider.defaultProps = {
118
132
  i18n: emptyObj,
119
133
  timeZone: '',
120
134
  datePattern: '',
121
135
  timeFormat: '',
122
- dateTimeFormat: '',
136
+ isEnabledCurrentYear: '',
123
137
  direction: 'ltr'
124
138
  };
125
-
126
139
  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
140
+ children: _propTypes["default"].element.isRequired,
141
+ datePattern: _propTypes["default"].string,
142
+ isEnabledCurrentYear: _propTypes["default"].string,
143
+ direction: _propTypes["default"].string,
144
+ i18n: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].func]),
145
+ onChange: _propTypes["default"].func,
146
+ timeFormat: _propTypes["default"].string,
147
+ timeZone: _propTypes["default"].string,
148
+ tzData: _propTypes["default"].object
136
149
  };
@@ -1,53 +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;
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; };
10
+ var _react = _interopRequireDefault(require("react"));
8
11
 
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; }; }();
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
13
 
11
- var _react = require('react');
14
+ var _FormatText = _interopRequireDefault(require("./FormatText"));
12
15
 
13
- var _react2 = _interopRequireDefault(_react);
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
17
 
15
- var _propTypes = require('prop-types');
18
+ 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); }
16
19
 
17
- var _propTypes2 = _interopRequireDefault(_propTypes);
20
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
21
 
19
- var _FormatText = require('./FormatText');
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); } }
20
23
 
21
- var _FormatText2 = _interopRequireDefault(_FormatText);
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; }
22
25
 
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
24
27
 
25
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
+
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); }; }
31
+
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); }
26
33
 
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; }
34
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
28
35
 
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; }
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; } }
30
37
 
31
- var PluralFormat = function (_React$Component) {
38
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
39
+
40
+ var PluralFormat = /*#__PURE__*/function (_React$Component) {
32
41
  _inherits(PluralFormat, _React$Component);
33
42
 
43
+ var _super = _createSuper(PluralFormat);
44
+
34
45
  function PluralFormat() {
35
46
  _classCallCheck(this, PluralFormat);
36
47
 
37
- return _possibleConstructorReturn(this, (PluralFormat.__proto__ || Object.getPrototypeOf(PluralFormat)).apply(this, arguments));
48
+ return _super.apply(this, arguments);
38
49
  }
39
50
 
40
51
  _createClass(PluralFormat, [{
41
- key: 'render',
52
+ key: "render",
42
53
  value: function render() {
43
- var _props = this.props,
44
- one = _props.one,
45
- many = _props.many,
46
- zero = _props.zero,
47
- value = _props.value;
48
-
54
+ var _this$props = this.props,
55
+ one = _this$props.one,
56
+ many = _this$props.many,
57
+ zero = _this$props.zero,
58
+ value = _this$props.value;
49
59
  var key = '',
50
60
  values = '';
61
+
51
62
  if (value > 1) {
52
63
  key = many;
53
64
  } else if (value == 1) {
@@ -55,9 +66,9 @@ var PluralFormat = function (_React$Component) {
55
66
  } else if (value == 0) {
56
67
  key = zero;
57
68
  }
58
- values = '' + value;
59
69
 
60
- return _react2.default.createElement(_FormatText2.default, _extends({}, this.props, {
70
+ values = "".concat(value);
71
+ return /*#__PURE__*/_react["default"].createElement(_FormatText["default"], _extends({}, this.props, {
61
72
  i18NKey: key,
62
73
  values: values,
63
74
  one: null,
@@ -68,14 +79,13 @@ var PluralFormat = function (_React$Component) {
68
79
  }]);
69
80
 
70
81
  return PluralFormat;
71
- }(_react2.default.Component);
72
-
73
- exports.default = PluralFormat;
82
+ }(_react["default"].Component);
74
83
 
84
+ exports["default"] = PluralFormat;
75
85
  PluralFormat.propTypes = {
76
- many: _propTypes2.default.string,
77
- one: _propTypes2.default.string,
78
- tag: _propTypes2.default.string,
79
- value: _propTypes2.default.number,
80
- zero: _propTypes2.default.string
86
+ many: _propTypes["default"].string,
87
+ one: _propTypes["default"].string,
88
+ tag: _propTypes["default"].string,
89
+ value: _propTypes["default"].number,
90
+ zero: _propTypes["default"].string
81
91
  };
@@ -1,85 +1,104 @@
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; }; }();
10
+ var _react = _interopRequireWildcard(require("react"));
8
11
 
9
- var _react = require('react');
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
13
 
11
- var _react2 = _interopRequireDefault(_react);
14
+ var _DateTimeDiffFormat = _interopRequireDefault(require("./DateTimeDiffFormat"));
12
15
 
13
- var _propTypes = require('prop-types');
16
+ var _I18NContext = require("../I18NContext");
14
17
 
15
- var _propTypes2 = _interopRequireDefault(_propTypes);
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
19
 
17
- var _DateTimeDiffFormat = require('./DateTimeDiffFormat');
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); }
18
21
 
19
- var _DateTimeDiffFormat2 = _interopRequireDefault(_DateTimeDiffFormat);
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; }
20
23
 
21
- var _I18NContext = require('../I18NContext');
24
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
25
 
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+ 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); } }
24
27
 
25
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
29
+
30
+ 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); }
31
+
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
+
34
+ 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); }; }
26
35
 
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; }
36
+ 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); }
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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
30
39
 
31
- var UserTimeDiffFormat = function (_Component) {
40
+ 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; } }
41
+
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
+
44
+ var UserTimeDiffFormat = /*#__PURE__*/function (_Component) {
32
45
  _inherits(UserTimeDiffFormat, _Component);
33
46
 
47
+ var _super = _createSuper(UserTimeDiffFormat);
48
+
34
49
  function UserTimeDiffFormat() {
35
50
  _classCallCheck(this, UserTimeDiffFormat);
36
51
 
37
- return _possibleConstructorReturn(this, (UserTimeDiffFormat.__proto__ || Object.getPrototypeOf(UserTimeDiffFormat)).apply(this, arguments));
52
+ return _super.apply(this, arguments);
38
53
  }
39
54
 
40
55
  _createClass(UserTimeDiffFormat, [{
41
- key: 'render',
56
+ key: "render",
42
57
  value: function render() {
43
58
  var currentTime = new Date();
44
59
  var currentTimeUTCString = currentTime.toISOString();
45
- var _props = this.props,
46
- type = _props.type,
47
- to = _props.to,
48
- today = _props.today,
49
- yesterday = _props.yesterday,
50
- tomorrow = _props.tomorrow,
51
- others = _props.others,
52
- ago = _props.ago,
53
- later = _props.later,
54
- format = _props.format,
55
- title = _props.title,
56
- className = _props.className,
57
- displayType = _props.displayType,
58
- dataId = _props.dataId,
59
- isOverdue = _props.isOverdue;
60
+ var _this$props = this.props,
61
+ type = _this$props.type,
62
+ page = _this$props.page,
63
+ isNeedTime = _this$props.isNeedTime,
64
+ to = _this$props.to,
65
+ today = _this$props.today,
66
+ yesterday = _this$props.yesterday,
67
+ tomorrow = _this$props.tomorrow,
68
+ others = _this$props.others,
69
+ ago = _this$props.ago,
70
+ later = _this$props.later,
71
+ format = _this$props.format,
72
+ title = _this$props.title,
73
+ className = _this$props.className,
74
+ displayType = _this$props.displayType,
75
+ dataId = _this$props.dataId,
76
+ isOverdue = _this$props.isOverdue,
77
+ isDateField = _this$props.isDateField;
60
78
 
61
79
  var _ref = this.context || {},
62
80
  tzData = _ref.tzData,
63
81
  timeFormat = _ref.timeFormat,
64
82
  datePattern = _ref.datePattern,
65
- dateTimeFormat = _ref.dateTimeFormat,
66
- timeZone = _ref.timeZone;
83
+ isEnabledCurrentYear = _ref.isEnabledCurrentYear;
67
84
 
68
85
  if (!format && !others) {
69
- var pattern = displayType === 'date' ? datePattern : displayType === 'time' ? timeFormat : displayType === 'dateTime' ? dateTimeFormat : '';
70
- format = function format() {
71
- return pattern;
86
+ format = function format(_ref2) {
87
+ var dateTimeFormat = _ref2.dateTimeFormat,
88
+ dateFormat = _ref2.dateFormat,
89
+ timeFormat = _ref2.timeFormat;
90
+ displayType === 'dateTime' ? dateTimeFormat : displayType === 'date' ? dateFormat : timeFormat;
72
91
  };
73
92
  }
74
93
 
75
- var tz = tzData || timeZone;
76
-
77
- return _react2.default.createElement(_DateTimeDiffFormat2.default, {
94
+ return /*#__PURE__*/_react["default"].createElement(_DateTimeDiffFormat["default"], {
78
95
  type: type,
96
+ page: page,
97
+ isNeedTime: isNeedTime,
79
98
  from: currentTimeUTCString,
80
- fromTzData: tz,
99
+ fromTzData: tzData,
81
100
  to: to,
82
- toTzData: tz,
101
+ toTzData: tzData,
83
102
  today: today,
84
103
  yesterday: yesterday,
85
104
  tomorrow: tomorrow,
@@ -90,7 +109,11 @@ var UserTimeDiffFormat = function (_Component) {
90
109
  title: title,
91
110
  className: className,
92
111
  dataId: dataId,
93
- isOverdue: isOverdue
112
+ isOverdue: isOverdue,
113
+ timeFormat: timeFormat,
114
+ datePattern: datePattern,
115
+ isEnabledCurrentYear: isEnabledCurrentYear,
116
+ isDateField: isDateField
94
117
  });
95
118
  }
96
119
  }]);
@@ -98,20 +121,20 @@ var UserTimeDiffFormat = function (_Component) {
98
121
  return UserTimeDiffFormat;
99
122
  }(_react.Component);
100
123
 
101
- exports.default = UserTimeDiffFormat;
102
-
124
+ exports["default"] = UserTimeDiffFormat;
103
125
  UserTimeDiffFormat.propTypes = {
104
- ago: _propTypes2.default.string,
105
- className: _propTypes2.default.string,
106
- dataId: _propTypes2.default.string,
107
- displayType: _propTypes2.default.oneOf(['date', 'time', 'dateTime']),
108
- format: _propTypes2.default.func,
109
- later: _propTypes2.default.string,
110
- others: _propTypes2.default.func,
111
- title: _propTypes2.default.string,
112
- to: _propTypes2.default.string,
113
- today: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object, _propTypes2.default.func]),
114
- tomorrow: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object, _propTypes2.default.func]),
115
- yesterday: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object, _propTypes2.default.func])
126
+ ago: _propTypes["default"].string,
127
+ className: _propTypes["default"].string,
128
+ dataId: _propTypes["default"].string,
129
+ displayType: _propTypes["default"].oneOf(['date', 'time', 'dateTime']),
130
+ format: _propTypes["default"].func,
131
+ isDateField: _propTypes["default"].bool,
132
+ later: _propTypes["default"].string,
133
+ others: _propTypes["default"].func,
134
+ title: _propTypes["default"].string,
135
+ to: _propTypes["default"].string,
136
+ today: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object, _propTypes["default"].func]),
137
+ tomorrow: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object, _propTypes["default"].func]),
138
+ yesterday: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object, _propTypes["default"].func])
116
139
  };
117
140
  UserTimeDiffFormat.contextType = _I18NContext.I18NContext;