use-intl 3.0.0-beta.1 → 3.0.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.
Files changed (65) hide show
  1. package/dist/core/MessageFormatCache.d.ts +5 -0
  2. package/dist/core/convertFormatsToIntlMessageFormat.esm.js +7 -2
  3. package/dist/core/convertFormatsToIntlMessageFormat.esm.js.map +1 -1
  4. package/dist/core/createBaseTranslator.d.ts +2 -2
  5. package/dist/core/createBaseTranslator.esm.js +21 -12
  6. package/dist/core/createBaseTranslator.esm.js.map +1 -1
  7. package/dist/core/use-intl.esm.js +30 -34
  8. package/dist/core/use-intl.esm.js.map +1 -1
  9. package/dist/core/use-intl.esm10.js +1 -1
  10. package/dist/core/use-intl.esm2.js +206 -29
  11. package/dist/core/use-intl.esm2.js.map +1 -1
  12. package/dist/core/use-intl.esm3.js +33 -10
  13. package/dist/core/use-intl.esm3.js.map +1 -1
  14. package/dist/core/use-intl.esm4.js +9 -196
  15. package/dist/core/use-intl.esm4.js.map +1 -1
  16. package/dist/core/use-intl.esm5.js +1 -1
  17. package/dist/core/use-intl.esm6.js +2 -2
  18. package/dist/core/use-intl.esm7.js +32 -10
  19. package/dist/core/use-intl.esm7.js.map +1 -1
  20. package/dist/core/use-intl.esm8.js +12 -47
  21. package/dist/core/use-intl.esm8.js.map +1 -1
  22. package/dist/core/use-intl.esm9.js +46 -28
  23. package/dist/core/use-intl.esm9.js.map +1 -1
  24. package/dist/core.cjs.development.js +1 -1
  25. package/dist/core.cjs.production.min.js +1 -1
  26. package/dist/{createIntl-8a2b87eb.js → createIntl-34d4281e.js} +28 -15
  27. package/dist/createIntl-34d4281e.js.map +1 -0
  28. package/dist/{createIntl-f7979de1.js → createIntl-bc325740.js} +2 -2
  29. package/dist/createIntl-bc325740.js.map +1 -0
  30. package/dist/react/IntlContext.d.ts +11 -2
  31. package/dist/react/IntlContext.esm.js.map +1 -1
  32. package/dist/react/IntlProvider.esm.js +9 -3
  33. package/dist/react/IntlProvider.esm.js.map +1 -1
  34. package/dist/react/use-intl.esm11.js.map +1 -1
  35. package/dist/react/use-intl.esm2.js +3 -19
  36. package/dist/react/use-intl.esm2.js.map +1 -1
  37. package/dist/react/use-intl.esm3.js +24 -39
  38. package/dist/react/use-intl.esm3.js.map +1 -1
  39. package/dist/react/use-intl.esm4.js +9 -3
  40. package/dist/react/use-intl.esm4.js.map +1 -1
  41. package/dist/react/use-intl.esm5.js +19 -3
  42. package/dist/react/use-intl.esm5.js.map +1 -1
  43. package/dist/react/use-intl.esm6.js +40 -3
  44. package/dist/react/use-intl.esm6.js.map +1 -1
  45. package/dist/react/use-intl.esm7.js +3 -25
  46. package/dist/react/use-intl.esm7.js.map +1 -1
  47. package/dist/react/use-intl.esm8.js +3 -3
  48. package/dist/react/use-intl.esm8.js.map +1 -1
  49. package/dist/react/use-intl.esm9.js +5 -5
  50. package/dist/react/use-intl.esm9.js.map +1 -1
  51. package/dist/react/useIntlContext.d.ts +10 -1
  52. package/dist/react/useTranslationsImpl.esm.js +4 -4
  53. package/dist/react/useTranslationsImpl.esm.js.map +1 -1
  54. package/dist/react.cjs.development.js +11 -5
  55. package/dist/react.cjs.development.js.map +1 -1
  56. package/dist/react.cjs.production.min.js +1 -1
  57. package/dist/react.cjs.production.min.js.map +1 -1
  58. package/dist/use-intl.cjs.development.js +37 -18
  59. package/dist/use-intl.cjs.development.js.map +1 -1
  60. package/dist/use-intl.cjs.production.min.js +1 -1
  61. package/dist/use-intl.cjs.production.min.js.map +1 -1
  62. package/dist/use-intl.esm.js +10 -10
  63. package/package.json +1 -1
  64. package/dist/createIntl-8a2b87eb.js.map +0 -1
  65. package/dist/createIntl-f7979de1.js.map +0 -1
@@ -1,45 +1,30 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useMemo } from 'react';
2
+ import createIntl from '../core/use-intl.esm4.js';
2
3
  import useIntlContext from './use-intl.esm10.js';
3
4
 
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;
5
+ var hasWarned = false;
6
+ /** @deprecated Switch to `useFormatter` instead. */
7
+ function useIntl() {
27
8
  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;
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]);
42
27
  }
43
28
 
