use-intl 2.17.5-alpha.1 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/use-intl.esm2.js +31 -132
- package/dist/core/use-intl.esm2.js.map +1 -1
- package/dist/core/use-intl.esm3.js +132 -8
- package/dist/core/use-intl.esm3.js.map +1 -1
- package/dist/core/use-intl.esm4.js +10 -33
- package/dist/core/use-intl.esm4.js.map +1 -1
- package/dist/core/use-intl.esm5.js +50 -12
- package/dist/core/use-intl.esm5.js.map +1 -1
- package/dist/core/use-intl.esm6.js +12 -50
- package/dist/core/use-intl.esm6.js.map +1 -1
- package/dist/core/use-intl.esm7.js +182 -19
- package/dist/core/use-intl.esm7.js.map +1 -1
- package/dist/core/use-intl.esm9.js +19 -182
- package/dist/core/use-intl.esm9.js.map +1 -1
- package/dist/react/use-intl.esm.js +2 -2
- package/dist/react/use-intl.esm10.js +26 -3
- package/dist/react/use-intl.esm10.js.map +1 -1
- package/dist/react/use-intl.esm11.js +1 -1
- package/dist/react/use-intl.esm12.js +1 -1
- package/dist/react/use-intl.esm2.js +21 -3
- package/dist/react/use-intl.esm2.js.map +1 -1
- package/dist/react/use-intl.esm3.js +3 -21
- package/dist/react/use-intl.esm3.js.map +1 -1
- package/dist/react/use-intl.esm4.js +40 -3
- package/dist/react/use-intl.esm4.js.map +1 -1
- package/dist/react/use-intl.esm5.js +3 -40
- package/dist/react/use-intl.esm5.js.map +1 -1
- package/dist/react/use-intl.esm6.js +3 -19
- package/dist/react/use-intl.esm6.js.map +1 -1
- package/dist/react/use-intl.esm7.js +4 -10
- package/dist/react/use-intl.esm7.js.map +1 -1
- package/dist/react/use-intl.esm8.js +25 -3
- package/dist/react/use-intl.esm8.js.map +1 -1
- package/dist/react/use-intl.esm9.js +3 -26
- package/dist/react/use-intl.esm9.js.map +1 -1
- package/dist/src/react/IntlContext.d.ts +1 -1
- package/dist/src/react/useIntlContext.d.ts +1 -1
- package/dist/use-intl.esm.js +10 -10
- package/package.json +13 -11
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import useIntlContext from './use-intl.esm11.js';
|
|
2
|
+
import useTranslationsImpl from './use-intl.esm12.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Translates messages from the given namespace by using the ICU syntax.
|
|
6
|
+
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
7
|
+
*
|
|
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`).
|
|
11
|
+
*/
|
|
12
|
+
function useTranslations(namespace) {
|
|
13
|
+
var context = useIntlContext();
|
|
14
|
+
var messages = context.messages;
|
|
15
|
+
// 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.
|
|
18
|
+
return useTranslationsImpl({
|
|
19
|
+
'!': messages
|
|
20
|
+
},
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
namespace ? "!." + namespace : '!', '!');
|
|
5
23
|
}
|
|
6
24
|
|
|
7
|
-
export {
|
|
25
|
+
export { useTranslations as default };
|
|
8
26
|
//# sourceMappingURL=use-intl.esm2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm2.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm2.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,eAAeA,CAMrCC,SAAqB,EAAA;AA6DrB,EAAA,IAAMC,OAAO,GAAGC,cAAc,EAAE,CAAA;AAChC,EAAA,IAAMC,QAAQ,GAAGF,OAAO,CAACE,QAAwB,CAAA;AAEjD;AACA;AACA;AACA,EAAA,OAAOC,mBAAmB,CAIxB;AAAC,IAAA,GAAG,EAAED,QAAAA;GAAS;AACf;AACAH,EAAAA,SAAS,UAAQA,SAAS,GAAK,GAAG,EAClC,GAAG,CACJ,CAAA;AACH;;;;"}
|
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
import useIntlContext from './use-intl.esm11.js';
|
|
2
|
-
import useTranslationsImpl from './use-intl.esm12.js';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
7
|
-
*
|
|
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`).
|
|
11
|
-
*/
|
|
12
|
-
function useTranslations(namespace) {
|
|
13
|
-
var context = useIntlContext();
|
|
14
|
-
var messages = context.messages;
|
|
15
|
-
// 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.
|
|
18
|
-
return useTranslationsImpl({
|
|
19
|
-
'!': messages
|
|
20
|
-
},
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
namespace ? "!." + namespace : '!', '!');
|
|
3
|
+
function useLocale() {
|
|
4
|
+
return useIntlContext().locale;
|
|
23
5
|
}
|
|
24
6
|
|
|
25
|
-
export {
|
|
7
|
+
export { useLocale as default };
|
|
26
8
|
//# sourceMappingURL=use-intl.esm3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm3.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm3.js","sources":["../../src/react/useLocale.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n"],"names":["useLocale","useIntlContext","locale"],"mappings":";;AAEc,SAAUA,SAASA,GAAA;AAC/B,EAAA,OAAOC,cAAc,EAAE,CAACC,MAAM,CAAA;AAChC;;;;"}
|
|
@@ -1,8 +1,45 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
1
2
|
import useIntlContext from './use-intl.esm11.js';
|
|
2
3
|
|
|
3
|
-
function
|
|
4
|
-
return
|
|
4
|
+
function getNow() {
|
|
5
|
+
return new Date();
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Reading the current date via `new Date()` in components should be avoided, as
|
|
9
|
+
* it causes components to be impure and can lead to flaky tests. Instead, this
|
|
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.
|
|
20
|
+
*
|
|
21
|
+
* For unit tests, this can be mocked to a constant value. For end-to-end
|
|
22
|
+
* testing, an environment parameter can be passed to the `now` parameter
|
|
23
|
+
* of the provider to mock this to a static value.
|
|
24
|
+
*/
|
|
25
|
+
function useNow(options) {
|
|
26
|
+
var updateInterval = options == null ? void 0 : options.updateInterval;
|
|
27
|
+
var _useIntlContext = useIntlContext(),
|
|
28
|
+
globalNow = _useIntlContext.now;
|
|
29
|
+
var _useState = useState(globalNow || getNow()),
|
|
30
|
+
now = _useState[0],
|
|
31
|
+
setNow = _useState[1];
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
if (!updateInterval) return;
|
|
34
|
+
var intervalId = setInterval(function () {
|
|
35
|
+
setNow(getNow());
|
|
36
|
+
}, updateInterval);
|
|
37
|
+
return function () {
|
|
38
|
+
clearInterval(intervalId);
|
|
39
|
+
};
|
|
40
|
+
}, [globalNow, updateInterval]);
|
|
41
|
+
return now;
|
|
5
42
|
}
|
|
6
43
|
|
|
7
|
-
export {
|
|
44
|
+
export { useNow as default };
|
|
8
45
|
//# 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/useNow.tsx"],"sourcesContent":["import {useState, useEffect} from 'react';\nimport useIntlContext from './useIntlContext';\n\ntype Options = {\n updateInterval?: number;\n};\n\nfunction getNow() {\n return new Date();\n}\n\n/**\n * Reading the current date via `new Date()` in components should be avoided, as\n * it causes components to be impure and can lead to flaky tests. Instead, this\n * hook can be used.\n *\n * By default, it returns the time when the component mounts. If `updateInterval`\n * is specified, the value will be updated based on the interval.\n *\n * You can however also return a static value from this hook, if you\n * configure the `now` parameter on the context provider. Note however,\n * that if `updateInterval` is configured in this case, the component\n * will initialize with the global value, but will afterwards update\n * continuously based on the interval.\n *\n * For unit tests, this can be mocked to a constant value. For end-to-end\n * testing, an environment parameter can be passed to the `now` parameter\n * of the provider to mock this to a static value.\n */\nexport default function useNow(options?: Options) {\n const updateInterval = options?.updateInterval;\n\n const {now: globalNow} = useIntlContext();\n const [now, setNow] = useState(globalNow || getNow());\n\n useEffect(() => {\n if (!updateInterval) return;\n\n const intervalId = setInterval(() => {\n setNow(getNow());\n }, updateInterval);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [globalNow, updateInterval]);\n\n return now;\n}\n"],"names":["getNow","Date","useNow","options","updateInterval","_useIntlContext","useIntlContext","globalNow","now","_useState","useState","setNow","useEffect","intervalId","setInterval","clearInterval"],"mappings":";;;AAOA,SAASA,MAAMA,GAAA;EACb,OAAO,IAAIC,IAAI,EAAE,CAAA;AACnB,CAAA;AAEA;;;;;;;;;;;;;;;;;AAiBG;AACqB,SAAAC,MAAMA,CAACC,OAAiB,EAAA;AAC9C,EAAA,IAAMC,cAAc,GAAGD,OAAO,IAAPA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAAEC,cAAc,CAAA;AAE9C,EAAA,IAAAC,eAAA,GAAyBC,cAAc,EAAE;IAA7BC,SAAS,GAAAF,eAAA,CAAdG,GAAG,CAAA;EACV,IAAAC,SAAA,GAAsBC,QAAQ,CAACH,SAAS,IAAIP,MAAM,EAAE,CAAC;AAA9CQ,IAAAA,GAAG,GAAAC,SAAA,CAAA,CAAA,CAAA;AAAEE,IAAAA,MAAM,GAAAF,SAAA,CAAA,CAAA,CAAA,CAAA;AAElBG,EAAAA,SAAS,CAAC,YAAK;IACb,IAAI,CAACR,cAAc,EAAE,OAAA;AAErB,IAAA,IAAMS,UAAU,GAAGC,WAAW,CAAC,YAAK;AAClCH,MAAAA,MAAM,CAACX,MAAM,EAAE,CAAC,CAAA;KACjB,EAAEI,cAAc,CAAC,CAAA;AAElB,IAAA,OAAO,YAAK;MACVW,aAAa,CAACF,UAAU,CAAC,CAAA;KAC1B,CAAA;AACH,GAAC,EAAE,CAACN,SAAS,EAAEH,cAAc,CAAC,CAAC,CAAA;AAE/B,EAAA,OAAOI,GAAG,CAAA;AACZ;;;;"}
|
|
@@ -1,45 +1,8 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
1
|
import useIntlContext from './use-intl.esm11.js';
|
|
3
2
|
|
|
4
|
-
function
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Reading the current date via `new Date()` in components should be avoided, as
|
|
9
|
-
* it causes components to be impure and can lead to flaky tests. Instead, this
|
|
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.
|
|
20
|
-
*
|
|
21
|
-
* For unit tests, this can be mocked to a constant value. For end-to-end
|
|
22
|
-
* testing, an environment parameter can be passed to the `now` parameter
|
|
23
|
-
* of the provider to mock this to a static value.
|
|
24
|
-
*/
|
|
25
|
-
function useNow(options) {
|
|
26
|
-
var updateInterval = options == null ? void 0 : options.updateInterval;
|
|
27
|
-
var _useIntlContext = useIntlContext(),
|
|
28
|
-
globalNow = _useIntlContext.now;
|
|
29
|
-
var _useState = useState(globalNow || getNow()),
|
|
30
|
-
now = _useState[0],
|
|
31
|
-
setNow = _useState[1];
|
|
32
|
-
useEffect(function () {
|
|
33
|
-
if (!updateInterval) return;
|
|
34
|
-
var intervalId = setInterval(function () {
|
|
35
|
-
setNow(getNow());
|
|
36
|
-
}, updateInterval);
|
|
37
|
-
return function () {
|
|
38
|
-
clearInterval(intervalId);
|
|
39
|
-
};
|
|
40
|
-
}, [globalNow, updateInterval]);
|
|
41
|
-
return now;
|
|
3
|
+
function useTimeZone() {
|
|
4
|
+
return useIntlContext().timeZone;
|
|
42
5
|
}
|
|
43
6
|
|
|
44
|
-
export {
|
|
7
|
+
export { useTimeZone as default };
|
|
45
8
|
//# sourceMappingURL=use-intl.esm5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm5.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm5.js","sources":["../../src/react/useTimeZone.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"names":["useTimeZone","useIntlContext","timeZone"],"mappings":";;AAEc,SAAUA,WAAWA,GAAA;AACjC,EAAA,OAAOC,cAAc,EAAE,CAACC,QAAQ,CAAA;AAClC;;;;"}
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import createFormatter from '../core/use-intl.esm2.js';
|
|
3
1
|
import useIntlContext from './use-intl.esm11.js';
|
|
4
2
|
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
formats = _useIntlContext.formats,
|
|
8
|
-
locale = _useIntlContext.locale,
|
|
9
|
-
globalNow = _useIntlContext.now,
|
|
10
|
-
onError = _useIntlContext.onError,
|
|
11
|
-
timeZone = _useIntlContext.timeZone;
|
|
12
|
-
return useMemo(function () {
|
|
13
|
-
return createFormatter({
|
|
14
|
-
formats: formats,
|
|
15
|
-
locale: locale,
|
|
16
|
-
now: globalNow,
|
|
17
|
-
onError: onError,
|
|
18
|
-
timeZone: timeZone
|
|
19
|
-
});
|
|
20
|
-
}, [formats, globalNow, locale, onError, timeZone]);
|
|
3
|
+
function useMessages() {
|
|
4
|
+
return useIntlContext().messages;
|
|
21
5
|
}
|
|
22
6
|
|
|
23
|
-
export {
|
|
7
|
+
export { useMessages as default };
|
|
24
8
|
//# 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/useMessages.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useMessages() {\n return useIntlContext().messages;\n}\n"],"names":["useMessages","useIntlContext","messages"],"mappings":";;AAEc,SAAUA,WAAWA,GAAA;AACjC,EAAA,OAAOC,cAAc,EAAE,CAACC,QAAQ,CAAA;AAClC;;;;"}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import createFormatter from '../core/use-intl.esm3.js';
|
|
3
3
|
import useIntlContext from './use-intl.esm11.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
/** @deprecated Switch to `useFormatter` instead. */
|
|
7
|
-
function useIntl() {
|
|
5
|
+
function useFormatter() {
|
|
8
6
|
var _useIntlContext = useIntlContext(),
|
|
9
7
|
formats = _useIntlContext.formats,
|
|
10
8
|
locale = _useIntlContext.locale,
|
|
11
9
|
globalNow = _useIntlContext.now,
|
|
12
10
|
onError = _useIntlContext.onError,
|
|
13
11
|
timeZone = _useIntlContext.timeZone;
|
|
14
|
-
if (!hasWarned) {
|
|
15
|
-
hasWarned = true;
|
|
16
|
-
console.warn('`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.');
|
|
17
|
-
}
|
|
18
12
|
return useMemo(function () {
|
|
19
|
-
return
|
|
13
|
+
return createFormatter({
|
|
20
14
|
formats: formats,
|
|
21
15
|
locale: locale,
|
|
22
16
|
now: globalNow,
|
|
@@ -26,5 +20,5 @@ function useIntl() {
|
|
|
26
20
|
}, [formats, globalNow, locale, onError, timeZone]);
|
|
27
21
|
}
|
|
28
22
|
|
|
29
|
-
export {
|
|
23
|
+
export { useFormatter as default };
|
|
30
24
|
//# 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","useIntlContext","formats","locale","globalNow","now","onError","timeZone","useMemo","createFormatter"],"mappings":";;;;AAIc,SAAUA,YAAYA,GAAA;AAClC,EAAA,IAAAC,eAAA,GAA6DC,cAAc,EAAE;IAAtEC,OAAO,GAAAF,eAAA,CAAPE,OAAO;IAAEC,MAAM,GAAAH,eAAA,CAANG,MAAM;IAAOC,SAAS,GAAAJ,eAAA,CAAdK,GAAG;IAAaC,OAAO,GAAAN,eAAA,CAAPM,OAAO;IAAEC,QAAQ,GAAAP,eAAA,CAARO,QAAQ,CAAA;AAEzD,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,eAAe,CAAC;AACdP,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,MAAM,EAANA,MAAM;AACNE,MAAAA,GAAG,EAAED,SAAS;AACdE,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;GACJ,EAAA,CAACL,OAAO,EAAEE,SAAS,EAAED,MAAM,EAAEG,OAAO,EAAEC,QAAQ,CAAC,CAChD,CAAA;AACH;;;;"}
|
|
@@ -1,8 +1,30 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import createIntl from '../core/use-intl.esm4.js';
|
|
1
3
|
import useIntlContext from './use-intl.esm11.js';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
var hasWarned = false;
|
|
6
|
+
/** @deprecated Switch to `useFormatter` instead. */
|
|
7
|
+
function useIntl() {
|
|
8
|
+
var _useIntlContext = useIntlContext(),
|
|
9
|
+
formats = _useIntlContext.formats,
|
|
10
|
+
locale = _useIntlContext.locale,
|
|
11
|
+
globalNow = _useIntlContext.now,
|
|
12
|
+
onError = _useIntlContext.onError,
|
|
13
|
+
timeZone = _useIntlContext.timeZone;
|
|
14
|
+
if (!hasWarned) {
|
|
15
|
+
hasWarned = true;
|
|
16
|
+
console.warn('`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.');
|
|
17
|
+
}
|
|
18
|
+
return useMemo(function () {
|
|
19
|
+
return createIntl({
|
|
20
|
+
formats: formats,
|
|
21
|
+
locale: locale,
|
|
22
|
+
now: globalNow,
|
|
23
|
+
onError: onError,
|
|
24
|
+
timeZone: timeZone
|
|
25
|
+
});
|
|
26
|
+
}, [formats, globalNow, locale, onError, timeZone]);
|
|
5
27
|
}
|
|
6
28
|
|
|
7
|
-
export {
|
|
29
|
+
export { useIntl as default };
|
|
8
30
|
//# 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/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` instead. */\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","useIntlContext","formats","locale","globalNow","now","onError","timeZone","console","warn","useMemo","createIntl"],"mappings":";;;;AAIA,IAAIA,SAAS,GAAG,KAAK,CAAA;AAErB;AACc,SAAUC,OAAOA,GAAA;AAC7B,EAAA,IAAAC,eAAA,GAA6DC,cAAc,EAAE;IAAtEC,OAAO,GAAAF,eAAA,CAAPE,OAAO;IAAEC,MAAM,GAAAH,eAAA,CAANG,MAAM;IAAOC,SAAS,GAAAJ,eAAA,CAAdK,GAAG;IAAaC,OAAO,GAAAN,eAAA,CAAPM,OAAO;IAAEC,QAAQ,GAAAP,eAAA,CAARO,QAAQ,CAAA;EAEzD,IAAI,CAACT,SAAS,EAAE;AACdA,IAAAA,SAAS,GAAG,IAAI,CAAA;AAChBU,IAAAA,OAAO,CAACC,IAAI,CACV,6GAA6G,CAC9G,CAAA;AACF,GAAA;AAED,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,UAAU,CAAC;AACTT,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,MAAM,EAANA,MAAM;AACNE,MAAAA,GAAG,EAAED,SAAS;AACdE,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;GACJ,EAAA,CAACL,OAAO,EAAEE,SAAS,EAAED,MAAM,EAAEG,OAAO,EAAEC,QAAQ,CAAC,CAChD,CAAA;AACH;;;;"}
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defaultOnError, defaultGetMessageFallback } from '../core/use-intl.esm5.js';
|
|
3
|
-
import validateMessages from '../core/use-intl.esm7.js';
|
|
1
|
+
import { createContext } from 'react';
|
|
4
2
|
|
|
5
|
-
var
|
|
6
|
-
/**
|
|
7
|
-
* Enhances the incoming props with defaults.
|
|
8
|
-
*/
|
|
9
|
-
function getInitializedConfig(_ref) {
|
|
10
|
-
var getMessageFallback = _ref.getMessageFallback,
|
|
11
|
-
messages = _ref.messages,
|
|
12
|
-
onError = _ref.onError,
|
|
13
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
14
|
-
var finalOnError = onError || defaultOnError;
|
|
15
|
-
var finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
|
|
16
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
17
|
-
if (messages) {
|
|
18
|
-
validateMessages(messages, finalOnError);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return _extends({}, rest, {
|
|
22
|
-
messages: messages,
|
|
23
|
-
onError: finalOnError,
|
|
24
|
-
getMessageFallback: finalGetMessageFallback
|
|
25
|
-
});
|
|
26
|
-
}
|
|
3
|
+
var IntlContext = /*#__PURE__*/createContext(undefined);
|
|
27
4
|
|
|
28
|
-
export {
|
|
5
|
+
export { IntlContext as default };
|
|
29
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 {InitializedIntlConfig} from '../core/IntlConfig';\n\nconst IntlContext = createContext<InitializedIntlConfig | undefined>(undefined);\n\nexport default IntlContext;\n"],"names":["IntlContext","createContext","undefined"],"mappings":";;AAGA,IAAMA,WAAW,gBAAGC,aAAa,CAAoCC,SAAS;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InitializedIntlConfig } from '../core/IntlConfig';
|
|
3
|
-
declare const IntlContext: import("react").Context<InitializedIntlConfig
|
|
3
|
+
declare const IntlContext: import("react").Context<InitializedIntlConfig | undefined>;
|
|
4
4
|
export default IntlContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useIntlContext(): import("../core/IntlConfig").InitializedIntlConfig
|
|
1
|
+
export default function useIntlContext(): import("../core/IntlConfig").InitializedIntlConfig;
|
package/dist/use-intl.esm.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { default as IntlError, IntlErrorCode } from './core/use-intl.esm.js';
|
|
2
|
-
export { default as createTranslator } from './core/use-intl.
|
|
3
|
-
export { default as createFormatter } from './core/use-intl.
|
|
4
|
-
export { default as createIntl } from './core/use-intl.
|
|
2
|
+
export { default as createTranslator } from './core/use-intl.esm2.js';
|
|
3
|
+
export { default as createFormatter } from './core/use-intl.esm3.js';
|
|
4
|
+
export { default as createIntl } from './core/use-intl.esm4.js';
|
|
5
5
|
export { default as IntlProvider } from './react/use-intl.esm.js';
|
|
6
|
-
export { default as useTranslations } from './react/use-intl.
|
|
7
|
-
export { default as useLocale } from './react/use-intl.
|
|
8
|
-
export { default as useNow } from './react/use-intl.
|
|
9
|
-
export { default as useTimeZone } from './react/use-intl.
|
|
10
|
-
export { default as useMessages } from './react/use-intl.
|
|
11
|
-
export { default as useFormatter } from './react/use-intl.
|
|
12
|
-
export { default as useIntl } from './react/use-intl.
|
|
6
|
+
export { default as useTranslations } from './react/use-intl.esm2.js';
|
|
7
|
+
export { default as useLocale } from './react/use-intl.esm3.js';
|
|
8
|
+
export { default as useNow } from './react/use-intl.esm4.js';
|
|
9
|
+
export { default as useTimeZone } from './react/use-intl.esm5.js';
|
|
10
|
+
export { default as useMessages } from './react/use-intl.esm6.js';
|
|
11
|
+
export { default as useFormatter } from './react/use-intl.esm7.js';
|
|
12
|
+
export { default as useIntl } from './react/use-intl.esm8.js';
|
|
13
13
|
//# sourceMappingURL=use-intl.esm.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-intl",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"description": "Minimal, but complete solution for managing internationalization in React apps.",
|
|
@@ -10,6 +10,15 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/amannn/next-intl/tree/main/packages/use-intl"
|
|
12
12
|
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "pnpm build:default && pnpm build:rsc",
|
|
15
|
+
"build:default": "rm -rf dist && dts build",
|
|
16
|
+
"build:rsc": "tsc && rm -rf dist/test",
|
|
17
|
+
"test": "TZ=Europe/Berlin vitest",
|
|
18
|
+
"lint": "eslint src test && tsc --noEmit",
|
|
19
|
+
"prepublishOnly": "CI=true turbo test && turbo lint && turbo build",
|
|
20
|
+
"size": "size-limit"
|
|
21
|
+
},
|
|
13
22
|
"main": "dist/index.js",
|
|
14
23
|
"module": "dist/use-intl.esm.js",
|
|
15
24
|
"typings": "dist/index.d.ts",
|
|
@@ -47,7 +56,7 @@
|
|
|
47
56
|
"react": "^18.2.0",
|
|
48
57
|
"react-dom": "^18.2.0",
|
|
49
58
|
"size-limit": "^8.2.6",
|
|
50
|
-
"typescript": "^
|
|
59
|
+
"typescript": "^5.0.0",
|
|
51
60
|
"vitest": "^0.32.2"
|
|
52
61
|
},
|
|
53
62
|
"size-limit": [
|
|
@@ -63,12 +72,5 @@
|
|
|
63
72
|
"engines": {
|
|
64
73
|
"node": ">=10"
|
|
65
74
|
},
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
"build:default": "rm -rf dist && dts build",
|
|
69
|
-
"build:rsc": "tsc && rm -rf dist/test",
|
|
70
|
-
"test": "TZ=Europe/Berlin vitest",
|
|
71
|
-
"lint": "eslint src test && tsc --noEmit",
|
|
72
|
-
"size": "size-limit"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
+
"gitHead": "023d23a7a71f5594d8a457c09ea988b56b248239"
|
|
76
|
+
}
|