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

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 +116 -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 +59 -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 +82 -70
  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 +34 -25
  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
package/README.md CHANGED
@@ -1,9 +1,123 @@
1
1
  # i18n
2
2
 
3
- # 1.0.0-beta.0
3
+ # 1.0.0-beta.30
4
4
 
5
- - Test Publish
5
+ - Upgrading @zoho/SecurityJS package to 6.4.2
6
+
7
+ # 1.0.0-beta.29
8
+
9
+ - Downgrading @zoho/SecurityJS package to 6.3.0
10
+
11
+
12
+ # 1.0.0-beta.28
13
+
14
+ - Updating @zoho/SecurityJS package to 7.0.2
15
+
16
+
17
+ # 1.0.0-beta.27
18
+
19
+ - JSX support within a text
20
+
21
+ # 1.0.0-beta.26
22
+
23
+ - Localization feature enhancement in i18n method.
24
+
25
+ # 1.0.0-beta.25
26
+
27
+ - July i18n key correction
28
+
29
+ # 1.0.0-beta.24
30
+
31
+ - I18N support for Days, Months and 12-hour time variables.
32
+
33
+ # 1.0.0-beta.23
34
+
35
+ - Zoho security version updated.
36
+
37
+ # 1.0.0-beta.22
38
+
39
+ - Data test id added for I18N.js
40
+
41
+ # 1.0.0-beta.21
42
+
43
+ - Data test id added for dateTimedifformat.js
44
+
45
+ # 1.0.0-beta.20
46
+
47
+ - Date field issue fixed in UserTimeDiffFormat component
48
+
49
+ # 1.0.0-beta.19
50
+
51
+ - In this version we have made changes in i18n provider to call user date format function only if the time zone data is available.
52
+
53
+ # 1.0.0-beta.18
54
+
55
+ - Localization feature added and incorporated into getI18NValue Method.
56
+
57
+ # 1.0.0-beta.17
58
+
59
+ - There was some i18n changes done in live before moving the date format build to live. Since we need these changes we have published it as new version.
60
+
61
+ # 1.0.0-beta.16
62
+
63
+ - DatePattern and dateTimePattern key has been changed for the date format build.
64
+
65
+ # 1.0.0-beta.15.1
66
+
67
+ - Zoho security version updated.
68
+
69
+ # 1.0.0-beta.15
70
+
71
+ - When working on date format build we have published I18n. Also, before moving date format build to master we had a emergency fix that need to be sent, so when publishing I18n we have published the date format changes with the next version.
72
+
73
+ # 1.0.0-beta.14
74
+
75
+ - Issue fixed in enable current year.
76
+
77
+ # 1.0.0-beta.13
78
+
79
+ - Issue fixed in due date.
80
+
81
+ # 1.0.0-beta.12
82
+
83
+ - Issue fixed in date Format Pattern.
84
+
85
+ # 1.0.0-beta.11
86
+
87
+ - Date Format Changes
88
+
89
+ # 1.0.0-beta.10
90
+
91
+ - Date Format Issue Fixes
92
+
93
+ # 1.0.0-beta.9
94
+
95
+ - Date Format Changes
96
+
97
+ # 1.0.0-beta.8
98
+
99
+ - ES Module Support Changes
100
+
101
+ # 1.0.0-beta.7
102
+
103
+ - 'userDateFormat' util method - 'others' function fix
104
+
105
+ # 1.0.0-beta.6
106
+
107
+ - Added new prop 'isNeedTime' for DateTimeDiffFormat Component
108
+
109
+ # 1.0.0-beta.5
110
+
111
+ - Timezone logic moved to @zohodesk/datetimejs
112
+
113
+ # 1.0.0-beta.4
114
+
115
+ - Added new prop 'page' for DateTimeDiffFormat Component
6
116
 
7
117
  # 1.0.0-beta.3
8
118
 
9
119
  - Added support for exact times along with relative times in format() function
120
+
121
+ # 1.0.0-beta.0
122
+
123
+ - Test Publish
package/es/I18NContext.js CHANGED
@@ -1,3 +1,2 @@
1
1
  import React from 'react';
2
-
3
- export var I18NContext = React.createContext();
2
+ export const I18NContext = /*#__PURE__*/React.createContext();
@@ -1,220 +1,211 @@
1
- import _typeof from 'babel-runtime/helpers/typeof';
2
- import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
3
- import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4
- import _createClass from 'babel-runtime/helpers/createClass';
5
- import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
6
- import _inherits from 'babel-runtime/helpers/inherits';
7
1
  import React from 'react';
