use-intl 2.12.0 → 2.13.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +542 -0
- package/dist/core/createIntl.d.ts +1 -1
- package/dist/core/use-intl.esm2.js +151 -35
- package/dist/core/use-intl.esm2.js.map +1 -1
- package/dist/core/use-intl.esm3.js +8 -148
- package/dist/core/use-intl.esm3.js.map +1 -1
- package/dist/core/use-intl.esm4.js +34 -10
- package/dist/core/use-intl.esm4.js.map +1 -1
- package/dist/core/use-intl.esm5.js +12 -56
- package/dist/core/use-intl.esm5.js.map +1 -1
- package/dist/core/use-intl.esm6.js +56 -12
- package/dist/core/use-intl.esm6.js.map +1 -1
- package/dist/core/use-intl.esm8.js +1 -1
- package/dist/core/use-intl.esm8.js.map +1 -1
- package/dist/react/IntlContext.d.ts +2 -19
- package/dist/react/IntlContextValue.d.ts +19 -0
- package/dist/react/IntlProvider.d.ts +2 -16
- package/dist/react/IntlProviderProps.d.ts +15 -0
- package/dist/react/getIntlContextValue.d.ts +18 -0
- package/dist/react/use-intl.esm.js +7 -26
- package/dist/react/use-intl.esm.js.map +1 -1
- package/dist/react/use-intl.esm10.js +9 -38
- package/dist/react/use-intl.esm10.js.map +1 -1
- package/dist/react/use-intl.esm11.js +44 -0
- package/dist/react/use-intl.esm11.js.map +1 -0
- package/dist/react/use-intl.esm2.js +4 -22
- package/dist/react/use-intl.esm2.js.map +1 -1
- package/dist/react/use-intl.esm3.js +46 -4
- package/dist/react/use-intl.esm3.js.map +1 -1
- package/dist/react/use-intl.esm4.js +17 -41
- package/dist/react/use-intl.esm4.js.map +1 -1
- package/dist/react/use-intl.esm5.js +1 -1
- package/dist/react/use-intl.esm6.js +13 -5
- package/dist/react/use-intl.esm6.js.map +1 -1
- package/dist/react/use-intl.esm7.js +5 -13
- package/dist/react/use-intl.esm7.js.map +1 -1
- package/dist/react/use-intl.esm8.js +30 -3
- package/dist/react/use-intl.esm8.js.map +1 -1
- package/dist/react/use-intl.esm9.js +3 -12
- package/dist/react/use-intl.esm9.js.map +1 -1
- package/dist/react/useFormatter.d.ts +1 -1
- package/dist/react/useIntl.d.ts +1 -1
- package/dist/react/useIntlContext.d.ts +1 -1
- package/dist/src/core/createBaseTranslator.js +1 -1
- package/dist/src/core/createBaseTranslator.js.map +1 -1
- package/dist/src/react/IntlContext.d.ts +2 -19
- package/dist/src/react/IntlContext.js.map +1 -1
- package/dist/src/react/IntlContextValue.d.ts +19 -0
- package/dist/src/react/IntlContextValue.js +2 -0
- package/dist/src/react/IntlContextValue.js.map +1 -0
- package/dist/src/react/IntlProvider.d.ts +2 -16
- package/dist/src/react/IntlProvider.js +4 -13
- package/dist/src/react/IntlProvider.js.map +1 -1
- package/dist/src/react/IntlProviderProps.d.ts +15 -0
- package/dist/src/react/IntlProviderProps.js +2 -0
- package/dist/src/react/IntlProviderProps.js.map +1 -0
- package/dist/src/react/getIntlContextValue.d.ts +18 -0
- package/dist/src/react/getIntlContextValue.js +21 -0
- package/dist/src/react/getIntlContextValue.js.map +1 -0
- package/dist/src/react/useIntlContext.d.ts +1 -1
- package/dist/src/react/useTranslationsImpl.js.map +1 -1
- package/dist/use-intl.cjs.development.js +33 -24
- package/dist/use-intl.cjs.development.js.map +1 -1
- package/dist/use-intl.cjs.production.min.js +1 -1
- package/dist/use-intl.cjs.production.min.js.map +1 -1
- package/dist/use-intl.esm.js +8 -8
- package/package.json +3 -4
- package/src/core/createBaseTranslator.tsx +1 -1
- package/src/react/IntlContext.tsx +2 -20
- package/src/react/IntlContextValue.tsx +21 -0
- package/src/react/IntlProvider.tsx +5 -36
- package/src/react/IntlProviderProps.tsx +17 -0
- package/src/react/getIntlContextValue.tsx +30 -0
- package/src/react/useTranslationsImpl.tsx +2 -1
- package/LICENSE +0 -21
|
@@ -1,50 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import useIntlContext from './use-intl.esm10.js';
|
|
2
|
+
import useTranslationsImpl from './use-intl.esm11.js';
|
|
3
3
|
|
|
4
|
-
function getNow() {
|
|
5
|
-
return new Date();
|
|
6
|
-
}
|
|
7
4
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* hook can be used.
|
|
11
|
-
*
|
|
12
|
-
* By default, it returns the time when the component mounts. If `updateInterval`
|
|
13
|
-
* is specified, the value will be updated based on the interval.
|
|
14
|
-
*
|
|
15
|
-
* You can however also return a static value from this hook, if you
|
|
16
|
-
* configure the `now` parameter on the context provider. Note however,
|
|
17
|
-
* that if `updateInterval` is configured in this case, the component
|
|
18
|
-
* will initialize with the global value, but will afterwards update
|
|
19
|
-
* continuously based on the interval.
|
|
5
|
+
* Translates messages from the given namespace by using the ICU syntax.
|
|
6
|
+
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
20
7
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
8
|
+
* If no namespace is provided, all available messages are returned.
|
|
9
|
+
* The namespace can also indicate nesting by using a dot
|
|
10
|
+
* (e.g. `namespace.Component`).
|
|
24
11
|
*/
|
|
25
12
|
|
|
13
|
+
function useTranslations(namespace) {
|
|
14
|
+
var context = useIntlContext();
|
|
15
|
+
var messages = context.messages; // We have to wrap the actual hook so the type inference for the optional
|
|
16
|
+
// namespace works correctly. See https://stackoverflow.com/a/71529575/343045
|
|
17
|
+
// The prefix ("!") is arbitrary.
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
globalNow = _useIntlContext.now;
|
|
32
|
-
|
|
33
|
-
var _useState = useState(globalNow || getNow()),
|
|
34
|
-
now = _useState[0],
|
|
35
|
-
setNow = _useState[1];
|
|
36
|
-
|
|
37
|
-
useEffect(function () {
|
|
38
|
-
if (!updateInterval) return;
|
|
39
|
-
var intervalId = setInterval(function () {
|
|
40
|
-
setNow(getNow());
|
|
41
|
-
}, updateInterval);
|
|
42
|
-
return function () {
|
|
43
|
-
clearInterval(intervalId);
|
|
44
|
-
};
|
|
45
|
-
}, [globalNow, updateInterval]);
|
|
46
|
-
return now;
|
|
19
|
+
return useTranslationsImpl({
|
|
20
|
+
'!': messages
|
|
21
|
+
}, // @ts-ignore
|
|
22
|
+
namespace ? "!." + namespace : '!', '!');
|
|
47
23
|
}
|
|
48
24
|
|
|
49
|
-
export {
|
|
25
|
+
export { useTranslations as default };
|
|
50
26
|
//# sourceMappingURL=use-intl.esm4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/useTranslations.tsx"],"sourcesContent":["import {ReactElement, ReactNodeArray} from 'react';\nimport Formats from '../core/Formats';\nimport TranslationValues, {\n RichTranslationValues\n} from '../core/TranslationValues';\nimport MessageKeys from '../core/utils/MessageKeys';\nimport NamespaceKeys from '../core/utils/NamespaceKeys';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport NestedValueOf from '../core/utils/NestedValueOf';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function useTranslations<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>(\n namespace?: NestedKey\n): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: RichTranslationValues,\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n const context = useIntlContext();\n const messages = context.messages as IntlMessages;\n\n // We have to wrap the actual hook so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return useTranslationsImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {'!': messages},\n // @ts-ignore\n namespace ? `!.${namespace}` : '!',\n '!'\n );\n}\n"],"names":["useTranslations","namespace","context","useIntlContext","messages","useTranslationsImpl"],"mappings":";;;AAYA;;;;;;;AAOG;;AACqB,SAAAA,eAAA,CAMtBC,SANsB,EAMD;AA6DrB,EAAMC,IAAAA,OAAO,GAAGC,cAAc,EAA9B,CAAA;AACA,EAAA,IAAMC,QAAQ,GAAGF,OAAO,CAACE,QAAzB,CA9DqB;AAiErB;AACA;;AACA,EAAA,OAAOC,mBAAmB,CAIxB;AAAC,IAAKD,GAAAA,EAAAA,QAAAA;AAAN,GAJwB;AAMxBH,EAAAA,SAAS,GAAQA,IAAAA,GAAAA,SAAR,GAAsB,GANP,EAOxB,GAPwB,CAA1B,CAAA;AASD;;;;"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import useIntlContext from './use-intl.
|
|
2
|
+
import createIntl from '../core/use-intl.esm3.js';
|
|
3
|
+
import useIntlContext from './use-intl.esm10.js';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
var hasWarned = false;
|
|
6
|
+
/** @deprecated Switch to `useFormatter` */
|
|
7
|
+
|
|
8
|
+
function useIntl() {
|
|
6
9
|
var _useIntlContext = useIntlContext(),
|
|
7
10
|
formats = _useIntlContext.formats,
|
|
8
11
|
locale = _useIntlContext.locale,
|
|
@@ -10,8 +13,13 @@ function useFormatter() {
|
|
|
10
13
|
onError = _useIntlContext.onError,
|
|
11
14
|
timeZone = _useIntlContext.timeZone;
|
|
12
15
|
|
|
16
|
+
if (!hasWarned) {
|
|
17
|
+
hasWarned = true;
|
|
18
|
+
console.warn('`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.');
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
return useMemo(function () {
|
|
14
|
-
return
|
|
22
|
+
return createIntl({
|
|
15
23
|
formats: formats,
|
|
16
24
|
locale: locale,
|
|
17
25
|
now: globalNow,
|
|
@@ -21,5 +29,5 @@ function useFormatter() {
|
|
|
21
29
|
}, [formats, globalNow, locale, onError, timeZone]);
|
|
22
30
|
}
|
|
23
31
|
|
|
24
|
-
export {
|
|
32
|
+
export { useIntl as default };
|
|
25
33
|
//# sourceMappingURL=use-intl.esm6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm6.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm6.js","sources":["../../src/react/useIntl.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport createIntl from '../core/createIntl';\nimport useIntlContext from './useIntlContext';\n\nlet hasWarned = false;\n\n/** @deprecated Switch to `useFormatter` */\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n if (!hasWarned) {\n hasWarned = true;\n console.warn(\n '`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.'\n );\n }\n\n return useMemo(\n () =>\n createIntl({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n"],"names":["hasWarned","useIntl","useIntlContext","formats","locale","globalNow","now","onError","timeZone","console","warn","useMemo","createIntl"],"mappings":";;;;AAIA,IAAIA,SAAS,GAAG,KAAhB,CAAA;AAEA;;AACc,SAAUC,OAAV,GAAiB;AAC7B,EAAA,IAAA,eAAA,GAA6DC,cAAc,EAA3E;AAAA,MAAOC,OAAP,mBAAOA,OAAP;AAAA,MAAgBC,MAAhB,mBAAgBA,MAAhB;AAAA,MAA6BC,SAA7B,mBAAwBC,GAAxB;AAAA,MAAwCC,OAAxC,mBAAwCA,OAAxC;AAAA,MAAiDC,QAAjD,mBAAiDA,QAAjD,CAAA;;AAEA,EAAI,IAAA,CAACR,SAAL,EAAgB;AACdA,IAAAA,SAAS,GAAG,IAAZ,CAAA;AACAS,IAAAA,OAAO,CAACC,IAAR,CACE,6GADF,CAAA,CAAA;AAGD,GAAA;;AAED,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,UAAU,CAAC;AACTT,MAAAA,OAAO,EAAPA,OADS;AAETC,MAAAA,MAAM,EAANA,MAFS;AAGTE,MAAAA,GAAG,EAAED,SAHI;AAITE,MAAAA,OAAO,EAAPA,OAJS;AAKTC,MAAAA,QAAQ,EAARA,QAAAA;AALS,KAAD,CADZ,CAAA;AAAA,GADY,EASZ,CAACL,OAAD,EAAUE,SAAV,EAAqBD,MAArB,EAA6BG,OAA7B,EAAsCC,QAAtC,CATY,CAAd,CAAA;AAWD;;;;"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import useIntlContext from './use-intl.
|
|
2
|
+
import createFormatter from '../core/use-intl.esm2.js';
|
|
3
|
+
import useIntlContext from './use-intl.esm10.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
/** @deprecated Switch to `useFormatter` */
|
|
7
|
-
|
|
8
|
-
function useIntl() {
|
|
5
|
+
function useFormatter() {
|
|
9
6
|
var _useIntlContext = useIntlContext(),
|
|
10
7
|
formats = _useIntlContext.formats,
|
|
11
8
|
locale = _useIntlContext.locale,
|
|
@@ -13,13 +10,8 @@ function useIntl() {
|
|
|
13
10
|
onError = _useIntlContext.onError,
|
|
14
11
|
timeZone = _useIntlContext.timeZone;
|
|
15
12
|
|
|
16
|
-
if (!hasWarned) {
|
|
17
|
-
hasWarned = true;
|
|
18
|
-
console.warn('`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
13
|
return useMemo(function () {
|
|
22
|
-
return
|
|
14
|
+
return createFormatter({
|
|
23
15
|
formats: formats,
|
|
24
16
|
locale: locale,
|
|
25
17
|
now: globalNow,
|
|
@@ -29,5 +21,5 @@ function useIntl() {
|
|
|
29
21
|
}, [formats, globalNow, locale, onError, timeZone]);
|
|
30
22
|
}
|
|
31
23
|
|
|
32
|
-
export {
|
|
24
|
+
export { useFormatter as default };
|
|
33
25
|
//# sourceMappingURL=use-intl.esm7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm7.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm7.js","sources":["../../src/react/useFormatter.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport createFormatter from '../core/createFormatter';\nimport useIntlContext from './useIntlContext';\n\nexport default function useFormatter() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n return useMemo(\n () =>\n createFormatter({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n"],"names":["useFormatter","useIntlContext","formats","locale","globalNow","now","onError","timeZone","useMemo","createFormatter"],"mappings":";;;;AAIc,SAAUA,YAAV,GAAsB;AAClC,EAAA,IAAA,eAAA,GAA6DC,cAAc,EAA3E;AAAA,MAAOC,OAAP,mBAAOA,OAAP;AAAA,MAAgBC,MAAhB,mBAAgBA,MAAhB;AAAA,MAA6BC,SAA7B,mBAAwBC,GAAxB;AAAA,MAAwCC,OAAxC,mBAAwCA,OAAxC;AAAA,MAAiDC,QAAjD,mBAAiDA,QAAjD,CAAA;;AAEA,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,eAAe,CAAC;AACdP,MAAAA,OAAO,EAAPA,OADc;AAEdC,MAAAA,MAAM,EAANA,MAFc;AAGdE,MAAAA,GAAG,EAAED,SAHS;AAIdE,MAAAA,OAAO,EAAPA,OAJc;AAKdC,MAAAA,QAAQ,EAARA,QAAAA;AALc,KAAD,CADjB,CAAA;AAAA,GADY,EASZ,CAACL,OAAD,EAAUE,SAAV,EAAqBD,MAArB,EAA6BG,OAA7B,EAAsCC,QAAtC,CATY,CAAd,CAAA;AAWD;;;;"}
|
|
@@ -1,6 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
|
|
2
|
+
import { defaultOnError, defaultGetMessageFallback } from '../core/use-intl.esm5.js';
|
|
3
|
+
import validateMessages from '../core/use-intl.esm7.js';
|
|
2
4
|
|
|
3
|
-
var
|
|
5
|
+
var _excluded = ["getMessageFallback", "messages", "onError"];
|
|
6
|
+
/**
|
|
7
|
+
* Enhances the incoming props with defaults.
|
|
8
|
+
*/
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
function getIntlContextValue(_ref) {
|
|
11
|
+
var getMessageFallback = _ref.getMessageFallback,
|
|
12
|
+
messages = _ref.messages,
|
|
13
|
+
onError = _ref.onError,
|
|
14
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
15
|
+
|
|
16
|
+
var finalOnError = onError || defaultOnError;
|
|
17
|
+
var finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
|
|
18
|
+
|
|
19
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
20
|
+
if (messages) {
|
|
21
|
+
validateMessages(messages, finalOnError);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return _extends({}, rest, {
|
|
26
|
+
messages: messages,
|
|
27
|
+
onError: finalOnError,
|
|
28
|
+
getMessageFallback: finalGetMessageFallback
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { getIntlContextValue as default };
|
|
6
33
|
//# sourceMappingURL=use-intl.esm8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm8.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm8.js","sources":["../../src/react/getIntlContextValue.tsx"],"sourcesContent":["import {defaultGetMessageFallback, defaultOnError} from '../core/defaults';\nimport validateMessages from '../core/validateMessages';\nimport IntlProviderProps from './IntlProviderProps';\n\n/**\n * Enhances the incoming props with defaults.\n */\nexport default function getIntlContextValue({\n getMessageFallback,\n messages,\n onError,\n ...rest\n}: Omit<IntlProviderProps, 'children'>) {\n const finalOnError = onError || defaultOnError;\n const finalGetMessageFallback =\n getMessageFallback || defaultGetMessageFallback;\n\n if (process.env.NODE_ENV !== 'production') {\n if (messages) {\n validateMessages(messages, finalOnError);\n }\n }\n\n return {\n ...rest,\n messages,\n onError: finalOnError,\n getMessageFallback: finalGetMessageFallback\n };\n}\n"],"names":["getIntlContextValue","getMessageFallback","messages","onError","rest","finalOnError","defaultOnError","finalGetMessageFallback","defaultGetMessageFallback","process","env","NODE_ENV","validateMessages"],"mappings":";;;;;AAIA;;AAEG;;AACqB,SAAAA,mBAAA,CAKc,IAAA,EAAA;AAAA,EAJpCC,IAAAA,kBAIoC,QAJpCA,kBAIoC;AAAA,MAHpCC,QAGoC,QAHpCA,QAGoC;AAAA,MAFpCC,OAEoC,QAFpCA,OAEoC;AAAA,MADjCC,IACiC,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACpC,EAAA,IAAMC,YAAY,GAAGF,OAAO,IAAIG,cAAhC,CAAA;AACA,EAAA,IAAMC,uBAAuB,GAC3BN,kBAAkB,IAAIO,yBADxB,CAAA;;AAGA,EAAA,IAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,IAAA,IAAIT,QAAJ,EAAc;AACZU,MAAAA,gBAAgB,CAACV,QAAD,EAAWG,YAAX,CAAhB,CAAA;AACD,KAAA;AACF,GAAA;;AAED,EAAA,OAAA,QAAA,CAAA,EAAA,EACKD,IADL,EAAA;AAEEF,IAAAA,QAAQ,EAARA,QAFF;AAGEC,IAAAA,OAAO,EAAEE,YAHX;AAIEJ,IAAAA,kBAAkB,EAAEM,uBAAAA;AAJtB,GAAA,CAAA,CAAA;AAMD;;;;"}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import IntlContext from './use-intl.esm8.js';
|
|
1
|
+
import { createContext } from 'react';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
var context = useContext(IntlContext);
|
|
3
|
+
var IntlContext = /*#__PURE__*/createContext(undefined);
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
throw new Error(process.env.NODE_ENV !== 'production' ? 'No intl context found. Have you configured the provider?' : undefined);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return context;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { useIntlContext as default };
|
|
5
|
+
export { IntlContext as default };
|
|
15
6
|
//# sourceMappingURL=use-intl.esm9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm9.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm9.js","sources":["../../src/react/IntlContext.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport IntlContextValue from './IntlContextValue';\n\nconst IntlContext = createContext<IntlContextValue | undefined>(undefined);\n\nexport default IntlContext;\n"],"names":["IntlContext","createContext","undefined"],"mappings":";;AAGA,IAAMA,WAAW,gBAAGC,aAAa,CAA+BC,SAA/B;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default function useFormatter(): {
|
|
2
2
|
dateTime: (value: number | Date, formatOrOptions?: string | import("../core/DateTimeFormatOptions").default | undefined) => string;
|
|
3
|
-
number: (value: number
|
|
3
|
+
number: (value: number, formatOrOptions?: string | import("@formatjs/ecma402-abstract").NumberFormatOptions | undefined) => string;
|
|
4
4
|
relativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
|
5
5
|
};
|
package/dist/react/useIntl.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @deprecated Switch to `useFormatter` */
|
|
2
2
|
export default function useIntl(): {
|
|
3
3
|
formatDateTime: (value: number | Date, formatOrOptions?: string | import("../core/DateTimeFormatOptions").default | undefined) => string;
|
|
4
|
-
formatNumber: (value: number
|
|
4
|
+
formatNumber: (value: number, formatOrOptions?: string | import("@formatjs/ecma402-abstract").NumberFormatOptions | undefined) => string;
|
|
5
5
|
formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useIntlContext(): import("./
|
|
1
|
+
export default function useIntlContext(): import("./IntlContextValue").default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-named-as-default
|
|
1
|
+
// eslint-disable-next-line import/no-named-as-default -- False positive
|
|
2
2
|
import IntlMessageFormat from 'intl-messageformat';
|
|
3
3
|
import { cloneElement, isValidElement } from 'react';
|
|
4
4
|
import IntlError, { IntlErrorCode } from './IntlError';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseTranslator.js","sourceRoot":"","sources":["../../../src/core/createBaseTranslator.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"createBaseTranslator.js","sourceRoot":"","sources":["../../../src/core/createBaseTranslator.tsx"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,YAAY,EACZ,cAAc,EAIf,MAAM,OAAO,CAAC;AAIf,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAErD,OAAO,iCAAiC,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAKrE,SAAS,WAAW,CAClB,QAA0C,EAC1C,GAAW,EACX,SAAkB;IAElB,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YACnC,CAAC,CAAC,8BAA8B,SAAS,KAAK;YAC9C,CAAC,CAAC,SAAS,CACd,CAAC;KACH;IAED,IAAI,OAAO,GAAG,QAAQ,CAAC;IAEvB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAI,OAAe,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;YAChC,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;gBACnC,CAAC,CAAC,uBAAuB,GAAG,SACxB,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,UACnC,GAAG;gBACL,CAAC,CAAC,SAAS,CACd,CAAC;SACH;QAED,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,wBAAwB,CAAC,MAA6B;IAC7D,IAAI,M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,KAAK,YAAY;gBACnC,CAAC,CAAC,iBAAiB,GAAG,SAClB,SAAS,CAAC,CAAC,CAAC,eAAe,SAAS,IAAI,CAAC,CAAC,CAAC,UAC7C,uFAAuF;gBACzF,CAAC,CAAC,SAAS,CACd,CAAC;SACH;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,IAAI,GAAG,eAAe,CAAC;IAEnC,WAAW,CAAC,GAAG,GAAG;IAChB,+EAA+E;IAC/E,GAAW,EACN,EAAE;QACP,IAAI,eAAe,YAAY,SAAS,EAAE;YACxC,kDAAkD;YAClD,OAAO,kBAAkB,CAAC;gBACxB,KAAK,EAAE,eAAe;gBACtB,GAAG;gBACH,SAAS;aACV,CAAC,CAAC;SACJ;QACD,MAAM,QAAQ,GAAG,eAAe,CAAC;QAEjC,IAAI;YACF,OAAO,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;SAC9C;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,6BAA6B,CAClC,GAAG,EACH,aAAa,CAAC,eAAe,EAC5B,KAAe,CAAC,OAAO,CACzB,CAAC;SACH;IACH,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import IntlError from '../core/IntlError';
|
|
5
|
-
import { RichTranslationValues } from '../core/TranslationValues';
|
|
6
|
-
export declare type IntlContextShape = {
|
|
7
|
-
messages?: AbstractIntlMessages;
|
|
8
|
-
locale: string;
|
|
9
|
-
formats?: Partial<Formats>;
|
|
10
|
-
timeZone?: string;
|
|
11
|
-
onError(error: IntlError): void;
|
|
12
|
-
getMessageFallback(info: {
|
|
13
|
-
error: IntlError;
|
|
14
|
-
key: string;
|
|
15
|
-
namespace?: string;
|
|
16
|
-
}): string;
|
|
17
|
-
now?: Date;
|
|
18
|
-
defaultTranslationValues?: RichTranslationValues;
|
|
19
|
-
};
|
|
20
|
-
declare const IntlContext: import("react").Context<IntlContextShape | undefined>;
|
|
2
|
+
import IntlContextValue from './IntlContextValue';
|
|
3
|
+
declare const IntlContext: import("react").Context<IntlContextValue | undefined>;
|
|
21
4
|
export default IntlContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlContext.js","sourceRoot":"","sources":["../../../src/react/IntlContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"IntlContext.js","sourceRoot":"","sources":["../../../src/react/IntlContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAGpC,MAAM,WAAW,GAAG,aAAa,CAA+B,SAAS,CAAC,CAAC;AAE3E,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import AbstractIntlMessages from '../core/AbstractIntlMessages';
|
|
2
|
+
import Formats from '../core/Formats';
|
|
3
|
+
import IntlError from '../core/IntlError';
|
|
4
|
+
import { RichTranslationValues } from '../core/TranslationValues';
|
|
5
|
+
declare type IntlContextValue = {
|
|
6
|
+
messages?: AbstractIntlMessages;
|
|
7
|
+
locale: string;
|
|
8
|
+
formats?: Partial<Formats>;
|
|
9
|
+
timeZone?: string;
|
|
10
|
+
onError(error: IntlError): void;
|
|
11
|
+
getMessageFallback(info: {
|
|
12
|
+
error: IntlError;
|
|
13
|
+
key: string;
|
|
14
|
+
namespace?: string;
|
|
15
|
+
}): string;
|
|
16
|
+
now?: Date;
|
|
17
|
+
defaultTranslationValues?: RichTranslationValues;
|
|
18
|
+
};
|
|
19
|
+
export default IntlContextValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlContextValue.js","sourceRoot":"","sources":["../../../src/react/IntlContextValue.tsx"],"names":[],"mappings":""}
|
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import IntlConfiguration from '../core/IntlConfiguration';
|
|
4
|
-
import { RichTranslationValues } from '../core/TranslationValues';
|
|
5
|
-
declare type Props = IntlConfiguration & {
|
|
6
|
-
/** All components that use the provided hooks should be within this tree. */
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
/** Global default values for translation values and rich text elements.
|
|
9
|
-
* Can be used for consistent usage or styling of rich text elements.
|
|
10
|
-
* Defaults will be overidden by locally provided values. */
|
|
11
|
-
defaultTranslationValues?: RichTranslationValues;
|
|
12
|
-
/** All messages that will be available in your components. */
|
|
13
|
-
messages?: AbstractIntlMessages;
|
|
14
|
-
};
|
|
15
|
-
export default function IntlProvider({ children, onError, getMessageFallback, messages, ...contextValues }: Props): JSX.Element;
|
|
16
|
-
export {};
|
|
1
|
+
import IntlProviderProps from './IntlProviderProps';
|
|
2
|
+
export default function IntlProvider({ children, ...props }: IntlProviderProps): JSX.Element;
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { defaultGetMessageFallback, defaultOnError } from '../core/defaults';
|
|
3
|
-
import validateMessages from '../core/validateMessages';
|
|
1
|
+
import React from 'react';
|
|
4
2
|
import IntlContext from './IntlContext';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (messages) {
|
|
10
|
-
validateMessages(messages, onError);
|
|
11
|
-
}
|
|
12
|
-
}, [messages, onError]);
|
|
13
|
-
}
|
|
14
|
-
return (React.createElement(IntlContext.Provider, { value: { ...contextValues, messages, onError, getMessageFallback } }, children));
|
|
3
|
+
import getIntlContextValue from './getIntlContextValue';
|
|
4
|
+
export default function IntlProvider({ children, ...props }) {
|
|
5
|
+
return (React.createElement(IntlContext.Provider, { value: getIntlContextValue(props) }, children));
|
|
15
6
|
}
|
|
16
7
|
//# sourceMappingURL=IntlProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../../src/react/IntlProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../../src/react/IntlProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAC,QAAQ,EAAE,GAAG,KAAK,EAAoB;IAC1E,OAAO,CACL,oBAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC,IACpD,QAAQ,CACY,CACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AbstractIntlMessages } from '../core';
|
|
3
|
+
import IntlConfiguration from '../core/IntlConfiguration';
|
|
4
|
+
import { RichTranslationValues } from '../core/TranslationValues';
|
|
5
|
+
declare type IntlProviderProps = IntlConfiguration & {
|
|
6
|
+
/** All components that use the provided hooks should be within this tree. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Global default values for translation values and rich text elements.
|
|
9
|
+
* Can be used for consistent usage or styling of rich text elements.
|
|
10
|
+
* Defaults will be overidden by locally provided values. */
|
|
11
|
+
defaultTranslationValues?: RichTranslationValues;
|
|
12
|
+
/** All messages that will be available in your components. */
|
|
13
|
+
messages?: AbstractIntlMessages;
|
|
14
|
+
};
|
|
15
|
+
export default IntlProviderProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlProviderProps.js","sourceRoot":"","sources":["../../../src/react/IntlProviderProps.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import IntlProviderProps from './IntlProviderProps';
|
|
2
|
+
/**
|
|
3
|
+
* Enhances the incoming props with defaults.
|
|
4
|
+
*/
|
|
5
|
+
export default function getIntlContextValue({ getMessageFallback, messages, onError, ...rest }: Omit<IntlProviderProps, 'children'>): {
|
|
6
|
+
messages: import("../core/AbstractIntlMessages").default | undefined;
|
|
7
|
+
onError: (error: import("..").IntlError) => void;
|
|
8
|
+
getMessageFallback: (info: {
|
|
9
|
+
error: import("..").IntlError;
|
|
10
|
+
key: string;
|
|
11
|
+
namespace?: string | undefined;
|
|
12
|
+
}) => string;
|
|
13
|
+
defaultTranslationValues?: import("..").RichTranslationValues | undefined;
|
|
14
|
+
formats?: Partial<import("../core/Formats").default> | undefined;
|
|
15
|
+
locale: string;
|
|
16
|
+
timeZone?: string | undefined;
|
|
17
|
+
now?: Date | undefined;
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defaultGetMessageFallback, defaultOnError } from '../core/defaults';
|
|
2
|
+
import validateMessages from '../core/validateMessages';
|
|
3
|
+
/**
|
|
4
|
+
* Enhances the incoming props with defaults.
|
|
5
|
+
*/
|
|
6
|
+
export default function getIntlContextValue({ getMessageFallback, messages, onError, ...rest }) {
|
|
7
|
+
const finalOnError = onError || defaultOnError;
|
|
8
|
+
const finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
|
|
9
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
10
|
+
if (messages) {
|
|
11
|
+
validateMessages(messages, finalOnError);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
...rest,
|
|
16
|
+
messages,
|
|
17
|
+
onError: finalOnError,
|
|
18
|
+
getMessageFallback: finalGetMessageFallback
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=getIntlContextValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getIntlContextValue.js","sourceRoot":"","sources":["../../../src/react/getIntlContextValue.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC3E,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAGxD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,kBAAkB,EAClB,QAAQ,EACR,OAAO,EACP,GAAG,IAAI,EAC6B;IACpC,MAAM,YAAY,GAAG,OAAO,IAAI,cAAc,CAAC;IAC/C,MAAM,uBAAuB,GAC3B,kBAAkB,IAAI,yBAAyB,CAAC;IAElD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAI,QAAQ,EAAE;YACZ,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;SAC1C;KACF;IAED,OAAO;QACL,GAAG,IAAI;QACP,QAAQ;QACR,OAAO,EAAE,YAAY;QACrB,kBAAkB,EAAE,uBAAuB;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useIntlContext(): import("./
|
|
1
|
+
export default function useIntlContext(): import("./IntlContextValue").default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslationsImpl.js","sourceRoot":"","sources":["../../../src/react/useTranslationsImpl.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTranslationsImpl.js","sourceRoot":"","sources":["../../../src/react/useTranslationsImpl.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAEtC,OAAO,oBAAoB,EAAE,EAC3B,kBAAkB,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAExD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAGzC,WAAqB,EAAE,SAAoB,EAAE,eAAuB;IACpE,MAAM,EACJ,wBAAwB,EACxB,OAAO,EAAE,aAAa,EACtB,kBAAkB,EAClB,MA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