44
- export { useNow as default };
29
+ export { useIntl as default };
45
30
  //# sourceMappingURL=use-intl.esm3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm3.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
+ {"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` 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,5 +1,5 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../_virtual/use-intl.esm.js';
2
- import React from 'react';
1
+ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
2
+ import React, { useState } from 'react';
3
3
  import initializeConfig from '../core/use-intl.esm5.js';
4
4
  import IntlContext from './use-intl.esm11.js';
5
5
 
@@ -7,8 +7,14 @@ var _excluded = ["children"];
7
7
  function IntlProvider(_ref) {
8
8
  var children = _ref.children,
9
9
  config = _objectWithoutPropertiesLoose(_ref, _excluded);
10
+ var _useState = useState(function () {
11
+ return new Map();
12
+ }),
13
+ messageFormatCache = _useState[0];
10
14
  return React.createElement(IntlContext.Provider, {
11
- value: initializeConfig(config)
15
+ value: _extends({}, initializeConfig(config), {
16
+ messageFormatCache: messageFormatCache
17
+ })
12
18
  }, children);
13
19
  }
14
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/IntlProvider.tsx"],"sourcesContent":["import React, {ReactNode} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport initializeConfig from '../core/initializeConfig';\nimport IntlContext from './IntlContext';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...config}: Props) {\n return (\n <IntlContext.Provider value={initializeConfig(config)}>\n {children}\n </IntlContext.Provider>\n );\n}\n"],"names":["IntlProvider","_ref","children","config","_objectWithoutPropertiesLoose","_excluded","React","createElement","IntlContext","Provider","value","initializeConfig"],"mappings":";;;;;;AASc,SAAUA,YAAYA,CAAAC,IAAA,EAA6B;AAAA,EAAA,IAA3BC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;AAAKC,IAAAA,MAAM,GAAAC,6BAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;AACvD,EAAA,OACEC,KAAC,CAAAC,aAAA,CAAAC,WAAW,CAACC,QAAQ;IAACC,KAAK,EAAEC,gBAAgB,CAACR,MAAM,CAAA;GAAC,EAClDD,QAAQ,CACY,CAAA;AAE3B;;;;"}
1
+ {"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/IntlProvider.tsx"],"sourcesContent":["import React, {ReactNode, useState} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport initializeConfig from '../core/initializeConfig';\nimport IntlContext from './IntlContext';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...config}: Props) {\n const [messageFormatCache] = useState(() => new Map());\n\n return (\n <IntlContext.Provider\n value={{\n ...initializeConfig(config),\n messageFormatCache\n }}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n"],"names":["IntlProvider","_ref","children","config","_objectWithoutPropertiesLoose","_excluded","_useState","useState","Map","messageFormatCache","React","createElement","IntlContext","Provider","value","_extends","initializeConfig"],"mappings":";;;;;;AASc,SAAUA,YAAYA,CAAAC,IAAA,EAA6B;AAAA,EAAA,IAA3BC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;AAAKC,IAAAA,MAAM,GAAAC,6BAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;EACvD,IAAAC,SAAA,GAA6BC,QAAQ,CAAC,YAAA;MAAA,OAAM,IAAIC,GAAG,EAAE,CAAA;KAAC,CAAA;AAA/CC,IAAAA,kBAAkB,GAAAH,SAAA,CAAA,CAAA,CAAA,CAAA;AAEzB,EAAA,OACEI,KAAC,CAAAC,aAAA,CAAAC,WAAW,CAACC,QAAQ,EAAA;AACnBC,IAAAA,KAAK,EAAAC,QAAA,CAAA,EAAA,EACAC,gBAAgB,CAACb,MAAM,CAAC,EAAA;AAC3BM,MAAAA,kBAAkB,EAAlBA,kBAAAA;AAAkB,KAAA,CAAA;GAGnB,EAAAP,QAAQ,CACY,CAAA;AAE3B;;;;"}
@@ -1,8 +1,24 @@
1
+ import { useMemo } from 'react';
2
+ import createFormatter from '../core/use-intl.esm6.js';
1
3
  import useIntlContext from './use-intl.esm10.js';
2
4
 
3
- function useTimeZone() {
4
- return useIntlContext().timeZone;
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
+ 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]);
5
21
  }
6
22
 
7
- export { useTimeZone as default };
23
+ export { useFormatter as default };
8
24
  //# sourceMappingURL=use-intl.esm5.js.map
@@ -1 +1 @@
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
+ {"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","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,45 @@
1
+ import { useState, useEffect } from 'react';
1
2
  import useIntlContext from './use-intl.esm10.js';
2
3
 
3
- function useMessages() {
4
- return useIntlContext().messages;
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 { useMessages as default };
44
+ export { useNow as default };
8
45
  //# sourceMappingURL=use-intl.esm6.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"use-intl.esm6.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,30 +1,8 @@
1
- import { useMemo } from 'react';
2
- import createIntl from '../core/use-intl.esm3.js';
3
1
  import useIntlContext from './use-intl.esm10.js';
4
2
 
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]);
3
+ function useTimeZone() {
4
+ return useIntlContext().timeZone;
27
5
  }