8
2
  import PropTypes from 'prop-types';
9
- import { pad, getValues, getDiffObj, formatDate, getLyears, convertUtcToUserTz } from '../utils';
3
+ import { pad, getValues, getDiffObj, formatDate, getLyears, getDatePatternWithoutYear } from '../utils';
10
4
  import FormatText from './FormatText';
5
+ import datetime from '@zohodesk/datetimejs';
6
+ export default class DateTimeDiffFormat extends React.Component {
7
+ constructor(props) {
8
+ super(props);
9
+ this.getSuffix = this.getSuffix.bind(this);
10
+ }
11
11
 
12
- var DateTimeDiffFormat = function (_React$Component) {
13
- _inherits(DateTimeDiffFormat, _React$Component);
14
-
15
- function DateTimeDiffFormat(props) {
16
- _classCallCheck(this, DateTimeDiffFormat);
12
+ getSuffix(min) {
13
+ let suffix;
17
14
 
18
- var _this = _possibleConstructorReturn(this, (DateTimeDiffFormat.__proto__ || _Object$getPrototypeOf(DateTimeDiffFormat)).call(this, props));
15
+ if (this.props.ago && min < 0) {
16
+ suffix = this.props.ago || '';
17
+ } else if (this.props.later || min > 0) {
18
+ suffix = this.props.later || '';
19
+ } else {
20
+ suffix = '';
21
+ }
19
22
 
20
- _this.getSuffix = _this.getSuffix.bind(_this);
21
- return _this;
23
+ return suffix;
22
24
  }
23
25
 
24
- _createClass(DateTimeDiffFormat, [{
25
- key: 'getSuffix',
26
- value: function getSuffix(min) {
27
- var suffix = void 0;
28
- if (this.props.ago && min < 0) {
29
- suffix = this.props.ago || '';
30
- } else if (this.props.later || min > 0) {
31
- suffix = this.props.later || '';
32
- } else {
33
- suffix = '';
34
- }
35
- return suffix;
26
+ render() {
27
+ const {
28
+ type,
29
+ page,
30
+ isNeedTime,
31
+ from,
32
+ fromTzData,
33
+ to,
34
+ toTzData,
35
+ today,
36
+ yesterday,
37
+ tomorrow,
38
+ others,
39
+ format,
40
+ dataId,
41
+ className = null,
42
+ title = null,
43
+ isOverdue,
44
+ timeFormat,
45
+ datePattern,
46
+ isEnabledCurrentYear,
47
+ isDateField
48
+ } = this.props;
49
+ let fromDateObj = datetime.toDate(datetime.tz.utcToTz(from, fromTzData)).getTime();
50
+ let toDateObj = datetime.toDate(isDateField ? to : datetime.tz.utcToTz(to, toTzData)).getTime();
51
+ let diffMin = new Date(to).getTime() - new Date(from).getTime();
52
+ let suffix = this.getSuffix(diffMin);
53
+ let diff = getDiffObj(diffMin);
54
+ let withInAWeak = diff.y === 0 && diff.yd <= 7;
55
+ let diffObj = {
56
+ h: diff.h,
57
+ m: diff.m,
58
+ s: diff.s,
59
+ y: diff.y,
60
+ hh: pad(diff.h, 2),
61
+ mm: pad(diff.m, 2),
62
+ ss: pad(diff.s, 2),
63
+ yy: pad(diff.y, 2),
64
+ days: diff.yd,
65
+ yDays: pad(diff.yd, 2),
66
+ isWithInAWeek: withInAWeak,
67
+ suffix: suffix
68
+ };
69
+ let diffObj1 = {
70
+ to: to,
71
+ type: type,
72
+ page: page,
73
+ isNeedTime: isNeedTime,
74
+ hours: diff.h,
75
+ minutes: diff.m,
76
+ seconds: diff.s,
77
+ years: diff.y,
78
+ yDays: diff.yd,
79
+ isWithInAWeek: withInAWeak,
80
+ suffix: suffix,
81
+ crntDate: new Date(from).getDate(),
82
+ crntMonth: new Date(from).getMonth(),
83
+ crntYear: new Date(from).getFullYear(),
84
+ crntHours: new Date(from).getHours(),
85
+ crntMinutes: new Date(from).getMinutes(),
86
+ crntSeconds: new Date(from).getSeconds(),
87
+ tDate: new Date(to).getDate(),
88
+ tMonth: new Date(to).getMonth(),
89
+ tYear: new Date(to).getFullYear(),
90
+ tHours: new Date(to).getHours(),
91
+ tMinutes: new Date(to).getMinutes(),
92
+ tSeconds: new Date(to).getSeconds(),
93
+ betweenleepYears: getLyears(from, to),
94
+ isOverdue: isOverdue,
95
+ timeFormat: timeFormat,
96
+ datePattern: datePattern,
97
+ dateTimePattern: `${datePattern} ${timeFormat}`
98
+ }; //In if condition we'll remove year and set date format if the current year is not required
99
+ //In else part we'll set the date format as it is
100
+
101
+ if (isEnabledCurrentYear === true && diffObj1.years === 0 && diffObj1.tYear === diffObj1.crntYear) {
102
+ let dateFormat = getDatePatternWithoutYear(datePattern);
103
+ diffObj1.dateFormat = dateFormat;
104
+ diffObj1.dateTimeFormat = `${dateFormat} ${timeFormat}`;
105
+ } else {
106
+ diffObj1.dateFormat = datePattern;
107
+ diffObj1.dateTimeFormat = `${datePattern} ${timeFormat}`;
36
108
  }
37
- }, {
38
- key: 'render',
39
- value: function render() {
40
- var _props = this.props,
41
- type = _props.type,
42
- from = _props.from,
43
- fromTzData = _props.fromTzData,
44
- to = _props.to,
45
- toTzData = _props.toTzData,
46
- today = _props.today,
47
- yesterday = _props.yesterday,
48
- tomorrow = _props.tomorrow,
49
- others = _props.others,
50
- format = _props.format,
51
- dataId = _props.dataId,
52
- _props$className = _props.className,
53
- className = _props$className === undefined ? null : _props$className,
54
- _props$title = _props.title,
55
- title = _props$title === undefined ? null : _props$title,
56
- isOverdue = _props.isOverdue;
57
-
58
-
59
- var fromDateObj = convertUtcToUserTz(from, fromTzData).getTime();
60
- var toDateObj = convertUtcToUserTz(to, toTzData).getTime();
61
-
62
- var diffMin = new Date(to).getTime() - new Date(from).getTime();
63
- var suffix = this.getSuffix(diffMin);
64
- var diff = getDiffObj(diffMin);
65
- var withInAWeak = diff.y === 0 && diff.yd <= 7;
66
-
67
- var diffObj = {
68
- h: diff.h,
69
- m: diff.m,
70
- s: diff.s,
71
- y: diff.y,
72
- hh: pad(diff.h, 2),
73
- mm: pad(diff.m, 2),
74
- ss: pad(diff.s, 2),
75
- yy: pad(diff.y, 2),
76
- days: diff.yd,
77
- yDays: pad(diff.yd, 2),
78
- isWithInAWeek: withInAWeak,
79
- suffix: suffix
80
- };
81
- var diffObj1 = {
82
- type: type,
83
- hours: diff.h,
84
- minutes: diff.m,
85
- seconds: diff.s,
86
- years: diff.y,
87
- yDays: diff.yd,
88
- yMonth: diff.m,
89
- isWithInAWeek: withInAWeak,
90
- suffix: suffix,
91
- crntDate: new Date(from).getDate(),
92
- crntMonth: new Date(from).getMonth(),
93
- crntYear: new Date(from).getFullYear(),
94
- crntHours: new Date(from).getHours(),
95
- crntMinutes: new Date(from).getMinutes(),
96
- crntSeconds: new Date(from).getSeconds(),
97
- tDate: new Date(to).getDate(),
98
- tMonth: new Date(to).getMonth(),
99
- tYear: new Date(to).getFullYear(),
100
- tHours: new Date(to).getHours(),
101
- tMinutes: new Date(to).getMinutes(),
102
- tSeconds: new Date(to).getSeconds(),
103
- betweenleepYears: getLyears(from, to),
104
- isOverdue: isOverdue
105
- };
106
-
107
- var key = '';
108
- var values = [];
109
- var text = null;
110
- var isSuffixEnable = false;
111
- if (format) {
112
- var years = void 0,
113
- months = void 0,
114
- days = void 0,
115
- hours = void 0,
116
- minutes = void 0,
117
- seconds = void 0;
118
- years = diffObj1.years > 1 ? '2' : diffObj1.years;
119
-
120
- days = diff.yd > 1 ? '2' : diff.yd;
121
- hours = diffObj1.hours > 1 ? '2' : diffObj1.hours;
122
- minutes = diffObj1.minutes > 1 ? '2' : diffObj1.minutes;
123
-
124
- var count = 0;
125
- var pattern = [years, days, hours, minutes].reduce(function (res, next) {
126
- if (count === 2) {
127
- res = res + '0';
128
- } else if (next !== 0) {
129
- count++;
130
- res = res + next;
131
- } else {
132
- res = res + next;
133
- }
134
- return res;
135
- }, '');
136
-
137
- var _value = format(diffObj1, pattern);
138
- if (_value && (typeof _value === 'undefined' ? 'undefined' : _typeof(_value)) === 'object') {
139
- key = _value.key;
140
- values = getValues(_value.params, diffObj);
141
- if (pattern.indexOf('00000') === 0) {
142
- //suffix ignore for second hook
143
- isSuffixEnable = false;
144
- } else {
145
- isSuffixEnable = true;
146
- }
147
- } else if (typeof _value === 'string') {
148
- text = formatDate(toDateObj, _value, diffObj1);
109
+
110
+ let key = '';
111
+ let values = [];
112
+ let text = null;
113
+ let isSuffixEnable = false;
114
+
115
+ if (format) {
116
+ let years, months, days, hours, minutes, seconds;
117
+ years = diffObj1.years > 1 ? '2' : diffObj1.years;
118
+ days = diff.yd > 1 ? '2' : diff.yd;
119
+ hours = diffObj1.hours > 1 ? '2' : diffObj1.hours;
120
+ minutes = diffObj1.minutes > 1 ? '2' : diffObj1.minutes;
121
+ let count = 0;
122
+ let pattern = [years, days, hours, minutes].reduce((res, next) => {
123
+ if (count === 2) {
124
+ res = `${res}0`;
125
+ } else if (next !== 0) {
126
+ count++;
127
+ res = res + next;
128
+ } else {
129
+ res = res + next;
149
130
  }
150
- } else {
151
- if (diff.y === 0 && (diff.yd === 0 || diff.yd === 1)) {
152
- var dateObj = new Date(toDateObj);
153
- var curDateObj = new Date(fromDateObj);
154
- if (dateObj.getDate() === curDateObj.getDate()) {
155
- if (typeof today === 'function') {
156
- var value = today(diffObj1);
157
- key = value.key;
158
- values = getValues(value.params, diffObj);
159
- } else if ((typeof today === 'undefined' ? 'undefined' : _typeof(today)) === 'object') {
160
- key = today.key;
161
- values = getValues(today.params, diffObj);
162
- isSuffixEnable = true;
163
- } else if (typeof today === 'string') {
164
- text = formatDate(toDateObj, today);
165
- }
166
- } else if (dateObj.getDate() < curDateObj.getDate()) {
167
- if (typeof yesterday === 'function') {
168
- var value = yesterday(diffObj1);
169
- key = value.key;
170
- values = getValues(value.params, diffObj);
171
- } else if ((typeof yesterday === 'undefined' ? 'undefined' : _typeof(yesterday)) === 'object') {
172
- key = yesterday.key;
173
- values = getValues(yesterday.params, diffObj);
174
- } else if (typeof yesterday === 'string') {
175
- text = formatDate(toDateObj, yesterday);
176
- }
177
- } else if (dateObj.getDate() > curDateObj.getDate()) {
178
- if (typeof tomorrow === 'function') {
179
- var value = tomorrow(diffObj1);
180
- key = value.key;
181
- text = getValues(value.params, diffObj);
182
- } else if ((typeof tomorrow === 'undefined' ? 'undefined' : _typeof(tomorrow)) === 'object') {
183
- key = tomorrow.key;
184
- values = getValues(tomorrow.params, diffObj);
185
- } else if (typeof tomorrow === 'string') {
186
- text = formatDate(toDateObj, tomorrow);
187
- }
188
- }
131
+
132
+ return res;
133
+ }, '');
134
+ let value = format(diffObj1, pattern);
135
+
136
+ if (value && typeof value === 'object') {
137
+ key = value.key;
138
+ values = getValues(value.params, diffObj);
139
+
140
+ if (pattern.indexOf('00000') === 0) {
141
+ //suffix ignore for second hook
142
+ isSuffixEnable = false;
189
143
  } else {
190
- var value = others(diffObj1);
191
- if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
192
- key = value.key;
193
- values = getValues(value.params, diffObj);
194
- isSuffixEnable = true;
195
- } else if (typeof value === 'string') {
196
- text = formatDate(toDateObj, value);
144
+ isSuffixEnable = true;
145
+ }
146
+ } else if (typeof value === 'string') {
147
+ text = formatDate(toDateObj, value, diffObj1);
148
+ }
149
+ } else {
150
+ let dateObj = new Date(toDateObj);
151
+ let curDateObj = new Date(fromDateObj);
152
+ let diffDayType = diffObj1.yDays; //In this condition, to calculate different days we have copied it from live --> diffDayType
153
+
154
+ if (isOverdue && dateObj.getDate() < curDateObj.getDate() && diffObj1.yDays == 0) {
155
+ diffDayType = -1;
156
+ }
157
+
158
+ if (!isOverdue) {
159
+ let diffHr = dateObj.getHours() - curDateObj.getHours();
160
+
161
+ if (diffHr < 0) {
162
+ diffDayType += 1;
163
+ } else if (diffHr == 0) {
164
+ let diffMins = dateObj.getMinutes() - curDateObj.getMinutes();
165
+
166
+ if (diffMins < 0) {
167
+ diffDayType += 1;
168
+ } else if (diffMins == 0) {
169
+ let diffSec = dateObj.getSeconds() - curDateObj.getSeconds();
170
+
171
+ if (diffSec < 0) {
172
+ diffDayType += 1;
173
+ }
197
174
  }
198
175
  }
199
176
  }
200
- return text ? React.createElement(
201
- 'span',
202
- { className: className, 'data-title': title, 'data-id': dataId },
203
- text
204
- ) : React.createElement(FormatText, {
205
- i18NKey: isSuffixEnable && suffix !== '' ? key + '.' + suffix : key,
206
- values: values,
207
- className: className,
208
- 'data-title': title
209
- });
210
- }
211
- }]);
212
177
 
213
- return DateTimeDiffFormat;
214
- }(React.Component);
178
+ if (diff.y === 0 && (diffDayType === 0 || diffDayType === 1)) {
179
+ if (dateObj.getDate() === curDateObj.getDate()) {
180
+ var value = today && today(diffObj1) || others(diffObj1);
181
+ text = formatDate(toDateObj, value);
182
+ } else if (dateObj.getMonth() === curDateObj.getMonth() && dateObj.getDate() < curDateObj.getDate() || dateObj.getMonth() < curDateObj.getMonth()) {
183
+ var value = yesterday && yesterday(diffObj1) || others(diffObj1);
184
+ text = formatDate(toDateObj, value);
185
+ } else if (!isOverdue && diff.y === 0 && diffDayType === 1) {
186
+ var value = tomorrow && tomorrow(diffObj1) || others(diffObj1);
187
+ text = formatDate(toDateObj, value);
188
+ }
189
+ } else {
190
+ var value = others(diffObj1);
191
+ text = formatDate(toDateObj, value);
192
+ }
193
+ }
215
194
 
216
- export default DateTimeDiffFormat;
195
+ return text ? /*#__PURE__*/React.createElement("span", {
196
+ className: className,
197
+ "data-title": title,
198
+ "data-id": dataId,
199
+ "data-test-id": dataId
200
+ }, text) : /*#__PURE__*/React.createElement(FormatText, {
201
+ i18NKey: isSuffixEnable && suffix !== '' ? `${key}.${suffix}` : key,
202
+ values: values,
203
+ className: className,
204
+ "data-title": title
205
+ });
206
+ }
217
207
 
208
+ }
218
209
  DateTimeDiffFormat.propTypes = {
219
210
  ago: PropTypes.string,
220
211
  className: PropTypes.string,
@@ -222,6 +213,7 @@ DateTimeDiffFormat.propTypes = {
222
213
  format: PropTypes.func,
223
214
  from: PropTypes.string,
224
215
  fromTzData: PropTypes.object,
216
+ isDateField: PropTypes.bool,
225
217
  later: PropTypes.string,
226
218
  others: PropTypes.func,
227
219
  title: PropTypes.string,
@@ -1,33 +1,12 @@
1
- import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
2
- import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
3
- import _createClass from 'babel-runtime/helpers/createClass';
4
- import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
5
- import _inherits from 'babel-runtime/helpers/inherits';
6
1
  import React from 'react';
7
2
  import PropTypes from 'prop-types';
8
3
  import I18N from './I18N';
9
-
10
- var FormatText = function (_React$Component) {
11
- _inherits(FormatText, _React$Component);
12
-
13
- function FormatText() {
14
- _classCallCheck(this, FormatText);
15
-
16
- return _possibleConstructorReturn(this, (FormatText.__proto__ || _Object$getPrototypeOf(FormatText)).apply(this, arguments));
4
+ export default class FormatText extends React.Component {
5
+ render() {
6
+ return /*#__PURE__*/React.createElement(I18N, this.props);
17
7
  }
18
8
 
19
- _createClass(FormatText, [{
20
- key: 'render',
21
- value: function render() {
22
- return React.createElement(I18N, this.props);
23
- }
24
- }]);
25
-
26
- return FormatText;
27
- }(React.Component);
28
-
29
- export default FormatText;
30
-
9
+ }
31
10
  FormatText.propTypes = {
32
11
  i18NKey: PropTypes.string.isRequired,
33
12
  isHtml: PropTypes.bool,
@@ -1,60 +1,48 @@
1
- import _extends from 'babel-runtime/helpers/extends';
2
- import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
3
- import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4
- import _createClass from 'babel-runtime/helpers/createClass';
5
- import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
6
- import _inherits from 'babel-runtime/helpers/inherits';
1
+ 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); }
2
+
7
3
  import React, { Children } from 'react';
8
4
  import PropTypes from 'prop-types';
9
5
  import { replaceI18NValuesWithRegex, unescapeUnicode } from '../utils';
10
6
  import { I18NContext } from '../I18NContext';
11
7
  export default (function () {
12
- var i18NKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
13
- return function (Component) {
14
- var HOCI18N = function (_React$Component) {
15
- _inherits(HOCI18N, _React$Component);
8
+ let i18NKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
9
+ return Component => {
10
+ class HOCI18N extends React.Component {
11
+ constructor(props) {
12
+ super(props);
13
+ this.getI18NValue = this.getI18NValue.bind(this);
14
+ }
16
15
 
17
- function HOCI18N(props) {
18
- _classCallCheck(this, HOCI18N);
16
+ getI18NValue(key) {
17
+ const {
18
+ i18n
19
+ } = this.context || {};
19
20
 
20
- var _this = _possibleConstructorReturn(this, (HOCI18N.__proto__ || _Object$getPrototypeOf(HOCI18N)).call(this, props));
21
+ if (typeof i18n === 'undefined') {
22
+ return key;
23
+ }
21
24
 
22
- _this.getI18NValue = _this.getI18NValue.bind(_this);
23
- return _this;
24
- }
25
+ let i18nStr = i18n[key];
25
26
 
26
- _createClass(HOCI18N, [{
27
- key: 'getI18NValue',
28
- value: function getI18NValue(key) {
29
- var _ref = this.context || {},
30
- i18n = _ref.i18n;
27
+ if (i18nStr === undefined) {
28
+ return key;
29
+ }
31
30
 
32
- if (typeof i18n === 'undefined') {
33
- return key;
34
- }
35
- var i18nStr = i18n[key];
36
- if (i18nStr === undefined) {
37
- return key;
31
+ return unescapeUnicode(i18nStr);
32
+ }
33
+
34
+ render() {
35
+ let i18nProps = i18NKeys.reduce((result, key) => {
36
+ if (this.props[key]) {
37
+ result[key] = this.getI18NValue(this.props[key]);
38
38
  }
39
- return unescapeUnicode(i18nStr);
40
- }
41
- }, {
42
- key: 'render',
43
- value: function render() {
44
- var _this2 = this;
45
-
46
- var i18nProps = i18NKeys.reduce(function (result, key) {
47
- if (_this2.props[key]) {
48
- result[key] = _this2.getI18NValue(_this2.props[key]);
49
- }
50
- return result;
51
- }, {});
52
- return React.createElement(Component, _extends({}, this.props, i18nProps));
53
- }
54
- }]);
55
39
 
56
- return HOCI18N;
57
- }(React.Component);
40
+ return result;
41
+ }, {});
42
+ return /*#__PURE__*/React.createElement(Component, _extends({}, this.props, i18nProps));
43
+ }
44
+
45
+ }
58
46
 
59
47
  HOCI18N.contextType = I18NContext;
60
48
  return HOCI18N;