@zohodesk/i18n 1.0.0-beta.15.1 → 1.0.0-beta.18
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 +73 -41
- package/es/components/DateTimeDiffFormat.js +46 -12
- package/es/components/HOCI18N.js +33 -30
- package/es/components/I18NProvider.js +7 -16
- package/es/components/UserTimeDiffFormat.js +11 -9
- package/es/components/__tests__/DateTimeDiffFormat.spec.js +177 -136
- package/es/components/__tests__/FormatText.spec.js +0 -1
- package/es/components/__tests__/HOCI18N.spec.js +0 -1
- package/es/components/__tests__/I18N.spec.js +0 -2
- package/es/components/__tests__/I18NProvider.spec.js +0 -1
- package/es/components/__tests__/PluralFormat.spec.js +0 -1
- package/es/components/__tests__/UserTimeDiffFormat.spec.js +287 -206
- package/es/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
- package/es/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
- package/es/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
- package/es/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
- package/es/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
- package/es/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
- package/es/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
- package/es/index.js +2 -3
- package/es/utils.js +119 -171
- package/lib/components/DateTimeDiffFormat.js +49 -15
- package/lib/components/FormatText.js +4 -4
- package/lib/components/HOCI18N.js +4 -4
- package/lib/components/I18N.js +4 -4
- package/lib/components/I18NProvider.js +12 -21
- package/lib/components/PluralFormat.js +4 -4
- package/lib/components/UserTimeDiffFormat.js +12 -14
- package/lib/components/__tests__/I18NProvider.spec.js +1 -1
- package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1 -1
- package/lib/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
- package/lib/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
- package/lib/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
- package/lib/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
- package/lib/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
- package/lib/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
- package/lib/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
- package/lib/index.js +54 -56
- package/lib/utils.js +130 -212
- package/package.json +28 -28
- package/src/I18NContext.js +2 -2
- package/src/components/DateTimeDiffFormat.js +254 -211
- package/src/components/FormatText.js +14 -14
- package/src/components/HOCI18N.js +37 -37
- package/src/components/I18N.js +72 -72
- package/src/components/I18NProvider.js +106 -116
- package/src/components/PluralFormat.js +37 -37
- package/src/components/UserTimeDiffFormat.js +94 -103
- package/src/components/__tests__/DateTimeDiffFormat.spec.js +618 -618
- package/src/components/__tests__/FormatText.spec.js +26 -26
- package/src/components/__tests__/HOCI18N.spec.js +33 -33
- package/src/components/__tests__/I18N.spec.js +29 -29
- package/src/components/__tests__/I18NProvider.spec.js +65 -65
- package/src/components/__tests__/PluralFormat.spec.js +27 -27
- package/src/components/__tests__/UserTimeDiffFormat.spec.js +1076 -1076
- package/src/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
- package/src/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
- package/src/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
- package/src/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
- package/src/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
- package/src/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
- package/src/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
- package/src/index.js +33 -33
- package/src/utils.js +527 -587
- package/es/components/NewDateFormat.js +0 -53
- package/lib/components/NewDateFormat.js +0 -60
- package/src/components/NewDateFormat.js +0 -60
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { getFormatedDate } from '../utils';
|
|
4
|
-
import FormatText from './FormatText';
|
|
5
|
-
import { I18NContext } from '../I18NContext';
|
|
6
|
-
export default function NewDateFormat(props, context) {
|
|
7
|
-
let currentTime = new Date();
|
|
8
|
-
let {
|
|
9
|
-
to,
|
|
10
|
-
today,
|
|
11
|
-
yesterday,
|
|
12
|
-
tomorrow,
|
|
13
|
-
others,
|
|
14
|
-
ago,
|
|
15
|
-
later,
|
|
16
|
-
format,
|
|
17
|
-
titleFormat,
|
|
18
|
-
titleString,
|
|
19
|
-
className,
|
|
20
|
-
displayType,
|
|
21
|
-
calculateFrom
|
|
22
|
-
} = props;
|
|
23
|
-
calculateFrom = calculateFrom === undefined ? currentTime : calculateFrom;
|
|
24
|
-
let {
|
|
25
|
-
tzData
|
|
26
|
-
} = context;
|
|
27
|
-
let formatResponse = getFormatedDate(to, today, yesterday, tomorrow, others, ago, later, format, titleFormat, titleString, calculateFrom, tzData);
|
|
28
|
-
let isI18nValue = formatResponse.isFormatText;
|
|
29
|
-
|
|
30
|
-
if (isI18nValue) {
|
|
31
|
-
let {
|
|
32
|
-
i18nText,
|
|
33
|
-
values,
|
|
34
|
-
title
|
|
35
|
-
} = formatResponse;
|
|
36
|
-
return /*#__PURE__*/React.createElement(FormatText, {
|
|
37
|
-
i18NKey: i18nText,
|
|
38
|
-
values: values,
|
|
39
|
-
className: className,
|
|
40
|
-
"data-title": title
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let {
|
|
45
|
-
title,
|
|
46
|
-
formatedDate
|
|
47
|
-
} = formatResponse;
|
|
48
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
49
|
-
className: className,
|
|
50
|
-
"data-title": title
|
|
51
|
-
}, formatedDate);
|
|
52
|
-
}
|
|
53
|
-
NewDateFormat.contextType = I18NContext;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = NewDateFormat;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _utils = require("../utils");
|
|
13
|
-
|
|
14
|
-
var _FormatText = _interopRequireDefault(require("./FormatText"));
|
|
15
|
-
|
|
16
|
-
var _I18NContext = require("../I18NContext");
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
|
-
function NewDateFormat(props, context) {
|
|
21
|
-
var currentTime = new Date();
|
|
22
|
-
var to = props.to,
|
|
23
|
-
today = props.today,
|
|
24
|
-
yesterday = props.yesterday,
|
|
25
|
-
tomorrow = props.tomorrow,
|
|
26
|
-
others = props.others,
|
|
27
|
-
ago = props.ago,
|
|
28
|
-
later = props.later,
|
|
29
|
-
format = props.format,
|
|
30
|
-
titleFormat = props.titleFormat,
|
|
31
|
-
titleString = props.titleString,
|
|
32
|
-
className = props.className,
|
|
33
|
-
displayType = props.displayType,
|
|
34
|
-
calculateFrom = props.calculateFrom;
|
|
35
|
-
calculateFrom = calculateFrom === undefined ? currentTime : calculateFrom;
|
|
36
|
-
var tzData = context.tzData;
|
|
37
|
-
var formatResponse = (0, _utils.getFormatedDate)(to, today, yesterday, tomorrow, others, ago, later, format, titleFormat, titleString, calculateFrom, tzData);
|
|
38
|
-
var isI18nValue = formatResponse.isFormatText;
|
|
39
|
-
|
|
40
|
-
if (isI18nValue) {
|
|
41
|
-
var i18nText = formatResponse.i18nText,
|
|
42
|
-
values = formatResponse.values,
|
|
43
|
-
_title = formatResponse.title;
|
|
44
|
-
return /*#__PURE__*/_react["default"].createElement(_FormatText["default"], {
|
|
45
|
-
i18NKey: i18nText,
|
|
46
|
-
values: values,
|
|
47
|
-
className: className,
|
|
48
|
-
"data-title": _title
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
var title = formatResponse.title,
|
|
53
|
-
formatedDate = formatResponse.formatedDate;
|
|
54
|
-
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
55
|
-
className: className,
|
|
56
|
-
"data-title": title
|
|
57
|
-
}, formatedDate);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
NewDateFormat.contextType = _I18NContext.I18NContext;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
|
|
4
|
-
import { getFormatedDate } from '../utils';
|
|
5
|
-
import FormatText from './FormatText';
|
|
6
|
-
import { I18NContext } from '../I18NContext';
|
|
7
|
-
|
|
8
|
-
export default function NewDateFormat(props, context) {
|
|
9
|
-
let currentTime = new Date();
|
|
10
|
-
let {
|
|
11
|
-
to,
|
|
12
|
-
today,
|
|
13
|
-
yesterday,
|
|
14
|
-
tomorrow,
|
|
15
|
-
others,
|
|
16
|
-
ago,
|
|
17
|
-
later,
|
|
18
|
-
format,
|
|
19
|
-
titleFormat,
|
|
20
|
-
titleString,
|
|
21
|
-
className,
|
|
22
|
-
displayType,
|
|
23
|
-
calculateFrom
|
|
24
|
-
} = props;
|
|
25
|
-
calculateFrom = calculateFrom === undefined ? currentTime : calculateFrom;
|
|
26
|
-
let { tzData } = context;
|
|
27
|
-
let formatResponse = getFormatedDate(
|
|
28
|
-
to,
|
|
29
|
-
today,
|
|
30
|
-
yesterday,
|
|
31
|
-
tomorrow,
|
|
32
|
-
others,
|
|
33
|
-
ago,
|
|
34
|
-
later,
|
|
35
|
-
format,
|
|
36
|
-
titleFormat,
|
|
37
|
-
titleString,
|
|
38
|
-
calculateFrom,
|
|
39
|
-
tzData
|
|
40
|
-
);
|
|
41
|
-
let isI18nValue = formatResponse.isFormatText;
|
|
42
|
-
if (isI18nValue) {
|
|
43
|
-
let { i18nText, values, title } = formatResponse;
|
|
44
|
-
return (
|
|
45
|
-
<FormatText
|
|
46
|
-
i18NKey={i18nText}
|
|
47
|
-
values={values}
|
|
48
|
-
className={className}
|
|
49
|
-
data-title={title}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
let { title, formatedDate } = formatResponse;
|
|
54
|
-
return (
|
|
55
|
-
<span className={className} data-title={title}>
|
|
56
|
-
{formatedDate}
|
|
57
|
-
</span>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
NewDateFormat.contextType = I18NContext;
|