28
6
 
29
- export { useIntl as default };
7
+ export { useTimeZone as default };
30
8
  //# sourceMappingURL=use-intl.esm7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm7.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
+ {"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,WAAWA,GAAA;AACjC,EAAA,OAAOC,cAAc,EAAE,CAACC,QAAQ,CAAA;AAClC;;;;"}
@@ -1,8 +1,8 @@
1
1
  import useIntlContext from './use-intl.esm10.js';
2
2
 
3
- function useLocale() {
4
- return useIntlContext().locale;
3
+ function useMessages() {
4
+ return useIntlContext().messages;
5
5
  }
6
6
 
7
- export { useLocale as default };
7
+ export { useMessages as default };
8
8
  //# sourceMappingURL=use-intl.esm8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm8.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
+ {"version":3,"file":"use-intl.esm8.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,5 +1,5 @@
1
- import { useRef, useMemo } from 'react';
2
- import createBaseTranslator from '../core/use-intl.esm4.js';
1
+ import { useMemo } from 'react';
2
+ import createBaseTranslator from '../core/use-intl.esm2.js';
3
3
  import resolveNamespace from '../core/use-intl.esm11.js';
4
4
  import useIntlContext from './use-intl.esm10.js';
5
5
 
@@ -9,16 +9,16 @@ function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
9
9
  globalFormats = _useIntlContext.formats,
10
10
  getMessageFallback = _useIntlContext.getMessageFallback,
11
11
  locale = _useIntlContext.locale,
12
+ messageFormatCache = _useIntlContext.messageFormatCache,
12
13
  onError = _useIntlContext.onError,
13
14
  timeZone = _useIntlContext.timeZone;
14
15
  // The `namespacePrefix` is part of the type system.
15
16
  // See the comment in the hook invocation.
16
17
  allMessages = allMessages[namespacePrefix];
17
18
  namespace = resolveNamespace(namespace, namespacePrefix);
18
- var cachedFormatsByLocaleRef = useRef({});
19
19
  var translate = useMemo(function () {
20
20
  return createBaseTranslator({
21
- cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
21
+ messageFormatCache: messageFormatCache,
22
22
  getMessageFallback: getMessageFallback,
23
23
  messages: allMessages,
24
24
  defaultTranslationValues: defaultTranslationValues,
@@ -28,7 +28,7 @@ function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
28
28
  locale: locale,
29
29
  timeZone: timeZone
30
30
  });
31
- }, [getMessageFallback, allMessages, namespace, onError, defaultTranslationValues, globalFormats, locale, timeZone]);
31
+ }, [messageFormatCache, getMessageFallback, allMessages, namespace, onError, defaultTranslationValues, globalFormats, locale, timeZone]);
32
32
  return translate;
33
33
  }
