@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,14 +1,14 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.I18NContext = undefined;
6
+ exports.I18NContext = void 0;
7
7
 
8
- var _react = require('react');
8
+ var _react = _interopRequireDefault(require("react"));
9
9
 
10
- var _react2 = _interopRequireDefault(_react);
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
11
 
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ var I18NContext = /*#__PURE__*/_react["default"].createContext();
13
13
 
14
- var I18NContext = exports.I18NContext = _react2.default.createContext();
14
+ exports.I18NContext = I18NContext;
@@ -1,88 +1,109 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports["default"] = void 0;
6
7
 
7
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
8
+ var _react = _interopRequireDefault(require("react"));
8
9
 
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 _propTypes = _interopRequireDefault(require("prop-types"));
10
11
 
11
- var _react = require('react');
12
+ var _utils = require("../utils");
12
13
 
13
- var _react2 = _interopRequireDefault(_react);
14
+ var _FormatText = _interopRequireDefault(require("./FormatText"));
14
15
 
15
- var _propTypes = require('prop-types');
16
+ var _datetimejs = _interopRequireDefault(require("@zohodesk/datetimejs"));
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 _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
20
21
 
21
- var _FormatText = require('./FormatText');
22
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
23
 
23
- var _FormatText2 = _interopRequireDefault(_FormatText);
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); } }
24
25
 
25
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
26
27
 
27
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
29
+
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; }
28
37
 
29
- 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; } }
30
39
 
31
- 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); }
32
41
 
