@zohodesk/i18n 1.0.0-beta.34 → 1.0.0-beta.36-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 +35 -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 +44 -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 +41 -0
- package/src/utils/index.js +8 -1
- package/src/utils/jsxTranslations.js +8 -1
package/lib/components/I18N.js
CHANGED
|
@@ -1,84 +1,55 @@
|
|
|
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 _SecurityJS = require("@zoho/SecurityJS");
|
|
17
|
-
|
|
18
12
|
var _I18NContext = require("../I18NContext");
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function _inherits(
|
|
33
|
-
|
|
34
|
-
|
|
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 I18N = /*#__PURE__*/function (_React$Component) {
|
|
47
|
-
_inherits(I18N, _React$Component);
|
|
48
|
-
|
|
49
|
-
var _super = _createSuper(I18N);
|
|
50
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
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 I18N = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
51
29
|
function I18N(props) {
|
|
52
30
|
var _this;
|
|
53
|
-
|
|
54
31
|
_classCallCheck(this, I18N);
|
|
55
|
-
|
|
56
|
-
_this =
|
|
57
|
-
_this.
|
|
58
|
-
_this.createElement = _this.createElement.bind(_assertThisInitialized(_this));
|
|
32
|
+
_this = _callSuper(this, I18N, [props]);
|
|
33
|
+
_this.getI18NValue = _this.getI18NValue.bind(_this);
|
|
34
|
+
_this.createElement = _this.createElement.bind(_this);
|
|
59
35
|
return _this;
|
|
60
36
|
}
|
|
61
|
-
|
|
62
|
-
_createClass(I18N, [{
|
|
37
|
+
_inherits(I18N, _React$Component);
|
|
38
|
+
return _createClass(I18N, [{
|
|
63
39
|
key: "getI18NValue",
|
|
64
40
|
value: function getI18NValue() {
|
|
65
41
|
var _this$props = this.props,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
key = _this$props.i18NKey,
|
|
43
|
+
values = _this$props.values;
|
|
69
44
|
var _ref = this.context || {},
|
|
70
|
-
|
|
71
|
-
|
|
45
|
+
i18n = _ref.i18n;
|
|
72
46
|
if (typeof i18n === 'undefined') {
|
|
73
47
|
return key;
|
|
74
48
|
}
|
|
75
|
-
|
|
76
49
|
var i18nStr = i18n[key];
|
|
77
|
-
|
|
78
50
|
if (i18nStr === undefined) {
|
|
79
51
|
return key;
|
|
80
52
|
}
|
|
81
|
-
|
|
82
53
|
i18nStr = (0, _utils.replaceI18NValuesWithRegex)(i18nStr, values);
|
|
83
54
|
return (0, _utils.unescapeUnicode)(i18nStr);
|
|
84
55
|
}
|
|
@@ -86,20 +57,17 @@ var I18N = /*#__PURE__*/function (_React$Component) {
|
|
|
86
57
|
key: "createElement",
|
|
87
58
|
value: function createElement() {
|
|
88
59
|
var _this2 = this;
|
|
89
|
-
|
|
90
60
|
var props = Object.keys(this.props).reduce(function (result, nextKey) {
|
|
91
61
|
if (nextKey != 'i18NKey' && nextKey != 'tag' && nextKey != 'values' && nextKey != 'isHtml' && nextKey != 'dataId') {
|
|
92
62
|
result[nextKey] = _this2.props[nextKey];
|
|
93
63
|
}
|
|
94
|
-
|
|
95
64
|
return result;
|
|
96
|
-
}, {});
|
|
97
|
-
|
|
65
|
+
}, {});
|
|
66
|
+
//const child=this.getI18NValue();
|
|
98
67
|
if (this.props.dataId) {
|
|
99
68
|
props['data-id'] = this.props.dataId;
|
|
100
69
|
props['data-test-id'] = this.props.dataId;
|
|
101
70
|
}
|
|
102
|
-
|
|
103
71
|
if (this.props.isHtml) {
|
|
104
72
|
var dangerouslySetInnerHTML = {
|
|
105
73
|
__html: _SecurityJS.HTMLPurifier.sanitize(this.getI18NValue())
|
|
@@ -108,7 +76,6 @@ var I18N = /*#__PURE__*/function (_React$Component) {
|
|
|
108
76
|
dangerouslySetInnerHTML: dangerouslySetInnerHTML
|
|
109
77
|
}));
|
|
110
78
|
}
|
|
111
|
-
|
|
112
79
|
return /*#__PURE__*/_react["default"].createElement(this.props.tag, props, this.getI18NValue());
|
|
113
80
|
}
|
|
114
81
|
}, {
|
|
@@ -117,11 +84,7 @@ var I18N = /*#__PURE__*/function (_React$Component) {
|
|
|
117
84
|
return this.createElement();
|
|
118
85
|
}
|
|
119
86
|
}]);
|
|
120
|
-
|
|
121
|
-
return I18N;
|
|
122
87
|
}(_react["default"].Component);
|
|
123
|
-
|
|
124
|
-
exports["default"] = I18N;
|
|
125
88
|
I18N.propTypes = {
|
|
126
89
|
i18NKey: _propTypes["default"].string.isRequired,
|
|
127
90
|
isHtml: _propTypes["default"].bool,
|
|
@@ -1,93 +1,63 @@
|
|
|
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.i18NProviderUtils = 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 _utils = require("../utils");
|
|
15
|
-
|
|
16
11
|
var _jsxTranslations = require("../utils/jsxTranslations");
|
|
17
|
-
|
|
18
12
|
var _I18NContext = require("../I18NContext");
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function
|
|
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
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
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); }
|
|
42
26
|
var emptyObj = {};
|
|
43
|
-
|
|
44
27
|
var dummy = function dummy(key, values) {
|
|
45
28
|
return key;
|
|
46
29
|
};
|
|
47
|
-
|
|
48
|
-
var i18NProviderUtils = {
|
|
30
|
+
var i18NProviderUtils = exports.i18NProviderUtils = {
|
|
49
31
|
getI18NValue: dummy,
|
|
50
32
|
userDateFormat: dummy,
|
|
51
33
|
getI18NComponent: dummy
|
|
52
34
|
};
|
|
53
|
-
exports
|
|
54
|
-
|
|
55
|
-
var I18NProvider = /*#__PURE__*/function (_React$Component) {
|
|
56
|
-
_inherits(I18NProvider, _React$Component);
|
|
57
|
-
|
|
58
|
-
var _super = _createSuper(I18NProvider);
|
|
59
|
-
|
|
35
|
+
var I18NProvider = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
60
36
|
function I18NProvider(props, context) {
|
|
61
37
|
var _this;
|
|
62
|
-
|
|
63
38
|
_classCallCheck(this, I18NProvider);
|
|
64
|
-
|
|
65
|
-
_this = _super.call(this, props, context);
|
|
39
|
+
_this = _callSuper(this, I18NProvider, [props, context]);
|
|
66
40
|
i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(props.i18n);
|
|
67
41
|
i18NProviderUtils.getI18NComponent = (0, _jsxTranslations.getI18NComponent)(props.i18n);
|
|
68
|
-
|
|
69
42
|
if (props.tzData) {
|
|
70
43
|
i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, props.isEnabledCurrentYear);
|
|
71
44
|
}
|
|
72
|
-
|
|
73
45
|
return _this;
|
|
74
46
|
}
|
|
75
|
-
|
|
76
|
-
_createClass(I18NProvider, [{
|
|
47
|
+
_inherits(I18NProvider, _React$Component);
|
|
48
|
+
return _createClass(I18NProvider, [{
|
|
77
49
|
key: "componentDidUpdate",
|
|
78
50
|
value: function componentDidUpdate(prevProps) {
|
|
79
51
|
var _this2 = this;
|
|
80
|
-
|
|
81
52
|
var _this$props = this.props,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
53
|
+
i18n = _this$props.i18n,
|
|
54
|
+
timeZone = _this$props.timeZone,
|
|
55
|
+
datePattern = _this$props.datePattern,
|
|
56
|
+
timeFormat = _this$props.timeFormat,
|
|
57
|
+
direction = _this$props.direction,
|
|
58
|
+
onChange = _this$props.onChange,
|
|
59
|
+
tzData = _this$props.tzData,
|
|
60
|
+
isEnabledCurrentYear = _this$props.isEnabledCurrentYear;
|
|
91
61
|
if (i18n !== prevProps.i18n || timeZone !== prevProps.timeZone || datePattern !== prevProps.datePattern || timeFormat !== prevProps.timeFormat || direction !== prevProps.direction || tzData !== prevProps.tzData || isEnabledCurrentYear !== prevProps.isEnabledCurrentYear) {
|
|
92
62
|
this.promise = new Promise(function (res, rej) {
|
|
93
63
|
_this2.resolve = res;
|
|
@@ -95,11 +65,9 @@ var I18NProvider = /*#__PURE__*/function (_React$Component) {
|
|
|
95
65
|
}).then(function () {
|
|
96
66
|
i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(_this2.props.i18n);
|
|
97
67
|
i18NProviderUtils.getI18NComponent = (0, _jsxTranslations.getI18NComponent)(_this2.props.i18n);
|
|
98
|
-
|
|
99
68
|
if (_this2.props.tzData) {
|
|
100
69
|
i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, _this2.props.tzData, _this2.props.timeFormat, _this2.props.datePattern, _this2.props.isEnabledCurrentYear);
|
|
101
70
|
}
|
|
102
|
-
|
|
103
71
|
_this2.promise = null;
|
|
104
72
|
}, function () {
|
|
105
73
|
_this2.promise = null;
|
|
@@ -123,11 +91,7 @@ var I18NProvider = /*#__PURE__*/function (_React$Component) {
|
|
|
123
91
|
}, this.props.children);
|
|
124
92
|
}
|
|
125
93
|
}]);
|
|
126
|
-
|
|
127
|
-
return I18NProvider;
|
|
128
94
|
}(_react["default"].Component);
|
|
129
|
-
|
|
130
|
-
exports["default"] = I18NProvider;
|
|
131
95
|
I18NProvider.defaultProps = {
|
|
132
96
|
i18n: emptyObj,
|
|
133
97
|
timeZone: '',
|
|
@@ -1,64 +1,43 @@
|
|
|
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 _FormatText = _interopRequireDefault(require("./FormatText"));
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function _setPrototypeOf(
|
|
29
|
-
|
|
30
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
31
|
-
|
|
32
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
33
|
-
|
|
34
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
-
|
|
36
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
-
|
|
38
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
-
|
|
40
|
-
var PluralFormat = /*#__PURE__*/function (_React$Component) {
|
|
41
|
-
_inherits(PluralFormat, _React$Component);
|
|
42
|
-
|
|
43
|
-
var _super = _createSuper(PluralFormat);
|
|
44
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
+
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); }
|
|
13
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
14
|
+
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); } }
|
|
15
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
|
+
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); }
|
|
18
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
19
|
+
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); }
|
|
20
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
21
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
23
|
+
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); }
|
|
24
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
25
|
+
var PluralFormat = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
45
26
|
function PluralFormat() {
|
|
46
27
|
_classCallCheck(this, PluralFormat);
|
|
47
|
-
|
|
48
|
-
return _super.apply(this, arguments);
|
|
28
|
+
return _callSuper(this, PluralFormat, arguments);
|
|
49
29
|
}
|
|
50
|
-
|
|
51
|
-
_createClass(PluralFormat, [{
|
|
30
|
+
_inherits(PluralFormat, _React$Component);
|
|
31
|
+
return _createClass(PluralFormat, [{
|
|
52
32
|
key: "render",
|
|
53
33
|
value: function render() {
|
|
54
34
|
var _this$props = this.props,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
35
|
+
one = _this$props.one,
|
|
36
|
+
many = _this$props.many,
|
|
37
|
+
zero = _this$props.zero,
|
|
38
|
+
value = _this$props.value;
|
|
59
39
|
var key = '',
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
values = '';
|
|
62
41
|
if (value > 1) {
|
|
63
42
|
key = many;
|
|
64
43
|
} else if (value == 1) {
|
|
@@ -66,7 +45,6 @@ var PluralFormat = /*#__PURE__*/function (_React$Component) {
|
|
|
66
45
|
} else if (value == 0) {
|
|
67
46
|
key = zero;
|
|
68
47
|
}
|
|
69
|
-
|
|
70
48
|
values = "".concat(value);
|
|
71
49
|
return /*#__PURE__*/_react["default"].createElement(_FormatText["default"], _extends({}, this.props, {
|
|
72
50
|
i18NKey: key,
|
|
@@ -77,11 +55,7 @@ var PluralFormat = /*#__PURE__*/function (_React$Component) {
|
|
|
77
55
|
}));
|
|
78
56
|
}
|
|
79
57
|
}]);
|
|
80
|
-
|
|
81
|
-
return PluralFormat;
|
|
82
58
|
}(_react["default"].Component);
|
|
83
|
-
|
|
84
|
-
exports["default"] = PluralFormat;
|
|
85
59
|
PluralFormat.propTypes = {
|
|
86
60
|
many: _propTypes["default"].string,
|
|
87
61
|
one: _propTypes["default"].string,
|
|
@@ -1,96 +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 _DateTimeDiffFormat = _interopRequireDefault(require("./DateTimeDiffFormat"));
|
|
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 _inherits(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
35
|
-
|
|
36
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
37
|
-
|
|
38
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
|
-
|
|
40
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
|
-
|
|
42
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
43
|
-
|
|
44
|
-
var UserTimeDiffFormat = /*#__PURE__*/function (_Component) {
|
|
45
|
-
_inherits(UserTimeDiffFormat, _Component);
|
|
46
|
-
|
|
47
|
-
var _super = _createSuper(UserTimeDiffFormat);
|
|
48
|
-
|
|
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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
16
|
+
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); } }
|
|
17
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
19
|
+
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); }
|
|
20
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
21
|
+
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); }
|
|
22
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
23
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
24
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
25
|
+
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); }
|
|
26
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
27
|
+
var UserTimeDiffFormat = exports["default"] = /*#__PURE__*/function (_Component) {
|
|
49
28
|
function UserTimeDiffFormat() {
|
|
50
29
|
_classCallCheck(this, UserTimeDiffFormat);
|
|
51
|
-
|
|
52
|
-
return _super.apply(this, arguments);
|
|
30
|
+
return _callSuper(this, UserTimeDiffFormat, arguments);
|
|
53
31
|
}
|
|
54
|
-
|
|
55
|
-
_createClass(UserTimeDiffFormat, [{
|
|
32
|
+
_inherits(UserTimeDiffFormat, _Component);
|
|
33
|
+
return _createClass(UserTimeDiffFormat, [{
|
|
56
34
|
key: "render",
|
|
57
35
|
value: function render() {
|
|
58
36
|
var currentTime = new Date();
|
|
59
37
|
var currentTimeUTCString = currentTime.toISOString();
|
|
60
38
|
var _this$props = this.props,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
39
|
+
type = _this$props.type,
|
|
40
|
+
page = _this$props.page,
|
|
41
|
+
isNeedTime = _this$props.isNeedTime,
|
|
42
|
+
to = _this$props.to,
|
|
43
|
+
today = _this$props.today,
|
|
44
|
+
yesterday = _this$props.yesterday,
|
|
45
|
+
tomorrow = _this$props.tomorrow,
|
|
46
|
+
others = _this$props.others,
|
|
47
|
+
ago = _this$props.ago,
|
|
48
|
+
later = _this$props.later,
|
|
49
|
+
format = _this$props.format,
|
|
50
|
+
title = _this$props.title,
|
|
51
|
+
className = _this$props.className,
|
|
52
|
+
displayType = _this$props.displayType,
|
|
53
|
+
dataId = _this$props.dataId,
|
|
54
|
+
isOverdue = _this$props.isOverdue,
|
|
55
|
+
isDateField = _this$props.isDateField;
|
|
79
56
|
var _ref = this.context || {},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
57
|
+
tzData = _ref.tzData,
|
|
58
|
+
timeFormat = _ref.timeFormat,
|
|
59
|
+
datePattern = _ref.datePattern,
|
|
60
|
+
isEnabledCurrentYear = _ref.isEnabledCurrentYear;
|
|
85
61
|
if (!format && !others) {
|
|
86
62
|
format = function format(_ref2) {
|
|
87
63
|
var dateTimeFormat = _ref2.dateTimeFormat,
|
|
88
|
-
|
|
89
|
-
|
|
64
|
+
dateFormat = _ref2.dateFormat,
|
|
65
|
+
timeFormat = _ref2.timeFormat;
|
|
90
66
|
displayType === 'dateTime' ? dateTimeFormat : displayType === 'date' ? dateFormat : timeFormat;
|
|
91
67
|
};
|
|
92
68
|
}
|
|
93
|
-
|
|
94
69
|
return /*#__PURE__*/_react["default"].createElement(_DateTimeDiffFormat["default"], {
|
|
95
70
|
type: type,
|
|
96
71
|
page: page,
|
|
@@ -117,11 +92,7 @@ var UserTimeDiffFormat = /*#__PURE__*/function (_Component) {
|
|
|
117
92
|
});
|
|
118
93
|
}
|
|
119
94
|
}]);
|
|
120
|
-
|
|
121
|
-
return UserTimeDiffFormat;
|
|
122
95
|
}(_react.Component);
|
|
123
|
-
|
|
124
|
-
exports["default"] = UserTimeDiffFormat;
|
|
125
96
|
UserTimeDiffFormat.propTypes = {
|
|
126
97
|
ago: _propTypes["default"].string,
|
|
127
98
|
className: _propTypes["default"].string,
|