@zohodesk/i18n 1.0.0-beta.3 → 1.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -2
- package/es/I18NContext.js +1 -2
- package/es/components/DateTimeDiffFormat.js +192 -200
- package/es/components/FormatText.js +4 -25
- package/es/components/HOCI18N.js +33 -45
- package/es/components/I18N.js +48 -63
- package/es/components/I18NProvider.js +59 -85
- package/es/components/PluralFormat.js +29 -48
- package/es/components/UserTimeDiffFormat.js +65 -74
- 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/__tests__/jsxTranslations.spec.js +174 -0
- package/es/utils/index.js +592 -0
- package/es/utils/jsxTranslations.js +193 -0
- package/lib/I18NContext.js +6 -6
- package/lib/components/DateTimeDiffFormat.js +151 -123
- package/lib/components/FormatText.js +32 -22
- package/lib/components/HOCI18N.js +47 -23
- package/lib/components/I18N.js +62 -36
- package/lib/components/I18NProvider.js +82 -70
- package/lib/components/PluralFormat.js +42 -32
- package/lib/components/UserTimeDiffFormat.js +79 -56
- 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 +85 -110
- package/lib/utils/__tests__/jsxTranslations.spec.js +183 -0
- package/lib/utils/index.js +658 -0
- package/lib/utils/jsxTranslations.js +242 -0
- package/package.json +3 -2
- package/src/components/DateTimeDiffFormat.js +86 -55
- package/src/components/I18N.js +2 -0
- package/src/components/I18NProvider.js +34 -25
- package/src/components/UserTimeDiffFormat.js +24 -18
- package/src/index.js +7 -9
- package/src/utils/__tests__/jsxTranslations.spec.js +213 -0
- package/src/utils/index.js +632 -0
- package/src/utils/jsxTranslations.js +180 -0
- package/es/components/NewDateFormat.js +0 -50
- package/es/offset.js +0 -629
- package/es/timezones.js +0 -118
- package/es/utils.js +0 -621
- package/lib/components/NewDateFormat.js +0 -68
- package/lib/offset.js +0 -634
- package/lib/timezones.js +0 -129
- package/lib/utils.js +0 -651
- package/src/components/NewDateFormat.js +0 -60
- package/src/offset.js +0 -629
- package/src/timezones.js +0 -113
- package/src/utils.js +0 -648
|
@@ -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
|
};
|
|
@@ -1,50 +1,68 @@
|
|
|
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;
|
|
6
9
|
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
|
|
11
|
-
var
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
13
|
|
|
13
|
-
var
|
|
14
|
+
var _utils = require("../utils");
|
|
14
15
|
|
|
15
|
-
var
|
|
16
|
+
var _I18NContext = require("../I18NContext");
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
19
|
|
|
19
|
-
var
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
21
|
|
|
21
|
-
var
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
23
|
|
|
23
|
-
function
|
|
24
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
24
25
|
|
|
25
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
26
27
|
|
|
27
|
-
function
|
|
28
|
+
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); } }
|
|
29
|
+
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
|
+
|
|
32
|
+
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); }
|
|
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; } }
|
|
28
43
|
|
|
29
|
-
function
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
45
|
|
|
31
|
-
|
|
46
|
+
var _default = function _default() {
|
|
32
47
|
var i18NKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
33
48
|
return function (Component) {
|
|
34
|
-
var HOCI18N = function (_React$Component) {
|
|
49
|
+
var HOCI18N = /*#__PURE__*/function (_React$Component) {
|
|
35
50
|
_inherits(HOCI18N, _React$Component);
|
|
36
51
|
|
|
52
|
+
var _super = _createSuper(HOCI18N);
|
|
53
|
+
|
|
37
54
|
function HOCI18N(props) {
|
|
38
|
-
|
|
55
|
+
var _this;
|
|
39
56
|
|
|
40
|
-
|
|
57
|
+
_classCallCheck(this, HOCI18N);
|
|
41
58
|
|
|
42
|
-
_this
|
|
59
|
+
_this = _super.call(this, props);
|
|
60
|
+
_this.getI18NValue = _this.getI18NValue.bind(_assertThisInitialized(_this));
|
|
43
61
|
return _this;
|
|
44
62
|
}
|
|
45
63
|
|
|
46
64
|
_createClass(HOCI18N, [{
|
|
47
|
-
key:
|
|
65
|
+
key: "getI18NValue",
|
|
48
66
|
value: function getI18NValue(key) {
|
|
49
67
|
var _ref = this.context || {},
|
|
50
68
|
i18n = _ref.i18n;
|
|
@@ -52,14 +70,17 @@ exports.default = function () {
|
|
|
52
70
|
if (typeof i18n === 'undefined') {
|
|
53
71
|
return key;
|
|
54
72
|
}
|
|
73
|
+
|
|
55
74
|
var i18nStr = i18n[key];
|
|
75
|
+
|
|
56
76
|
if (i18nStr === undefined) {
|
|
57
77
|
return key;
|
|
58
78
|
}
|
|
79
|
+
|
|
59
80
|
return (0, _utils.unescapeUnicode)(i18nStr);
|
|
60
81
|
}
|
|
61
82
|
}, {
|
|
62
|
-
key:
|
|
83
|
+
key: "render",
|
|
63
84
|
value: function render() {
|
|
64
85
|
var _this2 = this;
|
|
65
86
|
|
|
@@ -67,16 +88,19 @@ exports.default = function () {
|
|
|
67
88
|
if (_this2.props[key]) {
|
|
68
89
|
result[key] = _this2.getI18NValue(_this2.props[key]);
|
|
69
90
|
}
|
|
91
|
+
|
|
70
92
|
return result;
|
|
71
93
|
}, {});
|
|
72
|
-
return
|
|
94
|
+
return /*#__PURE__*/_react["default"].createElement(Component, _extends({}, this.props, i18nProps));
|
|
73
95
|
}
|
|
74
96
|
}]);
|
|
75
97
|
|
|
76
98
|
return HOCI18N;
|
|
77
|
-
}(
|
|
99
|
+
}(_react["default"].Component);
|
|
78
100
|
|
|
79
101
|
HOCI18N.contextType = _I18NContext.I18NContext;
|
|
80
102
|
return HOCI18N;
|
|
81
103
|
};
|
|
82
|
-
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
exports["default"] = _default;
|
package/lib/components/I18N.js
CHANGED
|
@@ -1,52 +1,70 @@
|
|
|
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;
|
|
6
9
|
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var _react = require('react');
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
|
|
11
|
-
var
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
13
|
|
|
13
|
-
var
|
|
14
|
+
var _utils = require("../utils");
|
|
14
15
|
|
|
15
|
-
var
|
|
16
|
+
var _SecurityJS = require("@zoho/SecurityJS");
|
|
16
17
|
|
|
17
|
-
var
|
|
18
|
+
var _I18NContext = require("../I18NContext");
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
20
21
|
|
|
21
|
-
var
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
23
|
|
|
23
|
-
function
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
25
|
|
|
25
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
26
27
|
|
|
27
|
-
function
|
|
28
|
+
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); } }
|
|
29
|
+
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
|
+
|
|
32
|
+
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); }
|
|
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); }; }
|
|
28
37
|
|
|
29
|
-
function
|
|
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); }
|
|
30
39
|
|
|
31
|
-
|
|
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) {
|
|
32
47
|
_inherits(I18N, _React$Component);
|
|
33
48
|
|
|
49
|
+
var _super = _createSuper(I18N);
|
|
50
|
+
|
|
34
51
|
function I18N(props) {
|
|
35
|
-
|
|
52
|
+
var _this;
|
|
36
53
|
|
|
37
|
-
|
|
54
|
+
_classCallCheck(this, I18N);
|
|
38
55
|
|
|
39
|
-
_this
|
|
40
|
-
_this.
|
|
56
|
+
_this = _super.call(this, props);
|
|
57
|
+
_this.getI18NValue = _this.getI18NValue.bind(_assertThisInitialized(_this));
|
|
58
|
+
_this.createElement = _this.createElement.bind(_assertThisInitialized(_this));
|
|
41
59
|
return _this;
|
|
42
60
|
}
|
|
43
61
|
|
|
44
62
|
_createClass(I18N, [{
|
|
45
|
-
key:
|
|
63
|
+
key: "getI18NValue",
|
|
46
64
|
value: function getI18NValue() {
|
|
47
|
-
var
|
|
48
|
-
key =
|
|
49
|
-
values =
|
|
65
|
+
var _this$props = this.props,
|
|
66
|
+
key = _this$props.i18NKey,
|
|
67
|
+
values = _this$props.values;
|
|
50
68
|
|
|
51
69
|
var _ref = this.context || {},
|
|
52
70
|
i18n = _ref.i18n;
|
|
@@ -54,15 +72,18 @@ var I18N = function (_React$Component) {
|
|
|
54
72
|
if (typeof i18n === 'undefined') {
|
|
55
73
|
return key;
|
|
56
74
|
}
|
|
75
|
+
|
|
57
76
|
var i18nStr = i18n[key];
|
|
77
|
+
|
|
58
78
|
if (i18nStr === undefined) {
|
|
59
79
|
return key;
|
|
60
80
|
}
|
|
81
|
+
|
|
61
82
|
i18nStr = (0, _utils.replaceI18NValuesWithRegex)(i18nStr, values);
|
|
62
83
|
return (0, _utils.unescapeUnicode)(i18nStr);
|
|
63
84
|
}
|
|
64
85
|
}, {
|
|
65
|
-
key:
|
|
86
|
+
key: "createElement",
|
|
66
87
|
value: function createElement() {
|
|
67
88
|
var _this2 = this;
|
|
68
89
|
|
|
@@ -70,38 +91,43 @@ var I18N = function (_React$Component) {
|
|
|
70
91
|
if (nextKey != 'i18NKey' && nextKey != 'tag' && nextKey != 'values' && nextKey != 'isHtml' && nextKey != 'dataId') {
|
|
71
92
|
result[nextKey] = _this2.props[nextKey];
|
|
72
93
|
}
|
|
94
|
+
|
|
73
95
|
return result;
|
|
74
|
-
}, {});
|
|
75
|
-
|
|
96
|
+
}, {}); //const child=this.getI18NValue();
|
|
97
|
+
|
|
76
98
|
if (this.props.dataId) {
|
|
77
99
|
props['data-id'] = this.props.dataId;
|
|
100
|
+
props['data-test-id'] = this.props.dataId;
|
|
78
101
|
}
|
|
102
|
+
|
|
79
103
|
if (this.props.isHtml) {
|
|
80
104
|
var dangerouslySetInnerHTML = {
|
|
81
105
|
__html: _SecurityJS.HTMLPurifier.sanitize(this.getI18NValue())
|
|
82
106
|
};
|
|
83
|
-
|
|
84
|
-
|
|
107
|
+
return /*#__PURE__*/_react["default"].createElement(this.props.tag, Object.assign(props, {
|
|
108
|
+
dangerouslySetInnerHTML: dangerouslySetInnerHTML
|
|
109
|
+
}));
|
|
85
110
|
}
|
|
86
|
-
|
|
111
|
+
|
|
112
|
+
return /*#__PURE__*/_react["default"].createElement(this.props.tag, props, this.getI18NValue());
|
|
87
113
|
}
|
|
88
114
|
}, {
|
|
89
|
-
key:
|
|
115
|
+
key: "render",
|
|
90
116
|
value: function render() {
|
|
91
117
|
return this.createElement();
|
|
92
118
|
}
|
|
93
119
|
}]);
|
|
94
120
|
|
|
95
121
|
return I18N;
|
|
96
|
-
}(
|
|
97
|
-
|
|
98
|
-
exports.default = I18N;
|
|
122
|
+
}(_react["default"].Component);
|
|
99
123
|
|
|
124
|
+
exports["default"] = I18N;
|
|
100
125
|
I18N.propTypes = {
|
|
101
|
-
i18NKey:
|
|
102
|
-
isHtml:
|
|
103
|
-
tag:
|
|
104
|
-
|
|
126
|
+
i18NKey: _propTypes["default"].string.isRequired,
|
|
127
|
+
isHtml: _propTypes["default"].bool,
|
|
128
|
+
tag: _propTypes["default"].string,
|
|
129
|
+
dataId: _propTypes["default"].string,
|
|
130
|
+
values: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].array])
|
|
105
131
|
};
|
|
106
132
|
I18N.defaultProps = {
|
|
107
133
|
tag: 'span',
|
|
@@ -1,85 +1,104 @@
|
|
|
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
|
});
|
|
6
|
-
exports.i18NProviderUtils =
|
|
8
|
+
exports.i18NProviderUtils = exports["default"] = void 0;
|
|
7
9
|
|
|
8
|
-
var
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
11
|
|
|
10
|
-
var
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
13
|
|
|
12
|
-
var
|
|
14
|
+
var _utils = require("../utils");
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _jsxTranslations = require("../utils/jsxTranslations");
|
|
15
17
|
|
|
16
|
-
var
|
|
18
|
+
var _I18NContext = require("../I18NContext");
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
23
|
|
|
22
|
-
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); } }
|
|
23
25
|
|
|
24
|
-
|
|
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; }
|
|
25
27
|
|
|
26
|
-
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); }
|
|
27
29
|
|
|
28
|
-
function
|
|
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; }
|
|
29
37
|
|
|
30
|
-
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; } }
|
|
31
39
|
|
|
32
|
-
function
|
|
40
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
33
41
|
|
|
34
42
|
var emptyObj = {};
|
|
43
|
+
|
|
35
44
|
var dummy = function dummy(key, values) {
|
|
36
45
|
return key;
|
|
37
46
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}], function (tzStr) {
|
|
41
|
-
return (0, _timezones.unpack)(tzStr);
|
|
42
|
-
});
|
|
43
|
-
var i18NProviderUtils = exports.i18NProviderUtils = {
|
|
47
|
+
|
|
48
|
+
var i18NProviderUtils = {
|
|
44
49
|
getI18NValue: dummy,
|
|
45
|
-
userDateFormat: dummy
|
|
50
|
+
userDateFormat: dummy,
|
|
51
|
+
getI18NComponent: dummy
|
|
46
52
|
};
|
|
53
|
+
exports.i18NProviderUtils = i18NProviderUtils;
|
|
47
54
|
|
|
48
|
-
var I18NProvider = function (_React$Component) {
|
|
55
|
+
var I18NProvider = /*#__PURE__*/function (_React$Component) {
|
|
49
56
|
_inherits(I18NProvider, _React$Component);
|
|
50
57
|
|
|
58
|
+
var _super = _createSuper(I18NProvider);
|
|
59
|
+
|
|
51
60
|
function I18NProvider(props, context) {
|
|
52
|
-
|
|
61
|
+
var _this;
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
_classCallCheck(this, I18NProvider);
|
|
55
64
|
|
|
65
|
+
_this = _super.call(this, props, context);
|
|
56
66
|
i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(props.i18n);
|
|
57
|
-
i18NProviderUtils.
|
|
67
|
+
i18NProviderUtils.getI18NComponent = (0, _jsxTranslations.getI18NComponent)(props.i18n);
|
|
68
|
+
|
|
69
|
+
if (props.tzData) {
|
|
70
|
+
i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, props.isEnabledCurrentYear);
|
|
71
|
+
}
|
|
72
|
+
|
|
58
73
|
return _this;
|
|
59
74
|
}
|
|
60
75
|
|
|
61
76
|
_createClass(I18NProvider, [{
|
|
62
|
-
key:
|
|
77
|
+
key: "componentDidUpdate",
|
|
63
78
|
value: function componentDidUpdate(next) {
|
|
64
79
|
var _this2 = this;
|
|
65
80
|
|
|
66
|
-
var
|
|
67
|
-
i18n =
|
|
68
|
-
timeZone =
|
|
69
|
-
datePattern =
|
|
70
|
-
timeFormat =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (i18n !== next.i18n || timeZone !== next.timeZone || datePattern !== next.datePattern || timeFormat !== next.timeFormat || dateTimeFormat !== next.dateTimeFormat || direction !== next.direction || tzData !== next.tzData) {
|
|
81
|
+
var _this$props = this.props,
|
|
82
|
+
i18n = _this$props.i18n,
|
|
83
|
+
timeZone = _this$props.timeZone,
|
|
84
|
+
datePattern = _this$props.datePattern,
|
|
85
|
+
timeFormat = _this$props.timeFormat,
|
|
86
|
+
direction = _this$props.direction,
|
|
87
|
+
onChange = _this$props.onChange,
|
|
88
|
+
tzData = _this$props.tzData;
|
|
89
|
+
|
|
90
|
+
if (i18n !== next.i18n || timeZone !== next.timeZone || datePattern !== next.datePattern || timeFormat !== next.timeFormat || direction !== next.direction || tzData !== next.tzData) {
|
|
77
91
|
this.promise = new Promise(function (res, rej) {
|
|
78
92
|
_this2.resolve = res;
|
|
79
93
|
_this2.reject = rej;
|
|
80
94
|
}).then(function () {
|
|
81
95
|
i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(nextProps.i18n);
|
|
82
|
-
i18NProviderUtils.
|
|
96
|
+
i18NProviderUtils.getI18NComponent = (0, _jsxTranslations.getI18NComponent)(nextProps.i18n);
|
|
97
|
+
|
|
98
|
+
if (props.tzData) {
|
|
99
|
+
i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, _this2.props.isEnabledCurrentYear);
|
|
100
|
+
}
|
|
101
|
+
|
|
83
102
|
_this2.promise = null;
|
|
84
103
|
}, function () {
|
|
85
104
|
_this2.promise = null;
|
|
@@ -88,49 +107,42 @@ var I18NProvider = function (_React$Component) {
|
|
|
88
107
|
}
|
|
89
108
|
}
|
|
90
109
|
}, {
|
|
91
|
-
key:
|
|
110
|
+
key: "render",
|
|
92
111
|
value: function render() {
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
this.props.children
|
|
107
|
-
);
|
|
112
|
+
return /*#__PURE__*/_react["default"].createElement(_I18NContext.I18NContext.Provider, {
|
|
113
|
+
value: {
|
|
114
|
+
i18n: this.props.i18n,
|
|
115
|
+
direction: this.props.direction,
|
|
116
|
+
timeZone: this.props.timeZone,
|
|
117
|
+
datePattern: this.props.datePattern,
|
|
118
|
+
timeFormat: this.props.timeFormat,
|
|
119
|
+
isEnabledCurrentYear: this.props.isEnabledCurrentYear,
|
|
120
|
+
tzData: this.props.tzData
|
|
121
|
+
}
|
|
122
|
+
}, this.props.children);
|
|
108
123
|
}
|
|
109
124
|
}]);
|
|
110
125
|
|
|
111
126
|
return I18NProvider;
|
|
112
|
-
}(
|
|
113
|
-
|
|
114
|
-
exports.default = I18NProvider;
|
|
115
|
-
|
|
127
|
+
}(_react["default"].Component);
|
|
116
128
|
|
|
129
|
+
exports["default"] = I18NProvider;
|
|
117
130
|
I18NProvider.defaultProps = {
|
|
118
131
|
i18n: emptyObj,
|
|
119
132
|
timeZone: '',
|
|
120
133
|
datePattern: '',
|
|
121
134
|
timeFormat: '',
|
|
122
|
-
|
|
135
|
+
isEnabledCurrentYear: '',
|
|
123
136
|
direction: 'ltr'
|
|
124
137
|
};
|
|
125
|
-
|
|
126
138
|
I18NProvider.propTypes = {
|
|
127
|
-
children:
|
|
128
|
-
datePattern:
|
|
129
|
-
|
|
130
|
-
direction:
|
|
131
|
-
i18n:
|
|
132
|
-
onChange:
|
|
133
|
-
timeFormat:
|
|
134
|
-
timeZone:
|
|
135
|
-
tzData:
|
|
139
|
+
children: _propTypes["default"].element.isRequired,
|
|
140
|
+
datePattern: _propTypes["default"].string,
|
|
141
|
+
isEnabledCurrentYear: _propTypes["default"].string,
|
|
142
|
+
direction: _propTypes["default"].string,
|
|
143
|
+
i18n: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].func]),
|
|
144
|
+
onChange: _propTypes["default"].func,
|
|
145
|
+
timeFormat: _propTypes["default"].string,
|
|
146
|
+
timeZone: _propTypes["default"].string,
|
|
147
|
+
tzData: _propTypes["default"].object
|
|
136
148
|
};
|