33
- var DateTimeDiffFormat = function (_React$Component) {
42
+ var DateTimeDiffFormat = /*#__PURE__*/function (_React$Component) {
34
43
  _inherits(DateTimeDiffFormat, _React$Component);
35
44
 
45
+ var _super = _createSuper(DateTimeDiffFormat);
46
+
36
47
  function DateTimeDiffFormat(props) {
37
- _classCallCheck(this, DateTimeDiffFormat);
48
+ var _this;
38
49
 
39
- var _this = _possibleConstructorReturn(this, (DateTimeDiffFormat.__proto__ || Object.getPrototypeOf(DateTimeDiffFormat)).call(this, props));
50
+ _classCallCheck(this, DateTimeDiffFormat);
40
51
 
41
- _this.getSuffix = _this.getSuffix.bind(_this);
52
+ _this = _super.call(this, props);
53
+ _this.getSuffix = _this.getSuffix.bind(_assertThisInitialized(_this));
42
54
  return _this;
43
55
  }
44
56
 
45
57
  _createClass(DateTimeDiffFormat, [{
46
- key: 'getSuffix',
58
+ key: "getSuffix",
47
59
  value: function getSuffix(min) {
48
- var suffix = void 0;
49
- if (min < 0) {
60
+ var suffix;
61
+
62
+ if (this.props.ago && min < 0) {
50
63
  suffix = this.props.ago || '';
51
- } else if (min > 0) {
64
+ } else if (this.props.later || min > 0) {
52
65
  suffix = this.props.later || '';
53
66
  } else {
54
67
  suffix = '';
55
68
  }
69
+
56
70
  return suffix;
57
71
  }
58
72
  }, {
59
- key: 'render',
73
+ key: "render",
60
74
  value: function render() {
61
- var _props = this.props,
62
- from = _props.from,
63
- fromTzData = _props.fromTzData,
64
- to = _props.to,
65
- toTzData = _props.toTzData,
66
- today = _props.today,
67
- yesterday = _props.yesterday,
68
- tomorrow = _props.tomorrow,
69
- others = _props.others,
70
- format = _props.format,
71
- dataId = _props.dataId,
72
- _props$className = _props.className,
73
- className = _props$className === undefined ? null : _props$className,
74
- _props$title = _props.title,
75
- title = _props$title === undefined ? null : _props$title;
76
-
77
-
78
- var fromDateObj = (0, _utils.convertUtcToUserTz)(from, fromTzData).getTime();
79
- var toDateObj = (0, _utils.convertUtcToUserTz)(to, toTzData).getTime();
75
+ var _this$props = this.props,
76
+ type = _this$props.type,
77
+ page = _this$props.page,
78
+ isNeedTime = _this$props.isNeedTime,
79
+ from = _this$props.from,
80
+ fromTzData = _this$props.fromTzData,
81
+ to = _this$props.to,
82
+ toTzData = _this$props.toTzData,
83
+ today = _this$props.today,
84
+ yesterday = _this$props.yesterday,
85
+ tomorrow = _this$props.tomorrow,
86
+ others = _this$props.others,
87
+ format = _this$props.format,
88
+ dataId = _this$props.dataId,
89
+ _this$props$className = _this$props.className,
90
+ className = _this$props$className === void 0 ? null : _this$props$className,
91
+ _this$props$title = _this$props.title,
92
+ title = _this$props$title === void 0 ? null : _this$props$title,
93
+ isOverdue = _this$props.isOverdue,
94
+ timeFormat = _this$props.timeFormat,
95
+ datePattern = _this$props.datePattern,
96
+ isEnabledCurrentYear = _this$props.isEnabledCurrentYear,
97
+ isDateField = _this$props.isDateField;
98
+
99
+ var fromDateObj = _datetimejs["default"].toDate(_datetimejs["default"].tz.utcToTz(from, fromTzData)).getTime();
100
+
101
+ var toDateObj = _datetimejs["default"].toDate(isDateField ? to : _datetimejs["default"].tz.utcToTz(to, toTzData)).getTime();
80
102
 
81
103
  var diffMin = new Date(to).getTime() - new Date(from).getTime();
82
104
  var suffix = this.getSuffix(diffMin);
83
105
  var diff = (0, _utils.getDiffObj)(diffMin);
84
106
  var withInAWeak = diff.y === 0 && diff.yd <= 7;
85
-
86
107
  var diffObj = {
87
108
  h: diff.h,
88
109
  m: diff.m,
@@ -98,6 +119,10 @@ var DateTimeDiffFormat = function (_React$Component) {
98
119
  suffix: suffix
99
120
  };
100
121
  var diffObj1 = {
122
+ to: to,
123
+ type: type,
124
+ page: page,
125
+ isNeedTime: isNeedTime,
101
126
  hours: diff.h,
102
127
  minutes: diff.m,
103
128
  seconds: diff.s,
@@ -105,44 +130,66 @@ var DateTimeDiffFormat = function (_React$Component) {
105
130
  yDays: diff.yd,
106
131
  isWithInAWeek: withInAWeak,
107
132
  suffix: suffix,
108
- crntMonth: new Date(to).getMonth(),
109
- betweenleepYears: (0, _utils.getLyears)(from, to)
110
- };
133
+ crntDate: new Date(from).getDate(),
134
+ crntMonth: new Date(from).getMonth(),
135
+ crntYear: new Date(from).getFullYear(),
136
+ crntHours: new Date(from).getHours(),
137
+ crntMinutes: new Date(from).getMinutes(),
138
+ crntSeconds: new Date(from).getSeconds(),
139
+ tDate: new Date(to).getDate(),
140
+ tMonth: new Date(to).getMonth(),
141
+ tYear: new Date(to).getFullYear(),
142
+ tHours: new Date(to).getHours(),
143
+ tMinutes: new Date(to).getMinutes(),
144
+ tSeconds: new Date(to).getSeconds(),
145
+ betweenleepYears: (0, _utils.getLyears)(from, to),
146
+ isOverdue: isOverdue,
147
+ timeFormat: timeFormat,
148
+ datePattern: datePattern,
149
+ dateTimePattern: "".concat(datePattern, " ").concat(timeFormat)
150
+ }; //In if condition we'll remove year and set date format if the current year is not required
151
+ //In else part we'll set the date format as it is
152
+
153
+ if (isEnabledCurrentYear === true && diffObj1.years === 0 && diffObj1.tYear === diffObj1.crntYear) {
154
+ var dateFormat = (0, _utils.getDatePatternWithoutYear)(datePattern);
155
+ diffObj1.dateFormat = dateFormat;
156
+ diffObj1.dateTimeFormat = "".concat(dateFormat, " ").concat(timeFormat);
157
+ } else {
158
+ diffObj1.dateFormat = datePattern;
159
+ diffObj1.dateTimeFormat = "".concat(datePattern, " ").concat(timeFormat);
160
+ }
111
161
 
112
162
  var key = '';
113
163
  var values = [];
114
164
  var text = null;
115
165
  var isSuffixEnable = false;
166
+
116
167
  if (format) {
117
- var years = void 0,
118
- months = void 0,
119
- days = void 0,
120
- hours = void 0,
121
- minutes = void 0,
122
- seconds = void 0;
168
+ var years, months, days, hours, minutes, seconds;
123
169
  years = diffObj1.years > 1 ? '2' : diffObj1.years;
124
-
125
170
  days = diff.yd > 1 ? '2' : diff.yd;
126
171
  hours = diffObj1.hours > 1 ? '2' : diffObj1.hours;
127
172
  minutes = diffObj1.minutes > 1 ? '2' : diffObj1.minutes;
128
-
129
173
  var count = 0;
130
174
  var pattern = [years, days, hours, minutes].reduce(function (res, next) {
131
175
  if (count === 2) {
132
- res = res + '0';
176
+ res = "".concat(res, "0");
133
177
  } else if (next !== 0) {
134
178
  count++;
135
179
  res = res + next;
136
180
  } else {
137
181
  res = res + next;
138
182
  }
183
+
139
184
  return res;
140
185
  }, '');
141
186
 
142
187
  var _value = format(diffObj1, pattern);
143
- if (_value && (typeof _value === 'undefined' ? 'undefined' : _typeof(_value)) === 'object') {
188
+
189
+ if (_value && _typeof(_value) === 'object') {
144
190
  key = _value.key;
145
191
  values = (0, _utils.getValues)(_value.params, diffObj);
192
+
146
193
  if (pattern.indexOf('00000') === 0) {
147
194
  //suffix ignore for second hook
148
195
  isSuffixEnable = false;
@@ -153,86 +200,83 @@ var DateTimeDiffFormat = function (_React$Component) {
153
200
  text = (0, _utils.formatDate)(toDateObj, _value, diffObj1);
154
201
  }
155
202
  } else {
156
- if (diff.y === 0 && (diff.yd === 0 || diff.yd === 1)) {
157
- var dateObj = new Date(toDateObj);
158
- var curDateObj = new Date(fromDateObj);
159
- if (dateObj.getDate() === curDateObj.getDate()) {
160
- if (typeof today === 'function') {
161
- var value = today(diffObj1);
162
- key = value.key;
163
- values = (0, _utils.getValues)(value.params, diffObj);
164
- } else if ((typeof today === 'undefined' ? 'undefined' : _typeof(today)) === 'object') {
165
- key = today.key;
166
- values = (0, _utils.getValues)(today.params, diffObj);
167
- isSuffixEnable = true;
168
- } else if (typeof today === 'string') {
169
- text = (0, _utils.formatDate)(toDateObj, today);
170
- }
171
- } else if (dateObj.getDate() < curDateObj.getDate()) {
172
- if (typeof yesterday === 'function') {
173
- var value = yesterday(diffObj1);
174
- key = value.key;
175
- values = (0, _utils.getValues)(value.params, diffObj);
176
- } else if ((typeof yesterday === 'undefined' ? 'undefined' : _typeof(yesterday)) === 'object') {
177
- key = yesterday.key;
178
- values = (0, _utils.getValues)(yesterday.params, diffObj);
179
- } else if (typeof yesterday === 'string') {
180
- text = (0, _utils.formatDate)(toDateObj, yesterday);
181
- }
182
- } else if (dateObj.getDate() > curDateObj.getDate()) {
183
- if (typeof tomorrow === 'function') {
184
- var value = tomorrow(diffObj1);
185
- key = value.key;
186
- text = (0, _utils.getValues)(value.params, diffObj);
187
- } else if ((typeof tomorrow === 'undefined' ? 'undefined' : _typeof(tomorrow)) === 'object') {
188
- key = tomorrow.key;
189
- values = (0, _utils.getValues)(tomorrow.params, diffObj);
190
- } else if (typeof tomorrow === 'string') {
191
- text = (0, _utils.formatDate)(toDateObj, tomorrow);
203
+ var dateObj = new Date(toDateObj);
204
+ var curDateObj = new Date(fromDateObj);
205
+ var diffDayType = diffObj1.yDays; //In this condition, to calculate different days we have copied it from live --> diffDayType
206
+
207
+ if (isOverdue && dateObj.getDate() < curDateObj.getDate() && diffObj1.yDays == 0) {
208
+ diffDayType = -1;
209
+ }
210
+
211
+ if (!isOverdue) {
212
+ var diffHr = dateObj.getHours() - curDateObj.getHours();
213
+
214
+ if (diffHr < 0) {
215
+ diffDayType += 1;
216
+ } else if (diffHr == 0) {
217
+ var diffMins = dateObj.getMinutes() - curDateObj.getMinutes();
218
+
219
+ if (diffMins < 0) {
220
+ diffDayType += 1;
221
+ } else if (diffMins == 0) {
222
+ var diffSec = dateObj.getSeconds() - curDateObj.getSeconds();
223
+
224
+ if (diffSec < 0) {
225
+ diffDayType += 1;
226
+ }
192
227
  }
193
228
  }
194
- } else {
195
- var value = others(diffObj1);
196
- if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
197
- key = value.key;
198
- values = (0, _utils.getValues)(value.params, diffObj);
199
- isSuffixEnable = true;
200
- } else if (typeof value === 'string') {
229
+ }
230
+
231
+ if (diff.y === 0 && (diffDayType === 0 || diffDayType === 1)) {
232
+ if (dateObj.getDate() === curDateObj.getDate()) {
233
+ var value = today && today(diffObj1) || others(diffObj1);
234
+ text = (0, _utils.formatDate)(toDateObj, value);
235
+ } else if (dateObj.getMonth() === curDateObj.getMonth() && dateObj.getDate() < curDateObj.getDate() || dateObj.getMonth() < curDateObj.getMonth()) {
236
+ var value = yesterday && yesterday(diffObj1) || others(diffObj1);
237
+ text = (0, _utils.formatDate)(toDateObj, value);
238
+ } else if (!isOverdue && diff.y === 0 && diffDayType === 1) {
239
+ var value = tomorrow && tomorrow(diffObj1) || others(diffObj1);
201
240
  text = (0, _utils.formatDate)(toDateObj, value);
202
241
  }
242
+ } else {
243
+ var value = others(diffObj1);
244
+ text = (0, _utils.formatDate)(toDateObj, value);
203
245
  }
204
246
  }
205
- return text ? _react2.default.createElement(
206
- 'span',
207
- { className: className, 'data-title': title, 'data-id': dataId },
208
- text
209
- ) : _react2.default.createElement(_FormatText2.default, {
210
- i18NKey: isSuffixEnable && suffix !== '' ? key + '.' + suffix : key,
247
+
248
+ return text ? /*#__PURE__*/_react["default"].createElement("span", {
249
+ className: className,
250
+ "data-title": title,
251
+ "data-id": dataId,
252
+ "data-test-id": dataId
253
+ }, text) : /*#__PURE__*/_react["default"].createElement(_FormatText["default"], {
254
+ i18NKey: isSuffixEnable && suffix !== '' ? "".concat(key, ".").concat(suffix) : key,
211
255
  values: values,
212
256
  className: className,
213
- 'data-title': title
257
+ "data-title": title
214
258
  });
215
259
  }
216
260
  }]);
217
261
 
218
262
  return DateTimeDiffFormat;
219
- }(_react2.default.Component);
220
-
221
- exports.default = DateTimeDiffFormat;
263
+ }(_react["default"].Component);
222
264
 
265
+ exports["default"] = DateTimeDiffFormat;
223
266
  DateTimeDiffFormat.propTypes = {
224
- ago: _propTypes2.default.string,
225
- className: _propTypes2.default.string,
226
- dataId: _propTypes2.default.string,
227
- format: _propTypes2.default.func,
228
- from: _propTypes2.default.string,
229
- fromTzData: _propTypes2.default.object,
230
- later: _propTypes2.default.string,
231
- others: _propTypes2.default.func,
232
- title: _propTypes2.default.string,
233
- to: _propTypes2.default.string,
234
- toTzData: _propTypes2.default.object,
235
- today: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object, _propTypes2.default.func]),
236
- tomorrow: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object, _propTypes2.default.func]),
237
- yesterday: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object, _propTypes2.default.func])
267
+ ago: _propTypes["default"].string,
268
+ className: _propTypes["default"].string,
269
+ dataId: _propTypes["default"].string,
270
+ format: _propTypes["default"].func,
271
+ from: _propTypes["default"].string,
272
+ fromTzData: _propTypes["default"].object,
273
+ isDateField: _propTypes["default"].bool,
274
+ later: _propTypes["default"].string,
275
+ others: _propTypes["default"].func,
276
+ title: _propTypes["default"].string,
277
+ to: _propTypes["default"].string,
278
+ toTzData: _propTypes["default"].object,
279
+ today: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object, _propTypes["default"].func]),
280
+ tomorrow: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object, _propTypes["default"].func]),
281
+ yesterday: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object, _propTypes["default"].func])
238
282
  };
@@ -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
  };