react-intl 4.4.0 → 4.5.0
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/createFormattedComponent.js +3 -1
- package/dist/error.d.ts +1 -1
- package/dist/formatters/relativeTime.js +1 -4
- package/dist/react-intl.d.ts +2 -1
- package/dist/react-intl.js +31 -17
- 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/createFormattedComponent.js +3 -1
- package/lib/error.d.ts +1 -1
- package/lib/formatters/relativeTime.js +1 -4
- package/package.json +14 -21
- package/src/components/createFormattedComponent.tsx +50 -48
- package/src/components/injectIntl.tsx +32 -32
- package/src/components/message.tsx +29 -29
- package/src/components/plural.tsx +22 -22
- package/src/components/provider.tsx +36 -36
- package/src/components/relative.tsx +70 -70
- package/src/components/useIntl.ts +7 -7
- package/src/error.ts +25 -16
- package/src/formatters/dateTime.ts +25 -33
- package/src/formatters/displayName.ts +11 -11
- package/src/formatters/list.ts +29 -29
- package/src/formatters/message.ts +36 -36
- package/src/formatters/number.ts +15 -15
- package/src/formatters/plural.ts +10 -10
- package/src/formatters/relativeTime.ts +18 -19
- package/src/index.ts +47 -37
- package/src/tsconfig.cjs.json +8 -8
- package/src/tsconfig.json +7 -7
- package/src/types.ts +57 -57
- package/src/utils.ts +29 -24
- package/src/vendor.d.ts +1 -1
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.5.0](https://github.com/formatjs/react-intl/compare/v4.4.0...v4.5.0) (2020-04-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* upgrade intl-messageformat & parser ([cbbd6cf](https://github.com/formatjs/react-intl/commit/cbbd6cf93ee6294bdfbc28af3e33227df0e621e4))
|
|
11
|
+
|
|
5
12
|
## [4.4.0](https://github.com/formatjs/react-intl/compare/v4.3.1...v4.4.0) (2020-04-14)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -54,7 +54,9 @@ exports.createFormattedDateTimePartsComponent = createFormattedDateTimePartsComp
|
|
|
54
54
|
function createFormattedComponent(name) {
|
|
55
55
|
var Component = function (props) { return (React.createElement(injectIntl_1.Context.Consumer, null, function (intl) {
|
|
56
56
|
utils_1.invariantIntlContext(intl);
|
|
57
|
-
var value = props.value, children = props.children, formatProps = __rest(props
|
|
57
|
+
var value = props.value, children = props.children, formatProps = __rest(props
|
|
58
|
+
// TODO: fix TS type definition for localeMatcher upstream
|
|
59
|
+
, ["value", "children"]);
|
|
58
60
|
// TODO: fix TS type definition for localeMatcher upstream
|
|
59
61
|
var formattedValue = intl[name](value, formatProps);
|
|
60
62
|
if (typeof children === 'function') {
|
package/dist/error.d.ts
CHANGED
|
@@ -3,10 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var utils_1 = require("../utils");
|
|
4
4
|
var intl_messageformat_1 = require("intl-messageformat");
|
|
5
5
|
var error_1 = require("../error");
|
|
6
|
-
var RELATIVE_TIME_FORMAT_OPTIONS = [
|
|
7
|
-
'numeric',
|
|
8
|
-
'style',
|
|
9
|
-
];
|
|
6
|
+
var RELATIVE_TIME_FORMAT_OPTIONS = ['numeric', 'style'];
|
|
10
7
|
function getFormatter(_a, getRelativeTimeFormat, options) {
|
|
11
8
|
var locale = _a.locale, formats = _a.formats, onError = _a.onError;
|
|
12
9
|
if (options === void 0) { options = {}; }
|
package/dist/react-intl.d.ts
CHANGED
|
@@ -345,7 +345,8 @@ declare class IntlMessageFormat {
|
|
|
345
345
|
locale: string;
|
|
346
346
|
};
|
|
347
347
|
getAst: () => MessageFormatElement[];
|
|
348
|
-
static
|
|
348
|
+
private static memoizedDefaultLocale;
|
|
349
|
+
static get defaultLocale(): string;
|
|
349
350
|
static __parse: typeof parse | undefined;
|
|
350
351
|
static formats: {
|
|
351
352
|
number: {
|
package/dist/react-intl.js
CHANGED
|
@@ -3998,7 +3998,7 @@
|
|
|
3998
3998
|
return unit.replace(/^(.*?)-/, '');
|
|
3999
3999
|
}
|
|
4000
4000
|
|
|
4001
|
-
var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(
|
|
4001
|
+
var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
|
|
4002
4002
|
var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
|
|
4003
4003
|
|
|
4004
4004
|
function parseSignificantPrecision(str) {
|
|
@@ -4102,6 +4102,7 @@
|
|
|
4102
4102
|
continue;
|
|
4103
4103
|
|
|
4104
4104
|
case 'precision-integer':
|
|
4105
|
+
case '.':
|
|
4105
4106
|
result.maximumFractionDigits = 0;
|
|
4106
4107
|
continue;
|
|
4107
4108
|
|
|
@@ -4161,6 +4162,7 @@
|
|
|
4161
4162
|
continue;
|
|
4162
4163
|
} // Precision
|
|
4163
4164
|
// https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#fraction-precision
|
|
4165
|
+
// precision-integer case
|
|
4164
4166
|
|
|
4165
4167
|
|
|
4166
4168
|
if (FRACTION_PRECISION_REGEX.test(token.stem)) {
|
|
@@ -4168,21 +4170,21 @@
|
|
|
4168
4170
|
throw new RangeError('Fraction-precision stems only accept a single optional option');
|
|
4169
4171
|
}
|
|
4170
4172
|
|
|
4171
|
-
token.stem.replace(FRACTION_PRECISION_REGEX, function (match, g1, g2) {
|
|
4172
|
-
//
|
|
4173
|
-
if (
|
|
4174
|
-
result.
|
|
4175
|
-
} //
|
|
4176
|
-
else if (
|
|
4177
|
-
result.
|
|
4178
|
-
} //
|
|
4179
|
-
else if (
|
|
4173
|
+
token.stem.replace(FRACTION_PRECISION_REGEX, function (match, g1, g2, g3, g4, g5) {
|
|
4174
|
+
// .000* case (before ICU67 it was .000+)
|
|
4175
|
+
if (g2 === '*') {
|
|
4176
|
+
result.minimumFractionDigits = g1.length;
|
|
4177
|
+
} // .### case
|
|
4178
|
+
else if (g3 && g3[0] === '#') {
|
|
4179
|
+
result.maximumFractionDigits = g3.length;
|
|
4180
|
+
} // .00## case
|
|
4181
|
+
else if (g4 && g5) {
|
|
4182
|
+
result.minimumFractionDigits = g4.length;
|
|
4183
|
+
result.maximumFractionDigits = g4.length + g5.length;
|
|
4184
|
+
} else {
|
|
4185
|
+
result.minimumFractionDigits = g1.length;
|
|
4180
4186
|
result.maximumFractionDigits = g1.length;
|
|
4181
|
-
}
|
|
4182
|
-
else {
|
|
4183
|
-
result.minimumFractionDigits = g1.length;
|
|
4184
|
-
result.maximumFractionDigits = g1.length + (typeof g2 === 'string' ? g2.length : 0);
|
|
4185
|
-
}
|
|
4187
|
+
}
|
|
4186
4188
|
|
|
4187
4189
|
return '';
|
|
4188
4190
|
});
|
|
@@ -4729,7 +4731,18 @@
|
|
|
4729
4731
|
this.formatters = opts && opts.formatters || createDefaultFormatters(this.formatterCache);
|
|
4730
4732
|
}
|
|
4731
4733
|
|
|
4732
|
-
IntlMessageFormat
|
|
4734
|
+
Object.defineProperty(IntlMessageFormat, "defaultLocale", {
|
|
4735
|
+
get: function get() {
|
|
4736
|
+
if (!IntlMessageFormat.memoizedDefaultLocale) {
|
|
4737
|
+
IntlMessageFormat.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
|
|
4738
|
+
}
|
|
4739
|
+
|
|
4740
|
+
return IntlMessageFormat.memoizedDefaultLocale;
|
|
4741
|
+
},
|
|
4742
|
+
enumerable: true,
|
|
4743
|
+
configurable: true
|
|
4744
|
+
});
|
|
4745
|
+
IntlMessageFormat.memoizedDefaultLocale = null;
|
|
4733
4746
|
IntlMessageFormat.__parse = parse; // Default format options used as the prototype of the `formats` provided to the
|
|
4734
4747
|
// constructor. These are used when constructing the internal Intl.NumberFormat
|
|
4735
4748
|
// and Intl.DateTimeFormat instances.
|
|
@@ -5437,7 +5450,8 @@
|
|
|
5437
5450
|
|
|
5438
5451
|
var value = props.value,
|
|
5439
5452
|
children = props.children,
|
|
5440
|
-
formatProps = __rest(props
|
|
5453
|
+
formatProps = __rest(props // TODO: fix TS type definition for localeMatcher upstream
|
|
5454
|
+
, ["value", "children"]); // TODO: fix TS type definition for localeMatcher upstream
|
|
5441
5455
|
|
|
5442
5456
|
|
|
5443
5457
|
var formattedValue = intl[name](value, formatProps);
|