@zohodesk/i18n 1.0.0-beta.3 → 1.0.0-beta.31
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 +120 -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 +60 -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 +85 -72
- 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 +44 -33
- 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,85 +1,105 @@
|
|
|
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:
|
|
63
|
-
value: function componentDidUpdate(
|
|
77
|
+
key: "componentDidUpdate",
|
|
78
|
+
value: function componentDidUpdate(prevProps) {
|
|
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 !==
|
|
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
|
+
isEnabledCurrentYear = _this$props.isEnabledCurrentYear;
|
|
90
|
+
|
|
91
|
+
if (i18n !== prevProps.i18n || timeZone !== prevProps.timeZone || datePattern !== prevProps.datePattern || timeFormat !== prevProps.timeFormat || direction !== prevProps.direction || tzData !== prevProps.tzData || isEnabledCurrentYear !== prevProps.isEnabledCurrentYear) {
|
|
77
92
|
this.promise = new Promise(function (res, rej) {
|
|
78
93
|
_this2.resolve = res;
|
|
79
94
|
_this2.reject = rej;
|
|
80
95
|
}).then(function () {
|
|
81
|
-
i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(
|
|
82
|
-
i18NProviderUtils.
|
|
96
|
+
i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(_this2.props.i18n);
|
|
97
|
+
i18NProviderUtils.getI18NComponent = (0, _jsxTranslations.getI18NComponent)(_this2.props.i18n);
|
|
98
|
+
|
|
99
|
+
if (_this2.props.tzData) {
|
|
100
|
+
i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, _this2.props.tzData, _this2.props.timeFormat, _this2.props.datePattern, _this2.props.isEnabledCurrentYear);
|
|
101
|
+
}
|
|
102
|
+
|
|
83
103
|
_this2.promise = null;
|
|
84
104
|
}, function () {
|
|
85
105
|
_this2.promise = null;
|
|
@@ -88,49 +108,42 @@ var I18NProvider = function (_React$Component) {
|
|
|
88
108
|
}
|
|
89
109
|
}
|
|
90
110
|
}, {
|
|
91
|
-
key:
|
|
111
|
+
key: "render",
|
|
92
112
|
value: function render() {
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
this.props.children
|
|
107
|
-
);
|
|
113
|
+
return /*#__PURE__*/_react["default"].createElement(_I18NContext.I18NContext.Provider, {
|
|
114
|
+
value: {
|
|
115
|
+
i18n: this.props.i18n,
|
|
116
|
+
direction: this.props.direction,
|
|
117
|
+
timeZone: this.props.timeZone,
|
|
118
|
+
datePattern: this.props.datePattern,
|
|
119
|
+
timeFormat: this.props.timeFormat,
|
|
120
|
+
isEnabledCurrentYear: this.props.isEnabledCurrentYear,
|
|
121
|
+
tzData: this.props.tzData
|
|
122
|
+
}
|
|
123
|
+
}, this.props.children);
|
|
108
124
|
}
|
|
109
125
|
}]);
|
|
110
126
|
|
|
111
127
|
return I18NProvider;
|
|
112
|
-
}(
|
|
113
|
-
|
|
114
|
-
exports.default = I18NProvider;
|
|
115
|
-
|
|
128
|
+
}(_react["default"].Component);
|
|
116
129
|
|
|
130
|
+
exports["default"] = I18NProvider;
|
|
117
131
|
I18NProvider.defaultProps = {
|
|
118
132
|
i18n: emptyObj,
|
|
119
133
|
timeZone: '',
|
|
120
134
|
datePattern: '',
|
|
121
135
|
timeFormat: '',
|
|
122
|
-
|
|
136
|
+
isEnabledCurrentYear: '',
|
|
123
137
|
direction: 'ltr'
|
|
124
138
|
};
|
|
125
|
-
|
|
126
139
|
I18NProvider.propTypes = {
|
|
127
|
-
children:
|
|
128
|
-
datePattern:
|
|
129
|
-
|
|
130
|
-
direction:
|
|
131
|
-
i18n:
|
|
132
|
-
onChange:
|
|
133
|
-
timeFormat:
|
|
134
|
-
timeZone:
|
|
135
|
-
tzData:
|
|
140
|
+
children: _propTypes["default"].element.isRequired,
|
|
141
|
+
datePattern: _propTypes["default"].string,
|
|
142
|
+
isEnabledCurrentYear: _propTypes["default"].string,
|
|
143
|
+
direction: _propTypes["default"].string,
|
|
144
|
+
i18n: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].func]),
|
|
145
|
+
onChange: _propTypes["default"].func,
|
|
146
|
+
timeFormat: _propTypes["default"].string,
|
|
147
|
+
timeZone: _propTypes["default"].string,
|
|
148
|
+
tzData: _propTypes["default"].object
|
|
136
149
|
};
|
|
@@ -1,53 +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;
|
|
6
9
|
|
|
7
|
-
var
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
11
|
|
|
9
|
-
var
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
13
|
|
|
11
|
-
var
|
|
14
|
+
var _FormatText = _interopRequireDefault(require("./FormatText"));
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
17
|
|
|
15
|
-
var
|
|
18
|
+
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); }
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
21
|
|
|
19
|
-
var
|
|
22
|
+
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); } }
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
22
25
|
|
|
23
|
-
function
|
|
26
|
+
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); }
|
|
24
27
|
|
|
25
|
-
function
|
|
28
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
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); }
|
|
26
33
|
|
|
27
|
-
function
|
|
34
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
35
|
|
|
29
|
-
function
|
|
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; } }
|
|
30
37
|
|
|
31
|
-
|
|
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) {
|
|
32
41
|
_inherits(PluralFormat, _React$Component);
|
|
33
42
|
|
|
43
|
+
var _super = _createSuper(PluralFormat);
|
|
44
|
+
|
|
34
45
|
function PluralFormat() {
|
|
35
46
|
_classCallCheck(this, PluralFormat);
|
|
36
47
|
|
|
37
|
-
return
|
|
48
|
+
return _super.apply(this, arguments);
|
|
38
49
|
}
|
|
39
50
|
|
|
40
51
|
_createClass(PluralFormat, [{
|
|
41
|
-
key:
|
|
52
|
+
key: "render",
|
|
42
53
|
value: function render() {
|
|
43
|
-
var
|
|
44
|
-
one =
|
|
45
|
-
many =
|
|
46
|
-
zero =
|
|
47
|
-
value =
|
|
48
|
-
|
|
54
|
+
var _this$props = this.props,
|
|
55
|
+
one = _this$props.one,
|
|
56
|
+
many = _this$props.many,
|
|
57
|
+
zero = _this$props.zero,
|
|
58
|
+
value = _this$props.value;
|
|
49
59
|
var key = '',
|
|
50
60
|
values = '';
|
|
61
|
+
|
|
51
62
|
if (value > 1) {
|
|
52
63
|
key = many;
|
|
53
64
|
} else if (value == 1) {
|
|
@@ -55,9 +66,9 @@ var PluralFormat = function (_React$Component) {
|
|
|
55
66
|
} else if (value == 0) {
|
|
56
67
|
key = zero;
|
|
57
68
|
}
|
|
58
|
-
values = '' + value;
|
|
59
69
|
|
|
60
|
-
|
|
70
|
+
values = "".concat(value);
|
|
71
|
+
return /*#__PURE__*/_react["default"].createElement(_FormatText["default"], _extends({}, this.props, {
|
|
61
72
|
i18NKey: key,
|
|
62
73
|
values: values,
|
|
63
74
|
one: null,
|
|
@@ -68,14 +79,13 @@ var PluralFormat = function (_React$Component) {
|
|
|
68
79
|
}]);
|
|
69
80
|
|
|
70
81
|
return PluralFormat;
|
|
71
|
-
}(
|
|
72
|
-
|
|
73
|
-
exports.default = PluralFormat;
|
|
82
|
+
}(_react["default"].Component);
|
|
74
83
|
|
|
84
|
+
exports["default"] = PluralFormat;
|
|
75
85
|
PluralFormat.propTypes = {
|
|
76
|
-
many:
|
|
77
|
-
one:
|
|
78
|
-
tag:
|
|
79
|
-
value:
|
|
80
|
-
zero:
|
|
86
|
+
many: _propTypes["default"].string,
|
|
87
|
+
one: _propTypes["default"].string,
|
|
88
|
+
tag: _propTypes["default"].string,
|
|
89
|
+
value: _propTypes["default"].number,
|
|
90
|
+
zero: _propTypes["default"].string
|
|
81
91
|
};
|
|
@@ -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
|
});
|
|
8
|
+
exports["default"] = void 0;
|
|
6
9
|
|
|
7
|
-
var
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
11
|
|
|
9
|
-
var
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
13
|
|
|
11
|
-
var
|
|
14
|
+
var _DateTimeDiffFormat = _interopRequireDefault(require("./DateTimeDiffFormat"));
|
|
12
15
|
|
|
13
|
-
var
|
|
16
|
+
var _I18NContext = require("../I18NContext");
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
19
|
|
|
17
|
-
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); }
|
|
18
21
|
|
|
19
|
-
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; }
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
22
25
|
|
|
23
|
-
function
|
|
26
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
24
27
|
|
|
25
|
-
function
|
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
29
|
+
|
|
30
|
+
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); }
|
|
31
|
+
|
|
32
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
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); }; }
|
|
26
35
|
|
|
27
|
-
function _possibleConstructorReturn(self, call) { if (
|
|
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); }
|
|
28
37
|
|
|
29
|
-
function
|
|
38
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
30
39
|
|
|
31
|
-
|
|
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) {
|
|
32
45
|
_inherits(UserTimeDiffFormat, _Component);
|
|
33
46
|
|
|
47
|
+
var _super = _createSuper(UserTimeDiffFormat);
|
|
48
|
+
|
|
34
49
|
function UserTimeDiffFormat() {
|
|
35
50
|
_classCallCheck(this, UserTimeDiffFormat);
|
|
36
51
|
|
|
37
|
-
return
|
|
52
|
+
return _super.apply(this, arguments);
|
|
38
53
|
}
|
|
39
54
|
|
|
40
55
|
_createClass(UserTimeDiffFormat, [{
|
|
41
|
-
key:
|
|
56
|
+
key: "render",
|
|
42
57
|
value: function render() {
|
|
43
58
|
var currentTime = new Date();
|
|
44
59
|
var currentTimeUTCString = currentTime.toISOString();
|
|
45
|
-
var
|
|
46
|
-
type =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
var _this$props = this.props,
|
|
61
|
+
type = _this$props.type,
|
|
62
|
+
page = _this$props.page,
|
|
63
|
+
isNeedTime = _this$props.isNeedTime,
|
|
64
|
+
to = _this$props.to,
|
|
65
|
+
today = _this$props.today,
|
|
66
|
+
yesterday = _this$props.yesterday,
|
|
67
|
+
tomorrow = _this$props.tomorrow,
|
|
68
|
+
others = _this$props.others,
|
|
69
|
+
ago = _this$props.ago,
|
|
70
|
+
later = _this$props.later,
|
|
71
|
+
format = _this$props.format,
|
|
72
|
+
title = _this$props.title,
|
|
73
|
+
className = _this$props.className,
|
|
74
|
+
displayType = _this$props.displayType,
|
|
75
|
+
dataId = _this$props.dataId,
|
|
76
|
+
isOverdue = _this$props.isOverdue,
|
|
77
|
+
isDateField = _this$props.isDateField;
|
|
60
78
|
|
|
61
79
|
var _ref = this.context || {},
|
|
62
80
|
tzData = _ref.tzData,
|
|
63
81
|
timeFormat = _ref.timeFormat,
|
|
64
82
|
datePattern = _ref.datePattern,
|
|
65
|
-
|
|
66
|
-
timeZone = _ref.timeZone;
|
|
83
|
+
isEnabledCurrentYear = _ref.isEnabledCurrentYear;
|
|
67
84
|
|
|
68
85
|
if (!format && !others) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
86
|
+
format = function format(_ref2) {
|
|
87
|
+
var dateTimeFormat = _ref2.dateTimeFormat,
|
|
88
|
+
dateFormat = _ref2.dateFormat,
|
|
89
|
+
timeFormat = _ref2.timeFormat;
|
|
90
|
+
displayType === 'dateTime' ? dateTimeFormat : displayType === 'date' ? dateFormat : timeFormat;
|
|
72
91
|
};
|
|
73
92
|
}
|
|
74
93
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return _react2.default.createElement(_DateTimeDiffFormat2.default, {
|
|
94
|
+
return /*#__PURE__*/_react["default"].createElement(_DateTimeDiffFormat["default"], {
|
|
78
95
|
type: type,
|
|
96
|
+
page: page,
|
|
97
|
+
isNeedTime: isNeedTime,
|
|
79
98
|
from: currentTimeUTCString,
|
|
80
|
-
fromTzData:
|
|
99
|
+
fromTzData: tzData,
|
|
81
100
|
to: to,
|
|
82
|
-
toTzData:
|
|
101
|
+
toTzData: tzData,
|
|
83
102
|
today: today,
|
|
84
103
|
yesterday: yesterday,
|
|
85
104
|
tomorrow: tomorrow,
|
|
@@ -90,7 +109,11 @@ var UserTimeDiffFormat = function (_Component) {
|
|
|
90
109
|
title: title,
|
|
91
110
|
className: className,
|
|
92
111
|
dataId: dataId,
|
|
93
|
-
isOverdue: isOverdue
|
|
112
|
+
isOverdue: isOverdue,
|
|
113
|
+
timeFormat: timeFormat,
|
|
114
|
+
datePattern: datePattern,
|
|
115
|
+
isEnabledCurrentYear: isEnabledCurrentYear,
|
|
116
|
+
isDateField: isDateField
|
|
94
117
|
});
|
|
95
118
|
}
|
|
96
119
|
}]);
|
|
@@ -98,20 +121,20 @@ var UserTimeDiffFormat = function (_Component) {
|
|
|
98
121
|
return UserTimeDiffFormat;
|
|
99
122
|
}(_react.Component);
|
|
100
123
|
|
|
101
|
-
exports
|
|
102
|
-
|
|
124
|
+
exports["default"] = UserTimeDiffFormat;
|
|
103
125
|
UserTimeDiffFormat.propTypes = {
|
|
104
|
-
ago:
|
|
105
|
-
className:
|
|
106
|
-
dataId:
|
|
107
|
-
displayType:
|
|
108
|
-
format:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
ago: _propTypes["default"].string,
|
|
127
|
+
className: _propTypes["default"].string,
|
|
128
|
+
dataId: _propTypes["default"].string,
|
|
129
|
+
displayType: _propTypes["default"].oneOf(['date', 'time', 'dateTime']),
|
|
130
|
+
format: _propTypes["default"].func,
|
|
131
|
+
isDateField: _propTypes["default"].bool,
|
|
132
|
+
later: _propTypes["default"].string,
|
|
133
|
+
others: _propTypes["default"].func,
|
|
134
|
+
title: _propTypes["default"].string,
|
|
135
|
+
to: _propTypes["default"].string,
|
|
136
|
+
today: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object, _propTypes["default"].func]),
|
|
137
|
+
tomorrow: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object, _propTypes["default"].func]),
|
|
138
|
+
yesterday: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object, _propTypes["default"].func])
|
|
116
139
|
};
|
|
117
140
|
UserTimeDiffFormat.contextType = _I18NContext.I18NContext;
|