use-intl 2.12.0 → 2.13.0-beta.2
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.esm.js +11 -38
- package/dist/core/use-intl.esm.js.map +1 -1
- package/dist/core/use-intl.esm2.js +41 -38
- package/dist/core/use-intl.esm2.js.map +1 -1
- package/dist/core/use-intl.esm3.js +35 -151
- package/dist/core/use-intl.esm3.js.map +1 -1
- package/dist/core/use-intl.esm4.js +148 -8
- 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.esm7.js +200 -19
- package/dist/core/use-intl.esm7.js.map +1 -1
- package/dist/core/use-intl.esm8.js +7 -210
- package/dist/core/use-intl.esm8.js.map +1 -1
- package/dist/core/use-intl.esm9.js +29 -7
- package/dist/core/use-intl.esm9.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 +13 -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 +29 -4
- package/dist/react/use-intl.esm3.js.map +1 -1
- package/dist/react/use-intl.esm4.js +1 -1
- package/dist/react/use-intl.esm5.js +21 -4
- package/dist/react/use-intl.esm5.js.map +1 -1
- package/dist/react/use-intl.esm6.js +21 -20
- package/dist/react/use-intl.esm6.js.map +1 -1
- package/dist/react/use-intl.esm7.js +4 -29
- 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 +13 -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 +9 -9
- 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 +29 -0
- package/src/react/useTranslationsImpl.tsx +2 -1
- package/LICENSE +0 -21
|
@@ -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;
|
|
@@ -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,13 @@
|
|
|
1
|
+
import IntlProviderProps from './IntlProviderProps';
|
|
2
|
+
/**
|
|
3
|
+
* Enhances the incoming props with defaults.
|
|
4
|
+
*/
|
|
5
|
+
export default function getIntlContextValue<Props extends Omit<IntlProviderProps, 'children'>>({ getMessageFallback, messages, onError, ...rest }: Props): Omit<Props, "onError" | "getMessageFallback" | "messages"> & {
|
|
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
|
+
};
|
|
@@ -1,34 +1,15 @@
|
|
|
1
|
-
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose
|
|
2
|
-
import React
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import IntlContext from './use-intl.esm8.js';
|
|
1
|
+
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../_virtual/use-intl.esm.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import IntlContext from './use-intl.esm9.js';
|
|
4
|
+
import getIntlContextValue from './use-intl.esm8.js';
|
|
6
5
|
|
|
7
|
-
var _excluded = ["children"
|
|
6
|
+
var _excluded = ["children"];
|
|
8
7
|
function IntlProvider(_ref) {
|
|
9
8
|
var children = _ref.children,
|
|
10
|
-
|
|
11
|
-
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
|
|
12
|
-
_ref$getMessageFallba = _ref.getMessageFallback,
|
|
13
|
-
getMessageFallback = _ref$getMessageFallba === void 0 ? defaultGetMessageFallback : _ref$getMessageFallba,
|
|
14
|
-
messages = _ref.messages,
|
|
15
|
-
contextValues = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
16
|
-
|
|
17
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
18
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
19
|
-
useEffect(function () {
|
|
20
|
-
if (messages) {
|
|
21
|
-
validateMessages(messages, onError);
|
|
22
|
-
}
|
|
23
|
-
}, [messages, onError]);
|
|
24
|
-
}
|
|
9
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
25
10
|
|
|
26
11
|
return React.createElement(IntlContext.Provider, {
|
|
27
|
-
value:
|
|
28
|
-
messages: messages,
|
|
29
|
-
onError: onError,
|
|
30
|
-
getMessageFallback: getMessageFallback
|
|
31
|
-
})
|
|
12
|
+
value: getIntlContextValue(props)
|
|
32
13
|
}, children);
|
|
33
14
|
}
|
|
34
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm.js","sources":["../../src/react/IntlProvider.tsx"],"sourcesContent":["import React
|
|
1
|
+
{"version":3,"file":"use-intl.esm.js","sources":["../../src/react/IntlProvider.tsx"],"sourcesContent":["import React from 'react';\nimport IntlContext from './IntlContext';\nimport IntlProviderProps from './IntlProviderProps';\nimport getIntlContextValue from './getIntlContextValue';\n\nexport default function IntlProvider({children, ...props}: IntlProviderProps) {\n return (\n <IntlContext.Provider value={getIntlContextValue(props)}>\n {children}\n </IntlContext.Provider>\n );\n}\n"],"names":["IntlProvider","children","props","React","createElement","IntlContext","Provider","value","getIntlContextValue"],"mappings":";;;;;;AAKc,SAAUA,YAAV,CAA8D,IAAA,EAAA;AAAA,EAAtCC,IAAAA,QAAsC,QAAtCA,QAAsC;AAAA,MAAzBC,KAAyB,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAC1E,EAAA,OACEC,KAAC,CAAAC,aAAD,CAACC,WAAW,CAACC,QAAb;AAAsBC,IAAAA,KAAK,EAAEC,mBAAmB,CAACN,KAAD,CAAA;GAAhD,EACGD,QADH,CADF,CAAA;AAKD;;;;"}
|
|
@@ -1,44 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import resolveNamespace from '../core/use-intl.esm9.js';
|
|
4
|
-
import useIntlContext from './use-intl.esm9.js';
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import IntlContext from './use-intl.esm9.js';
|
|
5
3
|
|
|
6
|
-
function
|
|
7
|
-
var
|
|
8
|
-
defaultTranslationValues = _useIntlContext.defaultTranslationValues,
|
|
9
|
-
globalFormats = _useIntlContext.formats,
|
|
10
|
-
getMessageFallback = _useIntlContext.getMessageFallback,
|
|
11
|
-
locale = _useIntlContext.locale,
|
|
12
|
-
onError = _useIntlContext.onError,
|
|
13
|
-
timeZone = _useIntlContext.timeZone; // The `namespacePrefix` is part of the type system.
|
|
14
|
-
// See the comment in the hook invocation.
|
|
4
|
+
function useIntlContext() {
|
|
5
|
+
var context = useContext(IntlContext);
|
|
15
6
|
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error(process.env.NODE_ENV !== 'production' ? 'No intl context found. Have you configured the provider?' : undefined);
|
|
9
|
+
}
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
namespace = resolveNamespace(namespace, namespacePrefix);
|
|
19
|
-
var cachedFormatsByLocaleRef = useRef({});
|
|
20
|
-
var messagesOrError = useMemo(function () {
|
|
21
|
-
return getMessagesOrError({
|
|
22
|
-
messages: allMessages,
|
|
23
|
-
namespace: namespace,
|
|
24
|
-
onError: onError
|
|
25
|
-
});
|
|
26
|
-
}, [allMessages, namespace, onError]);
|
|
27
|
-
var translate = useMemo(function () {
|
|
28
|
-
return createBaseTranslator({
|
|
29
|
-
cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
|
|
30
|
-
getMessageFallback: getMessageFallback,
|
|
31
|
-
messagesOrError: messagesOrError,
|
|
32
|
-
defaultTranslationValues: defaultTranslationValues,
|
|
33
|
-
namespace: namespace,
|
|
34
|
-
onError: onError,
|
|
35
|
-
formats: globalFormats,
|
|
36
|
-
locale: locale,
|
|
37
|
-
timeZone: timeZone
|
|
38
|
-
});
|
|
39
|
-
}, [getMessageFallback, messagesOrError, defaultTranslationValues, namespace, onError, globalFormats, locale, timeZone]);
|
|
40
|
-
return translate;
|
|
11
|
+
return context;
|
|
41
12
|
}
|
|
42
13
|
|
|
43
|
-
export {
|
|
14
|
+
export { useIntlContext as default };
|
|
44
15
|
//# sourceMappingURL=use-intl.esm10.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm10.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm10.js","sources":["../../src/react/useIntlContext.tsx"],"sourcesContent":["import {useContext} from 'react';\nimport IntlContext from './IntlContext';\n\nexport default function useIntlContext() {\n const context = useContext(IntlContext);\n\n if (!context) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n"],"names":["useIntlContext","context","useContext","IntlContext","Error","process","env","NODE_ENV","undefined"],"mappings":";;;AAGc,SAAUA,cAAV,GAAwB;AACpC,EAAA,IAAMC,OAAO,GAAGC,UAAU,CAACC,WAAD,CAA1B,CAAA;;AAEA,EAAI,IAAA,CAACF,OAAL,EAAc;AACZ,IAAA,MAAM,IAAIG,KAAJ,CACJC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAAzB,GACI,0DADJ,GAEIC,SAHA,CAAN,CAAA;AAKD,GAAA;;AAED,EAAA,OAAOP,OAAP,CAAA;AACD;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useRef, useMemo } from 'react';
|
|
2
|
+
import createBaseTranslator, { getMessagesOrError } from '../core/use-intl.esm7.js';
|
|
3
|
+
import resolveNamespace from '../core/use-intl.esm8.js';
|
|
4
|
+
import useIntlContext from './use-intl.esm10.js';
|
|
5
|
+
|
|
6
|
+
function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
|
|
7
|
+
var _useIntlContext = useIntlContext(),
|
|
8
|
+
defaultTranslationValues = _useIntlContext.defaultTranslationValues,
|
|
9
|
+
globalFormats = _useIntlContext.formats,
|
|
10
|
+
getMessageFallback = _useIntlContext.getMessageFallback,
|
|
11
|
+
locale = _useIntlContext.locale,
|
|
12
|
+
onError = _useIntlContext.onError,
|
|
13
|
+
timeZone = _useIntlContext.timeZone; // The `namespacePrefix` is part of the type system.
|
|
14
|
+
// See the comment in the hook invocation.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
allMessages = allMessages[namespacePrefix];
|
|
18
|
+
namespace = resolveNamespace(namespace, namespacePrefix);
|
|
19
|
+
var cachedFormatsByLocaleRef = useRef({});
|
|
20
|
+
var messagesOrError = useMemo(function () {
|
|
21
|
+
return getMessagesOrError({
|
|
22
|
+
messages: allMessages,
|
|
23
|
+
namespace: namespace,
|
|
24
|
+
onError: onError
|
|
25
|
+
});
|
|
26
|
+
}, [allMessages, namespace, onError]);
|
|
27
|
+
var translate = useMemo(function () {
|
|
28
|
+
return createBaseTranslator({
|
|
29
|
+
cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
|
|
30
|
+
getMessageFallback: getMessageFallback,
|
|
31
|
+
messagesOrError: messagesOrError,
|
|
32
|
+
defaultTranslationValues: defaultTranslationValues,
|
|
33
|
+
namespace: namespace,
|
|
34
|
+
onError: onError,
|
|
35
|
+
formats: globalFormats,
|
|
36
|
+
locale: locale,
|
|
37
|
+
timeZone: timeZone
|
|
38
|
+
});
|
|
39
|
+
}, [getMessageFallback, messagesOrError, defaultTranslationValues, namespace, onError, globalFormats, locale, timeZone]);
|
|
40
|
+
return translate;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { useTranslationsImpl as default };
|
|
44
|
+
//# sourceMappingURL=use-intl.esm11.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-intl.esm11.js","sources":["../../src/react/useTranslationsImpl.tsx"],"sourcesContent":["// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {useMemo, useRef} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport createBaseTranslator, {\n getMessagesOrError\n} from '../core/createBaseTranslator';\nimport resolveNamespace from '../core/resolveNamespace';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport useIntlContext from './useIntlContext';\n\nexport default function useTranslationsImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey, namespacePrefix: string) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n // The `namespacePrefix` is part of the type system.\n // See the comment in the hook invocation.\n allMessages = allMessages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const messagesOrError = useMemo(\n () => getMessagesOrError({messages: allMessages, namespace, onError}),\n [allMessages, namespace, onError]\n );\n\n const translate = useMemo(\n () =>\n createBaseTranslator({\n cachedFormatsByLocale: cachedFormatsByLocaleRef.current,\n getMessageFallback,\n messagesOrError,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n getMessageFallback,\n messagesOrError,\n defaultTranslationValues,\n namespace,\n onError,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n"],"names":["useTranslationsImpl","allMessages","namespace","namespacePrefix","useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","onError","timeZone","resolveNamespace","cachedFormatsByLocaleRef","useRef","messagesOrError","useMemo","getMessagesOrError","messages","translate","createBaseTranslator","cachedFormatsByLocale","current"],"mappings":";;;;;AAWwB,SAAAA,mBAAA,CAGtBC,WAHsB,EAGCC,SAHD,EAGuBC,eAHvB,EAG8C;AACpE,EAAA,IAAA,eAAA,GAOIC,cAAc,EAPlB;AAAA,MACEC,wBADF,mBACEA,wBADF;AAAA,MAEWC,aAFX,mBAEEC,OAFF;AAAA,MAGEC,kBAHF,mBAGEA,kBAHF;AAAA,MAIEC,MAJF,mBAIEA,MAJF;AAAA,MAKEC,OALF,mBAKEA,OALF;AAAA,MAMEC,QANF,GAAA,eAAA,CAMEA,QANF,CADoE;AAWpE;;;AACAV,EAAAA,WAAW,GAAGA,WAAW,CAACE,eAAD,CAAzB,CAAA;AACAD,EAAAA,SAAS,GAAGU,gBAAgB,CAACV,SAAD,EAAYC,eAAZ,CAA5B,CAAA;AAEA,EAAA,IAAMU,wBAAwB,GAAGC,MAAM,CAErC,EAFqC,CAAvC,CAAA;AAIA,EAAMC,IAAAA,eAAe,GAAGC,OAAO,CAC7B,YAAA;AAAA,IAAA,OAAMC,kBAAkB,CAAC;AAACC,MAAAA,QAAQ,EAAEjB,WAAX;AAAwBC,MAAAA,SAAS,EAATA,SAAxB;AAAmCQ,MAAAA,OAAO,EAAPA,OAAAA;AAAnC,KAAD,CAAxB,CAAA;AAAA,GAD6B,EAE7B,CAACT,WAAD,EAAcC,SAAd,EAAyBQ,OAAzB,CAF6B,CAA/B,CAAA;AAKA,EAAMS,IAAAA,SAAS,GAAGH,OAAO,CACvB,YAAA;AAAA,IAAA,OACEI,oBAAoB,CAAC;AACnBC,MAAAA,qBAAqB,EAAER,wBAAwB,CAACS,OAD7B;AAEnBd,MAAAA,kBAAkB,EAAlBA,kBAFmB;AAGnBO,MAAAA,eAAe,EAAfA,eAHmB;AAInBV,MAAAA,wBAAwB,EAAxBA,wBAJmB;AAKnBH,MAAAA,SAAS,EAATA,SALmB;AAMnBQ,MAAAA,OAAO,EAAPA,OANmB;AAOnBH,MAAAA,OAAO,EAAED,aAPU;AAQnBG,MAAAA,MAAM,EAANA,MARmB;AASnBE,MAAAA,QAAQ,EAARA,QAAAA;AATmB,KAAD,CADtB,CAAA;AAAA,GADuB,EAavB,CACEH,kBADF,EAEEO,eAFF,EAGEV,wBAHF,EAIEH,SAJF,EAKEQ,OALF,EAMEJ,aANF,EAOEG,MAPF,EAQEE,QARF,CAbuB,CAAzB,CAAA;AAyBA,EAAA,OAAOQ,SAAP,CAAA;AACD;;;;"}
|
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import useIntlContext from './use-intl.
|
|
2
|
-
import useTranslationsImpl from './use-intl.esm10.js';
|
|
1
|
+
import useIntlContext from './use-intl.esm10.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
|
-
|
|
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.
|
|
18
|
-
|
|
19
|
-
return useTranslationsImpl({
|
|
20
|
-
'!': messages
|
|
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.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/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,SAAV,GAAmB;AAC/B,EAAOC,OAAAA,cAAc,GAAGC,MAAxB,CAAA;AACD;;;;"}
|
|
@@ -1,8 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import createIntl from '../core/use-intl.esm.js';
|
|
3
|
+
import useIntlContext from './use-intl.esm10.js';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
var hasWarned = false;
|
|
6
|
+
/** @deprecated Switch to `useFormatter` */
|
|
7
|
+
|
|
8
|
+
function useIntl() {
|
|
9
|
+
var _useIntlContext = useIntlContext(),
|
|
10
|
+
formats = _useIntlContext.formats,
|
|
11
|
+
locale = _useIntlContext.locale,
|
|
12
|
+
globalNow = _useIntlContext.now,
|
|
13
|
+
onError = _useIntlContext.onError,
|
|
14
|
+
timeZone = _useIntlContext.timeZone;
|
|
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
|
+
|
|
21
|
+
return useMemo(function () {
|
|
22
|
+
return createIntl({
|
|
23
|
+
formats: formats,
|
|
24
|
+
locale: locale,
|
|
25
|
+
now: globalNow,
|
|
26
|
+
onError: onError,
|
|
27
|
+
timeZone: timeZone
|
|
28
|
+
});
|
|
29
|
+
}, [formats, globalNow, locale, onError, timeZone]);
|
|
5
30
|
}
|
|
6
31
|
|
|
7
|
-
export {
|
|
32
|
+
export { useIntl as default };
|
|
8
33
|
//# 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/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,8 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import createFormatter from '../core/use-intl.esm4.js';
|
|
3
|
+
import useIntlContext from './use-intl.esm10.js';
|
|
2
4
|
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
+
function useFormatter() {
|
|
6
|
+
var _useIntlContext = useIntlContext(),
|
|
7
|
+
formats = _useIntlContext.formats,
|
|
8
|
+
locale = _useIntlContext.locale,
|
|
9
|
+
globalNow = _useIntlContext.now,
|
|
10
|
+
onError = _useIntlContext.onError,
|
|
11
|
+
timeZone = _useIntlContext.timeZone;
|
|
12
|
+
|
|
13
|
+
return useMemo(function () {
|
|
14
|
+
return createFormatter({
|
|
15
|
+
formats: formats,
|
|
16
|
+
locale: locale,
|
|
17
|
+
now: globalNow,
|
|
18
|
+
onError: onError,
|
|
19
|
+
timeZone: timeZone
|
|
20
|
+
});
|
|
21
|
+
}, [formats, globalNow, locale, onError, timeZone]);
|
|
5
22
|
}
|
|
6
23
|
|
|
7
|
-
export {
|
|
24
|
+
export { useFormatter as default };
|
|
8
25
|
//# 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/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,25 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import useIntlContext from './use-intl.esm9.js';
|
|
1
|
+
import useIntlContext from './use-intl.esm10.js';
|
|
2
|
+
import useTranslationsImpl from './use-intl.esm11.js';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
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.
|
|
18
|
+
|
|
19
|
+
return useTranslationsImpl({
|
|
20
|
+
'!': messages
|
|
21
|
+
}, // @ts-ignore
|
|
22
|
+
namespace ? "!." + namespace : '!', '!');
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export {
|
|
25
|
+
export { useTranslations as default };
|
|
25
26
|
//# 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/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,33 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import createIntl from '../core/use-intl.esm4.js';
|
|
3
|
-
import useIntlContext from './use-intl.esm9.js';
|
|
1
|
+
import useIntlContext from './use-intl.esm10.js';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function useIntl() {
|
|
9
|
-
var _useIntlContext = useIntlContext(),
|
|
10
|
-
formats = _useIntlContext.formats,
|
|
11
|
-
locale = _useIntlContext.locale,
|
|
12
|
-
globalNow = _useIntlContext.now,
|
|
13
|
-
onError = _useIntlContext.onError,
|
|
14
|
-
timeZone = _useIntlContext.timeZone;
|
|
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
|
-
|
|
21
|
-
return useMemo(function () {
|
|
22
|
-
return createIntl({
|
|
23
|
-
formats: formats,
|
|
24
|
-
locale: locale,
|
|
25
|
-
now: globalNow,
|
|
26
|
-
onError: onError,
|
|
27
|
-
timeZone: timeZone
|
|
28
|
-
});
|
|
29
|
-
}, [formats, globalNow, locale, onError, timeZone]);
|
|
3
|
+
function useTimeZone() {
|
|
4
|
+
return useIntlContext().timeZone;
|
|
30
5
|
}
|
|
31
6
|
|
|
32
|
-
export {
|
|
7
|
+
export { useTimeZone as default };
|
|
33
8
|
//# 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/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,WAAV,GAAqB;AACjC,EAAOC,OAAAA,cAAc,GAAGC,QAAxB,CAAA;AACD;;;;"}
|
|
@@ -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.esm9.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 // This is a generic to allow for stricter typing. E.g.\n // the RSC integration always provides a `now` value.\n Props extends Omit<IntlProviderProps, 'children'>\n>({getMessageFallback, messages, onError, ...rest}: Props) {\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,CAIiC,IAAA,EAAA;AAAA,EAAtDC,IAAAA,kBAAsD,QAAtDA,kBAAsD;AAAA,MAAlCC,QAAkC,QAAlCA,QAAkC;AAAA,MAAxBC,OAAwB,QAAxBA,OAAwB;AAAA,MAAZC,IAAY,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACvD,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';
|