34
34
 
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm9.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 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 translate = useMemo(\n () =>\n createBaseTranslator({\n cachedFormatsByLocale: cachedFormatsByLocaleRef.current,\n getMessageFallback,\n messages: allMessages,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n getMessageFallback,\n allMessages,\n namespace,\n onError,\n defaultTranslationValues,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n"],"names":["useTranslationsImpl","allMessages","namespace","namespacePrefix","_useIntlContext","useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","onError","timeZone","resolveNamespace","cachedFormatsByLocaleRef","useRef","translate","useMemo","createBaseTranslator","cachedFormatsByLocale","current","messages"],"mappings":";;;;;AASwB,SAAAA,mBAAmBA,CAGzCC,WAAqB,EAAEC,SAAoB,EAAEC,eAAuB,EAAA;AACpE,EAAA,IAAAC,eAAA,GAOIC,cAAc,EAAE;IANlBC,wBAAwB,GAAAF,eAAA,CAAxBE,wBAAwB;IACfC,aAAa,GAAAH,eAAA,CAAtBI,OAAO;IACPC,kBAAkB,GAAAL,eAAA,CAAlBK,kBAAkB;IAClBC,MAAM,GAAAN,eAAA,CAANM,MAAM;IACNC,OAAO,GAAAP,eAAA,CAAPO,OAAO;IACPC,QAAQ,GAAAR,eAAA,CAARQ,QAAQ,CAAA;AAGV;AACA;AACAX,EAAAA,WAAW,GAAGA,WAAW,CAACE,eAAe,CAAa,CAAA;AACtDD,EAAAA,SAAS,GAAGW,gBAAgB,CAACX,SAAS,EAAEC,eAAe,CAAc,CAAA;AAErE,EAAA,IAAMW,wBAAwB,GAAGC,MAAM,CAErC,EAAE,CAAC,CAAA;EAEL,IAAMC,SAAS,GAAGC,OAAO,CACvB,YAAA;AAAA,IAAA,OACEC,oBAAoB,CAAC;MACnBC,qBAAqB,EAAEL,wBAAwB,CAACM,OAAO;AACvDX,MAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBY,MAAAA,QAAQ,EAAEpB,WAAW;AACrBK,MAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBJ,MAAAA,SAAS,EAATA,SAAS;AACTS,MAAAA,OAAO,EAAPA,OAAO;AACPH,MAAAA,OAAO,EAAED,aAAa;AACtBG,MAAAA,MAAM,EAANA,MAAM;AACNE,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;AAAA,GAAA,EACJ,CACEH,kBAAkB,EAClBR,WAAW,EACXC,SAAS,EACTS,OAAO,EACPL,wBAAwB,EACxBC,aAAa,EACbG,MAAM,EACNE,QAAQ,CACT,CACF,CAAA;AAED,EAAA,OAAOI,SAAS,CAAA;AAClB;;;;"}
1
+ {"version":3,"file":"use-intl.esm9.js","sources":["../../src/react/useTranslationsImpl.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport createBaseTranslator 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 messageFormatCache,\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 translate = useMemo(\n () =>\n createBaseTranslator({\n messageFormatCache,\n getMessageFallback,\n messages: allMessages,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n messageFormatCache,\n getMessageFallback,\n allMessages,\n namespace,\n onError,\n defaultTranslationValues,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n"],"names":["useTranslationsImpl","allMessages","namespace","namespacePrefix","_useIntlContext","useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","messageFormatCache","onError","timeZone","resolveNamespace","translate","useMemo","createBaseTranslator","messages"],"mappings":";;;;;AAOwB,SAAAA,mBAAmBA,CAGzCC,WAAqB,EAAEC,SAAoB,EAAEC,eAAuB,EAAA;AACpE,EAAA,IAAAC,eAAA,GAQIC,cAAc,EAAE;IAPlBC,wBAAwB,GAAAF,eAAA,CAAxBE,wBAAwB;IACfC,aAAa,GAAAH,eAAA,CAAtBI,OAAO;IACPC,kBAAkB,GAAAL,eAAA,CAAlBK,kBAAkB;IAClBC,MAAM,GAAAN,eAAA,CAANM,MAAM;IACNC,kBAAkB,GAAAP,eAAA,CAAlBO,kBAAkB;IAClBC,OAAO,GAAAR,eAAA,CAAPQ,OAAO;IACPC,QAAQ,GAAAT,eAAA,CAARS,QAAQ,CAAA;AAGV;AACA;AACAZ,EAAAA,WAAW,GAAGA,WAAW,CAACE,eAAe,CAAa,CAAA;AACtDD,EAAAA,SAAS,GAAGY,gBAAgB,CAACZ,SAAS,EAAEC,eAAe,CAAc,CAAA;EAErE,IAAMY,SAAS,GAAGC,OAAO,CACvB,YAAA;AAAA,IAAA,OACEC,oBAAoB,CAAC;AACnBN,MAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBF,MAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBS,MAAAA,QAAQ,EAAEjB,WAAW;AACrBK,MAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBJ,MAAAA,SAAS,EAATA,SAAS;AACTU,MAAAA,OAAO,EAAPA,OAAO;AACPJ,MAAAA,OAAO,EAAED,aAAa;AACtBG,MAAAA,MAAM,EAANA,MAAM;AACNG,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;AAAA,GAAA,EACJ,CACEF,kBAAkB,EAClBF,kBAAkB,EAClBR,WAAW,EACXC,SAAS,EACTU,OAAO,EACPN,wBAAwB,EACxBC,aAAa,EACbG,MAAM,EACNG,QAAQ,CACT,CACF,CAAA;AAED,EAAA,OAAOE,SAAS,CAAA;AAClB;;;;"}
@@ -1 +1,10 @@
1
- export default function useIntlContext(): import("../core/IntlConfig").InitializedIntlConfig<import("../core/AbstractIntlMessages").default>;
1
+ export default function useIntlContext(): import("../core/IntlConfig").default<import("../core/AbstractIntlMessages").default> & {
2
+ onError: (error: import("..").IntlError) => void;
3
+ getMessageFallback: (info: {
4
+ error: import("..").IntlError;
5
+ key: string;
6
+ namespace?: string | undefined;
7
+ }) => string;
8
+ } & {
9
+ messageFormatCache?: import("../core/MessageFormatCache").default | undefined;
10
+ };
@@ -1,4 +1,4 @@
1
- import { useRef, useMemo } from 'react';
1
+ import { useMemo } from 'react';
2
2
  import createBaseTranslator from '../core/createBaseTranslator.esm.js';
3
3
  import resolveNamespace from '../core/resolveNamespace.esm.js';
4
4
  import useIntlContext from './useIntlContext.esm.js';
@@ -9,16 +9,16 @@ function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
9
9
  globalFormats = _useIntlContext.formats,
10
10
  getMessageFallback = _useIntlContext.getMessageFallback,
11
11
  locale = _useIntlContext.locale,
12
+ messageFormatCache = _useIntlContext.messageFormatCache,
12
13
  onError = _useIntlContext.onError,
13
14
  timeZone = _useIntlContext.timeZone;
14
15
  // The `namespacePrefix` is part of the type system.
15
16
  // See the comment in the hook invocation.
16
17
  allMessages = allMessages[namespacePrefix];
17
18
  namespace = resolveNamespace(namespace, namespacePrefix);
18
- var cachedFormatsByLocaleRef = useRef({});
19
19
  var translate = useMemo(function () {
20
20
  return createBaseTranslator({
21
- cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
21
+ messageFormatCache: messageFormatCache,
22
22
  getMessageFallback: getMessageFallback,
23
23
  messages: allMessages,
24
24
  defaultTranslationValues: defaultTranslationValues,
@@ -28,7 +28,7 @@ function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
28
28
  locale: locale,
29
29
  timeZone: timeZone
30
30
  });
31
- }, [getMessageFallback, allMessages, namespace, onError, defaultTranslationValues, globalFormats, locale, timeZone]);
31
+ }, [messageFormatCache, getMessageFallback, allMessages, namespace, onError, defaultTranslationValues, globalFormats, locale, timeZone]);
32
32
  return translate;
33
33
  }
