@zohodesk/i18n 1.0.0-beta.34 → 1.0.0-beta.35-murphy
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/docs/murphy/01-MURPHY_OVERVIEW.md +148 -0
- package/docs/murphy/02-MURPHY_ARCHITECTURE.md +283 -0
- package/docs/murphy/03-MURPHY_BACKEND_CONFIG.md +337 -0
- package/docs/murphy/04-MURPHY_FRONTEND_INIT.md +437 -0
- package/docs/murphy/05-MURPHY_DESK_CLIENT_USAGE.md +467 -0
- package/docs/murphy/06-MURPHY_I18N_INTEGRATION.md +402 -0
- package/docs/murphy/07-MURPHY_WHY_I18N_APPROACH.md +391 -0
- package/es/components/DateTimeDiffFormat.js +5 -19
- package/es/components/FormatText.js +2 -2
- package/es/components/HOCI18N.js +32 -43
- package/es/components/I18N.js +2 -13
- package/es/components/I18NProvider.js +0 -9
- package/es/components/PluralFormat.js +3 -5
- package/es/components/UserTimeDiffFormat.js +5 -9
- package/es/components/__tests__/DateTimeDiffFormat.spec.js +157 -221
- package/es/components/__tests__/FormatText.spec.js +2 -2
- package/es/components/__tests__/HOCI18N.spec.js +2 -4
- package/es/components/__tests__/I18N.spec.js +6 -4
- package/es/components/__tests__/I18NProvider.spec.js +4 -4
- package/es/components/__tests__/PluralFormat.spec.js +2 -2
- package/es/components/__tests__/UserTimeDiffFormat.spec.js +249 -348
- package/es/index.js +1 -0
- package/es/utils/__tests__/jsxTranslations.spec.js +3 -7
- package/es/utils/errorReporter.js +31 -0
- package/es/utils/index.js +42 -92
- package/es/utils/jsxTranslations.js +34 -52
- package/lib/I18NContext.js +2 -7
- package/lib/components/DateTimeDiffFormat.js +46 -87
- package/lib/components/FormatText.js +18 -41
- package/lib/components/HOCI18N.js +24 -59
- package/lib/components/I18N.js +27 -64
- package/lib/components/I18NProvider.js +27 -63
- package/lib/components/PluralFormat.js +24 -50
- package/lib/components/UserTimeDiffFormat.js +43 -72
- package/lib/components/__tests__/DateTimeDiffFormat.spec.js +95 -165
- package/lib/components/__tests__/FormatText.spec.js +3 -10
- package/lib/components/__tests__/HOCI18N.spec.js +3 -14
- package/lib/components/__tests__/I18N.spec.js +4 -12
- package/lib/components/__tests__/I18NProvider.spec.js +8 -23
- package/lib/components/__tests__/PluralFormat.spec.js +3 -11
- package/lib/components/__tests__/UserTimeDiffFormat.spec.js +157 -225
- package/lib/index.js +25 -23
- package/lib/utils/__tests__/jsxTranslations.spec.js +1 -12
- package/lib/utils/errorReporter.js +39 -0
- package/lib/utils/index.js +49 -125
- package/lib/utils/jsxTranslations.js +61 -100
- package/package.json +1 -1
- package/src/index.js +5 -0
- package/src/utils/errorReporter.js +36 -0
- package/src/utils/index.js +8 -1
- package/src/utils/jsxTranslations.js +8 -1
|
@@ -4,61 +4,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _utils = require("../utils");
|
|
13
|
-
|
|
14
10
|
var _FormatText = _interopRequireDefault(require("./FormatText"));
|
|
15
|
-
|
|
16
11
|
var _datetimejs = _interopRequireDefault(require("@zohodesk/datetimejs"));
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function _setPrototypeOf(
|
|
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; }
|
|
37
|
-
|
|
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; } }
|
|
39
|
-
|
|
40
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
-
|
|
42
|
-
var DateTimeDiffFormat = /*#__PURE__*/function (_React$Component) {
|
|
43
|
-
_inherits(DateTimeDiffFormat, _React$Component);
|
|
44
|
-
|
|
45
|
-
var _super = _createSuper(DateTimeDiffFormat);
|
|
46
|
-
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
14
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
15
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
16
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
20
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
21
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
22
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
23
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
24
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
25
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
26
|
+
var DateTimeDiffFormat = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
47
27
|
function DateTimeDiffFormat(props) {
|
|
48
28
|
var _this;
|
|
49
|
-
|
|
50
29
|
_classCallCheck(this, DateTimeDiffFormat);
|
|
51
|
-
|
|
52
|
-
_this =
|
|
53
|
-
_this.getSuffix = _this.getSuffix.bind(_assertThisInitialized(_this));
|
|
30
|
+
_this = _callSuper(this, DateTimeDiffFormat, [props]);
|
|
31
|
+
_this.getSuffix = _this.getSuffix.bind(_this);
|
|
54
32
|
return _this;
|
|
55
33
|
}
|
|
56
|
-
|
|
57
|
-
_createClass(DateTimeDiffFormat, [{
|
|
34
|
+
_inherits(DateTimeDiffFormat, _React$Component);
|
|
35
|
+
return _createClass(DateTimeDiffFormat, [{
|
|
58
36
|
key: "getSuffix",
|
|
59
37
|
value: function getSuffix(min) {
|
|
60
38
|
var suffix;
|
|
61
|
-
|
|
62
39
|
if (this.props.ago && min < 0) {
|
|
63
40
|
suffix = this.props.ago || '';
|
|
64
41
|
} else if (this.props.later || min > 0) {
|
|
@@ -66,40 +43,36 @@ var DateTimeDiffFormat = /*#__PURE__*/function (_React$Component) {
|
|
|
66
43
|
} else {
|
|
67
44
|
suffix = '';
|
|
68
45
|
}
|
|
69
|
-
|
|
70
46
|
return suffix;
|
|
71
47
|
}
|
|
72
48
|
}, {
|
|
73
49
|
key: "render",
|
|
74
50
|
value: function render() {
|
|
75
51
|
var _this$props = this.props,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
52
|
+
type = _this$props.type,
|
|
53
|
+
page = _this$props.page,
|
|
54
|
+
isNeedTime = _this$props.isNeedTime,
|
|
55
|
+
from = _this$props.from,
|
|
56
|
+
fromTzData = _this$props.fromTzData,
|
|
57
|
+
to = _this$props.to,
|
|
58
|
+
toTzData = _this$props.toTzData,
|
|
59
|
+
today = _this$props.today,
|
|
60
|
+
yesterday = _this$props.yesterday,
|
|
61
|
+
tomorrow = _this$props.tomorrow,
|
|
62
|
+
others = _this$props.others,
|
|
63
|
+
format = _this$props.format,
|
|
64
|
+
dataId = _this$props.dataId,
|
|
65
|
+
_this$props$className = _this$props.className,
|
|
66
|
+
className = _this$props$className === void 0 ? null : _this$props$className,
|
|
67
|
+
_this$props$title = _this$props.title,
|
|
68
|
+
title = _this$props$title === void 0 ? null : _this$props$title,
|
|
69
|
+
isOverdue = _this$props.isOverdue,
|
|
70
|
+
timeFormat = _this$props.timeFormat,
|
|
71
|
+
datePattern = _this$props.datePattern,
|
|
72
|
+
isEnabledCurrentYear = _this$props.isEnabledCurrentYear,
|
|
73
|
+
isDateField = _this$props.isDateField;
|
|
99
74
|
var fromDateObj = _datetimejs["default"].toDate(_datetimejs["default"].tz.utcToTz(from, fromTzData)).getTime();
|
|
100
|
-
|
|
101
75
|
var toDateObj = _datetimejs["default"].toDate(isDateField ? to : _datetimejs["default"].tz.utcToTz(to, toTzData)).getTime();
|
|
102
|
-
|
|
103
76
|
var diffMin = new Date(to).getTime() - new Date(from).getTime();
|
|
104
77
|
var suffix = this.getSuffix(diffMin);
|
|
105
78
|
var diff = (0, _utils.getDiffObj)(diffMin);
|
|
@@ -147,9 +120,10 @@ var DateTimeDiffFormat = /*#__PURE__*/function (_React$Component) {
|
|
|
147
120
|
timeFormat: timeFormat,
|
|
148
121
|
datePattern: datePattern,
|
|
149
122
|
dateTimePattern: "".concat(datePattern, " ").concat(timeFormat)
|
|
150
|
-
};
|
|
151
|
-
//In else part we'll set the date format as it is
|
|
123
|
+
};
|
|
152
124
|
|
|
125
|
+
//In if condition we'll remove year and set date format if the current year is not required
|
|
126
|
+
//In else part we'll set the date format as it is
|
|
153
127
|
if (isEnabledCurrentYear === true && diffObj1.years === 0 && diffObj1.tYear === diffObj1.crntYear) {
|
|
154
128
|
var dateFormat = (0, _utils.getDatePatternWithoutYear)(datePattern);
|
|
155
129
|
diffObj1.dateFormat = dateFormat;
|
|
@@ -158,12 +132,10 @@ var DateTimeDiffFormat = /*#__PURE__*/function (_React$Component) {
|
|
|
158
132
|
diffObj1.dateFormat = datePattern;
|
|
159
133
|
diffObj1.dateTimeFormat = "".concat(datePattern, " ").concat(timeFormat);
|
|
160
134
|
}
|
|
161
|
-
|
|
162
135
|
var key = '';
|
|
163
136
|
var values = [];
|
|
164
137
|
var text = null;
|
|
165
138
|
var isSuffixEnable = false;
|
|
166
|
-
|
|
167
139
|
if (format) {
|
|
168
140
|
var years, months, days, hours, minutes, seconds;
|
|
169
141
|
years = diffObj1.years > 1 ? '2' : diffObj1.years;
|
|
@@ -180,16 +152,12 @@ var DateTimeDiffFormat = /*#__PURE__*/function (_React$Component) {
|
|
|
180
152
|
} else {
|
|
181
153
|
res = res + next;
|
|
182
154
|
}
|
|
183
|
-
|
|
184
155
|
return res;
|
|
185
156
|
}, '');
|
|
186
|
-
|
|
187
157
|
var _value = format(diffObj1, pattern);
|
|
188
|
-
|
|
189
158
|
if (_value && _typeof(_value) === 'object') {
|
|
190
159
|
key = _value.key;
|
|
191
160
|
values = (0, _utils.getValues)(_value.params, diffObj);
|
|
192
|
-
|
|
193
161
|
if (pattern.indexOf('00000') === 0) {
|
|
194
162
|
//suffix ignore for second hook
|
|
195
163
|
isSuffixEnable = false;
|
|
@@ -202,32 +170,28 @@ var DateTimeDiffFormat = /*#__PURE__*/function (_React$Component) {
|
|
|
202
170
|
} else {
|
|
203
171
|
var dateObj = new Date(toDateObj);
|
|
204
172
|
var curDateObj = new Date(fromDateObj);
|
|
205
|
-
var diffDayType = diffObj1.yDays;
|
|
173
|
+
var diffDayType = diffObj1.yDays;
|
|
206
174
|
|
|
175
|
+
//In this condition, to calculate different days we have copied it from live --> diffDayType
|
|
207
176
|
if (isOverdue && dateObj.getDate() < curDateObj.getDate() && diffObj1.yDays == 0) {
|
|
208
177
|
diffDayType = -1;
|
|
209
178
|
}
|
|
210
|
-
|
|
211
179
|
if (!isOverdue) {
|
|
212
180
|
var diffHr = dateObj.getHours() - curDateObj.getHours();
|
|
213
|
-
|
|
214
181
|
if (diffHr < 0) {
|
|
215
182
|
diffDayType += 1;
|
|
216
183
|
} else if (diffHr == 0) {
|
|
217
184
|
var diffMins = dateObj.getMinutes() - curDateObj.getMinutes();
|
|
218
|
-
|
|
219
185
|
if (diffMins < 0) {
|
|
220
186
|
diffDayType += 1;
|
|
221
187
|
} else if (diffMins == 0) {
|
|
222
188
|
var diffSec = dateObj.getSeconds() - curDateObj.getSeconds();
|
|
223
|
-
|
|
224
189
|
if (diffSec < 0) {
|
|
225
190
|
diffDayType += 1;
|
|
226
191
|
}
|
|
227
192
|
}
|
|
228
193
|
}
|
|
229
194
|
}
|
|
230
|
-
|
|
231
195
|
if (diff.y === 0 && (diffDayType === 0 || diffDayType === 1)) {
|
|
232
196
|
if (dateObj.getDate() === curDateObj.getDate()) {
|
|
233
197
|
var value = today && today(diffObj1) || others(diffObj1);
|
|
@@ -244,7 +208,6 @@ var DateTimeDiffFormat = /*#__PURE__*/function (_React$Component) {
|
|
|
244
208
|
text = (0, _utils.formatDate)(toDateObj, value);
|
|
245
209
|
}
|
|
246
210
|
}
|
|
247
|
-
|
|
248
211
|
return text ? /*#__PURE__*/_react["default"].createElement("span", {
|
|
249
212
|
className: className,
|
|
250
213
|
"data-title": title,
|
|
@@ -258,11 +221,7 @@ var DateTimeDiffFormat = /*#__PURE__*/function (_React$Component) {
|
|
|
258
221
|
});
|
|
259
222
|
}
|
|
260
223
|
}]);
|
|
261
|
-
|
|
262
|
-
return DateTimeDiffFormat;
|
|
263
224
|
}(_react["default"].Component);
|
|
264
|
-
|
|
265
|
-
exports["default"] = DateTimeDiffFormat;
|
|
266
225
|
DateTimeDiffFormat.propTypes = {
|
|
267
226
|
ago: _propTypes["default"].string,
|
|
268
227
|
className: _propTypes["default"].string,
|
|
@@ -1,62 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _I18N = _interopRequireDefault(require("./I18N"));
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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); }
|
|
31
|
-
|
|
32
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
33
|
-
|
|
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) {
|
|
39
|
-
_inherits(FormatText, _React$Component);
|
|
40
|
-
|
|
41
|
-
var _super = _createSuper(FormatText);
|
|
42
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
13
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
14
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
18
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
19
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
20
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
21
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
22
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
23
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
24
|
+
var FormatText = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
43
25
|
function FormatText() {
|
|
44
26
|
_classCallCheck(this, FormatText);
|
|
45
|
-
|
|
46
|
-
return _super.apply(this, arguments);
|
|
27
|
+
return _callSuper(this, FormatText, arguments);
|
|
47
28
|
}
|
|
48
|
-
|
|
49
|
-
_createClass(FormatText, [{
|
|
29
|
+
_inherits(FormatText, _React$Component);
|
|
30
|
+
return _createClass(FormatText, [{
|
|
50
31
|
key: "render",
|
|
51
32
|
value: function render() {
|
|
52
33
|
return /*#__PURE__*/_react["default"].createElement(_I18N["default"], this.props);
|
|
53
34
|
}
|
|
54
35
|
}]);
|
|
55
|
-
|
|
56
|
-
return FormatText;
|
|
57
36
|
}(_react["default"].Component);
|
|
58
|
-
|
|
59
|
-
exports["default"] = FormatText;
|
|
60
37
|
FormatText.propTypes = {
|
|
61
38
|
i18NKey: _propTypes["default"].string.isRequired,
|
|
62
39
|
isHtml: _propTypes["default"].bool,
|
|
@@ -1,106 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _utils = require("../utils");
|
|
15
|
-
|
|
16
11
|
var _I18NContext = require("../I18NContext");
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
|
-
|
|
36
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
37
|
-
|
|
38
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
39
|
-
|
|
40
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
|
-
|
|
42
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
43
|
-
|
|
44
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
45
|
-
|
|
46
|
-
var _default = function _default() {
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
15
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
16
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
17
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
18
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
21
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
22
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
23
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
24
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
25
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
26
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
27
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
28
|
+
var _default = exports["default"] = function _default() {
|
|
47
29
|
var i18NKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
48
30
|
return function (Component) {
|
|
49
31
|
var HOCI18N = /*#__PURE__*/function (_React$Component) {
|
|
50
|
-
_inherits(HOCI18N, _React$Component);
|
|
51
|
-
|
|
52
|
-
var _super = _createSuper(HOCI18N);
|
|
53
|
-
|
|
54
32
|
function HOCI18N(props) {
|
|
55
33
|
var _this;
|
|
56
|
-
|
|
57
34
|
_classCallCheck(this, HOCI18N);
|
|
58
|
-
|
|
59
|
-
_this =
|
|
60
|
-
_this.getI18NValue = _this.getI18NValue.bind(_assertThisInitialized(_this));
|
|
35
|
+
_this = _callSuper(this, HOCI18N, [props]);
|
|
36
|
+
_this.getI18NValue = _this.getI18NValue.bind(_this);
|
|
61
37
|
return _this;
|
|
62
38
|
}
|
|
63
|
-
|
|
64
|
-
_createClass(HOCI18N, [{
|
|
39
|
+
_inherits(HOCI18N, _React$Component);
|
|
40
|
+
return _createClass(HOCI18N, [{
|
|
65
41
|
key: "getI18NValue",
|
|
66
42
|
value: function getI18NValue(key) {
|
|
67
43
|
var _ref = this.context || {},
|
|
68
|
-
|
|
69
|
-
|
|
44
|
+
i18n = _ref.i18n;
|
|
70
45
|
if (typeof i18n === 'undefined') {
|
|
71
46
|
return key;
|
|
72
47
|
}
|
|
73
|
-
|
|
74
48
|
var i18nStr = i18n[key];
|
|
75
|
-
|
|
76
49
|
if (i18nStr === undefined) {
|
|
77
50
|
return key;
|
|
78
51
|
}
|
|
79
|
-
|
|
80
52
|
return (0, _utils.unescapeUnicode)(i18nStr);
|
|
81
53
|
}
|
|
82
54
|
}, {
|
|
83
55
|
key: "render",
|
|
84
56
|
value: function render() {
|
|
85
57
|
var _this2 = this;
|
|
86
|
-
|
|
87
58
|
var i18nProps = i18NKeys.reduce(function (result, key) {
|
|
88
59
|
if (_this2.props[key]) {
|
|
89
60
|
result[key] = _this2.getI18NValue(_this2.props[key]);
|
|
90
61
|
}
|
|
91
|
-
|
|
92
62
|
return result;
|
|
93
63
|
}, {});
|
|
94
64
|
return /*#__PURE__*/_react["default"].createElement(Component, _extends({}, this.props, i18nProps));
|
|
95
65
|
}
|
|
96
66
|
}]);
|
|
97
|
-
|
|
98
|
-
return HOCI18N;
|
|
99
67
|
}(_react["default"].Component);
|
|
100
|
-
|
|
101
68
|
HOCI18N.contextType = _I18NContext.I18NContext;
|
|
102
69
|
return HOCI18N;
|
|
103
70
|
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
exports["default"] = _default;
|
|
71
|
+
};
|