@zohodesk/i18n 1.0.0-beta.20 → 1.0.0-beta.21
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 +85 -80
- package/es/components/DateTimeDiffFormat.js +2 -1
- package/es/components/HOCI18N.js +1 -1
- package/es/components/PluralFormat.js +1 -1
- package/es/components/__tests__/I18N.spec.js +1 -1
- 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/lib/components/DateTimeDiffFormat.js +4 -3
- package/lib/components/FormatText.js +2 -2
- package/lib/components/HOCI18N.js +3 -3
- package/lib/components/I18N.js +2 -2
- package/lib/components/I18NProvider.js +2 -2
- package/lib/components/PluralFormat.js +3 -3
- package/lib/components/UserTimeDiffFormat.js +2 -2
- package/lib/components/__tests__/I18N.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/package.json +29 -29
- package/src/I18NContext.js +2 -2
- package/src/components/DateTimeDiffFormat.js +256 -256
- 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 +110 -110
- package/src/components/PluralFormat.js +37 -37
- package/src/components/UserTimeDiffFormat.js +97 -97
- 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 -527
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import DateTimeDiffFormat from './DateTimeDiffFormat';
|
|
4
|
-
import { I18NContext } from '../I18NContext';
|
|
5
|
-
|
|
6
|
-
export default class UserTimeDiffFormat extends Component {
|
|
7
|
-
render() {
|
|
8
|
-
let currentTime = new Date();
|
|
9
|
-
let currentTimeUTCString = currentTime.toISOString();
|
|
10
|
-
let {
|
|
11
|
-
type,
|
|
12
|
-
page,
|
|
13
|
-
isNeedTime,
|
|
14
|
-
to,
|
|
15
|
-
today,
|
|
16
|
-
yesterday,
|
|
17
|
-
tomorrow,
|
|
18
|
-
others,
|
|
19
|
-
ago,
|
|
20
|
-
later,
|
|
21
|
-
format,
|
|
22
|
-
title,
|
|
23
|
-
className,
|
|
24
|
-
displayType,
|
|
25
|
-
dataId,
|
|
26
|
-
isOverdue,
|
|
27
|
-
isDateField
|
|
28
|
-
} = this.props;
|
|
29
|
-
let { tzData, timeFormat, datePattern, isEnabledCurrentYear } =
|
|
30
|
-
this.context || {};
|
|
31
|
-
|
|
32
|
-
if (!format && !others) {
|
|
33
|
-
format = ({ dateTimeFormat, dateFormat, timeFormat }) => {
|
|
34
|
-
displayType === 'dateTime'
|
|
35
|
-
? dateTimeFormat
|
|
36
|
-
: displayType === 'date'
|
|
37
|
-
? dateFormat
|
|
38
|
-
: timeFormat;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<DateTimeDiffFormat
|
|
44
|
-
type={type}
|
|
45
|
-
page={page}
|
|
46
|
-
isNeedTime={isNeedTime}
|
|
47
|
-
from={currentTimeUTCString}
|
|
48
|
-
fromTzData={tzData}
|
|
49
|
-
to={to}
|
|
50
|
-
toTzData={tzData}
|
|
51
|
-
today={today}
|
|
52
|
-
yesterday={yesterday}
|
|
53
|
-
tomorrow={tomorrow}
|
|
54
|
-
others={others}
|
|
55
|
-
ago={ago}
|
|
56
|
-
later={later}
|
|
57
|
-
format={format}
|
|
58
|
-
title={title}
|
|
59
|
-
className={className}
|
|
60
|
-
dataId={dataId}
|
|
61
|
-
isOverdue={isOverdue}
|
|
62
|
-
timeFormat={timeFormat}
|
|
63
|
-
datePattern={datePattern}
|
|
64
|
-
isEnabledCurrentYear={isEnabledCurrentYear}
|
|
65
|
-
isDateField={isDateField}
|
|
66
|
-
/>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
UserTimeDiffFormat.propTypes = {
|
|
71
|
-
ago: PropTypes.string,
|
|
72
|
-
className: PropTypes.string,
|
|
73
|
-
dataId: PropTypes.string,
|
|
74
|
-
displayType: PropTypes.oneOf(['date', 'time', 'dateTime']),
|
|
75
|
-
format: PropTypes.func,
|
|
76
|
-
isDateField: PropTypes.bool,
|
|
77
|
-
later: PropTypes.string,
|
|
78
|
-
others: PropTypes.func,
|
|
79
|
-
title: PropTypes.string,
|
|
80
|
-
to: PropTypes.string,
|
|
81
|
-
today: PropTypes.oneOfType([
|
|
82
|
-
PropTypes.string,
|
|
83
|
-
PropTypes.object,
|
|
84
|
-
PropTypes.func,
|
|
85
|
-
]),
|
|
86
|
-
tomorrow: PropTypes.oneOfType([
|
|
87
|
-
PropTypes.string,
|
|
88
|
-
PropTypes.object,
|
|
89
|
-
PropTypes.func,
|
|
90
|
-
]),
|
|
91
|
-
yesterday: PropTypes.oneOfType([
|
|
92
|
-
PropTypes.string,
|
|
93
|
-
PropTypes.object,
|
|
94
|
-
PropTypes.func,
|
|
95
|
-
]),
|
|
96
|
-
};
|
|
97
|
-
UserTimeDiffFormat.contextType = I18NContext;
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import DateTimeDiffFormat from './DateTimeDiffFormat';
|
|
4
|
+
import { I18NContext } from '../I18NContext';
|
|
5
|
+
|
|
6
|
+
export default class UserTimeDiffFormat extends Component {
|
|
7
|
+
render() {
|
|
8
|
+
let currentTime = new Date();
|
|
9
|
+
let currentTimeUTCString = currentTime.toISOString();
|
|
10
|
+
let {
|
|
11
|
+
type,
|
|
12
|
+
page,
|
|
13
|
+
isNeedTime,
|
|
14
|
+
to,
|
|
15
|
+
today,
|
|
16
|
+
yesterday,
|
|
17
|
+
tomorrow,
|
|
18
|
+
others,
|
|
19
|
+
ago,
|
|
20
|
+
later,
|
|
21
|
+
format,
|
|
22
|
+
title,
|
|
23
|
+
className,
|
|
24
|
+
displayType,
|
|
25
|
+
dataId,
|
|
26
|
+
isOverdue,
|
|
27
|
+
isDateField
|
|
28
|
+
} = this.props;
|
|
29
|
+
let { tzData, timeFormat, datePattern, isEnabledCurrentYear } =
|
|
30
|
+
this.context || {};
|
|
31
|
+
|
|
32
|
+
if (!format && !others) {
|
|
33
|
+
format = ({ dateTimeFormat, dateFormat, timeFormat }) => {
|
|
34
|
+
displayType === 'dateTime'
|
|
35
|
+
? dateTimeFormat
|
|
36
|
+
: displayType === 'date'
|
|
37
|
+
? dateFormat
|
|
38
|
+
: timeFormat;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<DateTimeDiffFormat
|
|
44
|
+
type={type}
|
|
45
|
+
page={page}
|
|
46
|
+
isNeedTime={isNeedTime}
|
|
47
|
+
from={currentTimeUTCString}
|
|
48
|
+
fromTzData={tzData}
|
|
49
|
+
to={to}
|
|
50
|
+
toTzData={tzData}
|
|
51
|
+
today={today}
|
|
52
|
+
yesterday={yesterday}
|
|
53
|
+
tomorrow={tomorrow}
|
|
54
|
+
others={others}
|
|
55
|
+
ago={ago}
|
|
56
|
+
later={later}
|
|
57
|
+
format={format}
|
|
58
|
+
title={title}
|
|
59
|
+
className={className}
|
|
60
|
+
dataId={dataId}
|
|
61
|
+
isOverdue={isOverdue}
|
|
62
|
+
timeFormat={timeFormat}
|
|
63
|
+
datePattern={datePattern}
|
|
64
|
+
isEnabledCurrentYear={isEnabledCurrentYear}
|
|
65
|
+
isDateField={isDateField}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
UserTimeDiffFormat.propTypes = {
|
|
71
|
+
ago: PropTypes.string,
|
|
72
|
+
className: PropTypes.string,
|
|
73
|
+
dataId: PropTypes.string,
|
|
74
|
+
displayType: PropTypes.oneOf(['date', 'time', 'dateTime']),
|
|
75
|
+
format: PropTypes.func,
|
|
76
|
+
isDateField: PropTypes.bool,
|
|
77
|
+
later: PropTypes.string,
|
|
78
|
+
others: PropTypes.func,
|
|
79
|
+
title: PropTypes.string,
|
|
80
|
+
to: PropTypes.string,
|
|
81
|
+
today: PropTypes.oneOfType([
|
|
82
|
+
PropTypes.string,
|
|
83
|
+
PropTypes.object,
|
|
84
|
+
PropTypes.func,
|
|
85
|
+
]),
|
|
86
|
+
tomorrow: PropTypes.oneOfType([
|
|
87
|
+
PropTypes.string,
|
|
88
|
+
PropTypes.object,
|
|
89
|
+
PropTypes.func,
|
|
90
|
+
]),
|
|
91
|
+
yesterday: PropTypes.oneOfType([
|
|
92
|
+
PropTypes.string,
|
|
93
|
+
PropTypes.object,
|
|
94
|
+
PropTypes.func,
|
|
95
|
+
]),
|
|
96
|
+
};
|
|
97
|
+
UserTimeDiffFormat.contextType = I18NContext;
|