34
34
 
@@ -1 +1 @@
1
- {"version":3,"file":"useTranslationsImpl.esm.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 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 translate = useMemo(\n () =>\n createBaseTranslator({\n cachedFormatsByLocale: cachedFormatsByLocaleRef.current,\n getMessageFallback,\n messages: allMessages,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n getMessageFallback,\n allMessages,\n namespace,\n onError,\n defaultTranslationValues,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n"],"names":["useTranslationsImpl","allMessages","namespace","namespacePrefix","_useIntlContext","useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","onError","timeZone","resolveNamespace","cachedFormatsByLocaleRef","useRef","translate","useMemo","createBaseTranslator","cachedFormatsByLocale","current","messages"],"mappings":";;;;;AASwB,SAAAA,mBAAmBA,CAGzCC,WAAqB,EAAEC,SAAoB,EAAEC,eAAuB,EAAA;AACpE,EAAA,IAAAC,eAAA,GAOIC,cAAc,EAAE;IANlBC,wBAAwB,GAAAF,eAAA,CAAxBE,wBAAwB;IACfC,aAAa,GAAAH,eAAA,CAAtBI,OAAO;IACPC,kBAAkB,GAAAL,eAAA,CAAlBK,kBAAkB;IAClBC,MAAM,GAAAN,eAAA,CAANM,MAAM;IACNC,OAAO,GAAAP,eAAA,CAAPO,OAAO;IACPC,QAAQ,GAAAR,eAAA,CAARQ,QAAQ,CAAA;AAGV;AACA;AACAX,EAAAA,WAAW,GAAGA,WAAW,CAACE,eAAe,CAAa,CAAA;AACtDD,EAAAA,SAAS,GAAGW,gBAAgB,CAACX,SAAS,EAAEC,eAAe,CAAc,CAAA;AAErE,EAAA,IAAMW,wBAAwB,GAAGC,MAAM,CAErC,EAAE,CAAC,CAAA;EAEL,IAAMC,SAAS,GAAGC,OAAO,CACvB,YAAA;AAAA,IAAA,OACEC,oBAAoB,CAAC;MACnBC,qBAAqB,EAAEL,wBAAwB,CAACM,OAAO;AACvDX,MAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBY,MAAAA,QAAQ,EAAEpB,WAAW;AACrBK,MAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBJ,MAAAA,SAAS,EAATA,SAAS;AACTS,MAAAA,OAAO,EAAPA,OAAO;AACPH,MAAAA,OAAO,EAAED,aAAa;AACtBG,MAAAA,MAAM,EAANA,MAAM;AACNE,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;AAAA,GAAA,EACJ,CACEH,kBAAkB,EAClBR,WAAW,EACXC,SAAS,EACTS,OAAO,EACPL,wBAAwB,EACxBC,aAAa,EACbG,MAAM,EACNE,QAAQ,CACT,CACF,CAAA;AAED,EAAA,OAAOI,SAAS,CAAA;AAClB;;;;"}
1
+ {"version":3,"file":"useTranslationsImpl.esm.js","sources":["../../src/react/useTranslationsImpl.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport createBaseTranslator 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 messageFormatCache,\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 translate = useMemo(\n () =>\n createBaseTranslator({\n messageFormatCache,\n getMessageFallback,\n messages: allMessages,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n messageFormatCache,\n getMessageFallback,\n allMessages,\n namespace,\n onError,\n defaultTranslationValues,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n"],"names":["useTranslationsImpl","allMessages","namespace","namespacePrefix","_useIntlContext","useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","messageFormatCache","onError","timeZone","resolveNamespace","translate","useMemo","createBaseTranslator","messages"],"mappings":";;;;;AAOwB,SAAAA,mBAAmBA,CAGzCC,WAAqB,EAAEC,SAAoB,EAAEC,eAAuB,EAAA;AACpE,EAAA,IAAAC,eAAA,GAQIC,cAAc,EAAE;IAPlBC,wBAAwB,GAAAF,eAAA,CAAxBE,wBAAwB;IACfC,aAAa,GAAAH,eAAA,CAAtBI,OAAO;IACPC,kBAAkB,GAAAL,eAAA,CAAlBK,kBAAkB;IAClBC,MAAM,GAAAN,eAAA,CAANM,MAAM;IACNC,kBAAkB,GAAAP,eAAA,CAAlBO,kBAAkB;IAClBC,OAAO,GAAAR,eAAA,CAAPQ,OAAO;IACPC,QAAQ,GAAAT,eAAA,CAARS,QAAQ,CAAA;AAGV;AACA;AACAZ,EAAAA,WAAW,GAAGA,WAAW,CAACE,eAAe,CAAa,CAAA;AACtDD,EAAAA,SAAS,GAAGY,gBAAgB,CAACZ,SAAS,EAAEC,eAAe,CAAc,CAAA;EAErE,IAAMY,SAAS,GAAGC,OAAO,CACvB,YAAA;AAAA,IAAA,OACEC,oBAAoB,CAAC;AACnBN,MAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBF,MAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBS,MAAAA,QAAQ,EAAEjB,WAAW;AACrBK,MAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBJ,MAAAA,SAAS,EAATA,SAAS;AACTU,MAAAA,OAAO,EAAPA,OAAO;AACPJ,MAAAA,OAAO,EAAED,aAAa;AACtBG,MAAAA,MAAM,EAANA,MAAM;AACNG,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;AAAA,GAAA,EACJ,CACEF,kBAAkB,EAClBF,kBAAkB,EAClBR,WAAW,EACXC,SAAS,EACTU,OAAO,EACPN,wBAAwB,EACxBC,aAAa,EACbG,MAAM,EACNG,QAAQ,CACT,CACF,CAAA;AAED,EAAA,OAAOE,SAAS,CAAA;AAClB;;;;"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var createIntl = require('./createIntl-8a2b87eb.js');
5
+ var createIntl = require('./createIntl-34d4281e.js');
6
6
  var React = require('react');
7
7
  require('intl-messageformat');
8
8
 
@@ -16,8 +16,14 @@ var _excluded = ["children"];
16
16
  function IntlProvider(_ref) {
17
17
  var children = _ref.children,
18
18
  config = createIntl._objectWithoutPropertiesLoose(_ref, _excluded);
19
+ var _useState = React.useState(function () {
20
+ return new Map();
21
+ }),
22
+ messageFormatCache = _useState[0];
19
23
  return React__default["default"].createElement(IntlContext.Provider, {
20
- value: createIntl.initializeConfig(config)
24
+ value: createIntl._extends({}, createIntl.initializeConfig(config), {
25
+ messageFormatCache: messageFormatCache
26
+ })
21
27
  }, children);
22
28
  }
23
29
 
@@ -35,16 +41,16 @@ function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
35
41
  globalFormats = _useIntlContext.formats,
36
42
  getMessageFallback = _useIntlContext.getMessageFallback,
37
43
  locale = _useIntlContext.locale,
44
+ messageFormatCache = _useIntlContext.messageFormatCache,
38
45
  onError = _useIntlContext.onError,
39
46
  timeZone = _useIntlContext.timeZone;
40
47
  // The `namespacePrefix` is part of the type system.
41
48
  // See the comment in the hook invocation.
42
49
  allMessages = allMessages[namespacePrefix];
43
50
  namespace = createIntl.resolveNamespace(namespace, namespacePrefix);
44
- var cachedFormatsByLocaleRef = React.useRef({});
45
51
  var translate = React.useMemo(function () {
46
52
  return createIntl.createBaseTranslator({
47
- cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
53
+ messageFormatCache: messageFormatCache,
48
54
  getMessageFallback: getMessageFallback,
49
55
  messages: allMessages,
50
56
  defaultTranslationValues: defaultTranslationValues,
@@ -54,7 +60,7 @@ function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
54
60
  locale: locale,
55
61
  timeZone: timeZone
56
62
  });
57
- }, [getMessageFallback, allMessages, namespace, onError, defaultTranslationValues, globalFormats, locale, timeZone]);
63
+ }, [messageFormatCache, getMessageFallback, allMessages, namespace, onError, defaultTranslationValues, globalFormats, locale, timeZone]);
58
64
  return translate;
