react-intl 3.12.0 → 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 +8 -0
- package/dist/components/plural.d.ts +1 -1
- package/dist/components/provider.js +11 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -2
- package/dist/react-intl.api.md +1 -1
- package/dist/react-intl.d.ts +25 -9
- package/dist/react-intl.js +5820 -5860
- 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/lib/components/plural.d.ts +1 -1
- package/lib/components/provider.js +11 -7
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -1
- package/lib/react-intl.d.ts +3 -3
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +31 -33
- package/src/components/provider.tsx +19 -10
- package/src/index.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
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
|
+
### [3.12.1](https://github.com/formatjs/react-intl/compare/v3.12.0...v3.12.1) (2020-03-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* clarify err messages ([b207d80](https://github.com/formatjs/react-intl/commit/b207d805a9e5609983ac1b2ca8f9708030e12337))
|
|
11
|
+
* inline defineMessages macro, fix [#1592](https://github.com/formatjs/react-intl/issues/1592) ([5ae8349](https://github.com/formatjs/react-intl/commit/5ae8349dc2ee08b54a54a2a521b8a9c052960d04))
|
|
12
|
+
|
|
5
13
|
## [3.12.0](https://github.com/formatjs/react-intl/compare/v3.11.0...v3.12.0) (2020-02-04)
|
|
6
14
|
|
|
7
15
|
|
|
@@ -11,7 +11,7 @@ interface Props extends FormatPluralOptions {
|
|
|
11
11
|
many?: React.ReactNode;
|
|
12
12
|
children?(value: React.ReactNode): React.ReactElement | null;
|
|
13
13
|
}
|
|
14
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Props, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "
|
|
14
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Props, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "format" | "type" | "value"> & {
|
|
15
15
|
forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
|
|
16
16
|
} & React.RefAttributes<any>> & {
|
|
17
17
|
WrappedComponent: React.ComponentType<Props>;
|
|
@@ -32,7 +32,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
32
|
var React = require("react");
|
|
33
33
|
var injectIntl_1 = require("./injectIntl");
|
|
34
34
|
var utils_1 = require("../utils");
|
|
35
|
-
var intl_locales_supported_1 = require("intl-locales-supported");
|
|
36
35
|
var number_1 = require("../formatters/number");
|
|
37
36
|
var relativeTime_1 = require("../formatters/relativeTime");
|
|
38
37
|
var dateTime_1 = require("../formatters/dateTime");
|
|
@@ -62,12 +61,10 @@ function processIntlConfig(config) {
|
|
|
62
61
|
function createIntl(config, cache) {
|
|
63
62
|
var formatters = utils_1.createFormatters(cache);
|
|
64
63
|
var resolvedConfig = __assign(__assign({}, utils_1.DEFAULT_INTL_CONFIG), config);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
onError(utils_1.createError("Missing locale data for locale: \"" + locale + "\". " +
|
|
70
|
-
("Using default locale: \"" + defaultLocale + "\" as fallback.")));
|
|
64
|
+
var locale = resolvedConfig.locale, defaultLocale = resolvedConfig.defaultLocale, onError = resolvedConfig.onError;
|
|
65
|
+
if (!locale) {
|
|
66
|
+
if (onError) {
|
|
67
|
+
onError(utils_1.createError("\"locale\" was not configured, using \"" + defaultLocale + "\" as fallback. See https://github.com/formatjs/react-intl/blob/master/docs/API.md#intlshape for more details"));
|
|
71
68
|
}
|
|
72
69
|
// Since there's no registered locale data for `locale`, this will
|
|
73
70
|
// fallback to the `defaultLocale` to make sure things can render.
|
|
@@ -76,6 +73,13 @@ function createIntl(config, cache) {
|
|
|
76
73
|
// each <FormattedMessage> contains a `defaultMessage` prop.
|
|
77
74
|
resolvedConfig.locale = resolvedConfig.defaultLocale || 'en';
|
|
78
75
|
}
|
|
76
|
+
else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) {
|
|
77
|
+
onError(utils_1.createError("Missing locale data for locale: \"" + locale + "\" in Intl.NumberFormat. Using default locale: \"" + defaultLocale + "\" as fallback. See https://github.com/formatjs/react-intl/blob/master/docs/Getting-Started.md#runtime-requirements for more details"));
|
|
78
|
+
}
|
|
79
|
+
else if (!Intl.DateTimeFormat.supportedLocalesOf(locale).length &&
|
|
80
|
+
onError) {
|
|
81
|
+
onError(utils_1.createError("Missing locale data for locale: \"" + locale + "\" in Intl.DateTimeFormat. Using default locale: \"" + defaultLocale + "\" as fallback. See https://github.com/formatjs/react-intl/blob/master/docs/Getting-Started.md#runtime-requirements for more details"));
|
|
82
|
+
}
|
|
79
83
|
return __assign(__assign({}, resolvedConfig), { formatters: formatters, formatNumber: number_1.formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: number_1.formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: relativeTime_1.formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: dateTime_1.formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: dateTime_1.formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: dateTime_1.formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: dateTime_1.formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: plural_1.formatPlural.bind(null, resolvedConfig, formatters.getPluralRules), formatMessage: message_1.formatMessage.bind(null, resolvedConfig, formatters), formatHTMLMessage: message_1.formatHTMLMessage.bind(null, resolvedConfig, formatters), formatList: list_1.formatList.bind(null, resolvedConfig, formatters.getListFormat), formatDisplayName: displayName_1.formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames) });
|
|
80
84
|
}
|
|
81
85
|
exports.createIntl = createIntl;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export * from './types';
|
|
3
|
-
export
|
|
3
|
+
export declare function defineMessages<T, U extends Record<string, T>>(msgs: U): U;
|
|
4
4
|
import { CustomFormatConfig } from './types';
|
|
5
5
|
import { UnifiedNumberFormatOptions } from '@formatjs/intl-unified-numberformat';
|
|
6
6
|
import { IntlListFormatOptions } from '@formatjs/intl-listformat';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
function defineMessages(msgs) {
|
|
4
|
+
return msgs;
|
|
5
|
+
}
|
|
6
|
+
exports.defineMessages = defineMessages;
|
|
5
7
|
var createFormattedComponent_1 = require("./components/createFormattedComponent");
|
|
6
8
|
var injectIntl_1 = require("./components/injectIntl");
|
|
7
9
|
exports.injectIntl = injectIntl_1.default;
|
package/dist/react-intl.api.md
CHANGED
|
@@ -127,7 +127,7 @@ export const FormattedNumberParts: React.FC<Formatter['formatNumber'] & {
|
|
|
127
127
|
// Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts
|
|
128
128
|
//
|
|
129
129
|
// @public (undocumented)
|
|
130
|
-
export const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "
|
|
130
|
+
export const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "format" | "type" | "value"> & {
|
|
131
131
|
forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
|
|
132
132
|
} & React.RefAttributes<any>> & {
|
|
133
133
|
WrappedComponent: React.ComponentType<Props_2>;
|
package/dist/react-intl.d.ts
CHANGED
|
@@ -126,7 +126,7 @@ export declare const FormattedNumberParts: React.FC<Formatter['formatNumber'] &
|
|
|
126
126
|
children(val: Intl.NumberFormatPart[]): React.ReactElement | null;
|
|
127
127
|
}>;
|
|
128
128
|
|
|
129
|
-
export declare const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "
|
|
129
|
+
export declare const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "format" | "type" | "value"> & {
|
|
130
130
|
forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
|
|
131
131
|
} & React.RefAttributes<any>> & {
|
|
132
132
|
WrappedComponent: React.ComponentType<Props_2>;
|
|
@@ -718,17 +718,33 @@ declare enum TYPE {
|
|
|
718
718
|
}
|
|
719
719
|
|
|
720
720
|
declare type UnifiedNumberFormatOptions = Intl.NumberFormatOptions & NumberFormatDigitOptions & {
|
|
721
|
-
localeMatcher?:
|
|
722
|
-
style?:
|
|
723
|
-
compactDisplay?:
|
|
724
|
-
currencyDisplay?:
|
|
725
|
-
currencySign?:
|
|
726
|
-
notation?:
|
|
727
|
-
signDisplay?:
|
|
721
|
+
localeMatcher?: UnifiedNumberFormatOptionsLocaleMatcher;
|
|
722
|
+
style?: UnifiedNumberFormatOptionsStyle;
|
|
723
|
+
compactDisplay?: UnifiedNumberFormatOptionsCompactDisplay;
|
|
724
|
+
currencyDisplay?: UnifiedNumberFormatOptionsCurrencyDisplay;
|
|
725
|
+
currencySign?: UnifiedNumberFormatOptionsCurrencySign;
|
|
726
|
+
notation?: UnifiedNumberFormatOptionsNotation;
|
|
727
|
+
signDisplay?: UnifiedNumberFormatOptionsSignDisplay;
|
|
728
728
|
unit?: Unit_2;
|
|
729
|
-
unitDisplay?:
|
|
729
|
+
unitDisplay?: UnifiedNumberFormatOptionsUnitDisplay;
|
|
730
730
|
};
|
|
731
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';
|
|
747
|
+
|
|
732
748
|
declare type Unit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
733
749
|
|
|
734
750
|
declare type Unit_2 = 'degree' | 'acre' | 'hectare' | 'percent' | 'bit' | 'byte' | 'gigabit' | 'gigabyte' | 'kilobit' | 'kilobyte' | 'megabit' | 'megabyte' | 'petabyte' | 'terabit' | 'terabyte' | 'day' | 'hour' | 'millisecond' | 'minute' | 'month' | 'second' | 'week' | 'year' | 'centimeter' | 'foot' | 'inch' | 'kilometer' | 'meter' | 'mile-scandinavian' | 'mile' | 'millimeter' | 'yard' | 'gram' | 'kilogram' | 'ounce' | 'pound' | 'stone' | 'celsius' | 'fahrenheit' | 'fluid-ounce' | 'gallon' | 'liter' | 'milliliter';
|