react-intl 3.9.3 → 3.12.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 +34 -1
- package/dist/components/createFormattedComponent.d.ts +2 -1
- package/dist/components/createFormattedComponent.js +7 -2
- package/dist/components/html-message.js +1 -1
- package/dist/components/injectIntl.d.ts +1 -1
- package/dist/components/message.js +13 -4
- package/dist/components/plural.d.ts +1 -1
- package/dist/components/provider.js +14 -9
- package/dist/components/relative.js +3 -10
- package/dist/formatters/dateTime.js +2 -2
- package/dist/formatters/displayName.d.ts +2 -0
- package/dist/formatters/displayName.js +25 -0
- package/dist/formatters/message.d.ts +1 -0
- package/dist/formatters/message.js +19 -18
- package/dist/index.d.ts +7 -3
- package/dist/index.js +5 -2
- package/dist/react-intl.api.md +22 -5
- package/dist/react-intl.d.ts +64 -15
- package/dist/react-intl.js +5821 -5655
- package/dist/react-intl.js.map +1 -1
- package/dist/react-intl.min.js +1 -1
- package/dist/react-intl.min.js.map +1 -1
- package/dist/types.d.ts +6 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +5 -7
- package/lib/components/createFormattedComponent.d.ts +2 -1
- package/lib/components/createFormattedComponent.js +7 -2
- package/lib/components/html-message.js +1 -1
- package/lib/components/injectIntl.d.ts +1 -1
- package/lib/components/message.js +5 -3
- package/lib/components/plural.d.ts +1 -1
- package/lib/components/provider.js +14 -9
- package/lib/components/relative.js +3 -10
- package/lib/formatters/dateTime.js +2 -2
- package/lib/formatters/displayName.d.ts +2 -0
- package/lib/formatters/displayName.js +22 -0
- package/lib/formatters/message.d.ts +1 -0
- package/lib/formatters/message.js +12 -18
- package/lib/index.d.ts +7 -3
- package/lib/index.js +4 -1
- package/lib/react-intl.d.ts +20 -7
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types.d.ts +6 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +4 -6
- package/package.json +38 -39
- package/src/components/createFormattedComponent.tsx +5 -0
- package/src/components/provider.tsx +26 -11
- package/src/components/relative.tsx +6 -15
- package/src/formatters/displayName.ts +35 -0
- package/src/formatters/message.ts +13 -18
- package/src/index.ts +7 -1
- package/src/types.ts +16 -5
- package/src/utils.ts +5 -7
package/dist/react-intl.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { DisplayNames } from '@formatjs/intl-displaynames';
|
|
2
|
+
import { DisplayNamesOptions } from '@formatjs/intl-displaynames';
|
|
3
|
+
import { DisplayNamesOptions as DisplayNamesOptions_2 } from '@formatjs/intl-displaynames/lib';
|
|
1
4
|
import * as React from 'react';
|
|
2
5
|
|
|
3
6
|
declare type ArgumentElement = BaseElement<TYPE.argument>;
|
|
@@ -61,6 +64,8 @@ declare interface FieldData {
|
|
|
61
64
|
|
|
62
65
|
export declare type FormatDateOptions = Exclude<Intl.DateTimeFormatOptions, 'localeMatcher'> & CustomFormatConfig;
|
|
63
66
|
|
|
67
|
+
export declare type FormatDisplayNameOptions = Exclude<DisplayNamesOptions, 'localeMatcher'>;
|
|
68
|
+
|
|
64
69
|
export declare type FormatListOptions = Exclude<IntlListFormatOptions, 'localeMatcher'>;
|
|
65
70
|
|
|
66
71
|
export declare type FormatNumberOptions = Exclude<UnifiedNumberFormatOptions, 'localeMatcher'> & CustomFormatConfig;
|
|
@@ -81,11 +86,15 @@ export declare const FormattedDate: React.FC<Intl.DateTimeFormatOptions & Custom
|
|
|
81
86
|
value: string | number | Date | undefined;
|
|
82
87
|
}>;
|
|
83
88
|
|
|
84
|
-
export declare const FormattedDateParts: React.
|
|
89
|
+
export declare const FormattedDateParts: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig & {
|
|
85
90
|
value: string | number | Date | undefined;
|
|
86
91
|
children(val: Intl.DateTimeFormatPart[]): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null;
|
|
87
92
|
}>;
|
|
88
93
|
|
|
94
|
+
export declare const FormattedDisplayName: React.FC<DisplayNamesOptions_2 & {
|
|
95
|
+
value: string | number | object;
|
|
96
|
+
}>;
|
|
97
|
+
|
|
89
98
|
export declare class FormattedHTMLMessage extends FormattedMessage<Record<string, PrimitiveType>> {
|
|
90
99
|
static displayName: string;
|
|
91
100
|
static defaultProps: {
|
|
@@ -117,7 +126,7 @@ export declare const FormattedNumberParts: React.FC<Formatter['formatNumber'] &
|
|
|
117
126
|
children(val: Intl.NumberFormatPart[]): React.ReactElement | null;
|
|
118
127
|
}>;
|
|
119
128
|
|
|
120
|
-
export declare const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "
|
|
129
|
+
export declare const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "format" | "type" | "value"> & {
|
|
121
130
|
forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
|
|
122
131
|
} & React.RefAttributes<any>> & {
|
|
123
132
|
WrappedComponent: React.ComponentType<Props_2>;
|
|
@@ -141,7 +150,7 @@ export declare const FormattedTime: React.FC<Intl.DateTimeFormatOptions & Custom
|
|
|
141
150
|
value: string | number | Date | undefined;
|
|
142
151
|
}>;
|
|
143
152
|
|
|
144
|
-
export declare const FormattedTimeParts: React.
|
|
153
|
+
export declare const FormattedTimeParts: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig & {
|
|
145
154
|
value: string | number | Date | undefined;
|
|
146
155
|
children(val: Intl.DateTimeFormatPart[]): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null;
|
|
147
156
|
}>;
|
|
@@ -151,6 +160,7 @@ declare type Formatter = {
|
|
|
151
160
|
formatTime: FormatDateOptions;
|
|
152
161
|
formatNumber: FormatNumberOptions;
|
|
153
162
|
formatList: FormatListOptions;
|
|
163
|
+
formatDisplayName: FormatDisplayNameOptions;
|
|
154
164
|
};
|
|
155
165
|
|
|
156
166
|
export declare interface Formatters {
|
|
@@ -160,6 +170,7 @@ export declare interface Formatters {
|
|
|
160
170
|
getRelativeTimeFormat(...args: ConstructorParameters<typeof RelativeTimeFormat>): RelativeTimeFormat;
|
|
161
171
|
getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
|
|
162
172
|
getListFormat(...args: ConstructorParameters<typeof ListFormat>): ListFormat;
|
|
173
|
+
getDisplayNames(...args: ConstructorParameters<typeof DisplayNames>): DisplayNames;
|
|
163
174
|
}
|
|
164
175
|
|
|
165
176
|
declare interface Formatters_2 {
|
|
@@ -185,6 +196,7 @@ export declare interface IntlCache {
|
|
|
185
196
|
relativeTime: Record<string, RelativeTimeFormat>;
|
|
186
197
|
pluralRules: Record<string, Intl.PluralRules>;
|
|
187
198
|
list: Record<string, ListFormat>;
|
|
199
|
+
displayNames: Record<string, DisplayNames>;
|
|
188
200
|
}
|
|
189
201
|
|
|
190
202
|
export declare interface IntlConfig {
|
|
@@ -214,6 +226,7 @@ export declare interface IntlFormatters {
|
|
|
214
226
|
formatHTMLMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): React.ReactNode;
|
|
215
227
|
formatList(values: Array<string>, opts?: FormatListOptions): string;
|
|
216
228
|
formatList(values: Array<string | React.ReactNode>, opts?: FormatListOptions): React.ReactNode;
|
|
229
|
+
formatDisplayName(value: Parameters<DisplayNames['of']>[0], opts?: FormatDisplayNameOptions): string | undefined;
|
|
217
230
|
}
|
|
218
231
|
|
|
219
232
|
declare interface IntlListFormatOptions {
|
|
@@ -441,17 +454,25 @@ declare interface LocationDetails {
|
|
|
441
454
|
}
|
|
442
455
|
|
|
443
456
|
export declare interface MessageDescriptor {
|
|
444
|
-
id?: string;
|
|
457
|
+
id?: string | number;
|
|
445
458
|
description?: string | object;
|
|
446
459
|
defaultMessage?: string;
|
|
447
460
|
}
|
|
448
461
|
|
|
449
|
-
declare type MessageFormatElement = LiteralElement | ArgumentElement | NumberElement | DateElement | TimeElement | SelectElement | PluralElement;
|
|
462
|
+
declare type MessageFormatElement = LiteralElement | ArgumentElement | NumberElement | DateElement | TimeElement | SelectElement | PluralElement | PoundElement;
|
|
450
463
|
|
|
451
464
|
declare type MessageFormatPart = LiteralPart_2 | ArgumentPart;
|
|
452
465
|
|
|
453
466
|
declare type NumberElement = SimpleFormatElement<TYPE.number, NumberSkeleton>;
|
|
454
467
|
|
|
468
|
+
declare interface NumberFormatDigitOptions {
|
|
469
|
+
minimumIntegerDigits?: number;
|
|
470
|
+
minimumFractionDigits?: number;
|
|
471
|
+
maximumFractionDigits?: number;
|
|
472
|
+
minimumSignificantDigits?: number;
|
|
473
|
+
maximumSignificantDigits?: number;
|
|
474
|
+
}
|
|
475
|
+
|
|
455
476
|
declare interface NumberSkeleton {
|
|
456
477
|
type: SKELETON_TYPE.number;
|
|
457
478
|
tokens: NumberSkeletonToken[];
|
|
@@ -515,6 +536,11 @@ declare interface PluralOrSelectOption {
|
|
|
515
536
|
location?: Location;
|
|
516
537
|
}
|
|
517
538
|
|
|
539
|
+
declare interface PoundElement {
|
|
540
|
+
type: TYPE.pound;
|
|
541
|
+
location?: Location;
|
|
542
|
+
}
|
|
543
|
+
|
|
518
544
|
declare type PrimitiveType = string | number | boolean | null | undefined | Date;
|
|
519
545
|
|
|
520
546
|
declare interface Props extends FormatRelativeTimeOptions {
|
|
@@ -542,7 +568,7 @@ declare interface Props_3<V extends Record<string, any> = Record<string, React.R
|
|
|
542
568
|
children?(...nodes: React.ReactNodeArray): React.ReactNode;
|
|
543
569
|
}
|
|
544
570
|
|
|
545
|
-
export declare const RawIntlProvider: React.
|
|
571
|
+
export declare const RawIntlProvider: React.Provider<IntlShape>;
|
|
546
572
|
|
|
547
573
|
declare type RelativeTimeData = {
|
|
548
574
|
[u in LDMLPluralRule]?: string;
|
|
@@ -683,18 +709,41 @@ declare enum TYPE {
|
|
|
683
709
|
/**
|
|
684
710
|
* Variable w/ plural format
|
|
685
711
|
*/
|
|
686
|
-
plural = 6
|
|
712
|
+
plural = 6,
|
|
713
|
+
/**
|
|
714
|
+
* Only possible within plural argument.
|
|
715
|
+
* This is the `#` symbol that will be substituted with the count.
|
|
716
|
+
*/
|
|
717
|
+
pound = 7
|
|
687
718
|
}
|
|
688
719
|
|
|
689
|
-
declare
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
720
|
+
declare type UnifiedNumberFormatOptions = Intl.NumberFormatOptions & NumberFormatDigitOptions & {
|
|
721
|
+
localeMatcher?: UnifiedNumberFormatOptionsLocaleMatcher;
|
|
722
|
+
style?: UnifiedNumberFormatOptionsStyle;
|
|
723
|
+
compactDisplay?: UnifiedNumberFormatOptionsCompactDisplay;
|
|
724
|
+
currencyDisplay?: UnifiedNumberFormatOptionsCurrencyDisplay;
|
|
725
|
+
currencySign?: UnifiedNumberFormatOptionsCurrencySign;
|
|
726
|
+
notation?: UnifiedNumberFormatOptionsNotation;
|
|
727
|
+
signDisplay?: UnifiedNumberFormatOptionsSignDisplay;
|
|
695
728
|
unit?: Unit_2;
|
|
696
|
-
unitDisplay?:
|
|
697
|
-
}
|
|
729
|
+
unitDisplay?: UnifiedNumberFormatOptionsUnitDisplay;
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
declare type UnifiedNumberFormatOptionsCompactDisplay = 'short' | 'long';
|
|
733
|
+
|
|
734
|
+
declare type UnifiedNumberFormatOptionsCurrencyDisplay = 'symbol' | 'code' | 'name' | 'narrowSymbol';
|
|
735
|
+
|
|
736
|
+
declare type UnifiedNumberFormatOptionsCurrencySign = 'standard' | 'accounting';
|
|
737
|
+
|
|
738
|
+
declare type UnifiedNumberFormatOptionsLocaleMatcher = 'lookup' | 'best fit';
|
|
739
|
+
|
|
740
|
+
declare type UnifiedNumberFormatOptionsNotation = 'standard' | 'scientific' | 'engineering' | 'compact';
|
|
741
|
+
|
|
742
|
+
declare type UnifiedNumberFormatOptionsSignDisplay = 'auto' | 'always' | 'never' | 'exceptZero';
|
|
743
|
+
|
|
744
|
+
declare type UnifiedNumberFormatOptionsStyle = 'decimal' | 'percent' | 'currency' | 'unit';
|
|
745
|
+
|
|
746
|
+
declare type UnifiedNumberFormatOptionsUnitDisplay = 'long' | 'short' | 'narrow';
|
|
698
747
|
|
|
699
748
|
declare type Unit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
700
749
|
|