react-intl 5.20.13 → 5.21.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/index.js +7 -7
- package/lib/src/components/provider.d.ts +1 -1
- package/lib/src/components/provider.d.ts.map +1 -1
- package/lib/src/components/provider.js +2 -1
- package/lib/src/utils.d.ts +1 -1
- package/lib/src/utils.d.ts.map +1 -1
- package/package.json +5 -5
- package/react-intl.iife.js +53 -31
- package/src/components/createFormattedComponent.js +10 -10
- package/src/components/dateTimeRange.js +4 -4
- package/src/components/injectIntl.js +6 -6
- package/src/components/message.js +7 -7
- package/src/components/plural.js +3 -3
- package/src/components/provider.d.ts +1 -1
- package/src/components/provider.d.ts.map +1 -1
- package/src/components/provider.js +15 -14
- package/src/components/relative.js +7 -7
- package/src/components/useIntl.js +2 -2
- package/src/utils.d.ts +1 -1
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +3 -3
package/index.js
CHANGED
|
@@ -32,14 +32,14 @@ var provider_1 = require("./src/components/provider");
|
|
|
32
32
|
Object.defineProperty(exports, "IntlProvider", { enumerable: true, get: function () { return __importDefault(provider_1).default; } });
|
|
33
33
|
Object.defineProperty(exports, "createIntl", { enumerable: true, get: function () { return provider_1.createIntl; } });
|
|
34
34
|
// IMPORTANT: Explicit here to prevent api-extractor from outputing `import('./src/types').CustomFormatConfig`
|
|
35
|
-
exports.FormattedDate = createFormattedComponent_1.createFormattedComponent('formatDate');
|
|
36
|
-
exports.FormattedTime = createFormattedComponent_1.createFormattedComponent('formatTime');
|
|
35
|
+
exports.FormattedDate = (0, createFormattedComponent_1.createFormattedComponent)('formatDate');
|
|
36
|
+
exports.FormattedTime = (0, createFormattedComponent_1.createFormattedComponent)('formatTime');
|
|
37
37
|
// @ts-ignore issue w/ TS Intl types
|
|
38
|
-
exports.FormattedNumber = createFormattedComponent_1.createFormattedComponent('formatNumber');
|
|
39
|
-
exports.FormattedList = createFormattedComponent_1.createFormattedComponent('formatList');
|
|
40
|
-
exports.FormattedDisplayName = createFormattedComponent_1.createFormattedComponent('formatDisplayName');
|
|
41
|
-
exports.FormattedDateParts = createFormattedComponent_1.createFormattedDateTimePartsComponent('formatDate');
|
|
42
|
-
exports.FormattedTimeParts = createFormattedComponent_1.createFormattedDateTimePartsComponent('formatTime');
|
|
38
|
+
exports.FormattedNumber = (0, createFormattedComponent_1.createFormattedComponent)('formatNumber');
|
|
39
|
+
exports.FormattedList = (0, createFormattedComponent_1.createFormattedComponent)('formatList');
|
|
40
|
+
exports.FormattedDisplayName = (0, createFormattedComponent_1.createFormattedComponent)('formatDisplayName');
|
|
41
|
+
exports.FormattedDateParts = (0, createFormattedComponent_1.createFormattedDateTimePartsComponent)('formatDate');
|
|
42
|
+
exports.FormattedTimeParts = (0, createFormattedComponent_1.createFormattedDateTimePartsComponent)('formatTime');
|
|
43
43
|
var createFormattedComponent_2 = require("./src/components/createFormattedComponent");
|
|
44
44
|
Object.defineProperty(exports, "FormattedNumberParts", { enumerable: true, get: function () { return createFormattedComponent_2.FormattedNumberParts; } });
|
|
45
45
|
Object.defineProperty(exports, "FormattedListParts", { enumerable: true, get: function () { return createFormattedComponent_2.FormattedListParts; } });
|
|
@@ -25,7 +25,7 @@ interface State {
|
|
|
25
25
|
export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
|
|
26
26
|
export default class IntlProvider extends React.PureComponent<React.PropsWithChildren<IntlConfig>, State> {
|
|
27
27
|
static displayName: string;
|
|
28
|
-
static defaultProps: Pick<import("../types").ResolvedIntlConfig, "timeZone" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "onError" | "textComponent">;
|
|
28
|
+
static defaultProps: Pick<import("../types").ResolvedIntlConfig, "timeZone" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "onError" | "textComponent">;
|
|
29
29
|
private cache;
|
|
30
30
|
state: State;
|
|
31
31
|
static getDerivedStateFromProps(props: Readonly<IntlConfig>, { prevConfig, cache }: State): Partial<State> | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/react-intl/src/components/provider.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAA;AAC9C,OAAO,EAEL,SAAS,EAET,YAAY,EAEb,MAAM,gBAAgB,CAAA;AAQvB,UAAU,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,CAAA;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;;;OAIG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/react-intl/src/components/provider.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAA;AAC9C,OAAO,EAEL,SAAS,EAET,YAAY,EAEb,MAAM,gBAAgB,CAAA;AAQvB,UAAU,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,CAAA;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;;;OAIG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB;AAkED;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,KAAK,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,CA8BzE,CAAA;AAEH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,KAAK,CAAC,aAAa,CAG3D,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,EACnC,KAAK,CACN;IACC,MAAM,CAAC,WAAW,SAAiB;IACnC,MAAM,CAAC,YAAY,gLAAsB;IACzC,OAAO,CAAC,KAAK,CAA+B;IAC5C,KAAK,EAAE,KAAK,CAIX;IAED,MAAM,CAAC,wBAAwB,CAC7B,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,EAC3B,EAAC,UAAU,EAAE,KAAK,EAAC,EAAE,KAAK,GACzB,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI;IAWxB,MAAM,IAAI,GAAG,CAAC,OAAO;CAItB"}
|
|
@@ -13,6 +13,7 @@ function processIntlConfig(config) {
|
|
|
13
13
|
return {
|
|
14
14
|
locale: config.locale,
|
|
15
15
|
timeZone: config.timeZone,
|
|
16
|
+
fallbackOnEmptyString: config.fallbackOnEmptyString,
|
|
16
17
|
formats: config.formats,
|
|
17
18
|
textComponent: config.textComponent,
|
|
18
19
|
messages: config.messages,
|
|
@@ -44,7 +45,7 @@ var formatMessage = function (config, formatters, descriptor, rawValues) {
|
|
|
44
45
|
var chunks = coreFormatMessage.apply(void 0, __spreadArray([config,
|
|
45
46
|
formatters,
|
|
46
47
|
descriptor,
|
|
47
|
-
values], rest));
|
|
48
|
+
values], rest, false));
|
|
48
49
|
if (Array.isArray(chunks)) {
|
|
49
50
|
return React.Children.toArray(chunks);
|
|
50
51
|
}
|
package/lib/src/utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ResolvedIntlConfig } from './types';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { FormatXMLElementFn } from 'intl-messageformat';
|
|
4
4
|
export declare function invariantIntlContext(intl?: any): asserts intl;
|
|
5
|
-
export declare const DEFAULT_INTL_CONFIG: Pick<ResolvedIntlConfig, 'formats' | 'messages' | 'timeZone' | 'textComponent' | 'defaultLocale' | 'defaultFormats' | 'onError'>;
|
|
5
|
+
export declare const DEFAULT_INTL_CONFIG: Pick<ResolvedIntlConfig, 'fallbackOnEmptyString' | 'formats' | 'messages' | 'timeZone' | 'textComponent' | 'defaultLocale' | 'defaultFormats' | 'onError'>;
|
|
6
6
|
/**
|
|
7
7
|
* Takes a `formatXMLElementFn`, and composes it in function, which passes
|
|
8
8
|
* argument `parts` through, assigning unique key to each part, to prevent
|
package/lib/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react-intl/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AAKrD,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAM7D;AAED,eAAO,MAAM,mBAAmB,EAAE,IAAI,CACpC,kBAAkB,EAChB,SAAS,GACT,UAAU,GACV,UAAU,GACV,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,SAAS,CAIZ,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,kBAAkB,EAAE,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,GACtD,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAKrC;AAED,wBAAgB,YAAY,CAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,WA6BnB"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react-intl/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AAKrD,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAM7D;AAED,eAAO,MAAM,mBAAmB,EAAE,IAAI,CACpC,kBAAkB,EAChB,uBAAuB,GACvB,SAAS,GACT,UAAU,GACV,UAAU,GACV,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,SAAS,CAIZ,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,kBAAkB,EAAE,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,GACtD,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAKrC;AAED,wBAAgB,YAAY,CAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,WA6BnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intl",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.21.0",
|
|
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",
|
|
@@ -129,19 +129,19 @@
|
|
|
129
129
|
"sideEffects": false,
|
|
130
130
|
"dependencies": {
|
|
131
131
|
"@formatjs/ecma402-abstract": "1.10.0",
|
|
132
|
-
"@formatjs/icu-messageformat-parser": "2.0.
|
|
133
|
-
"@formatjs/intl": "1.
|
|
132
|
+
"@formatjs/icu-messageformat-parser": "2.0.14",
|
|
133
|
+
"@formatjs/intl": "1.15.0",
|
|
134
134
|
"@formatjs/intl-displaynames": "5.2.5",
|
|
135
135
|
"@formatjs/intl-listformat": "6.3.5",
|
|
136
136
|
"@types/hoist-non-react-statics": "^3.3.1",
|
|
137
137
|
"@types/react": "16 || 17",
|
|
138
138
|
"hoist-non-react-statics": "^3.3.2",
|
|
139
|
-
"intl-messageformat": "9.9.
|
|
139
|
+
"intl-messageformat": "9.9.4",
|
|
140
140
|
"tslib": "^2.1.0"
|
|
141
141
|
},
|
|
142
142
|
"peerDependencies": {
|
|
143
143
|
"react": "^16.3.0 || 17",
|
|
144
|
-
"typescript": "^4.
|
|
144
|
+
"typescript": "^4.4"
|
|
145
145
|
},
|
|
146
146
|
"peerDependenciesMeta": {
|
|
147
147
|
"typescript": {
|
package/react-intl.iife.js
CHANGED
|
@@ -8,9 +8,17 @@ var ReactIntl = (function() {
|
|
|
8
8
|
var __markAsModule = function(target) {
|
|
9
9
|
return __defProp(target, "__esModule", { value: true });
|
|
10
10
|
};
|
|
11
|
-
var __require =
|
|
11
|
+
var __require = /* @__PURE__ */ function(x) {
|
|
12
|
+
return typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
13
|
+
get: function(a, b) {
|
|
14
|
+
return (typeof require !== "undefined" ? require : a)[b];
|
|
15
|
+
}
|
|
16
|
+
}) : x;
|
|
17
|
+
}(function(x) {
|
|
18
|
+
if (typeof require !== "undefined")
|
|
19
|
+
return require.apply(this, arguments);
|
|
12
20
|
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
-
};
|
|
21
|
+
});
|
|
14
22
|
var __commonJS = function(cb, mod) {
|
|
15
23
|
return function __require2() {
|
|
16
24
|
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
@@ -350,7 +358,7 @@ var ReactIntl = (function() {
|
|
|
350
358
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
351
359
|
var locale = requestedLocales_1[_i];
|
|
352
360
|
var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
353
|
-
var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
|
|
361
|
+
var availableLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(availableLocales, noExtensionLocale);
|
|
354
362
|
if (availableLocale) {
|
|
355
363
|
result.locale = availableLocale;
|
|
356
364
|
if (locale !== noExtensionLocale) {
|
|
@@ -407,7 +415,7 @@ var ReactIntl = (function() {
|
|
|
407
415
|
foundLocale = minimizedRequestedLocale;
|
|
408
416
|
break;
|
|
409
417
|
}
|
|
410
|
-
foundLocale = BestAvailableLocale_1.BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
|
|
418
|
+
foundLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(minimizedAvailableLocales, maximizedRequestedLocale);
|
|
411
419
|
}
|
|
412
420
|
return {
|
|
413
421
|
locale: foundLocale && minimizedAvailableLocaleMap[foundLocale] || getDefaultLocale()
|
|
@@ -425,7 +433,7 @@ var ReactIntl = (function() {
|
|
|
425
433
|
exports.UnicodeExtensionValue = void 0;
|
|
426
434
|
var utils_1 = require_utils();
|
|
427
435
|
function UnicodeExtensionValue(extension, key) {
|
|
428
|
-
utils_1.invariant(key.length === 2, "key must have 2 elements");
|
|
436
|
+
(0, utils_1.invariant)(key.length === 2, "key must have 2 elements");
|
|
429
437
|
var size = extension.length;
|
|
430
438
|
var searchValue = "-" + key + "-";
|
|
431
439
|
var pos = extension.indexOf(searchValue);
|
|
@@ -479,25 +487,25 @@ var ReactIntl = (function() {
|
|
|
479
487
|
var matcher = options.localeMatcher;
|
|
480
488
|
var r;
|
|
481
489
|
if (matcher === "lookup") {
|
|
482
|
-
r = LookupMatcher_1.LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
490
|
+
r = (0, LookupMatcher_1.LookupMatcher)(availableLocales, requestedLocales, getDefaultLocale);
|
|
483
491
|
} else {
|
|
484
|
-
r = BestFitMatcher_1.BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
492
|
+
r = (0, BestFitMatcher_1.BestFitMatcher)(availableLocales, requestedLocales, getDefaultLocale);
|
|
485
493
|
}
|
|
486
494
|
var foundLocale = r.locale;
|
|
487
495
|
var result = { locale: "", dataLocale: foundLocale };
|
|
488
496
|
var supportedExtension = "-u";
|
|
489
497
|
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
|
|
490
498
|
var key = relevantExtensionKeys_1[_i];
|
|
491
|
-
utils_1.invariant(foundLocale in localeData, "Missing locale data for " + foundLocale);
|
|
499
|
+
(0, utils_1.invariant)(foundLocale in localeData, "Missing locale data for " + foundLocale);
|
|
492
500
|
var foundLocaleData = localeData[foundLocale];
|
|
493
|
-
utils_1.invariant(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data " + key + " must be an object");
|
|
501
|
+
(0, utils_1.invariant)(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data " + key + " must be an object");
|
|
494
502
|
var keyLocaleData = foundLocaleData[key];
|
|
495
|
-
utils_1.invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
|
|
503
|
+
(0, utils_1.invariant)(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
|
|
496
504
|
var value = keyLocaleData[0];
|
|
497
|
-
utils_1.invariant(typeof value === "string" || value === null, "value must be string or null but got " + typeof value + " in key " + key);
|
|
505
|
+
(0, utils_1.invariant)(typeof value === "string" || value === null, "value must be string or null but got " + typeof value + " in key " + key);
|
|
498
506
|
var supportedExtensionAddition = "";
|
|
499
507
|
if (r.extension) {
|
|
500
|
-
var requestedValue = UnicodeExtensionValue_1.UnicodeExtensionValue(r.extension, key);
|
|
508
|
+
var requestedValue = (0, UnicodeExtensionValue_1.UnicodeExtensionValue)(r.extension, key);
|
|
501
509
|
if (requestedValue !== void 0) {
|
|
502
510
|
if (requestedValue !== "") {
|
|
503
511
|
if (~keyLocaleData.indexOf(requestedValue)) {
|
|
@@ -512,7 +520,7 @@ var ReactIntl = (function() {
|
|
|
512
520
|
}
|
|
513
521
|
if (key in options) {
|
|
514
522
|
var optionsValue = options[key];
|
|
515
|
-
utils_1.invariant(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
|
|
523
|
+
(0, utils_1.invariant)(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
|
|
516
524
|
if (~keyLocaleData.indexOf(optionsValue)) {
|
|
517
525
|
if (optionsValue !== value) {
|
|
518
526
|
value = optionsValue;
|
|
@@ -554,7 +562,7 @@ var ReactIntl = (function() {
|
|
|
554
562
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
555
563
|
var locale = requestedLocales_1[_i];
|
|
556
564
|
var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
557
|
-
var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
|
|
565
|
+
var availableLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(availableLocales, noExtensionLocale);
|
|
558
566
|
if (availableLocale) {
|
|
559
567
|
subset.push(availableLocale);
|
|
560
568
|
}
|
|
@@ -577,7 +585,7 @@ var ReactIntl = (function() {
|
|
|
577
585
|
all.add(l);
|
|
578
586
|
return all;
|
|
579
587
|
}, new Set());
|
|
580
|
-
return ResolveLocale_1.ResolveLocale(locales, requestedLocales, {
|
|
588
|
+
return (0, ResolveLocale_1.ResolveLocale)(locales, requestedLocales, {
|
|
581
589
|
localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
|
|
582
590
|
}, [], {}, function() {
|
|
583
591
|
return defaultLocale;
|
|
@@ -2407,7 +2415,7 @@ var ReactIntl = (function() {
|
|
|
2407
2415
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2408
2416
|
args[_i] = arguments[_i];
|
|
2409
2417
|
}
|
|
2410
|
-
return new ((_a2 = Intl.NumberFormat).bind.apply(_a2, __spreadArray([void 0], args)))();
|
|
2418
|
+
return new ((_a2 = Intl.NumberFormat).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
2411
2419
|
}, {
|
|
2412
2420
|
cache: createFastMemoizeCache(cache.number),
|
|
2413
2421
|
strategy: strategies.variadic
|
|
@@ -2418,7 +2426,7 @@ var ReactIntl = (function() {
|
|
|
2418
2426
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2419
2427
|
args[_i] = arguments[_i];
|
|
2420
2428
|
}
|
|
2421
|
-
return new ((_a2 = Intl.DateTimeFormat).bind.apply(_a2, __spreadArray([void 0], args)))();
|
|
2429
|
+
return new ((_a2 = Intl.DateTimeFormat).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
2422
2430
|
}, {
|
|
2423
2431
|
cache: createFastMemoizeCache(cache.dateTime),
|
|
2424
2432
|
strategy: strategies.variadic
|
|
@@ -2429,7 +2437,7 @@ var ReactIntl = (function() {
|
|
|
2429
2437
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2430
2438
|
args[_i] = arguments[_i];
|
|
2431
2439
|
}
|
|
2432
|
-
return new ((_a2 = Intl.PluralRules).bind.apply(_a2, __spreadArray([void 0], args)))();
|
|
2440
|
+
return new ((_a2 = Intl.PluralRules).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
2433
2441
|
}, {
|
|
2434
2442
|
cache: createFastMemoizeCache(cache.pluralRules),
|
|
2435
2443
|
strategy: strategies.variadic
|
|
@@ -2580,7 +2588,9 @@ var ReactIntl = (function() {
|
|
|
2580
2588
|
var IntlError = function(_super) {
|
|
2581
2589
|
__extends(IntlError2, _super);
|
|
2582
2590
|
function IntlError2(code, message, exception) {
|
|
2583
|
-
var _this =
|
|
2591
|
+
var _this = this;
|
|
2592
|
+
var err = exception ? exception instanceof Error ? exception : new Error(String(exception)) : void 0;
|
|
2593
|
+
_this = _super.call(this, "[@formatjs/intl Error " + code + "] " + message + " \n" + (err ? "\n" + err.message + "\n" + err.stack : "")) || this;
|
|
2584
2594
|
_this.code = code;
|
|
2585
2595
|
if (typeof Error.captureStackTrace === "function") {
|
|
2586
2596
|
Error.captureStackTrace(_this, IntlError2);
|
|
@@ -2610,15 +2620,22 @@ var ReactIntl = (function() {
|
|
|
2610
2620
|
}
|
|
2611
2621
|
return MissingDataError2;
|
|
2612
2622
|
}(IntlError);
|
|
2623
|
+
var IntlFormatError = function(_super) {
|
|
2624
|
+
__extends(IntlFormatError2, _super);
|
|
2625
|
+
function IntlFormatError2(message, locale, exception) {
|
|
2626
|
+
return _super.call(this, IntlErrorCode.FORMAT_ERROR, message + " \nLocale: " + locale + "\n", exception) || this;
|
|
2627
|
+
}
|
|
2628
|
+
return IntlFormatError2;
|
|
2629
|
+
}(IntlError);
|
|
2613
2630
|
var MessageFormatError = function(_super) {
|
|
2614
2631
|
__extends(MessageFormatError2, _super);
|
|
2615
2632
|
function MessageFormatError2(message, locale, descriptor, exception) {
|
|
2616
|
-
var _this = _super.call(this,
|
|
2633
|
+
var _this = _super.call(this, message + " \nMessageID: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.id) + "\nDefault Message: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage) + "\nDescription: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.description) + " \n", locale, exception) || this;
|
|
2617
2634
|
_this.descriptor = descriptor;
|
|
2618
2635
|
return _this;
|
|
2619
2636
|
}
|
|
2620
2637
|
return MessageFormatError2;
|
|
2621
|
-
}(
|
|
2638
|
+
}(IntlFormatError);
|
|
2622
2639
|
var MissingTranslationError = function(_super) {
|
|
2623
2640
|
__extends(MissingTranslationError2, _super);
|
|
2624
2641
|
function MissingTranslationError2(descriptor, locale) {
|
|
@@ -2654,6 +2671,7 @@ var ReactIntl = (function() {
|
|
|
2654
2671
|
timeZone: void 0,
|
|
2655
2672
|
defaultLocale: "en",
|
|
2656
2673
|
defaultFormats: {},
|
|
2674
|
+
fallbackOnEmptyString: true,
|
|
2657
2675
|
onError: defaultErrorHandler
|
|
2658
2676
|
};
|
|
2659
2677
|
function createIntlCache() {
|
|
@@ -2694,7 +2712,7 @@ var ReactIntl = (function() {
|
|
|
2694
2712
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2695
2713
|
args[_i] = arguments[_i];
|
|
2696
2714
|
}
|
|
2697
|
-
return new ((_a2 = Intl.DateTimeFormat).bind.apply(_a2, __spreadArray([void 0], args)))();
|
|
2715
|
+
return new ((_a2 = Intl.DateTimeFormat).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
2698
2716
|
}, {
|
|
2699
2717
|
cache: createFastMemoizeCache2(cache.dateTime),
|
|
2700
2718
|
strategy: strategies.variadic
|
|
@@ -2705,7 +2723,7 @@ var ReactIntl = (function() {
|
|
|
2705
2723
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2706
2724
|
args[_i] = arguments[_i];
|
|
2707
2725
|
}
|
|
2708
|
-
return new ((_a2 = Intl.NumberFormat).bind.apply(_a2, __spreadArray([void 0], args)))();
|
|
2726
|
+
return new ((_a2 = Intl.NumberFormat).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
2709
2727
|
}, {
|
|
2710
2728
|
cache: createFastMemoizeCache2(cache.number),
|
|
2711
2729
|
strategy: strategies.variadic
|
|
@@ -2716,7 +2734,7 @@ var ReactIntl = (function() {
|
|
|
2716
2734
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2717
2735
|
args[_i] = arguments[_i];
|
|
2718
2736
|
}
|
|
2719
|
-
return new ((_a2 = Intl.PluralRules).bind.apply(_a2, __spreadArray([void 0], args)))();
|
|
2737
|
+
return new ((_a2 = Intl.PluralRules).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
2720
2738
|
}, {
|
|
2721
2739
|
cache: createFastMemoizeCache2(cache.pluralRules),
|
|
2722
2740
|
strategy: strategies.variadic
|
|
@@ -2739,7 +2757,7 @@ var ReactIntl = (function() {
|
|
|
2739
2757
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2740
2758
|
args[_i] = arguments[_i];
|
|
2741
2759
|
}
|
|
2742
|
-
return new (RelativeTimeFormat.bind.apply(RelativeTimeFormat, __spreadArray([void 0], args)))();
|
|
2760
|
+
return new (RelativeTimeFormat.bind.apply(RelativeTimeFormat, __spreadArray([void 0], args, false)))();
|
|
2743
2761
|
}, {
|
|
2744
2762
|
cache: createFastMemoizeCache2(cache.relativeTime),
|
|
2745
2763
|
strategy: strategies.variadic
|
|
@@ -2750,7 +2768,7 @@ var ReactIntl = (function() {
|
|
|
2750
2768
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2751
2769
|
args[_i] = arguments[_i];
|
|
2752
2770
|
}
|
|
2753
|
-
return new (ListFormat.bind.apply(ListFormat, __spreadArray([void 0], args)))();
|
|
2771
|
+
return new (ListFormat.bind.apply(ListFormat, __spreadArray([void 0], args, false)))();
|
|
2754
2772
|
}, {
|
|
2755
2773
|
cache: createFastMemoizeCache2(cache.list),
|
|
2756
2774
|
strategy: strategies.variadic
|
|
@@ -2760,7 +2778,7 @@ var ReactIntl = (function() {
|
|
|
2760
2778
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2761
2779
|
args[_i] = arguments[_i];
|
|
2762
2780
|
}
|
|
2763
|
-
return new (DisplayNames.bind.apply(DisplayNames, __spreadArray([void 0], args)))();
|
|
2781
|
+
return new (DisplayNames.bind.apply(DisplayNames, __spreadArray([void 0], args, false)))();
|
|
2764
2782
|
}, {
|
|
2765
2783
|
cache: createFastMemoizeCache2(cache.displayNames),
|
|
2766
2784
|
strategy: strategies.variadic
|
|
@@ -2801,7 +2819,7 @@ var ReactIntl = (function() {
|
|
|
2801
2819
|
return __assign(__assign(__assign({}, mfFormats), f1), { date: deepMergeOptions(setTimeZoneInOptions(mfFormats.date, timeZone), setTimeZoneInOptions(f1.date || {}, timeZone)), time: deepMergeOptions(setTimeZoneInOptions(mfFormats.time, timeZone), setTimeZoneInOptions(f1.time || {}, timeZone)) });
|
|
2802
2820
|
}
|
|
2803
2821
|
function formatMessage(_a2, state, messageDescriptor, values, opts) {
|
|
2804
|
-
var locale = _a2.locale, formats = _a2.formats, messages = _a2.messages, defaultLocale = _a2.defaultLocale, defaultFormats = _a2.defaultFormats, onError = _a2.onError, timeZone = _a2.timeZone, defaultRichTextElements = _a2.defaultRichTextElements;
|
|
2822
|
+
var locale = _a2.locale, formats = _a2.formats, messages = _a2.messages, defaultLocale = _a2.defaultLocale, defaultFormats = _a2.defaultFormats, fallbackOnEmptyString = _a2.fallbackOnEmptyString, onError = _a2.onError, timeZone = _a2.timeZone, defaultRichTextElements = _a2.defaultRichTextElements;
|
|
2805
2823
|
if (messageDescriptor === void 0) {
|
|
2806
2824
|
messageDescriptor = { id: "" };
|
|
2807
2825
|
}
|
|
@@ -2819,6 +2837,9 @@ var ReactIntl = (function() {
|
|
|
2819
2837
|
formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
|
|
2820
2838
|
defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
|
|
2821
2839
|
if (!message) {
|
|
2840
|
+
if (fallbackOnEmptyString === false && message === "") {
|
|
2841
|
+
return message;
|
|
2842
|
+
}
|
|
2822
2843
|
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
|
2823
2844
|
onError(new MissingTranslationError(messageDescriptor, locale));
|
|
2824
2845
|
}
|
|
@@ -3056,7 +3077,7 @@ var ReactIntl = (function() {
|
|
|
3056
3077
|
try {
|
|
3057
3078
|
return getPluralRules(locale, filteredOptions).select(value);
|
|
3058
3079
|
} catch (e) {
|
|
3059
|
-
onError(new
|
|
3080
|
+
onError(new IntlFormatError("Error formatting plural.", locale, e));
|
|
3060
3081
|
}
|
|
3061
3082
|
return "other";
|
|
3062
3083
|
}
|
|
@@ -3087,7 +3108,7 @@ var ReactIntl = (function() {
|
|
|
3087
3108
|
try {
|
|
3088
3109
|
return getFormatter2(config, getRelativeTimeFormat, options).format(value, unit);
|
|
3089
3110
|
} catch (e) {
|
|
3090
|
-
config.onError(new
|
|
3111
|
+
config.onError(new IntlFormatError("Error formatting relative time.", config.locale, e));
|
|
3091
3112
|
}
|
|
3092
3113
|
return String(value);
|
|
3093
3114
|
}
|
|
@@ -3306,6 +3327,7 @@ var ReactIntl = (function() {
|
|
|
3306
3327
|
return {
|
|
3307
3328
|
locale: config.locale,
|
|
3308
3329
|
timeZone: config.timeZone,
|
|
3330
|
+
fallbackOnEmptyString: config.fallbackOnEmptyString,
|
|
3309
3331
|
formats: config.formats,
|
|
3310
3332
|
textComponent: config.textComponent,
|
|
3311
3333
|
messages: config.messages,
|
|
@@ -3337,7 +3359,7 @@ var ReactIntl = (function() {
|
|
|
3337
3359
|
formatters,
|
|
3338
3360
|
descriptor,
|
|
3339
3361
|
values
|
|
3340
|
-
], rest));
|
|
3362
|
+
], rest, false));
|
|
3341
3363
|
if (Array.isArray(chunks)) {
|
|
3342
3364
|
return React5.Children.toArray(chunks);
|
|
3343
3365
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createFormattedComponent = exports.createFormattedDateTimePartsComponent = exports.FormattedListParts = exports.FormattedNumberParts = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var React = tslib_1.__importStar(require("react"));
|
|
6
|
-
var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
|
|
5
|
+
var React = (0, tslib_1.__importStar)(require("react"));
|
|
6
|
+
var useIntl_1 = (0, tslib_1.__importDefault)(require("./useIntl"));
|
|
7
7
|
var DisplayName;
|
|
8
8
|
(function (DisplayName) {
|
|
9
9
|
DisplayName["formatDate"] = "FormattedDate";
|
|
@@ -22,23 +22,23 @@ var DisplayNameParts;
|
|
|
22
22
|
DisplayNameParts["formatList"] = "FormattedListParts";
|
|
23
23
|
})(DisplayNameParts || (DisplayNameParts = {}));
|
|
24
24
|
var FormattedNumberParts = function (props) {
|
|
25
|
-
var intl = useIntl_1.default();
|
|
26
|
-
var value = props.value, children = props.children, formatProps = tslib_1.__rest(props, ["value", "children"]);
|
|
25
|
+
var intl = (0, useIntl_1.default)();
|
|
26
|
+
var value = props.value, children = props.children, formatProps = (0, tslib_1.__rest)(props, ["value", "children"]);
|
|
27
27
|
return children(intl.formatNumberToParts(value, formatProps));
|
|
28
28
|
};
|
|
29
29
|
exports.FormattedNumberParts = FormattedNumberParts;
|
|
30
30
|
exports.FormattedNumberParts.displayName = 'FormattedNumberParts';
|
|
31
31
|
var FormattedListParts = function (props) {
|
|
32
|
-
var intl = useIntl_1.default();
|
|
33
|
-
var value = props.value, children = props.children, formatProps = tslib_1.__rest(props, ["value", "children"]);
|
|
32
|
+
var intl = (0, useIntl_1.default)();
|
|
33
|
+
var value = props.value, children = props.children, formatProps = (0, tslib_1.__rest)(props, ["value", "children"]);
|
|
34
34
|
return children(intl.formatListToParts(value, formatProps));
|
|
35
35
|
};
|
|
36
36
|
exports.FormattedListParts = FormattedListParts;
|
|
37
37
|
exports.FormattedNumberParts.displayName = 'FormattedNumberParts';
|
|
38
38
|
function createFormattedDateTimePartsComponent(name) {
|
|
39
39
|
var ComponentParts = function (props) {
|
|
40
|
-
var intl = useIntl_1.default();
|
|
41
|
-
var value = props.value, children = props.children, formatProps = tslib_1.__rest(props, ["value", "children"]);
|
|
40
|
+
var intl = (0, useIntl_1.default)();
|
|
41
|
+
var value = props.value, children = props.children, formatProps = (0, tslib_1.__rest)(props, ["value", "children"]);
|
|
42
42
|
var date = typeof value === 'string' ? new Date(value || 0) : value;
|
|
43
43
|
var formattedParts = name === 'formatDate'
|
|
44
44
|
? intl.formatDateToParts(date, formatProps)
|
|
@@ -51,8 +51,8 @@ function createFormattedDateTimePartsComponent(name) {
|
|
|
51
51
|
exports.createFormattedDateTimePartsComponent = createFormattedDateTimePartsComponent;
|
|
52
52
|
function createFormattedComponent(name) {
|
|
53
53
|
var Component = function (props) {
|
|
54
|
-
var intl = useIntl_1.default();
|
|
55
|
-
var value = props.value, children = props.children, formatProps = tslib_1.__rest(props
|
|
54
|
+
var intl = (0, useIntl_1.default)();
|
|
55
|
+
var value = props.value, children = props.children, formatProps = (0, tslib_1.__rest)(props
|
|
56
56
|
// TODO: fix TS type definition for localeMatcher upstream
|
|
57
57
|
, ["value", "children"]);
|
|
58
58
|
// TODO: fix TS type definition for localeMatcher upstream
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var React = tslib_1.__importStar(require("react"));
|
|
5
|
-
var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
|
|
4
|
+
var React = (0, tslib_1.__importStar)(require("react"));
|
|
5
|
+
var useIntl_1 = (0, tslib_1.__importDefault)(require("./useIntl"));
|
|
6
6
|
var FormattedDateTimeRange = function (props) {
|
|
7
|
-
var intl = useIntl_1.default();
|
|
8
|
-
var from = props.from, to = props.to, children = props.children, formatProps = tslib_1.__rest(props, ["from", "to", "children"]);
|
|
7
|
+
var intl = (0, useIntl_1.default)();
|
|
8
|
+
var from = props.from, to = props.to, children = props.children, formatProps = (0, tslib_1.__rest)(props, ["from", "to", "children"]);
|
|
9
9
|
var formattedValue = intl.formatDateTimeRange(from, to, formatProps);
|
|
10
10
|
if (typeof children === 'function') {
|
|
11
11
|
return children(formattedValue);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Context = exports.Provider = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var React = tslib_1.__importStar(require("react"));
|
|
6
|
-
var hoist_non_react_statics_1 = tslib_1.__importDefault(require("hoist-non-react-statics"));
|
|
5
|
+
var React = (0, tslib_1.__importStar)(require("react"));
|
|
6
|
+
var hoist_non_react_statics_1 = (0, tslib_1.__importDefault)(require("hoist-non-react-statics"));
|
|
7
7
|
var utils_1 = require("../utils");
|
|
8
8
|
function getDisplayName(Component) {
|
|
9
9
|
return Component.displayName || Component.name || 'Component';
|
|
@@ -18,16 +18,16 @@ function injectIntl(WrappedComponent, options) {
|
|
|
18
18
|
var WithIntl = function (props) { return (React.createElement(IntlConsumer, null, function (intl) {
|
|
19
19
|
var _a;
|
|
20
20
|
if (enforceContext) {
|
|
21
|
-
utils_1.invariantIntlContext(intl);
|
|
21
|
+
(0, utils_1.invariantIntlContext)(intl);
|
|
22
22
|
}
|
|
23
23
|
var intlProp = (_a = {}, _a[intlPropName] = intl, _a);
|
|
24
|
-
return (React.createElement(WrappedComponent, tslib_1.__assign({}, props, intlProp, { ref: forwardRef ? props.forwardedRef : null })));
|
|
24
|
+
return (React.createElement(WrappedComponent, (0, tslib_1.__assign)({}, props, intlProp, { ref: forwardRef ? props.forwardedRef : null })));
|
|
25
25
|
})); };
|
|
26
26
|
WithIntl.displayName = "injectIntl(" + getDisplayName(WrappedComponent) + ")";
|
|
27
27
|
WithIntl.WrappedComponent = WrappedComponent;
|
|
28
28
|
if (forwardRef) {
|
|
29
|
-
return hoist_non_react_statics_1.default(React.forwardRef(function (props, ref) { return (React.createElement(WithIntl, tslib_1.__assign({}, props, { forwardedRef: ref }))); }), WrappedComponent);
|
|
29
|
+
return (0, hoist_non_react_statics_1.default)(React.forwardRef(function (props, ref) { return (React.createElement(WithIntl, (0, tslib_1.__assign)({}, props, { forwardedRef: ref }))); }), WrappedComponent);
|
|
30
30
|
}
|
|
31
|
-
return hoist_non_react_statics_1.default(WithIntl, WrappedComponent);
|
|
31
|
+
return (0, hoist_non_react_statics_1.default)(WithIntl, WrappedComponent);
|
|
32
32
|
}
|
|
33
33
|
exports.default = injectIntl;
|
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
var tslib_1 = require("tslib");
|
|
9
|
-
var React = tslib_1.__importStar(require("react"));
|
|
10
|
-
var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
|
|
9
|
+
var React = (0, tslib_1.__importStar)(require("react"));
|
|
10
|
+
var useIntl_1 = (0, tslib_1.__importDefault)(require("./useIntl"));
|
|
11
11
|
var utils_1 = require("../utils");
|
|
12
12
|
function areEqual(prevProps, nextProps) {
|
|
13
|
-
var values = prevProps.values, otherProps = tslib_1.__rest(prevProps, ["values"]);
|
|
14
|
-
var nextValues = nextProps.values, nextOtherProps = tslib_1.__rest(nextProps, ["values"]);
|
|
15
|
-
return (utils_1.shallowEqual(nextValues, values) &&
|
|
16
|
-
utils_1.shallowEqual(otherProps, nextOtherProps));
|
|
13
|
+
var values = prevProps.values, otherProps = (0, tslib_1.__rest)(prevProps, ["values"]);
|
|
14
|
+
var nextValues = nextProps.values, nextOtherProps = (0, tslib_1.__rest)(nextProps, ["values"]);
|
|
15
|
+
return ((0, utils_1.shallowEqual)(nextValues, values) &&
|
|
16
|
+
(0, utils_1.shallowEqual)(otherProps, nextOtherProps));
|
|
17
17
|
}
|
|
18
18
|
function FormattedMessage(props) {
|
|
19
|
-
var intl = useIntl_1.default();
|
|
19
|
+
var intl = (0, useIntl_1.default)();
|
|
20
20
|
var formatMessage = intl.formatMessage, _a = intl.textComponent, Text = _a === void 0 ? React.Fragment : _a;
|
|
21
21
|
var id = props.id, description = props.description, defaultMessage = props.defaultMessage, values = props.values, children = props.children, _b = props.tagName, Component = _b === void 0 ? Text : _b, ignoreTag = props.ignoreTag;
|
|
22
22
|
var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
|
package/src/components/plural.js
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
var tslib_1 = require("tslib");
|
|
9
|
-
var React = tslib_1.__importStar(require("react"));
|
|
10
|
-
var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
|
|
9
|
+
var React = (0, tslib_1.__importStar)(require("react"));
|
|
10
|
+
var useIntl_1 = (0, tslib_1.__importDefault)(require("./useIntl"));
|
|
11
11
|
var FormattedPlural = function (props) {
|
|
12
|
-
var _a = useIntl_1.default(), formatPlural = _a.formatPlural, Text = _a.textComponent;
|
|
12
|
+
var _a = (0, useIntl_1.default)(), formatPlural = _a.formatPlural, Text = _a.textComponent;
|
|
13
13
|
var value = props.value, other = props.other, children = props.children;
|
|
14
14
|
var pluralCategory = formatPlural(value, props);
|
|
15
15
|
var formattedPlural = props[pluralCategory] || other;
|
|
@@ -25,7 +25,7 @@ interface State {
|
|
|
25
25
|
export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
|
|
26
26
|
export default class IntlProvider extends React.PureComponent<React.PropsWithChildren<IntlConfig>, State> {
|
|
27
27
|
static displayName: string;
|
|
28
|
-
static defaultProps: Pick<import("../types").ResolvedIntlConfig, "timeZone" | "
|
|
28
|
+
static defaultProps: Pick<import("../types").ResolvedIntlConfig, "onError" | "timeZone" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "textComponent">;
|
|
29
29
|
private cache;
|
|
30
30
|
state: State;
|
|
31
31
|
static getDerivedStateFromProps(props: Readonly<IntlConfig>, { prevConfig, cache }: State): Partial<State> | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react-intl/src/components/provider.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAA;AAC9C,OAAO,EAEL,SAAS,EAET,YAAY,EAEb,MAAM,gBAAgB,CAAA;AAQvB,UAAU,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,CAAA;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;;;OAIG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react-intl/src/components/provider.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAA;AAC9C,OAAO,EAEL,SAAS,EAET,YAAY,EAEb,MAAM,gBAAgB,CAAA;AAQvB,UAAU,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,CAAA;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;;;OAIG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB;AAkED;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,KAAK,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,CA8BzE,CAAA;AAEH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,KAAK,CAAC,aAAa,CAG3D,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,EACnC,KAAK,CACN;IACC,MAAM,CAAC,WAAW,SAAiB;IACnC,MAAM,CAAC,YAAY,gLAAsB;IACzC,OAAO,CAAC,KAAK,CAA+B;IAC5C,KAAK,EAAE,KAAK,CAIX;IAED,MAAM,CAAC,wBAAwB,CAC7B,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,EAC3B,EAAC,UAAU,EAAE,KAAK,EAAC,EAAE,KAAK,GACzB,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI;IAWxB,MAAM,IAAI,GAAG,CAAC,OAAO;CAItB"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.createIntl = void 0;
|
|
9
9
|
var tslib_1 = require("tslib");
|
|
10
|
-
var React = tslib_1.__importStar(require("react"));
|
|
10
|
+
var React = (0, tslib_1.__importStar)(require("react"));
|
|
11
11
|
var injectIntl_1 = require("./injectIntl");
|
|
12
12
|
var utils_1 = require("../utils");
|
|
13
13
|
var intl_1 = require("@formatjs/intl");
|
|
@@ -16,6 +16,7 @@ function processIntlConfig(config) {
|
|
|
16
16
|
return {
|
|
17
17
|
locale: config.locale,
|
|
18
18
|
timeZone: config.timeZone,
|
|
19
|
+
fallbackOnEmptyString: config.fallbackOnEmptyString,
|
|
19
20
|
formats: config.formats,
|
|
20
21
|
textComponent: config.textComponent,
|
|
21
22
|
messages: config.messages,
|
|
@@ -32,8 +33,8 @@ function assignUniqueKeysToFormatXMLElementFnArgument(values) {
|
|
|
32
33
|
}
|
|
33
34
|
return Object.keys(values).reduce(function (acc, k) {
|
|
34
35
|
var v = values[k];
|
|
35
|
-
acc[k] = intl_messageformat_1.isFormatXMLElementFn(v)
|
|
36
|
-
? utils_1.assignUniqueKeysToParts(v)
|
|
36
|
+
acc[k] = (0, intl_messageformat_1.isFormatXMLElementFn)(v)
|
|
37
|
+
? (0, utils_1.assignUniqueKeysToParts)(v)
|
|
37
38
|
: v;
|
|
38
39
|
return acc;
|
|
39
40
|
}, {});
|
|
@@ -44,10 +45,10 @@ var formatMessage = function (config, formatters, descriptor, rawValues) {
|
|
|
44
45
|
rest[_i - 4] = arguments[_i];
|
|
45
46
|
}
|
|
46
47
|
var values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
|
|
47
|
-
var chunks = intl_1.formatMessage.apply(void 0, tslib_1.__spreadArray([config,
|
|
48
|
+
var chunks = intl_1.formatMessage.apply(void 0, (0, tslib_1.__spreadArray)([config,
|
|
48
49
|
formatters,
|
|
49
50
|
descriptor,
|
|
50
|
-
values], rest));
|
|
51
|
+
values], rest, false));
|
|
51
52
|
if (Array.isArray(chunks)) {
|
|
52
53
|
return React.Children.toArray(chunks);
|
|
53
54
|
}
|
|
@@ -59,10 +60,10 @@ var formatMessage = function (config, formatters, descriptor, rawValues) {
|
|
|
59
60
|
* @param cache cache for formatter instances to prevent memory leak
|
|
60
61
|
*/
|
|
61
62
|
var createIntl = function (_a, cache) {
|
|
62
|
-
var rawDefaultRichTextElements = _a.defaultRichTextElements, config = tslib_1.__rest(_a, ["defaultRichTextElements"]);
|
|
63
|
+
var rawDefaultRichTextElements = _a.defaultRichTextElements, config = (0, tslib_1.__rest)(_a, ["defaultRichTextElements"]);
|
|
63
64
|
var defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(rawDefaultRichTextElements);
|
|
64
|
-
var coreIntl = intl_1.createIntl(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, utils_1.DEFAULT_INTL_CONFIG), config), { defaultRichTextElements: defaultRichTextElements }), cache);
|
|
65
|
-
return tslib_1.__assign(tslib_1.__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, {
|
|
65
|
+
var coreIntl = (0, intl_1.createIntl)((0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, utils_1.DEFAULT_INTL_CONFIG), config), { defaultRichTextElements: defaultRichTextElements }), cache);
|
|
66
|
+
return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, coreIntl), { formatMessage: formatMessage.bind(null, {
|
|
66
67
|
locale: coreIntl.locale,
|
|
67
68
|
timeZone: coreIntl.timeZone,
|
|
68
69
|
formats: coreIntl.formats,
|
|
@@ -75,13 +76,13 @@ var createIntl = function (_a, cache) {
|
|
|
75
76
|
};
|
|
76
77
|
exports.createIntl = createIntl;
|
|
77
78
|
var IntlProvider = /** @class */ (function (_super) {
|
|
78
|
-
tslib_1.__extends(IntlProvider, _super);
|
|
79
|
+
(0, tslib_1.__extends)(IntlProvider, _super);
|
|
79
80
|
function IntlProvider() {
|
|
80
81
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
81
|
-
_this.cache = intl_1.createIntlCache();
|
|
82
|
+
_this.cache = (0, intl_1.createIntlCache)();
|
|
82
83
|
_this.state = {
|
|
83
84
|
cache: _this.cache,
|
|
84
|
-
intl: exports.createIntl(processIntlConfig(_this.props), _this.cache),
|
|
85
|
+
intl: (0, exports.createIntl)(processIntlConfig(_this.props), _this.cache),
|
|
85
86
|
prevConfig: processIntlConfig(_this.props),
|
|
86
87
|
};
|
|
87
88
|
return _this;
|
|
@@ -89,16 +90,16 @@ var IntlProvider = /** @class */ (function (_super) {
|
|
|
89
90
|
IntlProvider.getDerivedStateFromProps = function (props, _a) {
|
|
90
91
|
var prevConfig = _a.prevConfig, cache = _a.cache;
|
|
91
92
|
var config = processIntlConfig(props);
|
|
92
|
-
if (!utils_1.shallowEqual(prevConfig, config)) {
|
|
93
|
+
if (!(0, utils_1.shallowEqual)(prevConfig, config)) {
|
|
93
94
|
return {
|
|
94
|
-
intl: exports.createIntl(config, cache),
|
|
95
|
+
intl: (0, exports.createIntl)(config, cache),
|
|
95
96
|
prevConfig: config,
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
99
|
return null;
|
|
99
100
|
};
|
|
100
101
|
IntlProvider.prototype.render = function () {
|
|
101
|
-
utils_1.invariantIntlContext(this.state.intl);
|
|
102
|
+
(0, utils_1.invariantIntlContext)(this.state.intl);
|
|
102
103
|
return React.createElement(injectIntl_1.Provider, { value: this.state.intl }, this.props.children);
|
|
103
104
|
};
|
|
104
105
|
IntlProvider.displayName = 'IntlProvider';
|
|
@@ -6,9 +6,9 @@ var tslib_1 = require("tslib");
|
|
|
6
6
|
* Copyrights licensed under the New BSD License.
|
|
7
7
|
* See the accompanying LICENSE file for terms.
|
|
8
8
|
*/
|
|
9
|
-
var React = tslib_1.__importStar(require("react"));
|
|
9
|
+
var React = (0, tslib_1.__importStar)(require("react"));
|
|
10
10
|
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
11
|
-
var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
|
|
11
|
+
var useIntl_1 = (0, tslib_1.__importDefault)(require("./useIntl"));
|
|
12
12
|
var MINUTE = 60;
|
|
13
13
|
var HOUR = 60 * 60;
|
|
14
14
|
var DAY = 60 * 60 * 24;
|
|
@@ -60,8 +60,8 @@ function canIncrement(unit) {
|
|
|
60
60
|
return INCREMENTABLE_UNITS.indexOf(unit) > -1;
|
|
61
61
|
}
|
|
62
62
|
var SimpleFormattedRelativeTime = function (props) {
|
|
63
|
-
var _a = useIntl_1.default(), formatRelativeTime = _a.formatRelativeTime, Text = _a.textComponent;
|
|
64
|
-
var children = props.children, value = props.value, unit = props.unit, otherProps = tslib_1.__rest(props, ["children", "value", "unit"]);
|
|
63
|
+
var _a = (0, useIntl_1.default)(), formatRelativeTime = _a.formatRelativeTime, Text = _a.textComponent;
|
|
64
|
+
var children = props.children, value = props.value, unit = props.unit, otherProps = (0, tslib_1.__rest)(props, ["children", "value", "unit"]);
|
|
65
65
|
var formattedRelativeTime = formatRelativeTime(value || 0, unit, otherProps);
|
|
66
66
|
if (typeof children === 'function') {
|
|
67
67
|
return children(formattedRelativeTime);
|
|
@@ -72,8 +72,8 @@ var SimpleFormattedRelativeTime = function (props) {
|
|
|
72
72
|
return React.createElement(React.Fragment, null, formattedRelativeTime);
|
|
73
73
|
};
|
|
74
74
|
var FormattedRelativeTime = function (_a) {
|
|
75
|
-
var value = _a.value, unit = _a.unit, updateIntervalInSeconds = _a.updateIntervalInSeconds, otherProps = tslib_1.__rest(_a, ["value", "unit", "updateIntervalInSeconds"]);
|
|
76
|
-
ecma402_abstract_1.invariant(!updateIntervalInSeconds ||
|
|
75
|
+
var value = _a.value, unit = _a.unit, updateIntervalInSeconds = _a.updateIntervalInSeconds, otherProps = (0, tslib_1.__rest)(_a, ["value", "unit", "updateIntervalInSeconds"]);
|
|
76
|
+
(0, ecma402_abstract_1.invariant)(!updateIntervalInSeconds ||
|
|
77
77
|
!!(updateIntervalInSeconds && canIncrement(unit)), 'Cannot schedule update with unit longer than hour');
|
|
78
78
|
var _b = React.useState(), prevUnit = _b[0], setPrevUnit = _b[1];
|
|
79
79
|
var _c = React.useState(0), prevValue = _c[0], setPrevValue = _c[1];
|
|
@@ -121,7 +121,7 @@ var FormattedRelativeTime = function (_a) {
|
|
|
121
121
|
var unitDuration = getDurationInSeconds(currentUnit);
|
|
122
122
|
currentValue = Math.round(currentValueInSeconds / unitDuration);
|
|
123
123
|
}
|
|
124
|
-
return (React.createElement(SimpleFormattedRelativeTime, tslib_1.__assign({ value: currentValue, unit: currentUnit }, otherProps)));
|
|
124
|
+
return (React.createElement(SimpleFormattedRelativeTime, (0, tslib_1.__assign)({ value: currentValue, unit: currentUnit }, otherProps)));
|
|
125
125
|
};
|
|
126
126
|
FormattedRelativeTime.displayName = 'FormattedRelativeTime';
|
|
127
127
|
FormattedRelativeTime.defaultProps = {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var React = tslib_1.__importStar(require("react"));
|
|
4
|
+
var React = (0, tslib_1.__importStar)(require("react"));
|
|
5
5
|
var injectIntl_1 = require("./injectIntl");
|
|
6
6
|
var utils_1 = require("../utils");
|
|
7
7
|
function useIntl() {
|
|
8
8
|
var intl = React.useContext(injectIntl_1.Context);
|
|
9
|
-
utils_1.invariantIntlContext(intl);
|
|
9
|
+
(0, utils_1.invariantIntlContext)(intl);
|
|
10
10
|
return intl;
|
|
11
11
|
}
|
|
12
12
|
exports.default = useIntl;
|
package/src/utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ResolvedIntlConfig } from './types';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { FormatXMLElementFn } from 'intl-messageformat';
|
|
4
4
|
export declare function invariantIntlContext(intl?: any): asserts intl;
|
|
5
|
-
export declare const DEFAULT_INTL_CONFIG: Pick<ResolvedIntlConfig, 'formats' | 'messages' | 'timeZone' | 'textComponent' | 'defaultLocale' | 'defaultFormats' | 'onError'>;
|
|
5
|
+
export declare const DEFAULT_INTL_CONFIG: Pick<ResolvedIntlConfig, 'fallbackOnEmptyString' | 'formats' | 'messages' | 'timeZone' | 'textComponent' | 'defaultLocale' | 'defaultFormats' | 'onError'>;
|
|
6
6
|
/**
|
|
7
7
|
* Takes a `formatXMLElementFn`, and composes it in function, which passes
|
|
8
8
|
* argument `parts` through, assigning unique key to each part, to prevent
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/react-intl/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AAKrD,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAM7D;AAED,eAAO,MAAM,mBAAmB,EAAE,IAAI,CACpC,kBAAkB,EAChB,SAAS,GACT,UAAU,GACV,UAAU,GACV,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,SAAS,CAIZ,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,kBAAkB,EAAE,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,GACtD,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAKrC;AAED,wBAAgB,YAAY,CAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,WA6BnB"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/react-intl/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AAKrD,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAM7D;AAED,eAAO,MAAM,mBAAmB,EAAE,IAAI,CACpC,kBAAkB,EAChB,uBAAuB,GACvB,SAAS,GACT,UAAU,GACV,UAAU,GACV,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,SAAS,CAIZ,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,kBAAkB,EAAE,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,GACtD,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAKrC;AAED,wBAAgB,YAAY,CAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,WA6BnB"}
|
package/src/utils.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.shallowEqual = exports.assignUniqueKeysToParts = exports.DEFAULT_INTL_CONFIG = exports.invariantIntlContext = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var React = tslib_1.__importStar(require("react"));
|
|
5
|
+
var React = (0, tslib_1.__importStar)(require("react"));
|
|
6
6
|
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
7
7
|
var intl_1 = require("@formatjs/intl");
|
|
8
8
|
function invariantIntlContext(intl) {
|
|
9
|
-
ecma402_abstract_1.invariant(intl, '[React Intl] Could not find required `intl` object. ' +
|
|
9
|
+
(0, ecma402_abstract_1.invariant)(intl, '[React Intl] Could not find required `intl` object. ' +
|
|
10
10
|
'<IntlProvider> needs to exist in the component ancestry.');
|
|
11
11
|
}
|
|
12
12
|
exports.invariantIntlContext = invariantIntlContext;
|
|
13
|
-
exports.DEFAULT_INTL_CONFIG = tslib_1.__assign(tslib_1.__assign({}, intl_1.DEFAULT_INTL_CONFIG), { textComponent: React.Fragment });
|
|
13
|
+
exports.DEFAULT_INTL_CONFIG = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, intl_1.DEFAULT_INTL_CONFIG), { textComponent: React.Fragment });
|
|
14
14
|
/**
|
|
15
15
|
* Takes a `formatXMLElementFn`, and composes it in function, which passes
|
|
16
16
|
* argument `parts` through, assigning unique key to each part, to prevent
|