@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.
- package/README.md +80 -0
- package/es/I18NContext.js +1 -2
- package/es/components/DateTimeDiffFormat.js +192 -184
- package/es/components/FormatText.js +4 -25
- package/es/components/HOCI18N.js +33 -45
- package/es/components/I18N.js +46 -63
- package/es/components/I18NProvider.js +54 -84
- package/es/components/PluralFormat.js +29 -48
- package/es/components/UserTimeDiffFormat.js +65 -70
- package/es/components/__tests__/DateTimeDiffFormat.spec.js +868 -657
- package/es/components/__tests__/FormatText.spec.js +20 -17
- package/es/components/__tests__/HOCI18N.spec.js +18 -22
- package/es/components/__tests__/I18N.spec.js +20 -19
- package/es/components/__tests__/I18NProvider.spec.js +36 -45
- package/es/components/__tests__/PluralFormat.spec.js +20 -17
- package/es/components/__tests__/UserTimeDiffFormat.spec.js +1343 -1095
- package/es/index.js +2 -6
- package/es/utils.js +250 -385
- package/lib/I18NContext.js +6 -6
- package/lib/components/DateTimeDiffFormat.js +167 -123
- package/lib/components/FormatText.js +32 -22
- package/lib/components/HOCI18N.js +47 -23
- package/lib/components/I18N.js +60 -36
- package/lib/components/I18NProvider.js +76 -69
- package/lib/components/PluralFormat.js +42 -32
- package/lib/components/UserTimeDiffFormat.js +81 -54
- package/lib/components/__tests__/DateTimeDiffFormat.spec.js +815 -629
- package/lib/components/__tests__/FormatText.spec.js +23 -25
- package/lib/components/__tests__/HOCI18N.spec.js +26 -34
- package/lib/components/__tests__/I18N.spec.js +21 -26
- package/lib/components/__tests__/I18NProvider.spec.js +43 -51
- package/lib/components/__tests__/PluralFormat.spec.js +24 -28
- package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1256 -1039
- package/lib/index.js +73 -119
- package/lib/utils.js +222 -329
- package/package.json +2 -2
- package/src/I18NContext.js +3 -0
- package/src/components/DateTimeDiffFormat.js +256 -0
- package/src/components/FormatText.js +14 -0
- package/src/components/HOCI18N.js +37 -0
- package/src/components/I18N.js +72 -0
- package/src/components/I18NProvider.js +110 -0
- package/src/components/PluralFormat.js +37 -0
- package/src/components/UserTimeDiffFormat.js +97 -0
- package/src/components/__tests__/DateTimeDiffFormat.spec.js +618 -0
- package/src/components/__tests__/FormatText.spec.js +27 -0
- package/src/components/__tests__/HOCI18N.spec.js +33 -0
- package/src/components/__tests__/I18N.spec.js +30 -0
- package/src/components/__tests__/I18NProvider.spec.js +65 -0
- package/src/components/__tests__/PluralFormat.spec.js +28 -0
- package/src/components/__tests__/UserTimeDiffFormat.spec.js +1076 -0
- package/src/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -0
- package/src/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -0
- package/src/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -0
- package/src/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -0
- package/src/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -0
- package/src/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -0
- package/src/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -0
- package/src/index.js +33 -0
- package/src/utils.js +527 -0
- package/.DS_Store +0 -0
- package/es/components/NewDateFormat.js +0 -50
- package/es/offset.js +0 -629
- package/es/timezones.js +0 -112
- package/lib/components/NewDateFormat.js +0 -68
- package/lib/offset.js +0 -634
- package/lib/timezones.js +0 -120
package/lib/I18NContext.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.I18NContext =
|
|
6
|
+
exports.I18NContext = void 0;
|
|
7
7
|
|
|
8
|
-
var _react = require(
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
var I18NContext = /*#__PURE__*/_react["default"].createContext();
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
exports.I18NContext = I18NContext;
|
|
@@ -1,88 +1,109 @@
|
|
|
1
|
-
|
|
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
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
9
|
|
|
9
|
-
var
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
11
|
|
|
11
|
-
var
|
|
12
|
+
var _utils = require("../utils");
|
|
12
13
|
|
|
13
|
-
var
|
|
14
|
+
var _FormatText = _interopRequireDefault(require("./FormatText"));
|
|
14
15
|
|
|
15
|
-
var
|
|
16
|
+
var _datetimejs = _interopRequireDefault(require("@zohodesk/datetimejs"));
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
19
|
|
|
19
|
-
|
|
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
|
-
|
|
22
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
22
23
|
|
|
23
|
-
var
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
48
|
+
var _this;
|
|
38
49
|
|
|
39
|
-
|
|
50
|
+
_classCallCheck(this, DateTimeDiffFormat);
|
|
40
51
|
|
|
41
|
-
_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:
|
|
58
|
+
key: "getSuffix",
|
|
47
59
|
value: function getSuffix(min) {
|
|
48
|
-
var suffix
|
|
49
|
-
|
|
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:
|
|
73
|
+
key: "render",
|
|
60
74
|
value: function render() {
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
109
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
} else if (
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
257
|
+
"data-title": title
|
|
214
258
|
});
|
|
215
259
|
}
|
|
216
260
|
}]);
|
|
217
261
|
|
|
218
262
|
return DateTimeDiffFormat;
|
|
219
|
-
}(
|
|
220
|
-
|
|
221
|
-
exports.default = DateTimeDiffFormat;
|
|
263
|
+
}(_react["default"].Component);
|
|
222
264
|
|
|
265
|
+
exports["default"] = DateTimeDiffFormat;
|
|
223
266
|
DateTimeDiffFormat.propTypes = {
|
|
224
|
-
ago:
|
|
225
|
-
className:
|
|
226
|
-
dataId:
|
|
227
|
-
format:
|
|
228
|
-
from:
|
|
229
|
-
fromTzData:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
-
|
|
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
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
13
|
|
|
9
|
-
var
|
|
14
|
+
var _I18N = _interopRequireDefault(require("./I18N"));
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
19
|
|
|
15
|
-
var
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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 (
|
|
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
|
|
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
|
-
|
|
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
|
|
46
|
+
return _super.apply(this, arguments);
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
_createClass(FormatText, [{
|
|
39
|
-
key:
|
|
50
|
+
key: "render",
|
|
40
51
|
value: function render() {
|
|
41
|
-
return
|
|
52
|
+
return /*#__PURE__*/_react["default"].createElement(_I18N["default"], this.props);
|
|
42
53
|
}
|
|
43
54
|
}]);
|
|
44
55
|
|
|
45
56
|
return FormatText;
|
|
46
|
-
}(
|
|
47
|
-
|
|
48
|
-
exports.default = FormatText;
|
|
57
|
+
}(_react["default"].Component);
|
|
49
58
|
|
|
59
|
+
exports["default"] = FormatText;
|
|
50
60
|
FormatText.propTypes = {
|
|
51
|
-
i18NKey:
|
|
52
|
-
isHtml:
|
|
53
|
-
values:
|
|
61
|
+
i18NKey: _propTypes["default"].string.isRequired,
|
|
62
|
+
isHtml: _propTypes["default"].bool,
|
|
63
|
+
values: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].array])
|
|
54
64
|
};
|