react-intl 4.3.0 → 4.3.1
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/CHANGELOG.md +7 -0
- package/dist/components/message.d.ts +1 -1
- package/dist/react-intl.api.md +3 -3
- package/dist/react-intl.d.ts +6 -6
- package/dist/types.d.ts +2 -2
- package/lib/components/message.d.ts +1 -1
- package/lib/react-intl.d.ts +3 -3
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types.d.ts +2 -2
- package/package.json +6 -6
- package/src/components/message.tsx +4 -3
- package/src/formatters/message.ts +3 -1
- package/src/types.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [4.3.1](https://github.com/formatjs/react-intl/compare/v4.3.0...v4.3.1) (2020-03-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* tweak FormatXMLElementFn ([a914dc0](https://github.com/formatjs/react-intl/commit/a914dc059cc8d0c04baec6a63513cb686ff6dad3))
|
|
11
|
+
|
|
5
12
|
## [4.3.0](https://github.com/formatjs/react-intl/compare/v4.2.2...v4.3.0) (2020-03-26)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -6,7 +6,7 @@ export interface Props<V extends Record<string, any> = Record<string, React.Reac
|
|
|
6
6
|
tagName?: React.ElementType<any>;
|
|
7
7
|
children?(...nodes: React.ReactNodeArray): React.ReactNode;
|
|
8
8
|
}
|
|
9
|
-
declare class FormattedMessage<
|
|
9
|
+
declare class FormattedMessage<V extends Record<string, any> = Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<React.ReactNode, React.ReactNode>>> extends React.Component<Props<V>> {
|
|
10
10
|
static displayName: string;
|
|
11
11
|
static defaultProps: {
|
|
12
12
|
values: {};
|
package/dist/react-intl.api.md
CHANGED
|
@@ -83,7 +83,7 @@ export const FormattedList: React.FC<IntlListFormatOptions & {
|
|
|
83
83
|
// Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts
|
|
84
84
|
//
|
|
85
85
|
// @public (undocumented)
|
|
86
|
-
export class FormattedMessage<
|
|
86
|
+
export class FormattedMessage<V extends Record<string, any> = Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<React.ReactNode, React.ReactNode>>> extends React.Component<Props_3<V>> {
|
|
87
87
|
// (undocumented)
|
|
88
88
|
static defaultProps: {
|
|
89
89
|
values: {};
|
|
@@ -243,7 +243,7 @@ export interface IntlConfig {
|
|
|
243
243
|
export const IntlContext: React.Context<IntlShape>;
|
|
244
244
|
|
|
245
245
|
// @public (undocumented)
|
|
246
|
-
export interface IntlFormatters<T = React.ReactNode> {
|
|
246
|
+
export interface IntlFormatters<T = React.ReactNode, R = T> {
|
|
247
247
|
// (undocumented)
|
|
248
248
|
formatDate(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
|
|
249
249
|
// (undocumented)
|
|
@@ -257,7 +257,7 @@ export interface IntlFormatters<T = React.ReactNode> {
|
|
|
257
257
|
// (undocumented)
|
|
258
258
|
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string;
|
|
259
259
|
// (undocumented)
|
|
260
|
-
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<T>>): string | React.ReactNodeArray;
|
|
260
|
+
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<T, R>>): string | React.ReactNodeArray;
|
|
261
261
|
// (undocumented)
|
|
262
262
|
formatNumber(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): string;
|
|
263
263
|
// (undocumented)
|
package/dist/react-intl.d.ts
CHANGED
|
@@ -182,7 +182,7 @@ export declare const FormattedList: React.FC<IntlListFormatOptions & {
|
|
|
182
182
|
value: React.ReactNode[];
|
|
183
183
|
}>;
|
|
184
184
|
|
|
185
|
-
export declare class FormattedMessage<
|
|
185
|
+
export declare class FormattedMessage<V extends Record<string, any> = Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<React.ReactNode, React.ReactNode>>> extends React.Component<Props_3<V>> {
|
|
186
186
|
static displayName: string;
|
|
187
187
|
static defaultProps: {
|
|
188
188
|
values: {};
|
|
@@ -253,7 +253,7 @@ declare interface Formatters_2 {
|
|
|
253
253
|
getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
declare type FormatXMLElementFn<T
|
|
256
|
+
declare type FormatXMLElementFn<T, R = string | Array<string | T>> = (...args: Array<string | T>) => R;
|
|
257
257
|
|
|
258
258
|
export declare function injectIntl<IntlPropName extends string, P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>>(WrappedComponent: React.ComponentType<P>, options?: Opts<IntlPropName, false>): React.FC<WithIntlProps<P>> & {
|
|
259
259
|
WrappedComponent: React.ComponentType<P>;
|
|
@@ -287,7 +287,7 @@ export declare interface IntlConfig {
|
|
|
287
287
|
|
|
288
288
|
export declare const IntlContext: React.Context<IntlShape>;
|
|
289
289
|
|
|
290
|
-
export declare interface IntlFormatters<T = React.ReactNode> {
|
|
290
|
+
export declare interface IntlFormatters<T = React.ReactNode, R = T> {
|
|
291
291
|
formatDate(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
|
|
292
292
|
formatTime(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
|
|
293
293
|
formatDateToParts(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
|
|
@@ -297,7 +297,7 @@ export declare interface IntlFormatters<T = React.ReactNode> {
|
|
|
297
297
|
formatNumberToParts(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
|
|
298
298
|
formatPlural(value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>;
|
|
299
299
|
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string;
|
|
300
|
-
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<T>>): string | React.ReactNodeArray;
|
|
300
|
+
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<T, R>>): string | React.ReactNodeArray;
|
|
301
301
|
formatList(values: Array<string>, opts?: FormatListOptions): string;
|
|
302
302
|
formatList(values: Array<string | React.ReactNode>, opts?: FormatListOptions): React.ReactNode;
|
|
303
303
|
formatDisplayName(value: Parameters<DisplayNames['of']>[0], opts?: FormatDisplayNameOptions): string | undefined;
|
|
@@ -337,8 +337,8 @@ declare class IntlMessageFormat {
|
|
|
337
337
|
private readonly message;
|
|
338
338
|
private readonly formatterCache;
|
|
339
339
|
constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial<Formats>, opts?: Options);
|
|
340
|
-
format: <T = void>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T> | null | undefined> | undefined) => string | T | (string | T)[];
|
|
341
|
-
formatToParts: <T>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T> | null | undefined> | undefined) => MessageFormatPart<T>[];
|
|
340
|
+
format: <T = void>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T, string | (string | T)[]> | null | undefined> | undefined) => string | T | (string | T)[];
|
|
341
|
+
formatToParts: <T>(values?: Record<string, string | number | boolean | Date | T | FormatXMLElementFn<T, string | (string | T)[]> | null | undefined> | undefined) => MessageFormatPart<T>[];
|
|
342
342
|
resolvedOptions: () => {
|
|
343
343
|
locale: string;
|
|
344
344
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare type FormatRelativeTimeOptions = Exclude<IntlRelativeTimeFormatOp
|
|
|
29
29
|
export declare type FormatPluralOptions = Exclude<Intl.PluralRulesOptions, 'localeMatcher'> & CustomFormatConfig;
|
|
30
30
|
export declare type FormatListOptions = Exclude<IntlListFormatOptions, 'localeMatcher'>;
|
|
31
31
|
export declare type FormatDisplayNameOptions = Exclude<DisplayNamesOptions, 'localeMatcher'>;
|
|
32
|
-
export interface IntlFormatters<T = React.ReactNode> {
|
|
32
|
+
export interface IntlFormatters<T = React.ReactNode, R = T> {
|
|
33
33
|
formatDate(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
|
|
34
34
|
formatTime(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
|
|
35
35
|
formatDateToParts(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
|
|
@@ -39,7 +39,7 @@ export interface IntlFormatters<T = React.ReactNode> {
|
|
|
39
39
|
formatNumberToParts(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
|
|
40
40
|
formatPlural(value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>;
|
|
41
41
|
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string;
|
|
42
|
-
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<T>>): string | React.ReactNodeArray;
|
|
42
|
+
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<T, R>>): string | React.ReactNodeArray;
|
|
43
43
|
formatList(values: Array<string>, opts?: FormatListOptions): string;
|
|
44
44
|
formatList(values: Array<string | React.ReactNode>, opts?: FormatListOptions): React.ReactNode;
|
|
45
45
|
formatDisplayName(value: Parameters<DisplayNames['of']>[0], opts?: FormatDisplayNameOptions): string | undefined;
|
|
@@ -6,7 +6,7 @@ export interface Props<V extends Record<string, any> = Record<string, React.Reac
|
|
|
6
6
|
tagName?: React.ElementType<any>;
|
|
7
7
|
children?(...nodes: React.ReactNodeArray): React.ReactNode;
|
|
8
8
|
}
|
|
9
|
-
declare class FormattedMessage<
|
|
9
|
+
declare class FormattedMessage<V extends Record<string, any> = Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<React.ReactNode, React.ReactNode>>> extends React.Component<Props<V>> {
|
|
10
10
|
static displayName: string;
|
|
11
11
|
static defaultProps: {
|
|
12
12
|
values: {};
|
package/lib/react-intl.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare const FormattedList: React.FC<IntlListFormatOptions & {
|
|
|
65
65
|
value: React.ReactNode[];
|
|
66
66
|
}>;
|
|
67
67
|
|
|
68
|
-
export declare class FormattedMessage<
|
|
68
|
+
export declare class FormattedMessage<V extends Record<string, any> = Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<React.ReactNode, React.ReactNode>>> extends React.Component<Props_3<V>> {
|
|
69
69
|
static displayName: string;
|
|
70
70
|
static defaultProps: {
|
|
71
71
|
values: {};
|
|
@@ -162,7 +162,7 @@ export declare interface IntlConfig {
|
|
|
162
162
|
|
|
163
163
|
export declare const IntlContext: React.Context<IntlShape>;
|
|
164
164
|
|
|
165
|
-
export declare interface IntlFormatters<T = React.ReactNode> {
|
|
165
|
+
export declare interface IntlFormatters<T = React.ReactNode, R = T> {
|
|
166
166
|
formatDate(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
|
|
167
167
|
formatTime(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
|
|
168
168
|
formatDateToParts(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
|
|
@@ -172,7 +172,7 @@ export declare interface IntlFormatters<T = React.ReactNode> {
|
|
|
172
172
|
formatNumberToParts(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
|
|
173
173
|
formatPlural(value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>;
|
|
174
174
|
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string;
|
|
175
|
-
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<T>>): string | React.ReactNodeArray;
|
|
175
|
+
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<T, R>>): string | React.ReactNodeArray;
|
|
176
176
|
formatList(values: Array<string>, opts?: FormatListOptions): string;
|
|
177
177
|
formatList(values: Array<string | React.ReactNode>, opts?: FormatListOptions): React.ReactNode;
|
|
178
178
|
formatDisplayName(value: Parameters<DisplayNames['of']>[0], opts?: FormatDisplayNameOptions): string | undefined;
|
package/lib/tsdoc-metadata.json
CHANGED
package/lib/types.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare type FormatRelativeTimeOptions = Exclude<IntlRelativeTimeFormatOp
|
|
|
29
29
|
export declare type FormatPluralOptions = Exclude<Intl.PluralRulesOptions, 'localeMatcher'> & CustomFormatConfig;
|
|
30
30
|
export declare type FormatListOptions = Exclude<IntlListFormatOptions, 'localeMatcher'>;
|
|
31
31
|
export declare type FormatDisplayNameOptions = Exclude<DisplayNamesOptions, 'localeMatcher'>;
|
|
32
|
-
export interface IntlFormatters<T = React.ReactNode> {
|
|
32
|
+
export interface IntlFormatters<T = React.ReactNode, R = T> {
|
|
33
33
|
formatDate(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
|
|
34
34
|
formatTime(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
|
|
35
35
|
formatDateToParts(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
|
|
@@ -39,7 +39,7 @@ export interface IntlFormatters<T = React.ReactNode> {
|
|
|
39
39
|
formatNumberToParts(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
|
|
40
40
|
formatPlural(value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>;
|
|
41
41
|
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string;
|
|
42
|
-
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<T>>): string | React.ReactNodeArray;
|
|
42
|
+
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn<T, R>>): string | React.ReactNodeArray;
|
|
43
43
|
formatList(values: Array<string>, opts?: FormatListOptions): string;
|
|
44
44
|
formatList(values: Array<string | React.ReactNode>, opts?: FormatListOptions): React.ReactNode;
|
|
45
45
|
formatDisplayName(value: Parameters<DisplayNames['of']>[0], opts?: FormatDisplayNameOptions): string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intl",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"@types/invariant": "^2.2.31",
|
|
141
141
|
"hoist-non-react-statics": "^3.3.2",
|
|
142
142
|
"intl-format-cache": "^4.2.22",
|
|
143
|
-
"intl-messageformat": "^8.3.
|
|
143
|
+
"intl-messageformat": "^8.3.2",
|
|
144
144
|
"intl-messageformat-parser": "^4.1.1",
|
|
145
145
|
"shallow-equal": "^1.2.1"
|
|
146
146
|
},
|
|
@@ -155,8 +155,8 @@
|
|
|
155
155
|
"@babel/preset-env": "^7.9.0",
|
|
156
156
|
"@babel/preset-react": "^7.9.4",
|
|
157
157
|
"@formatjs/intl-pluralrules": "^1.5.3",
|
|
158
|
-
"@microsoft/api-documenter": "^7.7.
|
|
159
|
-
"@microsoft/api-extractor": "^7.7.
|
|
158
|
+
"@microsoft/api-documenter": "^7.7.15",
|
|
159
|
+
"@microsoft/api-extractor": "^7.7.11",
|
|
160
160
|
"@types/benchmark": "^1.0.31",
|
|
161
161
|
"@types/enzyme": "^3.10.5",
|
|
162
162
|
"@types/jest": "^25.1.4",
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
"@types/react-dom": "^16.9.5",
|
|
166
166
|
"@typescript-eslint/eslint-plugin": "^2.25.0",
|
|
167
167
|
"@typescript-eslint/parser": "^2.25.0",
|
|
168
|
-
"babel-jest": "^25.2.
|
|
168
|
+
"babel-jest": "^25.2.3",
|
|
169
169
|
"benchmark": "^2.1.4",
|
|
170
170
|
"core-js": "^3.6.4",
|
|
171
171
|
"cross-env": "^7.0.2",
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
"fs-extra": "^9.0.0",
|
|
178
178
|
"full-icu": "^1.3.1",
|
|
179
179
|
"glob": "^7.1.6",
|
|
180
|
-
"jest": "^25.2.
|
|
180
|
+
"jest": "^25.2.3",
|
|
181
181
|
"markdown-toc": "^1.2.0",
|
|
182
182
|
"mkdirp": "^1.0.3",
|
|
183
183
|
"parcel": "^1.12.4",
|
|
@@ -22,7 +22,7 @@ function defaultFormatMessage<T = React.ReactNode>(
|
|
|
22
22
|
descriptor: MessageDescriptor,
|
|
23
23
|
values?: Record<
|
|
24
24
|
string,
|
|
25
|
-
PrimitiveType | React.ReactElement | FormatXMLElementFn<T>
|
|
25
|
+
PrimitiveType | React.ReactElement | FormatXMLElementFn<T, T>
|
|
26
26
|
>
|
|
27
27
|
): string {
|
|
28
28
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -51,10 +51,11 @@ export interface Props<
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
class FormattedMessage<
|
|
54
|
-
T = React.ReactNode,
|
|
55
54
|
V extends Record<string, any> = Record<
|
|
56
55
|
string,
|
|
57
|
-
|
|
56
|
+
| PrimitiveType
|
|
57
|
+
| React.ReactElement
|
|
58
|
+
| FormatXMLElementFn<React.ReactNode, React.ReactNode>
|
|
58
59
|
>
|
|
59
60
|
> extends React.Component<Props<V>> {
|
|
60
61
|
static displayName = 'FormattedMessage';
|
|
@@ -125,7 +125,9 @@ export function formatMessage(
|
|
|
125
125
|
values:
|
|
126
126
|
| Record<
|
|
127
127
|
string,
|
|
128
|
-
|
|
128
|
+
| React.ReactNode
|
|
129
|
+
| Date
|
|
130
|
+
| FormatXMLElementFn<React.ReactNode, React.ReactNode>
|
|
129
131
|
>
|
|
130
132
|
| undefined = {}
|
|
131
133
|
): React.ReactNode {
|
package/src/types.ts
CHANGED
|
@@ -67,7 +67,7 @@ export type FormatDisplayNameOptions = Exclude<
|
|
|
67
67
|
'localeMatcher'
|
|
68
68
|
>;
|
|
69
69
|
|
|
70
|
-
export interface IntlFormatters<T = React.ReactNode> {
|
|
70
|
+
export interface IntlFormatters<T = React.ReactNode, R = T> {
|
|
71
71
|
formatDate(
|
|
72
72
|
value: Parameters<Intl.DateTimeFormat['format']>[0] | string,
|
|
73
73
|
opts?: FormatDateOptions
|
|
@@ -109,7 +109,7 @@ export interface IntlFormatters<T = React.ReactNode> {
|
|
|
109
109
|
descriptor: MessageDescriptor,
|
|
110
110
|
values?: Record<
|
|
111
111
|
string,
|
|
112
|
-
PrimitiveType | React.ReactElement | FormatXMLElementFn<T>
|
|
112
|
+
PrimitiveType | React.ReactElement | FormatXMLElementFn<T, R>
|
|
113
113
|
>
|
|
114
114
|
): string | React.ReactNodeArray;
|
|
115
115
|
formatList(values: Array<string>, opts?: FormatListOptions): string;
|