react-intl 6.8.9 → 7.0.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/README.md +1 -1
- package/index.d.ts +15 -18
- package/index.js +16 -16
- package/lib/index.d.ts +15 -18
- package/lib/index.js +9 -9
- package/lib/src/components/createFormattedComponent.d.ts +2 -3
- package/lib/src/components/createIntl.js +2 -6
- package/lib/src/components/dateTimeRange.d.ts +3 -4
- package/lib/src/components/provider.d.ts +1 -1
- package/lib/src/components/relative.d.ts +1 -2
- package/lib/src/components/relative.js +1 -1
- package/lib/src/utils.d.ts +3 -2
- package/lib/src/utils.js +6 -1
- package/package.json +5 -12
- package/react-intl.iife.js +115 -267
- package/src/components/createFormattedComponent.d.ts +2 -3
- package/src/components/createIntl.js +2 -6
- package/src/components/dateTimeRange.d.ts +3 -4
- package/src/components/provider.d.ts +1 -1
- package/src/components/relative.d.ts +1 -2
- package/src/components/relative.js +2 -2
- package/src/utils.d.ts +3 -2
- package/src/utils.js +8 -2
package/README.md
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
+
import { CustomFormatConfig, FormatDateOptions, MessageDescriptor } from '@formatjs/intl';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import { MessageDescriptor, CustomFormatConfig, FormatDateOptions } from '@formatjs/intl';
|
|
3
|
-
import { IntlListFormatOptions } from '@formatjs/intl-listformat';
|
|
4
|
-
import { DisplayNamesOptions } from '@formatjs/intl-displaynames';
|
|
5
|
-
import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
|
|
6
|
-
import injectIntl, { Provider as RawIntlProvider, Context as IntlContext, WithIntlProps, WrappedComponentProps } from './src/components/injectIntl';
|
|
7
|
-
import useIntl from './src/components/useIntl';
|
|
8
|
-
import IntlProvider from './src/components/provider';
|
|
9
3
|
import { createIntl } from './src/components/createIntl';
|
|
10
|
-
import FormattedRelativeTime from './src/components/relative';
|
|
11
|
-
import FormattedPlural from './src/components/plural';
|
|
12
|
-
import FormattedMessage from './src/components/message';
|
|
13
4
|
import FormattedDateTimeRange from './src/components/dateTimeRange';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
import injectIntl, { Context as IntlContext, Provider as RawIntlProvider, WithIntlProps, WrappedComponentProps } from './src/components/injectIntl';
|
|
6
|
+
import FormattedMessage from './src/components/message';
|
|
7
|
+
import FormattedPlural from './src/components/plural';
|
|
8
|
+
import IntlProvider from './src/components/provider';
|
|
9
|
+
import FormattedRelativeTime from './src/components/relative';
|
|
10
|
+
import useIntl from './src/components/useIntl';
|
|
11
|
+
export { createIntlCache, CustomFormatConfig, CustomFormats, FormatDateOptions, FormatDisplayNameOptions, FormatListOptions, FormatNumberOptions, FormatPluralOptions, FormatRelativeTimeOptions, Formatters, IntlCache, IntlFormatters, InvalidConfigError, MessageDescriptor, MessageFormatError, MissingDataError, MissingTranslationError, IntlError as ReactIntlError, IntlErrorCode as ReactIntlErrorCode, UnsupportedFormatterError, } from '@formatjs/intl';
|
|
12
|
+
export { IntlConfig, IntlShape, ResolvedIntlConfig } from './src/types';
|
|
13
|
+
export { createIntl, FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, injectIntl, IntlContext, IntlProvider, RawIntlProvider, useIntl, WithIntlProps, WrappedComponentProps, };
|
|
17
14
|
export declare function defineMessages<K extends keyof any, T = MessageDescriptor, U extends Record<K, T> = Record<K, T>>(msgs: U): U;
|
|
18
15
|
export declare function defineMessage<T extends MessageDescriptor>(msg: T): T;
|
|
19
16
|
export declare const FormattedDate: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig & {
|
|
@@ -24,15 +21,15 @@ export declare const FormattedTime: React.FC<Intl.DateTimeFormatOptions & Custom
|
|
|
24
21
|
value: string | number | Date | undefined;
|
|
25
22
|
children?(formattedTime: string): React.ReactElement | null;
|
|
26
23
|
}>;
|
|
27
|
-
export declare const FormattedNumber: React.FC<Omit<NumberFormatOptions, 'localeMatcher'> & CustomFormatConfig<'number'> & {
|
|
24
|
+
export declare const FormattedNumber: React.FC<Omit<Intl.NumberFormatOptions, 'localeMatcher'> & CustomFormatConfig<'number'> & {
|
|
28
25
|
value: number;
|
|
29
26
|
children?(formattedNumber: string): React.ReactElement | null;
|
|
30
27
|
}>;
|
|
31
|
-
export declare const FormattedList: React.FC<
|
|
28
|
+
export declare const FormattedList: React.FC<Intl.ListFormatOptions & {
|
|
32
29
|
value: readonly React.ReactNode[];
|
|
33
30
|
}>;
|
|
34
|
-
export declare const FormattedDisplayName: React.FC<DisplayNamesOptions & {
|
|
35
|
-
value: string
|
|
31
|
+
export declare const FormattedDisplayName: React.FC<Intl.DisplayNamesOptions & {
|
|
32
|
+
value: string;
|
|
36
33
|
}>;
|
|
37
34
|
export declare const FormattedDateParts: React.FC<FormatDateOptions & {
|
|
38
35
|
value: Parameters<Intl.DateTimeFormat['format']>[0] | string;
|
|
@@ -42,6 +39,6 @@ export declare const FormattedTimeParts: React.FC<FormatDateOptions & {
|
|
|
42
39
|
value: Parameters<Intl.DateTimeFormat['format']>[0] | string;
|
|
43
40
|
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
|
|
44
41
|
}>;
|
|
45
|
-
export { FormattedNumberParts, FormattedListParts, } from './src/components/createFormattedComponent';
|
|
46
42
|
export type { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
|
|
47
43
|
export type { PrimitiveType } from 'intl-messageformat';
|
|
44
|
+
export { FormattedListParts, FormattedNumberParts, } from './src/components/createFormattedComponent';
|
package/index.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FormattedNumberParts = exports.FormattedListParts = exports.FormattedTimeParts = exports.FormattedDateParts = exports.FormattedDisplayName = exports.FormattedList = exports.FormattedNumber = exports.FormattedTime = exports.FormattedDate = exports.useIntl = exports.RawIntlProvider = exports.IntlProvider = exports.IntlContext = exports.injectIntl = exports.FormattedRelativeTime = exports.FormattedPlural = exports.FormattedMessage = exports.FormattedDateTimeRange = exports.createIntl = exports.UnsupportedFormatterError = exports.ReactIntlErrorCode = exports.ReactIntlError = exports.MissingTranslationError = exports.MissingDataError = exports.MessageFormatError = exports.InvalidConfigError = exports.createIntlCache = void 0;
|
|
4
4
|
exports.defineMessages = defineMessages;
|
|
5
5
|
exports.defineMessage = defineMessage;
|
|
6
6
|
var tslib_1 = require("tslib");
|
|
7
7
|
var createFormattedComponent_1 = require("./src/components/createFormattedComponent");
|
|
8
|
+
var createIntl_1 = require("./src/components/createIntl");
|
|
9
|
+
Object.defineProperty(exports, "createIntl", { enumerable: true, get: function () { return createIntl_1.createIntl; } });
|
|
10
|
+
var dateTimeRange_1 = tslib_1.__importDefault(require("./src/components/dateTimeRange"));
|
|
11
|
+
exports.FormattedDateTimeRange = dateTimeRange_1.default;
|
|
8
12
|
var injectIntl_1 = tslib_1.__importStar(require("./src/components/injectIntl"));
|
|
9
13
|
exports.injectIntl = injectIntl_1.default;
|
|
10
|
-
Object.defineProperty(exports, "RawIntlProvider", { enumerable: true, get: function () { return injectIntl_1.Provider; } });
|
|
11
14
|
Object.defineProperty(exports, "IntlContext", { enumerable: true, get: function () { return injectIntl_1.Context; } });
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
Object.defineProperty(exports, "RawIntlProvider", { enumerable: true, get: function () { return injectIntl_1.Provider; } });
|
|
16
|
+
var message_1 = tslib_1.__importDefault(require("./src/components/message"));
|
|
17
|
+
exports.FormattedMessage = message_1.default;
|
|
18
|
+
var plural_1 = tslib_1.__importDefault(require("./src/components/plural"));
|
|
19
|
+
exports.FormattedPlural = plural_1.default;
|
|
14
20
|
var provider_1 = tslib_1.__importDefault(require("./src/components/provider"));
|
|
15
21
|
exports.IntlProvider = provider_1.default;
|
|
16
|
-
var createIntl_1 = require("./src/components/createIntl");
|
|
17
|
-
Object.defineProperty(exports, "createIntl", { enumerable: true, get: function () { return createIntl_1.createIntl; } });
|
|
18
22
|
var relative_1 = tslib_1.__importDefault(require("./src/components/relative"));
|
|
19
23
|
exports.FormattedRelativeTime = relative_1.default;
|
|
20
|
-
var
|
|
21
|
-
exports.
|
|
22
|
-
var message_1 = tslib_1.__importDefault(require("./src/components/message"));
|
|
23
|
-
exports.FormattedMessage = message_1.default;
|
|
24
|
-
var dateTimeRange_1 = tslib_1.__importDefault(require("./src/components/dateTimeRange"));
|
|
25
|
-
exports.FormattedDateTimeRange = dateTimeRange_1.default;
|
|
24
|
+
var useIntl_1 = tslib_1.__importDefault(require("./src/components/useIntl"));
|
|
25
|
+
exports.useIntl = useIntl_1.default;
|
|
26
26
|
var intl_1 = require("@formatjs/intl");
|
|
27
27
|
Object.defineProperty(exports, "createIntlCache", { enumerable: true, get: function () { return intl_1.createIntlCache; } });
|
|
28
|
-
Object.defineProperty(exports, "UnsupportedFormatterError", { enumerable: true, get: function () { return intl_1.UnsupportedFormatterError; } });
|
|
29
28
|
Object.defineProperty(exports, "InvalidConfigError", { enumerable: true, get: function () { return intl_1.InvalidConfigError; } });
|
|
30
|
-
Object.defineProperty(exports, "MissingDataError", { enumerable: true, get: function () { return intl_1.MissingDataError; } });
|
|
31
29
|
Object.defineProperty(exports, "MessageFormatError", { enumerable: true, get: function () { return intl_1.MessageFormatError; } });
|
|
30
|
+
Object.defineProperty(exports, "MissingDataError", { enumerable: true, get: function () { return intl_1.MissingDataError; } });
|
|
32
31
|
Object.defineProperty(exports, "MissingTranslationError", { enumerable: true, get: function () { return intl_1.MissingTranslationError; } });
|
|
33
|
-
Object.defineProperty(exports, "ReactIntlErrorCode", { enumerable: true, get: function () { return intl_1.IntlErrorCode; } });
|
|
34
32
|
Object.defineProperty(exports, "ReactIntlError", { enumerable: true, get: function () { return intl_1.IntlError; } });
|
|
33
|
+
Object.defineProperty(exports, "ReactIntlErrorCode", { enumerable: true, get: function () { return intl_1.IntlErrorCode; } });
|
|
34
|
+
Object.defineProperty(exports, "UnsupportedFormatterError", { enumerable: true, get: function () { return intl_1.UnsupportedFormatterError; } });
|
|
35
35
|
function defineMessages(msgs) {
|
|
36
36
|
return msgs;
|
|
37
37
|
}
|
|
@@ -47,5 +47,5 @@ exports.FormattedDisplayName = (0, createFormattedComponent_1.createFormattedCom
|
|
|
47
47
|
exports.FormattedDateParts = (0, createFormattedComponent_1.createFormattedDateTimePartsComponent)('formatDate');
|
|
48
48
|
exports.FormattedTimeParts = (0, createFormattedComponent_1.createFormattedDateTimePartsComponent)('formatTime');
|
|
49
49
|
var createFormattedComponent_2 = require("./src/components/createFormattedComponent");
|
|
50
|
-
Object.defineProperty(exports, "FormattedNumberParts", { enumerable: true, get: function () { return createFormattedComponent_2.FormattedNumberParts; } });
|
|
51
50
|
Object.defineProperty(exports, "FormattedListParts", { enumerable: true, get: function () { return createFormattedComponent_2.FormattedListParts; } });
|
|
51
|
+
Object.defineProperty(exports, "FormattedNumberParts", { enumerable: true, get: function () { return createFormattedComponent_2.FormattedNumberParts; } });
|
package/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
+
import { CustomFormatConfig, FormatDateOptions, MessageDescriptor } from '@formatjs/intl';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import { MessageDescriptor, CustomFormatConfig, FormatDateOptions } from '@formatjs/intl';
|
|
3
|
-
import { IntlListFormatOptions } from '@formatjs/intl-listformat';
|
|
4
|
-
import { DisplayNamesOptions } from '@formatjs/intl-displaynames';
|
|
5
|
-
import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
|
|
6
|
-
import injectIntl, { Provider as RawIntlProvider, Context as IntlContext, WithIntlProps, WrappedComponentProps } from './src/components/injectIntl';
|
|
7
|
-
import useIntl from './src/components/useIntl';
|
|
8
|
-
import IntlProvider from './src/components/provider';
|
|
9
3
|
import { createIntl } from './src/components/createIntl';
|
|
10
|
-
import FormattedRelativeTime from './src/components/relative';
|
|
11
|
-
import FormattedPlural from './src/components/plural';
|
|
12
|
-
import FormattedMessage from './src/components/message';
|
|
13
4
|
import FormattedDateTimeRange from './src/components/dateTimeRange';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
import injectIntl, { Context as IntlContext, Provider as RawIntlProvider, WithIntlProps, WrappedComponentProps } from './src/components/injectIntl';
|
|
6
|
+
import FormattedMessage from './src/components/message';
|
|
7
|
+
import FormattedPlural from './src/components/plural';
|
|
8
|
+
import IntlProvider from './src/components/provider';
|
|
9
|
+
import FormattedRelativeTime from './src/components/relative';
|
|
10
|
+
import useIntl from './src/components/useIntl';
|
|
11
|
+
export { createIntlCache, CustomFormatConfig, CustomFormats, FormatDateOptions, FormatDisplayNameOptions, FormatListOptions, FormatNumberOptions, FormatPluralOptions, FormatRelativeTimeOptions, Formatters, IntlCache, IntlFormatters, InvalidConfigError, MessageDescriptor, MessageFormatError, MissingDataError, MissingTranslationError, IntlError as ReactIntlError, IntlErrorCode as ReactIntlErrorCode, UnsupportedFormatterError, } from '@formatjs/intl';
|
|
12
|
+
export { IntlConfig, IntlShape, ResolvedIntlConfig } from './src/types';
|
|
13
|
+
export { createIntl, FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, injectIntl, IntlContext, IntlProvider, RawIntlProvider, useIntl, WithIntlProps, WrappedComponentProps, };
|
|
17
14
|
export declare function defineMessages<K extends keyof any, T = MessageDescriptor, U extends Record<K, T> = Record<K, T>>(msgs: U): U;
|
|
18
15
|
export declare function defineMessage<T extends MessageDescriptor>(msg: T): T;
|
|
19
16
|
export declare const FormattedDate: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig & {
|
|
@@ -24,15 +21,15 @@ export declare const FormattedTime: React.FC<Intl.DateTimeFormatOptions & Custom
|
|
|
24
21
|
value: string | number | Date | undefined;
|
|
25
22
|
children?(formattedTime: string): React.ReactElement | null;
|
|
26
23
|
}>;
|
|
27
|
-
export declare const FormattedNumber: React.FC<Omit<NumberFormatOptions, 'localeMatcher'> & CustomFormatConfig<'number'> & {
|
|
24
|
+
export declare const FormattedNumber: React.FC<Omit<Intl.NumberFormatOptions, 'localeMatcher'> & CustomFormatConfig<'number'> & {
|
|
28
25
|
value: number;
|
|
29
26
|
children?(formattedNumber: string): React.ReactElement | null;
|
|
30
27
|
}>;
|
|
31
|
-
export declare const FormattedList: React.FC<
|
|
28
|
+
export declare const FormattedList: React.FC<Intl.ListFormatOptions & {
|
|
32
29
|
value: readonly React.ReactNode[];
|
|
33
30
|
}>;
|
|
34
|
-
export declare const FormattedDisplayName: React.FC<DisplayNamesOptions & {
|
|
35
|
-
value: string
|
|
31
|
+
export declare const FormattedDisplayName: React.FC<Intl.DisplayNamesOptions & {
|
|
32
|
+
value: string;
|
|
36
33
|
}>;
|
|
37
34
|
export declare const FormattedDateParts: React.FC<FormatDateOptions & {
|
|
38
35
|
value: Parameters<Intl.DateTimeFormat['format']>[0] | string;
|
|
@@ -42,6 +39,6 @@ export declare const FormattedTimeParts: React.FC<FormatDateOptions & {
|
|
|
42
39
|
value: Parameters<Intl.DateTimeFormat['format']>[0] | string;
|
|
43
40
|
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
|
|
44
41
|
}>;
|
|
45
|
-
export { FormattedNumberParts, FormattedListParts, } from './src/components/createFormattedComponent';
|
|
46
42
|
export type { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
|
|
47
43
|
export type { PrimitiveType } from 'intl-messageformat';
|
|
44
|
+
export { FormattedListParts, FormattedNumberParts, } from './src/components/createFormattedComponent';
|
package/lib/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createFormattedComponent, createFormattedDateTimePartsComponent, } from './src/components/createFormattedComponent';
|
|
2
|
-
import injectIntl, { Provider as RawIntlProvider, Context as IntlContext, } from './src/components/injectIntl';
|
|
3
|
-
import useIntl from './src/components/useIntl';
|
|
4
|
-
import IntlProvider from './src/components/provider';
|
|
5
2
|
import { createIntl } from './src/components/createIntl';
|
|
6
|
-
import FormattedRelativeTime from './src/components/relative';
|
|
7
|
-
import FormattedPlural from './src/components/plural';
|
|
8
|
-
import FormattedMessage from './src/components/message';
|
|
9
3
|
import FormattedDateTimeRange from './src/components/dateTimeRange';
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import injectIntl, { Context as IntlContext, Provider as RawIntlProvider, } from './src/components/injectIntl';
|
|
5
|
+
import FormattedMessage from './src/components/message';
|
|
6
|
+
import FormattedPlural from './src/components/plural';
|
|
7
|
+
import IntlProvider from './src/components/provider';
|
|
8
|
+
import FormattedRelativeTime from './src/components/relative';
|
|
9
|
+
import useIntl from './src/components/useIntl';
|
|
10
|
+
export { createIntlCache, InvalidConfigError, MessageFormatError, MissingDataError, MissingTranslationError, IntlError as ReactIntlError, IntlErrorCode as ReactIntlErrorCode, UnsupportedFormatterError, } from '@formatjs/intl';
|
|
11
|
+
export { createIntl, FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, injectIntl, IntlContext, IntlProvider, RawIntlProvider, useIntl, };
|
|
12
12
|
export function defineMessages(msgs) {
|
|
13
13
|
return msgs;
|
|
14
14
|
}
|
|
@@ -23,4 +23,4 @@ export var FormattedList = createFormattedComponent('formatList');
|
|
|
23
23
|
export var FormattedDisplayName = createFormattedComponent('formatDisplayName');
|
|
24
24
|
export var FormattedDateParts = createFormattedDateTimePartsComponent('formatDate');
|
|
25
25
|
export var FormattedTimeParts = createFormattedDateTimePartsComponent('formatTime');
|
|
26
|
-
export {
|
|
26
|
+
export { FormattedListParts, FormattedNumberParts, } from './src/components/createFormattedComponent';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { FormatDateOptions, FormatDisplayNameOptions, FormatListOptions, FormatNumberOptions } from '@formatjs/intl';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import { FormatDateOptions, FormatNumberOptions, FormatListOptions, FormatDisplayNameOptions } from '@formatjs/intl';
|
|
3
3
|
import { IntlShape } from '../types';
|
|
4
|
-
import { Part } from '@formatjs/intl-listformat';
|
|
5
4
|
type Formatter = {
|
|
6
5
|
formatDate: FormatDateOptions;
|
|
7
6
|
formatTime: FormatDateOptions;
|
|
@@ -15,7 +14,7 @@ export declare const FormattedNumberParts: React.FC<Formatter['formatNumber'] &
|
|
|
15
14
|
}>;
|
|
16
15
|
export declare const FormattedListParts: React.FC<Formatter['formatList'] & {
|
|
17
16
|
value: Parameters<IntlShape['formatList']>[0];
|
|
18
|
-
children(val:
|
|
17
|
+
children(val: ReturnType<Intl.ListFormat['formatToParts']>): React.ReactElement | null;
|
|
19
18
|
}>;
|
|
20
19
|
export declare function createFormattedDateTimePartsComponent<Name extends 'formatDate' | 'formatTime'>(name: Name): React.FC<Formatter[Name] & {
|
|
21
20
|
value: Parameters<IntlShape[Name]>[0];
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { __assign, __rest, __spreadArray } from "tslib";
|
|
7
7
|
import { createIntl as coreCreateIntl, formatMessage as coreFormatMessage, } from '@formatjs/intl';
|
|
8
|
+
import { isFormatXMLElementFn, } from 'intl-messageformat';
|
|
8
9
|
import * as React from 'react';
|
|
9
10
|
import { DEFAULT_INTL_CONFIG, assignUniqueKeysToParts } from '../utils';
|
|
10
|
-
import { isFormatXMLElementFn, } from 'intl-messageformat';
|
|
11
11
|
function assignUniqueKeysToFormatXMLElementFnArgument(values) {
|
|
12
12
|
if (!values) {
|
|
13
13
|
return values;
|
|
@@ -55,9 +55,5 @@ export var createIntl = function (_a, cache) {
|
|
|
55
55
|
onError: coreIntl.onError,
|
|
56
56
|
defaultRichTextElements: defaultRichTextElements,
|
|
57
57
|
};
|
|
58
|
-
return __assign(__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, resolvedConfig,
|
|
59
|
-
// @ts-expect-error fix this
|
|
60
|
-
coreIntl.formatters),
|
|
61
|
-
// @ts-expect-error fix this
|
|
62
|
-
$t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
|
|
58
|
+
return __assign(__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, resolvedConfig, coreIntl.formatters), $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
|
|
63
59
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { FormatDateOptions } from '@formatjs/intl';
|
|
3
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
4
3
|
interface Props extends FormatDateOptions {
|
|
5
|
-
from: Parameters<DateTimeFormat['formatRange']>[0];
|
|
6
|
-
to: Parameters<DateTimeFormat['formatRange']>[1];
|
|
4
|
+
from: Parameters<Intl.DateTimeFormat['formatRange']>[0];
|
|
5
|
+
to: Parameters<Intl.DateTimeFormat['formatRange']>[1];
|
|
7
6
|
children?(value: React.ReactNode): React.ReactElement | null;
|
|
8
7
|
}
|
|
9
8
|
declare const FormattedDateTimeRange: React.FC<Props>;
|
|
@@ -19,7 +19,7 @@ interface State {
|
|
|
19
19
|
}
|
|
20
20
|
export default class IntlProvider extends React.PureComponent<React.PropsWithChildren<IntlConfig>, State> {
|
|
21
21
|
static displayName: string;
|
|
22
|
-
static defaultProps: Pick<import("../types").ResolvedIntlConfig, "timeZone" | "
|
|
22
|
+
static defaultProps: Pick<import("../types").ResolvedIntlConfig, "timeZone" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "onError" | "textComponent">;
|
|
23
23
|
private cache;
|
|
24
24
|
state: State;
|
|
25
25
|
static getDerivedStateFromProps(props: Readonly<IntlConfig>, { prevConfig, cache }: State): Partial<State> | null;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { RelativeTimeFormatSingularUnit } from '@formatjs/ecma402-abstract';
|
|
3
2
|
import { FormatRelativeTimeOptions } from '@formatjs/intl';
|
|
4
3
|
export interface Props extends FormatRelativeTimeOptions {
|
|
5
4
|
value?: number;
|
|
6
|
-
unit?:
|
|
5
|
+
unit?: Intl.RelativeTimeFormatUnit;
|
|
7
6
|
updateIntervalInSeconds?: number;
|
|
8
7
|
children?(value: string): React.ReactElement | null;
|
|
9
8
|
}
|
|
@@ -5,7 +5,7 @@ import { __assign, __rest } from "tslib";
|
|
|
5
5
|
* See the accompanying LICENSE file for terms.
|
|
6
6
|
*/
|
|
7
7
|
import * as React from 'react';
|
|
8
|
-
import { invariant
|
|
8
|
+
import { invariant } from '../utils';
|
|
9
9
|
import useIntl from './useIntl';
|
|
10
10
|
var MINUTE = 60;
|
|
11
11
|
var HOUR = 60 * 60;
|
package/lib/src/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ResolvedIntlConfig } from './types';
|
|
2
|
-
import * as React from 'react';
|
|
3
1
|
import { FormatXMLElementFn } from 'intl-messageformat';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ResolvedIntlConfig } from './types';
|
|
4
|
+
export declare function invariant(condition: boolean, message: string, Err?: any): asserts condition;
|
|
4
5
|
export declare function invariantIntlContext(intl?: any): asserts intl;
|
|
5
6
|
export declare const DEFAULT_INTL_CONFIG: Pick<ResolvedIntlConfig, 'fallbackOnEmptyString' | 'formats' | 'messages' | 'timeZone' | 'textComponent' | 'defaultLocale' | 'defaultFormats' | 'onError'>;
|
|
6
7
|
/**
|
package/lib/src/utils.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { invariant } from '@formatjs/ecma402-abstract';
|
|
4
3
|
import { DEFAULT_INTL_CONFIG as CORE_DEFAULT_INTL_CONFIG } from '@formatjs/intl';
|
|
4
|
+
export function invariant(condition, message, Err) {
|
|
5
|
+
if (Err === void 0) { Err = Error; }
|
|
6
|
+
if (!condition) {
|
|
7
|
+
throw new Err(message);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
5
10
|
export function invariantIntlContext(intl) {
|
|
6
11
|
invariant(intl, '[React Intl] Could not find required `intl` object. ' +
|
|
7
12
|
'<IntlProvider> needs to exist in the component ancestry.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intl",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.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",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"zouxuoz <zouxuoz@gmail.com>"
|
|
116
116
|
],
|
|
117
117
|
"license": "BSD-3-Clause",
|
|
118
|
-
"homepage": "https://formatjs.io/docs/react-intl",
|
|
118
|
+
"homepage": "https://formatjs.github.io/docs/react-intl",
|
|
119
119
|
"bugs": {
|
|
120
120
|
"url": "https://github.com/formatjs/formatjs/issues"
|
|
121
121
|
},
|
|
@@ -132,20 +132,13 @@
|
|
|
132
132
|
"@types/react": "16 || 17 || 18",
|
|
133
133
|
"hoist-non-react-statics": "3",
|
|
134
134
|
"tslib": "2",
|
|
135
|
-
"
|
|
136
|
-
"@formatjs/intl": "2.10.15",
|
|
137
|
-
"@formatjs/intl-displaynames": "6.8.5",
|
|
135
|
+
"intl-messageformat": "10.7.7",
|
|
138
136
|
"@formatjs/icu-messageformat-parser": "2.9.4",
|
|
139
|
-
"@formatjs/intl
|
|
140
|
-
"intl-messageformat": "10.7.7"
|
|
141
|
-
},
|
|
142
|
-
"devDependencies": {
|
|
143
|
-
"@formatjs/intl-relativetimeformat": "11.4.5",
|
|
144
|
-
"@formatjs/intl-numberformat": "8.14.5"
|
|
137
|
+
"@formatjs/intl": "3.0.1"
|
|
145
138
|
},
|
|
146
139
|
"peerDependencies": {
|
|
147
140
|
"react": "^16.6.0 || 17 || 18",
|
|
148
|
-
"typescript": "
|
|
141
|
+
"typescript": "5"
|
|
149
142
|
},
|
|
150
143
|
"peerDependenciesMeta": {
|
|
151
144
|
"typescript": {
|
package/react-intl.iife.js
CHANGED
|
@@ -288,7 +288,7 @@ var ReactIntl = (() => {
|
|
|
288
288
|
}
|
|
289
289
|
return TYPE_STATICS[component["$$typeof"]] || REACT_STATICS;
|
|
290
290
|
}
|
|
291
|
-
var
|
|
291
|
+
var defineProperty = Object.defineProperty;
|
|
292
292
|
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
293
293
|
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
294
294
|
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
@@ -313,7 +313,7 @@ var ReactIntl = (() => {
|
|
|
313
313
|
if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
|
314
314
|
var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
|
315
315
|
try {
|
|
316
|
-
|
|
316
|
+
defineProperty(targetComponent, key, descriptor);
|
|
317
317
|
} catch (e) {
|
|
318
318
|
}
|
|
319
319
|
}
|
|
@@ -368,64 +368,6 @@ var ReactIntl = (() => {
|
|
|
368
368
|
// packages/react-intl/src/utils.ts
|
|
369
369
|
var React = __toESM(window.React);
|
|
370
370
|
|
|
371
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/262.js
|
|
372
|
-
var MINUTES_PER_HOUR = 60;
|
|
373
|
-
var SECONDS_PER_MINUTE = 60;
|
|
374
|
-
var MS_PER_SECOND = 1e3;
|
|
375
|
-
var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
|
|
376
|
-
var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
|
|
377
|
-
|
|
378
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/IsSanctionedSimpleUnitIdentifier.js
|
|
379
|
-
var SANCTIONED_UNITS = [
|
|
380
|
-
"angle-degree",
|
|
381
|
-
"area-acre",
|
|
382
|
-
"area-hectare",
|
|
383
|
-
"concentr-percent",
|
|
384
|
-
"digital-bit",
|
|
385
|
-
"digital-byte",
|
|
386
|
-
"digital-gigabit",
|
|
387
|
-
"digital-gigabyte",
|
|
388
|
-
"digital-kilobit",
|
|
389
|
-
"digital-kilobyte",
|
|
390
|
-
"digital-megabit",
|
|
391
|
-
"digital-megabyte",
|
|
392
|
-
"digital-petabyte",
|
|
393
|
-
"digital-terabit",
|
|
394
|
-
"digital-terabyte",
|
|
395
|
-
"duration-day",
|
|
396
|
-
"duration-hour",
|
|
397
|
-
"duration-millisecond",
|
|
398
|
-
"duration-minute",
|
|
399
|
-
"duration-month",
|
|
400
|
-
"duration-second",
|
|
401
|
-
"duration-week",
|
|
402
|
-
"duration-year",
|
|
403
|
-
"length-centimeter",
|
|
404
|
-
"length-foot",
|
|
405
|
-
"length-inch",
|
|
406
|
-
"length-kilometer",
|
|
407
|
-
"length-meter",
|
|
408
|
-
"length-mile-scandinavian",
|
|
409
|
-
"length-mile",
|
|
410
|
-
"length-millimeter",
|
|
411
|
-
"length-yard",
|
|
412
|
-
"mass-gram",
|
|
413
|
-
"mass-kilogram",
|
|
414
|
-
"mass-ounce",
|
|
415
|
-
"mass-pound",
|
|
416
|
-
"mass-stone",
|
|
417
|
-
"temperature-celsius",
|
|
418
|
-
"temperature-fahrenheit",
|
|
419
|
-
"volume-fluid-ounce",
|
|
420
|
-
"volume-gallon",
|
|
421
|
-
"volume-liter",
|
|
422
|
-
"volume-milliliter"
|
|
423
|
-
];
|
|
424
|
-
function removeUnitNamespace(unit) {
|
|
425
|
-
return unit.slice(unit.indexOf("-") + 1);
|
|
426
|
-
}
|
|
427
|
-
var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
|
|
428
|
-
|
|
429
371
|
// node_modules/.aspect_rules_js/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
|
|
430
372
|
var extendStatics = function(d, b) {
|
|
431
373
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
@@ -549,95 +491,6 @@ var ReactIntl = (() => {
|
|
|
549
491
|
monadic: strategyMonadic
|
|
550
492
|
};
|
|
551
493
|
|
|
552
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/utils.js
|
|
553
|
-
function invariant(condition, message, Err) {
|
|
554
|
-
if (Err === void 0) {
|
|
555
|
-
Err = Error;
|
|
556
|
-
}
|
|
557
|
-
if (!condition) {
|
|
558
|
-
throw new Err(message);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
var createMemoizedNumberFormat = memoize(function() {
|
|
562
|
-
var _a2;
|
|
563
|
-
var args = [];
|
|
564
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
565
|
-
args[_i] = arguments[_i];
|
|
566
|
-
}
|
|
567
|
-
return new ((_a2 = Intl.NumberFormat).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
568
|
-
}, {
|
|
569
|
-
strategy: strategies.variadic
|
|
570
|
-
});
|
|
571
|
-
var createMemoizedDateTimeFormat = memoize(function() {
|
|
572
|
-
var _a2;
|
|
573
|
-
var args = [];
|
|
574
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
575
|
-
args[_i] = arguments[_i];
|
|
576
|
-
}
|
|
577
|
-
return new ((_a2 = Intl.DateTimeFormat).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
578
|
-
}, {
|
|
579
|
-
strategy: strategies.variadic
|
|
580
|
-
});
|
|
581
|
-
var createMemoizedPluralRules = memoize(function() {
|
|
582
|
-
var _a2;
|
|
583
|
-
var args = [];
|
|
584
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
585
|
-
args[_i] = arguments[_i];
|
|
586
|
-
}
|
|
587
|
-
return new ((_a2 = Intl.PluralRules).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
588
|
-
}, {
|
|
589
|
-
strategy: strategies.variadic
|
|
590
|
-
});
|
|
591
|
-
var createMemoizedLocale = memoize(function() {
|
|
592
|
-
var _a2;
|
|
593
|
-
var args = [];
|
|
594
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
595
|
-
args[_i] = arguments[_i];
|
|
596
|
-
}
|
|
597
|
-
return new ((_a2 = Intl.Locale).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
598
|
-
}, {
|
|
599
|
-
strategy: strategies.variadic
|
|
600
|
-
});
|
|
601
|
-
var createMemoizedListFormat = memoize(function() {
|
|
602
|
-
var _a2;
|
|
603
|
-
var args = [];
|
|
604
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
605
|
-
args[_i] = arguments[_i];
|
|
606
|
-
}
|
|
607
|
-
return new ((_a2 = Intl.ListFormat).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
608
|
-
}, {
|
|
609
|
-
strategy: strategies.variadic
|
|
610
|
-
});
|
|
611
|
-
|
|
612
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/regex.generated.js
|
|
613
|
-
var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
|
|
614
|
-
|
|
615
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/format_to_parts.js
|
|
616
|
-
var CARET_S_UNICODE_REGEX = new RegExp("^".concat(S_UNICODE_REGEX.source));
|
|
617
|
-
var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(S_UNICODE_REGEX.source, "$"));
|
|
618
|
-
|
|
619
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/data.js
|
|
620
|
-
var MissingLocaleDataError = (
|
|
621
|
-
/** @class */
|
|
622
|
-
function(_super) {
|
|
623
|
-
__extends(MissingLocaleDataError2, _super);
|
|
624
|
-
function MissingLocaleDataError2() {
|
|
625
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
626
|
-
_this.type = "MISSING_LOCALE_DATA";
|
|
627
|
-
return _this;
|
|
628
|
-
}
|
|
629
|
-
return MissingLocaleDataError2;
|
|
630
|
-
}(Error)
|
|
631
|
-
);
|
|
632
|
-
|
|
633
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/types/date-time.js
|
|
634
|
-
var RangePatternType;
|
|
635
|
-
(function(RangePatternType2) {
|
|
636
|
-
RangePatternType2["startRange"] = "startRange";
|
|
637
|
-
RangePatternType2["shared"] = "shared";
|
|
638
|
-
RangePatternType2["endRange"] = "endRange";
|
|
639
|
-
})(RangePatternType || (RangePatternType = {}));
|
|
640
|
-
|
|
641
494
|
// node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/lib/error.js
|
|
642
495
|
var ErrorKind;
|
|
643
496
|
(function(ErrorKind2) {
|
|
@@ -3512,7 +3365,7 @@ var ReactIntl = (() => {
|
|
|
3512
3365
|
function isFormatXMLElementFn(el) {
|
|
3513
3366
|
return typeof el === "function";
|
|
3514
3367
|
}
|
|
3515
|
-
function
|
|
3368
|
+
function formatToParts(els, locales, formatters, formats, values, currentPluralValue, originalMessage) {
|
|
3516
3369
|
if (els.length === 1 && isLiteralElement(els[0])) {
|
|
3517
3370
|
return [
|
|
3518
3371
|
{
|
|
@@ -3588,7 +3441,7 @@ var ReactIntl = (() => {
|
|
|
3588
3441
|
if (!isFormatXMLElementFn(formatFn)) {
|
|
3589
3442
|
throw new InvalidValueTypeError(value_1, "function", originalMessage);
|
|
3590
3443
|
}
|
|
3591
|
-
var parts =
|
|
3444
|
+
var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
|
|
3592
3445
|
var chunks = formatFn(parts.map(function(p) {
|
|
3593
3446
|
return p.value;
|
|
3594
3447
|
}));
|
|
@@ -3607,7 +3460,7 @@ var ReactIntl = (() => {
|
|
|
3607
3460
|
if (!opt) {
|
|
3608
3461
|
throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
|
|
3609
3462
|
}
|
|
3610
|
-
result.push.apply(result,
|
|
3463
|
+
result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
|
|
3611
3464
|
continue;
|
|
3612
3465
|
}
|
|
3613
3466
|
if (isPluralElement(el)) {
|
|
@@ -3622,7 +3475,7 @@ var ReactIntl = (() => {
|
|
|
3622
3475
|
if (!opt) {
|
|
3623
3476
|
throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
|
|
3624
3477
|
}
|
|
3625
|
-
result.push.apply(result,
|
|
3478
|
+
result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
|
|
3626
3479
|
continue;
|
|
3627
3480
|
}
|
|
3628
3481
|
}
|
|
@@ -3738,7 +3591,7 @@ var ReactIntl = (() => {
|
|
|
3738
3591
|
return result;
|
|
3739
3592
|
};
|
|
3740
3593
|
this.formatToParts = function(values) {
|
|
3741
|
-
return
|
|
3594
|
+
return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, void 0, _this.message);
|
|
3742
3595
|
};
|
|
3743
3596
|
this.resolvedOptions = function() {
|
|
3744
3597
|
var _a3;
|
|
@@ -3950,6 +3803,14 @@ var ReactIntl = (() => {
|
|
|
3950
3803
|
);
|
|
3951
3804
|
|
|
3952
3805
|
// node_modules/.aspect_rules_js/@formatjs+intl@0.0.0/node_modules/@formatjs/intl/lib/src/utils.js
|
|
3806
|
+
function invariant(condition, message, Err) {
|
|
3807
|
+
if (Err === void 0) {
|
|
3808
|
+
Err = Error;
|
|
3809
|
+
}
|
|
3810
|
+
if (!condition) {
|
|
3811
|
+
throw new Err(message);
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3953
3814
|
function filterProps(props, allowlist, defaults) {
|
|
3954
3815
|
if (defaults === void 0) {
|
|
3955
3816
|
defaults = {};
|
|
@@ -4133,7 +3994,7 @@ var ReactIntl = (() => {
|
|
|
4133
3994
|
messageDescriptor = { id: "" };
|
|
4134
3995
|
}
|
|
4135
3996
|
var msgId = messageDescriptor.id, defaultMessage = messageDescriptor.defaultMessage;
|
|
4136
|
-
invariant(!!msgId, "[@formatjs/intl] An `id` must be provided to format a message. You can either:\n1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.io/docs/tooling/babel-plugin)\nor [@formatjs/ts-transformer](https://formatjs.io/docs/tooling/ts-transformer) OR\n2. Configure your `eslint` config to include [eslint-plugin-formatjs](https://formatjs.io/docs/tooling/linter#enforce-id)\nto autofix this issue");
|
|
3997
|
+
invariant(!!msgId, "[@formatjs/intl] An `id` must be provided to format a message. You can either:\n1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.github.io/docs/tooling/babel-plugin)\nor [@formatjs/ts-transformer](https://formatjs.github.io/docs/tooling/ts-transformer) OR\n2. Configure your `eslint` config to include [eslint-plugin-formatjs](https://formatjs.github.io/docs/tooling/linter#enforce-id)\nto autofix this issue");
|
|
4137
3998
|
var id = String(msgId);
|
|
4138
3999
|
var message = (
|
|
4139
4000
|
// In case messages is Object.create(null)
|
|
@@ -4446,9 +4307,13 @@ var ReactIntl = (() => {
|
|
|
4446
4307
|
"unitDisplay",
|
|
4447
4308
|
"numberingSystem",
|
|
4448
4309
|
// ES2023 NumberFormat
|
|
4310
|
+
// @ts-expect-error: TypeScript doesn't know about this yet
|
|
4449
4311
|
"trailingZeroDisplay",
|
|
4312
|
+
// @ts-expect-error: TypeScript doesn't know about this yet
|
|
4450
4313
|
"roundingPriority",
|
|
4314
|
+
// @ts-expect-error: TypeScript doesn't know about this yet
|
|
4451
4315
|
"roundingIncrement",
|
|
4316
|
+
// @ts-expect-error: TypeScript doesn't know about this yet
|
|
4452
4317
|
"roundingMode"
|
|
4453
4318
|
];
|
|
4454
4319
|
function getFormatter3(_a2, getNumberFormat, options) {
|
|
@@ -4491,7 +4356,7 @@ var ReactIntl = (() => {
|
|
|
4491
4356
|
}
|
|
4492
4357
|
function verifyConfigMessages(config) {
|
|
4493
4358
|
if (config.onWarn && config.defaultRichTextElements && messagesContainString(config.messages || {})) {
|
|
4494
|
-
config.onWarn('[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled. \nPlease consider using "@formatjs/cli" to pre-compile your messages for performance.\nFor more details see https://formatjs.io/docs/getting-started/message-distribution');
|
|
4359
|
+
config.onWarn('[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled. \nPlease consider using "@formatjs/cli" to pre-compile your messages for performance.\nFor more details see https://formatjs.github.io/docs/getting-started/message-distribution');
|
|
4495
4360
|
}
|
|
4496
4361
|
}
|
|
4497
4362
|
function createIntl(config, cache) {
|
|
@@ -4500,39 +4365,26 @@ var ReactIntl = (() => {
|
|
|
4500
4365
|
var locale = resolvedConfig.locale, defaultLocale = resolvedConfig.defaultLocale, onError = resolvedConfig.onError;
|
|
4501
4366
|
if (!locale) {
|
|
4502
4367
|
if (onError) {
|
|
4503
|
-
onError(new InvalidConfigError('"locale" was not configured, using "'.concat(defaultLocale, '" as fallback. See https://formatjs.io/docs/react-intl/api#intlshape for more details')));
|
|
4368
|
+
onError(new InvalidConfigError('"locale" was not configured, using "'.concat(defaultLocale, '" as fallback. See https://formatjs.github.io/docs/react-intl/api#intlshape for more details')));
|
|
4504
4369
|
}
|
|
4505
4370
|
resolvedConfig.locale = resolvedConfig.defaultLocale || "en";
|
|
4506
4371
|
} else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) {
|
|
4507
|
-
onError(new MissingDataError('Missing locale data for locale: "'.concat(locale, '" in Intl.NumberFormat. Using default locale: "').concat(defaultLocale, '" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details')));
|
|
4372
|
+
onError(new MissingDataError('Missing locale data for locale: "'.concat(locale, '" in Intl.NumberFormat. Using default locale: "').concat(defaultLocale, '" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details')));
|
|
4508
4373
|
} else if (!Intl.DateTimeFormat.supportedLocalesOf(locale).length && onError) {
|
|
4509
|
-
onError(new MissingDataError('Missing locale data for locale: "'.concat(locale, '" in Intl.DateTimeFormat. Using default locale: "').concat(defaultLocale, '" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details')));
|
|
4374
|
+
onError(new MissingDataError('Missing locale data for locale: "'.concat(locale, '" in Intl.DateTimeFormat. Using default locale: "').concat(defaultLocale, '" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details')));
|
|
4510
4375
|
}
|
|
4511
4376
|
verifyConfigMessages(resolvedConfig);
|
|
4512
|
-
return __assign(__assign({}, resolvedConfig), {
|
|
4513
|
-
formatters,
|
|
4514
|
-
formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat),
|
|
4515
|
-
formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat),
|
|
4516
|
-
formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat),
|
|
4517
|
-
formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
4518
|
-
formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
4519
|
-
formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
4520
|
-
formatDateTimeRange: formatDateTimeRange.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
4521
|
-
formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
4522
|
-
formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules),
|
|
4523
|
-
// @ts-expect-error TODO: will get to this later
|
|
4524
|
-
formatMessage: formatMessage.bind(null, resolvedConfig, formatters),
|
|
4525
|
-
// @ts-expect-error TODO: will get to this later
|
|
4526
|
-
$t: formatMessage.bind(null, resolvedConfig, formatters),
|
|
4527
|
-
formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat),
|
|
4528
|
-
formatListToParts: formatListToParts.bind(null, resolvedConfig, formatters.getListFormat),
|
|
4529
|
-
formatDisplayName: formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames)
|
|
4530
|
-
});
|
|
4377
|
+
return __assign(__assign({}, resolvedConfig), { formatters, formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateTimeRange: formatDateTimeRange.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules), formatMessage: formatMessage.bind(null, resolvedConfig, formatters), $t: formatMessage.bind(null, resolvedConfig, formatters), formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat), formatListToParts: formatListToParts.bind(null, resolvedConfig, formatters.getListFormat), formatDisplayName: formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames) });
|
|
4531
4378
|
}
|
|
4532
4379
|
|
|
4533
4380
|
// packages/react-intl/src/utils.ts
|
|
4381
|
+
function invariant2(condition, message, Err = Error) {
|
|
4382
|
+
if (!condition) {
|
|
4383
|
+
throw new Err(message);
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
4534
4386
|
function invariantIntlContext(intl) {
|
|
4535
|
-
|
|
4387
|
+
invariant2(
|
|
4536
4388
|
intl,
|
|
4537
4389
|
"[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry."
|
|
4538
4390
|
);
|
|
@@ -4670,9 +4522,6 @@ var ReactIntl = (() => {
|
|
|
4670
4522
|
return Component;
|
|
4671
4523
|
}
|
|
4672
4524
|
|
|
4673
|
-
// packages/react-intl/src/components/provider.tsx
|
|
4674
|
-
var React6 = __toESM(window.React);
|
|
4675
|
-
|
|
4676
4525
|
// packages/react-intl/src/components/createIntl.ts
|
|
4677
4526
|
var React5 = __toESM(window.React);
|
|
4678
4527
|
function assignUniqueKeysToFormatXMLElementFnArgument(values) {
|
|
@@ -4725,15 +4574,86 @@ var ReactIntl = (() => {
|
|
|
4725
4574
|
formatMessage: formatMessage2.bind(
|
|
4726
4575
|
null,
|
|
4727
4576
|
resolvedConfig,
|
|
4728
|
-
// @ts-expect-error fix this
|
|
4729
4577
|
coreIntl.formatters
|
|
4730
4578
|
),
|
|
4731
|
-
// @ts-expect-error fix this
|
|
4732
4579
|
$t: formatMessage2.bind(null, resolvedConfig, coreIntl.formatters)
|
|
4733
4580
|
});
|
|
4734
4581
|
};
|
|
4735
4582
|
|
|
4583
|
+
// packages/react-intl/src/components/dateTimeRange.tsx
|
|
4584
|
+
var React6 = __toESM(window.React);
|
|
4585
|
+
var FormattedDateTimeRange = (props) => {
|
|
4586
|
+
const intl = useIntl();
|
|
4587
|
+
const _a2 = props, { from, to, children } = _a2, formatProps = __objRest(_a2, ["from", "to", "children"]);
|
|
4588
|
+
const formattedValue = intl.formatDateTimeRange(from, to, formatProps);
|
|
4589
|
+
if (typeof children === "function") {
|
|
4590
|
+
return children(formattedValue);
|
|
4591
|
+
}
|
|
4592
|
+
const Text = intl.textComponent || React6.Fragment;
|
|
4593
|
+
return React6.createElement(Text, null, formattedValue);
|
|
4594
|
+
};
|
|
4595
|
+
FormattedDateTimeRange.displayName = "FormattedDateTimeRange";
|
|
4596
|
+
var dateTimeRange_default = FormattedDateTimeRange;
|
|
4597
|
+
|
|
4598
|
+
// packages/react-intl/src/components/message.tsx
|
|
4599
|
+
var React7 = __toESM(window.React);
|
|
4600
|
+
function areEqual(prevProps, nextProps) {
|
|
4601
|
+
const _a2 = prevProps, { values } = _a2, otherProps = __objRest(_a2, ["values"]);
|
|
4602
|
+
const _b = nextProps, { values: nextValues } = _b, nextOtherProps = __objRest(_b, ["values"]);
|
|
4603
|
+
return shallowEqual(nextValues, values) && shallowEqual(otherProps, nextOtherProps);
|
|
4604
|
+
}
|
|
4605
|
+
function FormattedMessage(props) {
|
|
4606
|
+
const intl = useIntl();
|
|
4607
|
+
const { formatMessage: formatMessage3, textComponent: Text = React7.Fragment } = intl;
|
|
4608
|
+
const {
|
|
4609
|
+
id,
|
|
4610
|
+
description,
|
|
4611
|
+
defaultMessage,
|
|
4612
|
+
values,
|
|
4613
|
+
children,
|
|
4614
|
+
tagName: Component = Text,
|
|
4615
|
+
ignoreTag
|
|
4616
|
+
} = props;
|
|
4617
|
+
const descriptor = { id, description, defaultMessage };
|
|
4618
|
+
let nodes = formatMessage3(descriptor, values, {
|
|
4619
|
+
ignoreTag
|
|
4620
|
+
});
|
|
4621
|
+
if (typeof children === "function") {
|
|
4622
|
+
return children(Array.isArray(nodes) ? nodes : [nodes]);
|
|
4623
|
+
}
|
|
4624
|
+
if (Component) {
|
|
4625
|
+
return React7.createElement(Component, null, React7.Children.toArray(nodes));
|
|
4626
|
+
}
|
|
4627
|
+
return React7.createElement(React7.Fragment, null, nodes);
|
|
4628
|
+
}
|
|
4629
|
+
FormattedMessage.displayName = "FormattedMessage";
|
|
4630
|
+
var MemoizedFormattedMessage = React7.memo(
|
|
4631
|
+
FormattedMessage,
|
|
4632
|
+
areEqual
|
|
4633
|
+
);
|
|
4634
|
+
MemoizedFormattedMessage.displayName = "MemoizedFormattedMessage";
|
|
4635
|
+
var message_default = MemoizedFormattedMessage;
|
|
4636
|
+
|
|
4637
|
+
// packages/react-intl/src/components/plural.tsx
|
|
4638
|
+
var React8 = __toESM(window.React);
|
|
4639
|
+
var FormattedPlural = (props) => {
|
|
4640
|
+
const { formatPlural: formatPlural2, textComponent: Text } = useIntl();
|
|
4641
|
+
const { value, other, children } = props;
|
|
4642
|
+
const pluralCategory = formatPlural2(value, props);
|
|
4643
|
+
const formattedPlural = props[pluralCategory] || other;
|
|
4644
|
+
if (typeof children === "function") {
|
|
4645
|
+
return children(formattedPlural);
|
|
4646
|
+
}
|
|
4647
|
+
if (Text) {
|
|
4648
|
+
return React8.createElement(Text, null, formattedPlural);
|
|
4649
|
+
}
|
|
4650
|
+
return formattedPlural;
|
|
4651
|
+
};
|
|
4652
|
+
FormattedPlural.displayName = "FormattedPlural";
|
|
4653
|
+
var plural_default = FormattedPlural;
|
|
4654
|
+
|
|
4736
4655
|
// packages/react-intl/src/components/provider.tsx
|
|
4656
|
+
var React9 = __toESM(window.React);
|
|
4737
4657
|
function processIntlConfig(config) {
|
|
4738
4658
|
return {
|
|
4739
4659
|
locale: config.locale,
|
|
@@ -4750,7 +4670,7 @@ var ReactIntl = (() => {
|
|
|
4750
4670
|
defaultRichTextElements: config.defaultRichTextElements
|
|
4751
4671
|
};
|
|
4752
4672
|
}
|
|
4753
|
-
var IntlProvider2 = class extends
|
|
4673
|
+
var IntlProvider2 = class extends React9.PureComponent {
|
|
4754
4674
|
constructor() {
|
|
4755
4675
|
super(...arguments);
|
|
4756
4676
|
__publicField(this, "cache", createIntlCache());
|
|
@@ -4772,14 +4692,14 @@ var ReactIntl = (() => {
|
|
|
4772
4692
|
}
|
|
4773
4693
|
render() {
|
|
4774
4694
|
invariantIntlContext(this.state.intl);
|
|
4775
|
-
return
|
|
4695
|
+
return React9.createElement(Provider, { value: this.state.intl }, this.props.children);
|
|
4776
4696
|
}
|
|
4777
4697
|
};
|
|
4778
4698
|
__publicField(IntlProvider2, "displayName", "IntlProvider");
|
|
4779
4699
|
__publicField(IntlProvider2, "defaultProps", DEFAULT_INTL_CONFIG2);
|
|
4780
4700
|
|
|
4781
4701
|
// packages/react-intl/src/components/relative.tsx
|
|
4782
|
-
var
|
|
4702
|
+
var React10 = __toESM(window.React);
|
|
4783
4703
|
var MINUTE = 60;
|
|
4784
4704
|
var HOUR = 60 * 60;
|
|
4785
4705
|
var DAY = 60 * 60 * 24;
|
|
@@ -4837,9 +4757,9 @@ var ReactIntl = (() => {
|
|
|
4837
4757
|
return children(formattedRelativeTime);
|
|
4838
4758
|
}
|
|
4839
4759
|
if (Text) {
|
|
4840
|
-
return
|
|
4760
|
+
return React10.createElement(Text, null, formattedRelativeTime);
|
|
4841
4761
|
}
|
|
4842
|
-
return
|
|
4762
|
+
return React10.createElement(React10.Fragment, null, formattedRelativeTime);
|
|
4843
4763
|
};
|
|
4844
4764
|
var FormattedRelativeTime = (_a2) => {
|
|
4845
4765
|
var _b = _a2, {
|
|
@@ -4851,13 +4771,13 @@ var ReactIntl = (() => {
|
|
|
4851
4771
|
"unit",
|
|
4852
4772
|
"updateIntervalInSeconds"
|
|
4853
4773
|
]);
|
|
4854
|
-
|
|
4774
|
+
invariant2(
|
|
4855
4775
|
!updateIntervalInSeconds || !!(updateIntervalInSeconds && canIncrement(unit)),
|
|
4856
4776
|
"Cannot schedule update with unit longer than hour"
|
|
4857
4777
|
);
|
|
4858
|
-
const [prevUnit, setPrevUnit] =
|
|
4859
|
-
const [prevValue, setPrevValue] =
|
|
4860
|
-
const [currentValueInSeconds, setCurrentValueInSeconds] =
|
|
4778
|
+
const [prevUnit, setPrevUnit] = React10.useState();
|
|
4779
|
+
const [prevValue, setPrevValue] = React10.useState(0);
|
|
4780
|
+
const [currentValueInSeconds, setCurrentValueInSeconds] = React10.useState(0);
|
|
4861
4781
|
let updateTimer;
|
|
4862
4782
|
if (unit !== prevUnit || value !== prevValue) {
|
|
4863
4783
|
setPrevValue(value || 0);
|
|
@@ -4866,7 +4786,7 @@ var ReactIntl = (() => {
|
|
|
4866
4786
|
canIncrement(unit) ? valueToSeconds(value, unit) : 0
|
|
4867
4787
|
);
|
|
4868
4788
|
}
|
|
4869
|
-
|
|
4789
|
+
React10.useEffect(() => {
|
|
4870
4790
|
function clearUpdateTimer() {
|
|
4871
4791
|
clearTimeout(updateTimer);
|
|
4872
4792
|
}
|
|
@@ -4901,7 +4821,7 @@ var ReactIntl = (() => {
|
|
|
4901
4821
|
const unitDuration = getDurationInSeconds(currentUnit);
|
|
4902
4822
|
currentValue = Math.round(currentValueInSeconds / unitDuration);
|
|
4903
4823
|
}
|
|
4904
|
-
return
|
|
4824
|
+
return React10.createElement(
|
|
4905
4825
|
SimpleFormattedRelativeTime,
|
|
4906
4826
|
__spreadValues({
|
|
4907
4827
|
value: currentValue,
|
|
@@ -4912,78 +4832,6 @@ var ReactIntl = (() => {
|
|
|
4912
4832
|
FormattedRelativeTime.displayName = "FormattedRelativeTime";
|
|
4913
4833
|
var relative_default = FormattedRelativeTime;
|
|
4914
4834
|
|
|
4915
|
-
// packages/react-intl/src/components/plural.tsx
|
|
4916
|
-
var React8 = __toESM(window.React);
|
|
4917
|
-
var FormattedPlural = (props) => {
|
|
4918
|
-
const { formatPlural: formatPlural2, textComponent: Text } = useIntl();
|
|
4919
|
-
const { value, other, children } = props;
|
|
4920
|
-
const pluralCategory = formatPlural2(value, props);
|
|
4921
|
-
const formattedPlural = props[pluralCategory] || other;
|
|
4922
|
-
if (typeof children === "function") {
|
|
4923
|
-
return children(formattedPlural);
|
|
4924
|
-
}
|
|
4925
|
-
if (Text) {
|
|
4926
|
-
return React8.createElement(Text, null, formattedPlural);
|
|
4927
|
-
}
|
|
4928
|
-
return formattedPlural;
|
|
4929
|
-
};
|
|
4930
|
-
FormattedPlural.displayName = "FormattedPlural";
|
|
4931
|
-
var plural_default = FormattedPlural;
|
|
4932
|
-
|
|
4933
|
-
// packages/react-intl/src/components/message.tsx
|
|
4934
|
-
var React9 = __toESM(window.React);
|
|
4935
|
-
function areEqual(prevProps, nextProps) {
|
|
4936
|
-
const _a2 = prevProps, { values } = _a2, otherProps = __objRest(_a2, ["values"]);
|
|
4937
|
-
const _b = nextProps, { values: nextValues } = _b, nextOtherProps = __objRest(_b, ["values"]);
|
|
4938
|
-
return shallowEqual(nextValues, values) && shallowEqual(otherProps, nextOtherProps);
|
|
4939
|
-
}
|
|
4940
|
-
function FormattedMessage(props) {
|
|
4941
|
-
const intl = useIntl();
|
|
4942
|
-
const { formatMessage: formatMessage3, textComponent: Text = React9.Fragment } = intl;
|
|
4943
|
-
const {
|
|
4944
|
-
id,
|
|
4945
|
-
description,
|
|
4946
|
-
defaultMessage,
|
|
4947
|
-
values,
|
|
4948
|
-
children,
|
|
4949
|
-
tagName: Component = Text,
|
|
4950
|
-
ignoreTag
|
|
4951
|
-
} = props;
|
|
4952
|
-
const descriptor = { id, description, defaultMessage };
|
|
4953
|
-
let nodes = formatMessage3(descriptor, values, {
|
|
4954
|
-
ignoreTag
|
|
4955
|
-
});
|
|
4956
|
-
if (typeof children === "function") {
|
|
4957
|
-
return children(Array.isArray(nodes) ? nodes : [nodes]);
|
|
4958
|
-
}
|
|
4959
|
-
if (Component) {
|
|
4960
|
-
return React9.createElement(Component, null, React9.Children.toArray(nodes));
|
|
4961
|
-
}
|
|
4962
|
-
return React9.createElement(React9.Fragment, null, nodes);
|
|
4963
|
-
}
|
|
4964
|
-
FormattedMessage.displayName = "FormattedMessage";
|
|
4965
|
-
var MemoizedFormattedMessage = React9.memo(
|
|
4966
|
-
FormattedMessage,
|
|
4967
|
-
areEqual
|
|
4968
|
-
);
|
|
4969
|
-
MemoizedFormattedMessage.displayName = "MemoizedFormattedMessage";
|
|
4970
|
-
var message_default = MemoizedFormattedMessage;
|
|
4971
|
-
|
|
4972
|
-
// packages/react-intl/src/components/dateTimeRange.tsx
|
|
4973
|
-
var React10 = __toESM(window.React);
|
|
4974
|
-
var FormattedDateTimeRange = (props) => {
|
|
4975
|
-
const intl = useIntl();
|
|
4976
|
-
const _a2 = props, { from, to, children } = _a2, formatProps = __objRest(_a2, ["from", "to", "children"]);
|
|
4977
|
-
const formattedValue = intl.formatDateTimeRange(from, to, formatProps);
|
|
4978
|
-
if (typeof children === "function") {
|
|
4979
|
-
return children(formattedValue);
|
|
4980
|
-
}
|
|
4981
|
-
const Text = intl.textComponent || React10.Fragment;
|
|
4982
|
-
return React10.createElement(Text, null, formattedValue);
|
|
4983
|
-
};
|
|
4984
|
-
FormattedDateTimeRange.displayName = "FormattedDateTimeRange";
|
|
4985
|
-
var dateTimeRange_default = FormattedDateTimeRange;
|
|
4986
|
-
|
|
4987
4835
|
// packages/react-intl/index.ts
|
|
4988
4836
|
function defineMessages(msgs) {
|
|
4989
4837
|
return msgs;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { FormatDateOptions, FormatDisplayNameOptions, FormatListOptions, FormatNumberOptions } from '@formatjs/intl';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import { FormatDateOptions, FormatNumberOptions, FormatListOptions, FormatDisplayNameOptions } from '@formatjs/intl';
|
|
3
3
|
import { IntlShape } from '../types';
|
|
4
|
-
import { Part } from '@formatjs/intl-listformat';
|
|
5
4
|
type Formatter = {
|
|
6
5
|
formatDate: FormatDateOptions;
|
|
7
6
|
formatTime: FormatDateOptions;
|
|
@@ -15,7 +14,7 @@ export declare const FormattedNumberParts: React.FC<Formatter['formatNumber'] &
|
|
|
15
14
|
}>;
|
|
16
15
|
export declare const FormattedListParts: React.FC<Formatter['formatList'] & {
|
|
17
16
|
value: Parameters<IntlShape['formatList']>[0];
|
|
18
|
-
children(val:
|
|
17
|
+
children(val: ReturnType<Intl.ListFormat['formatToParts']>): React.ReactElement | null;
|
|
19
18
|
}>;
|
|
20
19
|
export declare function createFormattedDateTimePartsComponent<Name extends 'formatDate' | 'formatTime'>(name: Name): React.FC<Formatter[Name] & {
|
|
21
20
|
value: Parameters<IntlShape[Name]>[0];
|
|
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
exports.createIntl = void 0;
|
|
9
9
|
var tslib_1 = require("tslib");
|
|
10
10
|
var intl_1 = require("@formatjs/intl");
|
|
11
|
+
var intl_messageformat_1 = require("intl-messageformat");
|
|
11
12
|
var React = tslib_1.__importStar(require("react"));
|
|
12
13
|
var utils_1 = require("../utils");
|
|
13
|
-
var intl_messageformat_1 = require("intl-messageformat");
|
|
14
14
|
function assignUniqueKeysToFormatXMLElementFnArgument(values) {
|
|
15
15
|
if (!values) {
|
|
16
16
|
return values;
|
|
@@ -58,10 +58,6 @@ var createIntl = function (_a, cache) {
|
|
|
58
58
|
onError: coreIntl.onError,
|
|
59
59
|
defaultRichTextElements: defaultRichTextElements,
|
|
60
60
|
};
|
|
61
|
-
return tslib_1.__assign(tslib_1.__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, resolvedConfig,
|
|
62
|
-
// @ts-expect-error fix this
|
|
63
|
-
coreIntl.formatters),
|
|
64
|
-
// @ts-expect-error fix this
|
|
65
|
-
$t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
|
|
61
|
+
return tslib_1.__assign(tslib_1.__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, resolvedConfig, coreIntl.formatters), $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
|
|
66
62
|
};
|
|
67
63
|
exports.createIntl = createIntl;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { FormatDateOptions } from '@formatjs/intl';
|
|
3
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
4
3
|
interface Props extends FormatDateOptions {
|
|
5
|
-
from: Parameters<DateTimeFormat['formatRange']>[0];
|
|
6
|
-
to: Parameters<DateTimeFormat['formatRange']>[1];
|
|
4
|
+
from: Parameters<Intl.DateTimeFormat['formatRange']>[0];
|
|
5
|
+
to: Parameters<Intl.DateTimeFormat['formatRange']>[1];
|
|
7
6
|
children?(value: React.ReactNode): React.ReactElement | null;
|
|
8
7
|
}
|
|
9
8
|
declare const FormattedDateTimeRange: React.FC<Props>;
|
|
@@ -19,7 +19,7 @@ interface State {
|
|
|
19
19
|
}
|
|
20
20
|
export default class IntlProvider extends React.PureComponent<React.PropsWithChildren<IntlConfig>, State> {
|
|
21
21
|
static displayName: string;
|
|
22
|
-
static defaultProps: Pick<import("../types").ResolvedIntlConfig, "timeZone" | "
|
|
22
|
+
static defaultProps: Pick<import("../types").ResolvedIntlConfig, "timeZone" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "onError" | "textComponent">;
|
|
23
23
|
private cache;
|
|
24
24
|
state: State;
|
|
25
25
|
static getDerivedStateFromProps(props: Readonly<IntlConfig>, { prevConfig, cache }: State): Partial<State> | null;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { RelativeTimeFormatSingularUnit } from '@formatjs/ecma402-abstract';
|
|
3
2
|
import { FormatRelativeTimeOptions } from '@formatjs/intl';
|
|
4
3
|
export interface Props extends FormatRelativeTimeOptions {
|
|
5
4
|
value?: number;
|
|
6
|
-
unit?:
|
|
5
|
+
unit?: Intl.RelativeTimeFormatUnit;
|
|
7
6
|
updateIntervalInSeconds?: number;
|
|
8
7
|
children?(value: string): React.ReactElement | null;
|
|
9
8
|
}
|
|
@@ -7,7 +7,7 @@ var tslib_1 = require("tslib");
|
|
|
7
7
|
* See the accompanying LICENSE file for terms.
|
|
8
8
|
*/
|
|
9
9
|
var React = tslib_1.__importStar(require("react"));
|
|
10
|
-
var
|
|
10
|
+
var utils_1 = require("../utils");
|
|
11
11
|
var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
|
|
12
12
|
var MINUTE = 60;
|
|
13
13
|
var HOUR = 60 * 60;
|
|
@@ -73,7 +73,7 @@ var SimpleFormattedRelativeTime = function (props) {
|
|
|
73
73
|
};
|
|
74
74
|
var FormattedRelativeTime = function (_a) {
|
|
75
75
|
var _b = _a.value, value = _b === void 0 ? 0 : _b, _c = _a.unit, unit = _c === void 0 ? 'second' : _c, updateIntervalInSeconds = _a.updateIntervalInSeconds, otherProps = tslib_1.__rest(_a, ["value", "unit", "updateIntervalInSeconds"]);
|
|
76
|
-
(0,
|
|
76
|
+
(0, utils_1.invariant)(!updateIntervalInSeconds ||
|
|
77
77
|
!!(updateIntervalInSeconds && canIncrement(unit)), 'Cannot schedule update with unit longer than hour');
|
|
78
78
|
var _d = React.useState(), prevUnit = _d[0], setPrevUnit = _d[1];
|
|
79
79
|
var _e = React.useState(0), prevValue = _e[0], setPrevValue = _e[1];
|
package/src/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ResolvedIntlConfig } from './types';
|
|
2
|
-
import * as React from 'react';
|
|
3
1
|
import { FormatXMLElementFn } from 'intl-messageformat';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ResolvedIntlConfig } from './types';
|
|
4
|
+
export declare function invariant(condition: boolean, message: string, Err?: any): asserts condition;
|
|
4
5
|
export declare function invariantIntlContext(intl?: any): asserts intl;
|
|
5
6
|
export declare const DEFAULT_INTL_CONFIG: Pick<ResolvedIntlConfig, 'fallbackOnEmptyString' | 'formats' | 'messages' | 'timeZone' | 'textComponent' | 'defaultLocale' | 'defaultFormats' | 'onError'>;
|
|
6
7
|
/**
|
package/src/utils.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_INTL_CONFIG = void 0;
|
|
4
|
+
exports.invariant = invariant;
|
|
4
5
|
exports.invariantIntlContext = invariantIntlContext;
|
|
5
6
|
exports.assignUniqueKeysToParts = assignUniqueKeysToParts;
|
|
6
7
|
exports.shallowEqual = shallowEqual;
|
|
7
8
|
var tslib_1 = require("tslib");
|
|
8
9
|
var React = tslib_1.__importStar(require("react"));
|
|
9
|
-
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
10
10
|
var intl_1 = require("@formatjs/intl");
|
|
11
|
+
function invariant(condition, message, Err) {
|
|
12
|
+
if (Err === void 0) { Err = Error; }
|
|
13
|
+
if (!condition) {
|
|
14
|
+
throw new Err(message);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
11
17
|
function invariantIntlContext(intl) {
|
|
12
|
-
|
|
18
|
+
invariant(intl, '[React Intl] Could not find required `intl` object. ' +
|
|
13
19
|
'<IntlProvider> needs to exist in the component ancestry.');
|
|
14
20
|
}
|
|
15
21
|
exports.DEFAULT_INTL_CONFIG = tslib_1.__assign(tslib_1.__assign({}, intl_1.DEFAULT_INTL_CONFIG), { textComponent: React.Fragment });
|