react-intl 6.0.6 → 6.1.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/index.d.ts +43 -0
- package/index.d.ts.map +1 -0
- package/index.js +51 -0
- package/lib/index.d.ts +43 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +26 -0
- package/lib/src/components/createFormattedComponent.d.ts +29 -0
- package/lib/src/components/createFormattedComponent.d.ts.map +1 -0
- package/lib/src/components/createFormattedComponent.js +62 -0
- package/lib/src/components/dateTimeRange.d.ts +11 -0
- package/lib/src/components/dateTimeRange.d.ts.map +1 -0
- package/lib/src/components/dateTimeRange.js +15 -0
- package/lib/src/components/injectIntl.d.ts +22 -0
- package/lib/src/components/injectIntl.d.ts.map +1 -0
- package/lib/src/components/injectIntl.js +29 -0
- package/lib/src/components/message.d.ts +12 -0
- package/lib/src/components/message.d.ts.map +1 -0
- package/lib/src/components/message.js +35 -0
- package/lib/src/components/plural.d.ts +15 -0
- package/lib/src/components/plural.d.ts.map +1 -0
- package/lib/src/components/plural.js +26 -0
- package/lib/src/components/provider.d.ts +35 -0
- package/lib/src/components/provider.d.ts.map +1 -0
- package/lib/src/components/provider.js +112 -0
- package/lib/src/components/relative.d.ts +12 -0
- package/lib/src/components/relative.d.ts.map +1 -0
- package/lib/src/components/relative.js +129 -0
- package/lib/src/components/useIntl.d.ts +3 -0
- package/lib/src/components/useIntl.d.ts.map +1 -0
- package/lib/src/components/useIntl.js +8 -0
- package/lib/src/types.d.ts +12 -0
- package/lib/src/types.d.ts.map +1 -0
- package/lib/src/types.js +1 -0
- package/lib/src/utils.d.ts +14 -0
- package/lib/src/utils.d.ts.map +1 -0
- package/lib/src/utils.js +43 -0
- package/package.json +10 -10
- package/react-intl.iife.js +4688 -0
- package/src/components/createFormattedComponent.d.ts +29 -0
- package/src/components/createFormattedComponent.d.ts.map +1 -0
- package/src/components/createFormattedComponent.js +69 -0
- package/src/components/dateTimeRange.d.ts +11 -0
- package/src/components/dateTimeRange.d.ts.map +1 -0
- package/src/components/dateTimeRange.js +17 -0
- package/src/components/injectIntl.d.ts +22 -0
- package/src/components/injectIntl.d.ts.map +1 -0
- package/src/components/injectIntl.js +33 -0
- package/src/components/message.d.ts +12 -0
- package/src/components/message.d.ts.map +1 -0
- package/src/components/message.js +37 -0
- package/src/components/plural.d.ts +15 -0
- package/src/components/plural.d.ts.map +1 -0
- package/src/components/plural.js +29 -0
- package/src/components/provider.d.ts +35 -0
- package/src/components/provider.d.ts.map +1 -0
- package/src/components/provider.js +116 -0
- package/src/components/relative.d.ts +12 -0
- package/src/components/relative.d.ts.map +1 -0
- package/src/components/relative.js +131 -0
- package/src/components/useIntl.d.ts +3 -0
- package/src/components/useIntl.d.ts.map +1 -0
- package/src/components/useIntl.js +12 -0
- package/src/types.d.ts +12 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.js +2 -0
- package/src/utils.d.ts +14 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +49 -0
- package/BUILD +0 -130
- package/CHANGELOG.md +0 -1384
- package/example-sandboxes/rescripts/.rescriptsrc.js +0 -28
- package/example-sandboxes/rescripts/package-lock.json +0 -18035
- package/example-sandboxes/rescripts/package.json +0 -35
- package/example-sandboxes/rescripts/public/index.html +0 -42
- package/example-sandboxes/rescripts/src/App.tsx +0 -16
- package/example-sandboxes/rescripts/src/index.tsx +0 -5
- package/example-sandboxes/rescripts/src/react-app-env.d.ts +0 -1
- package/example-sandboxes/rescripts/src/styles.css +0 -4
- package/example-sandboxes/rescripts/tsconfig.json +0 -20
- package/example-sandboxes/strict-locale-type/.env +0 -1
- package/example-sandboxes/strict-locale-type/package-lock.json +0 -14595
- package/example-sandboxes/strict-locale-type/package.json +0 -35
- package/example-sandboxes/strict-locale-type/src/App.tsx +0 -48
- package/example-sandboxes/strict-locale-type/src/index.html +0 -28
- package/example-sandboxes/strict-locale-type/src/index.tsx +0 -7
- package/example-sandboxes/strict-locale-type/src/styles.css +0 -4
- package/example-sandboxes/strict-locale-type/tsconfig.json +0 -7
- package/example-sandboxes/strict-message-types/.env +0 -1
- package/example-sandboxes/strict-message-types/package-lock.json +0 -14596
- package/example-sandboxes/strict-message-types/package.json +0 -35
- package/example-sandboxes/strict-message-types/src/App.tsx +0 -31
- package/example-sandboxes/strict-message-types/src/index.html +0 -28
- package/example-sandboxes/strict-message-types/src/index.tsx +0 -7
- package/example-sandboxes/strict-message-types/src/styles.css +0 -4
- package/example-sandboxes/strict-message-types/tsconfig.json +0 -7
- package/examples/BUILD +0 -70
- package/examples/Bug2727.tsx +0 -37
- package/examples/HandleChange.tsx +0 -48
- package/examples/Hooks.tsx +0 -126
- package/examples/Injected.tsx +0 -41
- package/examples/Messages.tsx +0 -82
- package/examples/StaticTypeSafetyAndCodeSplitting/StaticTypeSafetyAndCodeSplitting.tsx +0 -44
- package/examples/StaticTypeSafetyAndCodeSplitting/en.json +0 -3
- package/examples/StaticTypeSafetyAndCodeSplitting/intlHelpers.tsx +0 -39
- package/examples/StaticTypeSafetyAndCodeSplitting/it.json +0 -3
- package/examples/TimeZone.tsx +0 -44
- package/examples/advanced/Advanced.tsx +0 -68
- package/examples/advanced/compiled-lang/en.json +0 -77
- package/examples/advanced/compiled-lang/fr.json +0 -77
- package/examples/index.html +0 -20
- package/examples/index.tsx +0 -44
- package/examples/package.json +0 -20
- package/index.ts +0 -127
- package/jest.config.js +0 -27
- package/src/components/createFormattedComponent.tsx +0 -123
- package/src/components/dateTimeRange.tsx +0 -26
- package/src/components/injectIntl.tsx +0 -111
- package/src/components/message.tsx +0 -73
- package/src/components/plural.tsx +0 -45
- package/src/components/provider.tsx +0 -196
- package/src/components/relative.tsx +0 -192
- package/src/components/useIntl.ts +0 -10
- package/src/types.ts +0 -29
- package/src/utils.ts +0 -77
- package/tests/functional/index.ts +0 -18
- package/tests/functional/support/build.ts +0 -16
- package/tests/functional/support/format.tsx +0 -112
- package/tests/perf/index.tsx +0 -196
- package/tests/setup.js +0 -10
- package/tests/unit/components/__snapshots__/displayName.tsx.snap +0 -19
- package/tests/unit/components/__snapshots__/message.tsx.snap +0 -41
- package/tests/unit/components/__snapshots__/relative.tsx.snap +0 -11
- package/tests/unit/components/__snapshots__/useIntl.tsx.snap +0 -25
- package/tests/unit/components/date.tsx +0 -233
- package/tests/unit/components/dateTimeRange.tsx +0 -103
- package/tests/unit/components/displayName.tsx +0 -57
- package/tests/unit/components/message.tsx +0 -509
- package/tests/unit/components/number.tsx +0 -198
- package/tests/unit/components/plural.tsx +0 -116
- package/tests/unit/components/provider.tsx +0 -215
- package/tests/unit/components/relative.tsx +0 -263
- package/tests/unit/components/time.tsx +0 -242
- package/tests/unit/components/useIntl.tsx +0 -64
- package/tests/unit/components/withIntl.tsx +0 -66
- package/tests/unit/react-intl.ts +0 -88
- package/tests/unit/testUtils.tsx +0 -42
- package/tsconfig.json +0 -5
package/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
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, { createIntl } from './src/components/provider';
|
|
9
|
+
import FormattedRelativeTime from './src/components/relative';
|
|
10
|
+
import FormattedPlural from './src/components/plural';
|
|
11
|
+
import FormattedMessage from './src/components/message';
|
|
12
|
+
import FormattedDateTimeRange from './src/components/dateTimeRange';
|
|
13
|
+
export { FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, IntlContext, IntlProvider, RawIntlProvider, WithIntlProps, WrappedComponentProps, createIntl, injectIntl, useIntl, };
|
|
14
|
+
export { IntlConfig, ResolvedIntlConfig, IntlShape } from './src/types';
|
|
15
|
+
export { createIntlCache, MessageDescriptor, IntlCache, Formatters, IntlFormatters, FormatDisplayNameOptions, FormatListOptions, FormatPluralOptions, FormatRelativeTimeOptions, FormatNumberOptions, FormatDateOptions, CustomFormatConfig, CustomFormats, UnsupportedFormatterError, InvalidConfigError, MissingDataError, MessageFormatError, MissingTranslationError, IntlErrorCode as ReactIntlErrorCode, IntlError as ReactIntlError, } from '@formatjs/intl';
|
|
16
|
+
export declare function defineMessages<K extends keyof any, T = MessageDescriptor, U extends Record<K, T> = Record<K, T>>(msgs: U): U;
|
|
17
|
+
export declare function defineMessage<T extends MessageDescriptor>(msg: T): T;
|
|
18
|
+
export declare const FormattedDate: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig & {
|
|
19
|
+
value: string | number | Date | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const FormattedTime: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig & {
|
|
22
|
+
value: string | number | Date | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const FormattedNumber: React.FC<NumberFormatOptions & CustomFormatConfig & {
|
|
25
|
+
value: number | bigint;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const FormattedList: React.FC<IntlListFormatOptions & {
|
|
28
|
+
value: readonly React.ReactNode[];
|
|
29
|
+
}>;
|
|
30
|
+
export declare const FormattedDisplayName: React.FC<DisplayNamesOptions & {
|
|
31
|
+
value: string | number | Record<string, unknown>;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const FormattedDateParts: React.FC<FormatDateOptions & {
|
|
34
|
+
value: Parameters<Intl.DateTimeFormat['format']>[0] | string;
|
|
35
|
+
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const FormattedTimeParts: React.FC<FormatDateOptions & {
|
|
38
|
+
value: Parameters<Intl.DateTimeFormat['format']>[0] | string;
|
|
39
|
+
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
|
|
40
|
+
}>;
|
|
41
|
+
export { FormattedNumberParts, FormattedListParts, } from './src/components/createFormattedComponent';
|
|
42
|
+
export type { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAA;AAC9D,OAAO,UAAU,EAAE,EACjB,QAAQ,IAAI,eAAe,EAC3B,OAAO,IAAI,WAAW,EACtB,aAAa,EACb,qBAAqB,EACtB,MAAM,6BAA6B,CAAA;AACpC,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,YAAY,EAAE,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,qBAAqB,MAAM,2BAA2B,CAAA;AAC7D,OAAO,eAAe,MAAM,yBAAyB,CAAA;AACrD,OAAO,gBAAgB,MAAM,0BAA0B,CAAA;AACvD,OAAO,sBAAsB,MAAM,gCAAgC,CAAA;AACnE,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,OAAO,GACR,CAAA;AACD,OAAO,EAAC,UAAU,EAAE,kBAAkB,EAAE,SAAS,EAAC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;IACtB,KAAK,EAAE,SAAS,KAAK,CAAC,SAAS,EAAE,CAAA;CAClC,CACuC,CAAA;AAC1C,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC,mBAAmB,GAAG;IACpB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACjD,CAC8C,CAAA;AACjD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CACvC,iBAAiB,GAAG;IAClB,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAA;IAC5D,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAAE,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CACpE,CACoD,CAAA;AACvD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CACvC,iBAAiB,GAAG;IAClB,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAA;IAC5D,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAAE,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CACpE,CACoD,CAAA;AAEvD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,2CAA2C,CAAA;AAClD,YAAY,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAA"}
|
package/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormattedListParts = exports.FormattedNumberParts = exports.FormattedTimeParts = exports.FormattedDateParts = exports.FormattedDisplayName = exports.FormattedList = exports.FormattedNumber = exports.FormattedTime = exports.FormattedDate = exports.defineMessage = exports.defineMessages = exports.ReactIntlError = exports.ReactIntlErrorCode = exports.MissingTranslationError = exports.MessageFormatError = exports.MissingDataError = exports.InvalidConfigError = exports.UnsupportedFormatterError = exports.createIntlCache = exports.useIntl = exports.injectIntl = exports.createIntl = exports.RawIntlProvider = exports.IntlProvider = exports.IntlContext = exports.FormattedRelativeTime = exports.FormattedPlural = exports.FormattedMessage = exports.FormattedDateTimeRange = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var createFormattedComponent_1 = require("./src/components/createFormattedComponent");
|
|
6
|
+
var injectIntl_1 = tslib_1.__importStar(require("./src/components/injectIntl"));
|
|
7
|
+
exports.injectIntl = injectIntl_1.default;
|
|
8
|
+
Object.defineProperty(exports, "RawIntlProvider", { enumerable: true, get: function () { return injectIntl_1.Provider; } });
|
|
9
|
+
Object.defineProperty(exports, "IntlContext", { enumerable: true, get: function () { return injectIntl_1.Context; } });
|
|
10
|
+
var useIntl_1 = tslib_1.__importDefault(require("./src/components/useIntl"));
|
|
11
|
+
exports.useIntl = useIntl_1.default;
|
|
12
|
+
var provider_1 = tslib_1.__importStar(require("./src/components/provider"));
|
|
13
|
+
exports.IntlProvider = provider_1.default;
|
|
14
|
+
Object.defineProperty(exports, "createIntl", { enumerable: true, get: function () { return provider_1.createIntl; } });
|
|
15
|
+
var relative_1 = tslib_1.__importDefault(require("./src/components/relative"));
|
|
16
|
+
exports.FormattedRelativeTime = relative_1.default;
|
|
17
|
+
var plural_1 = tslib_1.__importDefault(require("./src/components/plural"));
|
|
18
|
+
exports.FormattedPlural = plural_1.default;
|
|
19
|
+
var message_1 = tslib_1.__importDefault(require("./src/components/message"));
|
|
20
|
+
exports.FormattedMessage = message_1.default;
|
|
21
|
+
var dateTimeRange_1 = tslib_1.__importDefault(require("./src/components/dateTimeRange"));
|
|
22
|
+
exports.FormattedDateTimeRange = dateTimeRange_1.default;
|
|
23
|
+
var intl_1 = require("@formatjs/intl");
|
|
24
|
+
Object.defineProperty(exports, "createIntlCache", { enumerable: true, get: function () { return intl_1.createIntlCache; } });
|
|
25
|
+
Object.defineProperty(exports, "UnsupportedFormatterError", { enumerable: true, get: function () { return intl_1.UnsupportedFormatterError; } });
|
|
26
|
+
Object.defineProperty(exports, "InvalidConfigError", { enumerable: true, get: function () { return intl_1.InvalidConfigError; } });
|
|
27
|
+
Object.defineProperty(exports, "MissingDataError", { enumerable: true, get: function () { return intl_1.MissingDataError; } });
|
|
28
|
+
Object.defineProperty(exports, "MessageFormatError", { enumerable: true, get: function () { return intl_1.MessageFormatError; } });
|
|
29
|
+
Object.defineProperty(exports, "MissingTranslationError", { enumerable: true, get: function () { return intl_1.MissingTranslationError; } });
|
|
30
|
+
Object.defineProperty(exports, "ReactIntlErrorCode", { enumerable: true, get: function () { return intl_1.IntlErrorCode; } });
|
|
31
|
+
Object.defineProperty(exports, "ReactIntlError", { enumerable: true, get: function () { return intl_1.IntlError; } });
|
|
32
|
+
function defineMessages(msgs) {
|
|
33
|
+
return msgs;
|
|
34
|
+
}
|
|
35
|
+
exports.defineMessages = defineMessages;
|
|
36
|
+
function defineMessage(msg) {
|
|
37
|
+
return msg;
|
|
38
|
+
}
|
|
39
|
+
exports.defineMessage = defineMessage;
|
|
40
|
+
// IMPORTANT: Explicit here to prevent api-extractor from outputing `import('./src/types').CustomFormatConfig`
|
|
41
|
+
exports.FormattedDate = (0, createFormattedComponent_1.createFormattedComponent)('formatDate');
|
|
42
|
+
exports.FormattedTime = (0, createFormattedComponent_1.createFormattedComponent)('formatTime');
|
|
43
|
+
// @ts-ignore issue w/ TS Intl types
|
|
44
|
+
exports.FormattedNumber = (0, createFormattedComponent_1.createFormattedComponent)('formatNumber');
|
|
45
|
+
exports.FormattedList = (0, createFormattedComponent_1.createFormattedComponent)('formatList');
|
|
46
|
+
exports.FormattedDisplayName = (0, createFormattedComponent_1.createFormattedComponent)('formatDisplayName');
|
|
47
|
+
exports.FormattedDateParts = (0, createFormattedComponent_1.createFormattedDateTimePartsComponent)('formatDate');
|
|
48
|
+
exports.FormattedTimeParts = (0, createFormattedComponent_1.createFormattedDateTimePartsComponent)('formatTime');
|
|
49
|
+
var createFormattedComponent_2 = require("./src/components/createFormattedComponent");
|
|
50
|
+
Object.defineProperty(exports, "FormattedNumberParts", { enumerable: true, get: function () { return createFormattedComponent_2.FormattedNumberParts; } });
|
|
51
|
+
Object.defineProperty(exports, "FormattedListParts", { enumerable: true, get: function () { return createFormattedComponent_2.FormattedListParts; } });
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
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, { createIntl } from './src/components/provider';
|
|
9
|
+
import FormattedRelativeTime from './src/components/relative';
|
|
10
|
+
import FormattedPlural from './src/components/plural';
|
|
11
|
+
import FormattedMessage from './src/components/message';
|
|
12
|
+
import FormattedDateTimeRange from './src/components/dateTimeRange';
|
|
13
|
+
export { FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, IntlContext, IntlProvider, RawIntlProvider, WithIntlProps, WrappedComponentProps, createIntl, injectIntl, useIntl, };
|
|
14
|
+
export { IntlConfig, ResolvedIntlConfig, IntlShape } from './src/types';
|
|
15
|
+
export { createIntlCache, MessageDescriptor, IntlCache, Formatters, IntlFormatters, FormatDisplayNameOptions, FormatListOptions, FormatPluralOptions, FormatRelativeTimeOptions, FormatNumberOptions, FormatDateOptions, CustomFormatConfig, CustomFormats, UnsupportedFormatterError, InvalidConfigError, MissingDataError, MessageFormatError, MissingTranslationError, IntlErrorCode as ReactIntlErrorCode, IntlError as ReactIntlError, } from '@formatjs/intl';
|
|
16
|
+
export declare function defineMessages<K extends keyof any, T = MessageDescriptor, U extends Record<K, T> = Record<K, T>>(msgs: U): U;
|
|
17
|
+
export declare function defineMessage<T extends MessageDescriptor>(msg: T): T;
|
|
18
|
+
export declare const FormattedDate: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig & {
|
|
19
|
+
value: string | number | Date | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const FormattedTime: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig & {
|
|
22
|
+
value: string | number | Date | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const FormattedNumber: React.FC<NumberFormatOptions & CustomFormatConfig & {
|
|
25
|
+
value: number | bigint;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const FormattedList: React.FC<IntlListFormatOptions & {
|
|
28
|
+
value: readonly React.ReactNode[];
|
|
29
|
+
}>;
|
|
30
|
+
export declare const FormattedDisplayName: React.FC<DisplayNamesOptions & {
|
|
31
|
+
value: string | number | Record<string, unknown>;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const FormattedDateParts: React.FC<FormatDateOptions & {
|
|
34
|
+
value: Parameters<Intl.DateTimeFormat['format']>[0] | string;
|
|
35
|
+
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const FormattedTimeParts: React.FC<FormatDateOptions & {
|
|
38
|
+
value: Parameters<Intl.DateTimeFormat['format']>[0] | string;
|
|
39
|
+
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
|
|
40
|
+
}>;
|
|
41
|
+
export { FormattedNumberParts, FormattedListParts, } from './src/components/createFormattedComponent';
|
|
42
|
+
export type { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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AAK,CAAC,EAAE,CACvC,iBAAiB,GAAG;IAClB,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAA;IAC5D,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAAE,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CACpE,CACoD,CAAA;AACvD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CACvC,iBAAiB,GAAG;IAClB,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAA;IAC5D,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAAE,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CACpE,CACoD,CAAA;AAEvD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,2CAA2C,CAAA;AAClD,YAAY,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAA"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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, { createIntl } from './src/components/provider';
|
|
5
|
+
import FormattedRelativeTime from './src/components/relative';
|
|
6
|
+
import FormattedPlural from './src/components/plural';
|
|
7
|
+
import FormattedMessage from './src/components/message';
|
|
8
|
+
import FormattedDateTimeRange from './src/components/dateTimeRange';
|
|
9
|
+
export { FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, IntlContext, IntlProvider, RawIntlProvider, createIntl, injectIntl, useIntl, };
|
|
10
|
+
export { createIntlCache, UnsupportedFormatterError, InvalidConfigError, MissingDataError, MessageFormatError, MissingTranslationError, IntlErrorCode as ReactIntlErrorCode, IntlError as ReactIntlError, } from '@formatjs/intl';
|
|
11
|
+
export function defineMessages(msgs) {
|
|
12
|
+
return msgs;
|
|
13
|
+
}
|
|
14
|
+
export function defineMessage(msg) {
|
|
15
|
+
return msg;
|
|
16
|
+
}
|
|
17
|
+
// IMPORTANT: Explicit here to prevent api-extractor from outputing `import('./src/types').CustomFormatConfig`
|
|
18
|
+
export var FormattedDate = createFormattedComponent('formatDate');
|
|
19
|
+
export var FormattedTime = createFormattedComponent('formatTime');
|
|
20
|
+
// @ts-ignore issue w/ TS Intl types
|
|
21
|
+
export var FormattedNumber = createFormattedComponent('formatNumber');
|
|
22
|
+
export var FormattedList = createFormattedComponent('formatList');
|
|
23
|
+
export var FormattedDisplayName = createFormattedComponent('formatDisplayName');
|
|
24
|
+
export var FormattedDateParts = createFormattedDateTimePartsComponent('formatDate');
|
|
25
|
+
export var FormattedTimeParts = createFormattedDateTimePartsComponent('formatTime');
|
|
26
|
+
export { FormattedNumberParts, FormattedListParts, } from './src/components/createFormattedComponent';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FormatDateOptions, FormatNumberOptions, FormatListOptions, FormatDisplayNameOptions } from '@formatjs/intl';
|
|
3
|
+
import { IntlShape } from '../types';
|
|
4
|
+
import { Part } from '@formatjs/intl-listformat';
|
|
5
|
+
declare type Formatter = {
|
|
6
|
+
formatDate: FormatDateOptions;
|
|
7
|
+
formatTime: FormatDateOptions;
|
|
8
|
+
formatNumber: FormatNumberOptions;
|
|
9
|
+
formatList: FormatListOptions;
|
|
10
|
+
formatDisplayName: FormatDisplayNameOptions;
|
|
11
|
+
};
|
|
12
|
+
export declare const FormattedNumberParts: React.FC<Formatter['formatNumber'] & {
|
|
13
|
+
value: Parameters<IntlShape['formatNumber']>[0];
|
|
14
|
+
children(val: Intl.NumberFormatPart[]): React.ReactElement | null;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const FormattedListParts: React.FC<Formatter['formatList'] & {
|
|
17
|
+
value: Parameters<IntlShape['formatList']>[0];
|
|
18
|
+
children(val: Part[]): React.ReactElement | null;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function createFormattedDateTimePartsComponent<Name extends 'formatDate' | 'formatTime'>(name: Name): React.FC<Formatter[Name] & {
|
|
21
|
+
value: Parameters<IntlShape[Name]>[0];
|
|
22
|
+
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function createFormattedComponent<Name extends keyof Formatter>(name: Name): React.FC<Formatter[Name] & {
|
|
25
|
+
value: Parameters<IntlShape[Name]>[0];
|
|
26
|
+
children?(val: string): React.ReactElement | null;
|
|
27
|
+
}>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=createFormattedComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFormattedComponent.d.ts","sourceRoot":"","sources":["../../../src/components/createFormattedComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAElC,OAAO,EAAC,IAAI,EAAC,MAAM,2BAA2B,CAAA;AAmB9C,aAAK,SAAS,GAAG;IACf,UAAU,EAAE,iBAAiB,CAAA;IAC7B,UAAU,EAAE,iBAAiB,CAAA;IAC7B,YAAY,EAAE,mBAAmB,CAAA;IACjC,UAAU,EAAE,iBAAiB,CAAA;IAC7B,iBAAiB,EAAE,wBAAwB,CAAA;CAC5C,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC,SAAS,CAAC,cAAc,CAAC,GAAG;IAC1B,KAAK,EAAE,UAAU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
4
|
+
var DisplayName;
|
|
5
|
+
(function (DisplayName) {
|
|
6
|
+
DisplayName["formatDate"] = "FormattedDate";
|
|
7
|
+
DisplayName["formatTime"] = "FormattedTime";
|
|
8
|
+
DisplayName["formatNumber"] = "FormattedNumber";
|
|
9
|
+
DisplayName["formatList"] = "FormattedList";
|
|
10
|
+
// Note that this DisplayName is the locale display name, not to be confused with
|
|
11
|
+
// the name of the enum, which is for React component display name in dev tools.
|
|
12
|
+
DisplayName["formatDisplayName"] = "FormattedDisplayName";
|
|
13
|
+
})(DisplayName || (DisplayName = {}));
|
|
14
|
+
var DisplayNameParts;
|
|
15
|
+
(function (DisplayNameParts) {
|
|
16
|
+
DisplayNameParts["formatDate"] = "FormattedDateParts";
|
|
17
|
+
DisplayNameParts["formatTime"] = "FormattedTimeParts";
|
|
18
|
+
DisplayNameParts["formatNumber"] = "FormattedNumberParts";
|
|
19
|
+
DisplayNameParts["formatList"] = "FormattedListParts";
|
|
20
|
+
})(DisplayNameParts || (DisplayNameParts = {}));
|
|
21
|
+
export var FormattedNumberParts = function (props) {
|
|
22
|
+
var intl = useIntl();
|
|
23
|
+
var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
|
|
24
|
+
return children(intl.formatNumberToParts(value, formatProps));
|
|
25
|
+
};
|
|
26
|
+
FormattedNumberParts.displayName = 'FormattedNumberParts';
|
|
27
|
+
export var FormattedListParts = function (props) {
|
|
28
|
+
var intl = useIntl();
|
|
29
|
+
var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
|
|
30
|
+
return children(intl.formatListToParts(value, formatProps));
|
|
31
|
+
};
|
|
32
|
+
FormattedNumberParts.displayName = 'FormattedNumberParts';
|
|
33
|
+
export function createFormattedDateTimePartsComponent(name) {
|
|
34
|
+
var ComponentParts = function (props) {
|
|
35
|
+
var intl = useIntl();
|
|
36
|
+
var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
|
|
37
|
+
var date = typeof value === 'string' ? new Date(value || 0) : value;
|
|
38
|
+
var formattedParts = name === 'formatDate'
|
|
39
|
+
? intl.formatDateToParts(date, formatProps)
|
|
40
|
+
: intl.formatTimeToParts(date, formatProps);
|
|
41
|
+
return children(formattedParts);
|
|
42
|
+
};
|
|
43
|
+
ComponentParts.displayName = DisplayNameParts[name];
|
|
44
|
+
return ComponentParts;
|
|
45
|
+
}
|
|
46
|
+
export function createFormattedComponent(name) {
|
|
47
|
+
var Component = function (props) {
|
|
48
|
+
var intl = useIntl();
|
|
49
|
+
var value = props.value, children = props.children, formatProps = __rest(props
|
|
50
|
+
// TODO: fix TS type definition for localeMatcher upstream
|
|
51
|
+
, ["value", "children"]);
|
|
52
|
+
// TODO: fix TS type definition for localeMatcher upstream
|
|
53
|
+
var formattedValue = intl[name](value, formatProps);
|
|
54
|
+
if (typeof children === 'function') {
|
|
55
|
+
return children(formattedValue);
|
|
56
|
+
}
|
|
57
|
+
var Text = intl.textComponent || React.Fragment;
|
|
58
|
+
return React.createElement(Text, null, formattedValue);
|
|
59
|
+
};
|
|
60
|
+
Component.displayName = DisplayName[name];
|
|
61
|
+
return Component;
|
|
62
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FormatDateOptions } from '@formatjs/intl';
|
|
3
|
+
import { DateTimeFormat } from '@formatjs/ecma402-abstract';
|
|
4
|
+
interface Props extends FormatDateOptions {
|
|
5
|
+
from: Parameters<DateTimeFormat['formatRange']>[0];
|
|
6
|
+
to: Parameters<DateTimeFormat['formatRange']>[1];
|
|
7
|
+
children?(value: React.ReactNode): React.ReactElement | null;
|
|
8
|
+
}
|
|
9
|
+
declare const FormattedDateTimeRange: React.FC<Props>;
|
|
10
|
+
export default FormattedDateTimeRange;
|
|
11
|
+
//# sourceMappingURL=dateTimeRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateTimeRange.d.ts","sourceRoot":"","sources":["../../../src/components/dateTimeRange.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAA;AAGzD,UAAU,KAAM,SAAQ,iBAAiB;IACvC,IAAI,EAAE,UAAU,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAClD,EAAE,EAAE,UAAU,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD,QAAQ,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CAC7D;AAED,QAAA,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAW3C,CAAA;AAGD,eAAe,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import useIntl from './useIntl';
|
|
4
|
+
var FormattedDateTimeRange = function (props) {
|
|
5
|
+
var intl = useIntl();
|
|
6
|
+
var from = props.from, to = props.to, children = props.children, formatProps = __rest(props, ["from", "to", "children"]);
|
|
7
|
+
var formattedValue = intl.formatDateTimeRange(from, to, formatProps);
|
|
8
|
+
if (typeof children === 'function') {
|
|
9
|
+
return children(formattedValue);
|
|
10
|
+
}
|
|
11
|
+
var Text = intl.textComponent || React.Fragment;
|
|
12
|
+
return React.createElement(Text, null, formattedValue);
|
|
13
|
+
};
|
|
14
|
+
FormattedDateTimeRange.displayName = 'FormattedDateTimeRange';
|
|
15
|
+
export default FormattedDateTimeRange;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IntlShape } from '../types';
|
|
3
|
+
export declare const Provider: React.Provider<IntlShape>;
|
|
4
|
+
export declare const Context: React.Context<IntlShape>;
|
|
5
|
+
export interface Opts<IntlPropName extends string = 'intl', ForwardRef extends boolean = false> {
|
|
6
|
+
intlPropName?: IntlPropName;
|
|
7
|
+
forwardRef?: ForwardRef;
|
|
8
|
+
enforceContext?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare type WrappedComponentProps<IntlPropName extends string = 'intl'> = {
|
|
11
|
+
[k in IntlPropName]: IntlShape;
|
|
12
|
+
};
|
|
13
|
+
export declare type WithIntlProps<P> = Omit<P, keyof WrappedComponentProps> & {
|
|
14
|
+
forwardedRef?: React.Ref<any>;
|
|
15
|
+
};
|
|
16
|
+
export default function injectIntl<IntlPropName extends string = 'intl', P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>>(WrappedComponent: React.ComponentType<P>, options?: Opts<IntlPropName, false>): React.FC<WithIntlProps<P>> & {
|
|
17
|
+
WrappedComponent: React.ComponentType<P>;
|
|
18
|
+
};
|
|
19
|
+
export default function injectIntl<IntlPropName extends string = 'intl', P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>, T extends React.ComponentType<P> = any>(WrappedComponent: React.ComponentType<P>, options?: Opts<IntlPropName, true>): React.ForwardRefExoticComponent<React.PropsWithoutRef<WithIntlProps<React.PropsWithChildren<P>>> & React.RefAttributes<T>> & {
|
|
20
|
+
WrappedComponent: React.ComponentType<P>;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=injectIntl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectIntl.d.ts","sourceRoot":"","sources":["../../../src/components/injectIntl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAUlC,eAAO,MAAM,QAAQ,2BAAe,CAAA;AACpC,eAAO,MAAM,OAAO,0BAAc,CAAA;AAElC,MAAM,WAAW,IAAI,CACnB,YAAY,SAAS,MAAM,GAAG,MAAM,EACpC,UAAU,S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CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,GAC9D,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CACzB,GAAG;IACF,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;CACzC,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
4
|
+
import { invariantIntlContext } from '../utils';
|
|
5
|
+
function getDisplayName(Component) {
|
|
6
|
+
return Component.displayName || Component.name || 'Component';
|
|
7
|
+
}
|
|
8
|
+
// TODO: We should provide initial value here
|
|
9
|
+
var IntlContext = React.createContext(null);
|
|
10
|
+
var IntlConsumer = IntlContext.Consumer, IntlProvider = IntlContext.Provider;
|
|
11
|
+
export var Provider = IntlProvider;
|
|
12
|
+
export var Context = IntlContext;
|
|
13
|
+
export default function injectIntl(WrappedComponent, options) {
|
|
14
|
+
var _a = options || {}, _b = _a.intlPropName, intlPropName = _b === void 0 ? 'intl' : _b, _c = _a.forwardRef, forwardRef = _c === void 0 ? false : _c, _d = _a.enforceContext, enforceContext = _d === void 0 ? true : _d;
|
|
15
|
+
var WithIntl = function (props) { return (React.createElement(IntlConsumer, null, function (intl) {
|
|
16
|
+
var _a;
|
|
17
|
+
if (enforceContext) {
|
|
18
|
+
invariantIntlContext(intl);
|
|
19
|
+
}
|
|
20
|
+
var intlProp = (_a = {}, _a[intlPropName] = intl, _a);
|
|
21
|
+
return (React.createElement(WrappedComponent, __assign({}, props, intlProp, { ref: forwardRef ? props.forwardedRef : null })));
|
|
22
|
+
})); };
|
|
23
|
+
WithIntl.displayName = "injectIntl(".concat(getDisplayName(WrappedComponent), ")");
|
|
24
|
+
WithIntl.WrappedComponent = WrappedComponent;
|
|
25
|
+
if (forwardRef) {
|
|
26
|
+
return hoistNonReactStatics(React.forwardRef(function (props, ref) { return (React.createElement(WithIntl, __assign({}, props, { forwardedRef: ref }))); }), WrappedComponent);
|
|
27
|
+
}
|
|
28
|
+
return hoistNonReactStatics(WithIntl, WrappedComponent);
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { FormatXMLElementFn, Options as IntlMessageFormatOptions, PrimitiveType } from 'intl-messageformat';
|
|
3
|
+
import { MessageDescriptor } from '@formatjs/intl';
|
|
4
|
+
export interface Props<V extends Record<string, any> = Record<string, React.ReactNode | PrimitiveType | FormatXMLElementFn<React.ReactNode, React.ReactNode>>> extends MessageDescriptor {
|
|
5
|
+
values?: V;
|
|
6
|
+
tagName?: React.ElementType<any>;
|
|
7
|
+
children?(nodes: React.ReactNode[]): React.ReactElement | null;
|
|
8
|
+
ignoreTag?: IntlMessageFormatOptions['ignoreTag'];
|
|
9
|
+
}
|
|
10
|
+
declare const MemoizedFormattedMessage: React.NamedExoticComponent<Props<Record<string, string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | React.ReactPortal | Date | FormatXMLElementFn<React.ReactNode, React.ReactNode> | null | undefined>>>;
|
|
11
|
+
export default MemoizedFormattedMessage;
|
|
12
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/components/message.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EACV,kBAAkB,EAClB,OAAO,IAAI,wBAAwB,EACnC,aAAa,EACd,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAA;AAIhD,MAAM,WAAW,KAAK,CACpB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CACpC,MAAM,EACJ,KAAK,CAAC,SAAS,GACf,aAAa,GACb,kBAAkB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CACvD,CACD,SAAQ,iBAAiB;IACzB,MAAM,CAAC,EAAE,CAAC,CAAA;IACV,OAAO,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAChC,QAAQ,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;IAC9D,SAAS,CAAC,EAAE,wBAAwB,CAAC,WAAW,CAAC,CAAA;CAClD;AAwCD,QAAA,MAAM,wBAAwB,8QAAgD,CAAA;AAG9E,eAAe,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2015, Yahoo Inc.
|
|
3
|
+
* Copyrights licensed under the New BSD License.
|
|
4
|
+
* See the accompanying LICENSE file for terms.
|
|
5
|
+
*/
|
|
6
|
+
import { __rest } from "tslib";
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import useIntl from './useIntl';
|
|
9
|
+
import { shallowEqual } from '../utils';
|
|
10
|
+
function areEqual(prevProps, nextProps) {
|
|
11
|
+
var values = prevProps.values, otherProps = __rest(prevProps, ["values"]);
|
|
12
|
+
var nextValues = nextProps.values, nextOtherProps = __rest(nextProps, ["values"]);
|
|
13
|
+
return (shallowEqual(nextValues, values) &&
|
|
14
|
+
shallowEqual(otherProps, nextOtherProps));
|
|
15
|
+
}
|
|
16
|
+
function FormattedMessage(props) {
|
|
17
|
+
var intl = useIntl();
|
|
18
|
+
var formatMessage = intl.formatMessage, _a = intl.textComponent, Text = _a === void 0 ? React.Fragment : _a;
|
|
19
|
+
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;
|
|
20
|
+
var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
|
|
21
|
+
var nodes = formatMessage(descriptor, values, {
|
|
22
|
+
ignoreTag: ignoreTag,
|
|
23
|
+
});
|
|
24
|
+
if (typeof children === 'function') {
|
|
25
|
+
return children(Array.isArray(nodes) ? nodes : [nodes]);
|
|
26
|
+
}
|
|
27
|
+
if (Component) {
|
|
28
|
+
return React.createElement(Component, null, React.Children.toArray(nodes));
|
|
29
|
+
}
|
|
30
|
+
return React.createElement(React.Fragment, null, nodes);
|
|
31
|
+
}
|
|
32
|
+
FormattedMessage.displayName = 'FormattedMessage';
|
|
33
|
+
var MemoizedFormattedMessage = React.memo(FormattedMessage, areEqual);
|
|
34
|
+
MemoizedFormattedMessage.displayName = 'MemoizedFormattedMessage';
|
|
35
|
+
export default MemoizedFormattedMessage;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FormatPluralOptions } from '@formatjs/intl';
|
|
3
|
+
interface Props extends FormatPluralOptions {
|
|
4
|
+
value: number;
|
|
5
|
+
other: React.ReactNode;
|
|
6
|
+
zero?: React.ReactNode;
|
|
7
|
+
one?: React.ReactNode;
|
|
8
|
+
two?: React.ReactNode;
|
|
9
|
+
few?: React.ReactNode;
|
|
10
|
+
many?: React.ReactNode;
|
|
11
|
+
children?(value: React.ReactNode): React.ReactElement | null;
|
|
12
|
+
}
|
|
13
|
+
declare const FormattedPlural: React.FC<Props>;
|
|
14
|
+
export default FormattedPlural;
|
|
15
|
+
//# sourceMappingURL=plural.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plural.d.ts","sourceRoot":"","sources":["../../../src/components/plural.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,mBAAmB,EAAC,MAAM,gBAAgB,CAAA;AAGlD,UAAU,KAAM,SAAQ,mBAAmB;IACzC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,QAAQ,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CAC7D;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAepC,CAAA;AAQD,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2015, Yahoo Inc.
|
|
3
|
+
* Copyrights licensed under the New BSD License.
|
|
4
|
+
* See the accompanying LICENSE file for terms.
|
|
5
|
+
*/
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import useIntl from './useIntl';
|
|
8
|
+
var FormattedPlural = function (props) {
|
|
9
|
+
var _a = useIntl(), formatPlural = _a.formatPlural, Text = _a.textComponent;
|
|
10
|
+
var value = props.value, other = props.other, children = props.children;
|
|
11
|
+
var pluralCategory = formatPlural(value, props);
|
|
12
|
+
var formattedPlural = props[pluralCategory] || other;
|
|
13
|
+
if (typeof children === 'function') {
|
|
14
|
+
return children(formattedPlural);
|
|
15
|
+
}
|
|
16
|
+
if (Text) {
|
|
17
|
+
return React.createElement(Text, null, formattedPlural);
|
|
18
|
+
}
|
|
19
|
+
// Work around @types/react where React.FC cannot return string
|
|
20
|
+
return formattedPlural;
|
|
21
|
+
};
|
|
22
|
+
FormattedPlural.defaultProps = {
|
|
23
|
+
type: 'cardinal',
|
|
24
|
+
};
|
|
25
|
+
FormattedPlural.displayName = 'FormattedPlural';
|
|
26
|
+
export default FormattedPlural;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { IntlConfig, IntlShape, ResolvedIntlConfig } from '../types';
|
|
3
|
+
import { IntlCache, CreateIntlFn } from '@formatjs/intl';
|
|
4
|
+
interface State {
|
|
5
|
+
/**
|
|
6
|
+
* Explicit intl cache to prevent memory leaks
|
|
7
|
+
*/
|
|
8
|
+
cache: IntlCache;
|
|
9
|
+
/**
|
|
10
|
+
* Intl object we created
|
|
11
|
+
*/
|
|
12
|
+
intl?: IntlShape;
|
|
13
|
+
/**
|
|
14
|
+
* list of memoized config we care about.
|
|
15
|
+
* This is important since creating intl is
|
|
16
|
+
* very expensive
|
|
17
|
+
*/
|
|
18
|
+
prevConfig: IntlConfig;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create intl object
|
|
22
|
+
* @param config intl config
|
|
23
|
+
* @param cache cache for formatter instances to prevent memory leak
|
|
24
|
+
*/
|
|
25
|
+
export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
|
|
26
|
+
export default class IntlProvider extends React.PureComponent<React.PropsWithChildren<IntlConfig>, State> {
|
|
27
|
+
static displayName: string;
|
|
28
|
+
static defaultProps: Pick<ResolvedIntlConfig, "onError" | "timeZone" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "textComponent">;
|
|
29
|
+
private cache;
|
|
30
|
+
state: State;
|
|
31
|
+
static getDerivedStateFromProps(props: Readonly<IntlConfig>, { prevConfig, cache }: State): Partial<State> | null;
|
|
32
|
+
render(): JSX.Element;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/components/provider.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,OAAO,KAAK,EAAC,UAAU,EAAE,SAAS,EAAE,kBAAkB,EAAC,MAAM,UAAU,CAAA;AACvE,OAAO,EAEL,SAAS,EAET,YAAY,EAGb,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;AAmED;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,YAAY,CACnC,KAAK,CAAC,SAAS,EACf,UAAU,EACV,SAAS,CAwCV,CAAA;AAED,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,6JAAsB;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"}
|