59
65
  }
60
66
 
@@ -1 +1 @@
1
- {"version":3,"file":"react.cjs.development.js","sources":["../src/react/IntlContext.tsx","../src/react/IntlProvider.tsx","../src/react/useIntlContext.tsx","../src/react/useTranslationsImpl.tsx","../src/react/useTranslations.tsx","../src/react/useLocale.tsx","../src/react/useNow.tsx","../src/react/useTimeZone.tsx","../src/react/useMessages.tsx","../src/react/useFormatter.tsx","../src/react/useIntl.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport {InitializedIntlConfig} from '../core/IntlConfig';\n\nconst IntlContext = createContext<InitializedIntlConfig | undefined>(undefined);\n\nexport default IntlContext;\n","import React, {ReactNode} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport initializeConfig from '../core/initializeConfig';\nimport IntlContext from './IntlContext';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...config}: Props) {\n return (\n <IntlContext.Provider value={initializeConfig(config)}>\n {children}\n </IntlContext.Provider>\n );\n}\n","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","// 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 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 translate = useMemo(\n () =>\n createBaseTranslator({\n cachedFormatsByLocale: cachedFormatsByLocaleRef.current,\n getMessageFallback,\n messages: allMessages,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n getMessageFallback,\n allMessages,\n namespace,\n onError,\n defaultTranslationValues,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n","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","import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n","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","import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useMessages() {\n return useIntlContext().messages;\n}\n","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","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":["IntlContext","createContext","undefined","IntlProvider","_ref","children","config","_objectWithoutPropertiesLoose","_excluded","React","createElement","Provider","value","initializeConfig","useIntlContext","context","useContext","Error","useTranslationsImpl","allMessages","namespace","namespacePrefix","_useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","onError","timeZone","resolveNamespace","cachedFormatsByLocaleRef","useRef","translate","useMemo","createBaseTranslator","cachedFormatsByLocale","current","messages","useTranslations","useLocale","getNow","Date","useNow","options","updateInterval","globalNow","now","_useState","useState","setNow","useEffect","intervalId","setInterval","clearInterval","useTimeZone","useMessages","useFormatter","createFormatter","hasWarned","useIntl","console","warn","createIntl"],"mapp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AO,EAAPA,OAAO;AACPE,MAAAA,MAAM,EAANA,MAAM;AACNoB,MAAAA,GAAG,EAAED,SAAS;AACdlB,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;GACJ,EAAA,CAACJ,OAAO,EAAEqB,SAAS,EAAEnB,MAAM,EAAEC,OAAO,EAAEC,QAAQ,CAAC,CAChD,CAAA;AACH;;ACdA,IAAI8B,SAAS,GAAG,KAAK,CAAA;AAErB;AACc,SAAUC,OAAOA,GAAA;AAC7B,EAAA,IAAAtC,eAAA,GAA6DR,cAAc,EAAE;IAAtEW,OAAO,GAAAH,eAAA,CAAPG,OAAO;IAAEE,MAAM,GAAAL,eAAA,CAANK,MAAM;IAAOmB,SAAS,GAAAxB,eAAA,CAAdyB,GAAG;IAAanB,OAAO,GAAAN,eAAA,CAAPM,OAAO;IAAEC,QAAQ,GAAAP,eAAA,CAARO,QAAQ,CAAA;EAEzD,IAAI,CAAC8B,SAAS,EAAE;AACdA,IAAAA,SAAS,GAAG,IAAI,CAAA;AAChBE,IAAAA,OAAO,CAACC,IAAI,CACV,6GAA6G,CAC9G,CAAA;AACF,GAAA;AAED,EAAA,OAAO5B,aAAO,CACZ,YAAA;AAAA,IAAA,OACE6B,qBAAU,CAAC;AACTtC,MAAAA,OAAO,EAAPA,OAAO;AACPE,MAAAA,MAAM,EAANA,MAAM;AACNoB,MAAAA,GAAG,EAAED,SAAS;AACdlB,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;GACJ,EAAA,CAACJ,OAAO,EAAEqB,SAAS,EAAEnB,MAAM,EAAEC,OAAO,EAAEC,QAAQ,CAAC,CAChD,CAAA;AACH;;;;;;;;;;;"}
1
+ {"version":3,"file":"react.cjs.development.js","sources":["../src/react/IntlContext.tsx","../src/react/IntlProvider.tsx","../src/react/useIntlContext.tsx","../src/react/useTranslationsImpl.tsx","../src/react/useTranslations.tsx","../src/react/useLocale.tsx","../src/react/useNow.tsx","../src/react/useTimeZone.tsx","../src/react/useMessages.tsx","../src/react/useFormatter.tsx","../src/react/useIntl.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport {InitializedIntlConfig} from '../core/IntlConfig';\nimport MessageFormatCache from '../core/MessageFormatCache';\n\nconst IntlContext = createContext<\n | (InitializedIntlConfig & {\n messageFormatCache?: MessageFormatCache;\n })\n | undefined\n>(undefined);\n\nexport default IntlContext;\n","import React, {ReactNode, useState} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport initializeConfig from '../core/initializeConfig';\nimport IntlContext from './IntlContext';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...config}: Props) {\n const [messageFormatCache] = useState(() => new Map());\n\n return (\n <IntlContext.Provider\n value={{\n ...initializeConfig(config),\n messageFormatCache\n }}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n","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","import {useMemo} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport createBaseTranslator 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 messageFormatCache,\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 translate = useMemo(\n () =>\n createBaseTranslator({\n messageFormatCache,\n getMessageFallback,\n messages: allMessages,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n messageFormatCache,\n getMessageFallback,\n allMessages,\n namespace,\n onError,\n defaultTranslationValues,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n","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","import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n","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","import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useMessages() {\n return useIntlContext().messages;\n}\n","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","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":["IntlContext","createContext","undefined","IntlProvider","_ref","children","config","_objectWithoutPropertiesLoose","_excluded","_useState","useState","Map","messageFormatCache","React","createElement","Provider","value","_extends","initializeConfig","useIntlContext","context","useContext","Error","useTranslationsImpl","allMessages","namespace","namespacePrefix","_useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","onError","timeZone","resolveNamespace","translate","useMemo","createBaseTranslator","messages","useTranslations","useLocale","getNow","Date","useNow","options","updateInterval","globalNow","now","setNow","useEffect","intervalId","setInterval","clearInterval","useTimeZone","useMessages","useFormatter","createFormatter","hasWarned","useIntl","console","warn","createIntl"],"mappings":";;;;;;;;;;;;AAIA,IAAMA,WAAW,gBAA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AA,CAACJ,OAAO,EAAEiB,SAAS,EAAEf,MAAM,EAAEC,OAAO,EAAEC,QAAQ,CAAC,CAChD,CAAA;AACH;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./createIntl-f7979de1.js"),r=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("intl-messageformat");var n=t(r),o=r.createContext(void 0),a=["children"];function s(){var e=r.useContext(o);if(!e)throw new Error(void 0);return e}function u(){return new Date}var i=!1;exports.IntlProvider=function(r){var t=r.children,s=e._objectWithoutPropertiesLoose(r,a);return n.default.createElement(o.Provider,{value:e.initializeConfig(s)},t)},exports.useFormatter=function(){var t=s(),n=t.formats,o=t.locale,a=t.now,u=t.onError,i=t.timeZone;return r.useMemo((function(){return e.createFormatter({formats:n,locale:o,now:a,onError:u,timeZone:i})}),[n,a,o,u,i])},exports.useIntl=function(){var t=s(),n=t.formats,o=t.locale,a=t.now,u=t.onError,l=t.timeZone;return i||(i=!0,console.warn("`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.")),r.useMemo((function(){return e.createIntl({formats:n,locale:o,now:a,onError:u,timeZone:l})}),[n,a,o,u,l])},exports.useLocale=function(){return s().locale},exports.useMessages=function(){return s().messages},exports.useNow=function(e){var t=null==e?void 0:e.updateInterval,n=s().now,o=r.useState(n||u()),a=o[0],i=o[1];return r.useEffect((function(){if(t){var e=setInterval((function(){i(u())}),t);return function(){clearInterval(e)}}}),[n,t]),a},exports.useTimeZone=function(){return s().timeZone},exports.useTranslations=function(t){return function(t,n,o){var a=s(),u=a.defaultTranslationValues,i=a.formats,l=a.getMessageFallback,c=a.locale,f=a.onError,m=a.timeZone;t=t["!"],n=e.resolveNamespace(n,"!");var v=r.useRef({});return r.useMemo((function(){return e.createBaseTranslator({cachedFormatsByLocale:v.current,getMessageFallback:l,messages:t,defaultTranslationValues:u,namespace:n,onError:f,formats:i,locale:c,timeZone:m})}),[l,t,n,f,u,i,c,m])}({"!":s().messages},t?"!."+t:"!")};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./createIntl-bc325740.js"),r=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("intl-messageformat");var n=t(r),o=r.createContext(void 0),a=["children"];function s(){var e=r.useContext(o);if(!e)throw new Error(void 0);return e}function u(){return new Date}var i=!1;exports.IntlProvider=function(t){var s=t.children,u=e._objectWithoutPropertiesLoose(t,a),i=r.useState((function(){return new Map}))[0];return n.default.createElement(o.Provider,{value:e._extends({},e.initializeConfig(u),{messageFormatCache:i})},s)},exports.useFormatter=function(){var t=s(),n=t.formats,o=t.locale,a=t.now,u=t.onError,i=t.timeZone;return r.useMemo((function(){return e.createFormatter({formats:n,locale:o,now:a,onError:u,timeZone:i})}),[n,a,o,u,i])},exports.useIntl=function(){var t=s(),n=t.formats,o=t.locale,a=t.now,u=t.onError,l=t.timeZone;return i||(i=!0,console.warn("`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.")),r.useMemo((function(){return e.createIntl({formats:n,locale:o,now:a,onError:u,timeZone:l})}),[n,a,o,u,l])},exports.useLocale=function(){return s().locale},exports.useMessages=function(){return s().messages},exports.useNow=function(e){var t=null==e?void 0:e.updateInterval,n=s().now,o=r.useState(n||u()),a=o[0],i=o[1];return r.useEffect((function(){if(t){var e=setInterval((function(){i(u())}),t);return function(){clearInterval(e)}}}),[n,t]),a},exports.useTimeZone=function(){return s().timeZone},exports.useTranslations=function(t){return function(t,n,o){var a=s(),u=a.defaultTranslationValues,i=a.formats,l=a.getMessageFallback,c=a.locale,f=a.messageFormatCache,m=a.onError,v=a.timeZone;return t=t["!"],n=e.resolveNamespace(n,"!"),r.useMemo((function(){return e.createBaseTranslator({messageFormatCache:f,getMessageFallback:l,messages:t,defaultTranslationValues:u,namespace:n,onError:m,formats:i,locale:c,timeZone:v})}),[f,l,t,n,m,u,i,c,v])}({"!":s().messages},t?"!."+t:"!")};
2
2
  //# sourceMappingURL=react.cjs.production.min.js.map