use-intl 2.17.2-alpha.1 → 2.17.2-alpha.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 (219) hide show
  1. package/dist/core/createFormatter.js +1 -1
  2. package/dist/src/core/createFormatter.js +1 -1
  3. package/package.json +1 -1
  4. package/dist/core/AbstractIntlMessages.d.mts +0 -10
  5. package/dist/core/AbstractIntlMessages.mjs +0 -1
  6. package/dist/core/AbstractIntlMessages.mjs.map +0 -1
  7. package/dist/core/DateTimeFormatOptions.d.mts +0 -75
  8. package/dist/core/DateTimeFormatOptions.mjs +0 -1
  9. package/dist/core/DateTimeFormatOptions.mjs.map +0 -1
  10. package/dist/core/Formats.d.mts +0 -11
  11. package/dist/core/Formats.mjs +0 -1
  12. package/dist/core/Formats.mjs.map +0 -1
  13. package/dist/core/IntlConfig.d.mts +0 -60
  14. package/dist/core/IntlConfig.mjs +0 -1
  15. package/dist/core/IntlConfig.mjs.map +0 -1
  16. package/dist/core/IntlError.d.mts +0 -15
  17. package/dist/core/IntlError.mjs +0 -2
  18. package/dist/core/IntlError.mjs.map +0 -1
  19. package/dist/core/NumberFormatOptions.d.mts +0 -2
  20. package/dist/core/NumberFormatOptions.mjs +0 -2
  21. package/dist/core/NumberFormatOptions.mjs.map +0 -1
  22. package/dist/core/TimeZone.d.mts +0 -3
  23. package/dist/core/TimeZone.mjs +0 -1
  24. package/dist/core/TimeZone.mjs.map +0 -1
  25. package/dist/core/TranslationValues.d.mts +0 -7
  26. package/dist/core/TranslationValues.mjs +0 -1
  27. package/dist/core/TranslationValues.mjs.map +0 -1
  28. package/dist/core/convertFormatsToIntlMessageFormat.d.mts +0 -16
  29. package/dist/core/convertFormatsToIntlMessageFormat.mjs +0 -2
  30. package/dist/core/convertFormatsToIntlMessageFormat.mjs.map +0 -1
  31. package/dist/core/createBaseTranslator.d.mts +0 -32
  32. package/dist/core/createBaseTranslator.mjs +0 -2
  33. package/dist/core/createBaseTranslator.mjs.map +0 -1
  34. package/dist/core/createFormatter.d.mts +0 -21
  35. package/dist/core/createFormatter.mjs +0 -2
  36. package/dist/core/createFormatter.mjs.map +0 -1
  37. package/dist/core/createIntl.d.mts +0 -15
  38. package/dist/core/createIntl.mjs +0 -2
  39. package/dist/core/createIntl.mjs.map +0 -1
  40. package/dist/core/createTranslator.d.mts +0 -57
  41. package/dist/core/createTranslator.mjs +0 -2
  42. package/dist/core/createTranslator.mjs.map +0 -1
  43. package/dist/core/createTranslatorImpl.d.mts +0 -25
  44. package/dist/core/createTranslatorImpl.mjs +0 -2
  45. package/dist/core/createTranslatorImpl.mjs.map +0 -1
  46. package/dist/core/defaults.d.mts +0 -14
  47. package/dist/core/defaults.mjs +0 -2
  48. package/dist/core/defaults.mjs.map +0 -1
  49. package/dist/core/index.d.mts +0 -17
  50. package/dist/core/index.mjs +0 -2
  51. package/dist/core/index.mjs.map +0 -1
  52. package/dist/core/resolveNamespace.d.mts +0 -7
  53. package/dist/core/resolveNamespace.mjs +0 -2
  54. package/dist/core/resolveNamespace.mjs.map +0 -1
  55. package/dist/core/utils/MessageKeys.d.mts +0 -7
  56. package/dist/core/utils/MessageKeys.mjs +0 -1
  57. package/dist/core/utils/MessageKeys.mjs.map +0 -1
  58. package/dist/core/utils/NamespaceKeys.d.mts +0 -7
  59. package/dist/core/utils/NamespaceKeys.mjs +0 -1
  60. package/dist/core/utils/NamespaceKeys.mjs.map +0 -1
  61. package/dist/core/utils/NestedKeyOf.d.mts +0 -5
  62. package/dist/core/utils/NestedKeyOf.mjs +0 -1
  63. package/dist/core/utils/NestedKeyOf.mjs.map +0 -1
  64. package/dist/core/utils/NestedValueOf.d.mts +0 -3
  65. package/dist/core/utils/NestedValueOf.mjs +0 -1
  66. package/dist/core/utils/NestedValueOf.mjs.map +0 -1
  67. package/dist/core/validateMessages.d.mts +0 -6
  68. package/dist/core/validateMessages.mjs +0 -34
  69. package/dist/core/validateMessages.mjs.map +0 -1
  70. package/dist/index.d.mts +0 -25
  71. package/dist/index.mjs +0 -2
  72. package/dist/index.mjs.map +0 -1
  73. package/dist/react/IntlContext.d.mts +0 -13
  74. package/dist/react/IntlContext.mjs +0 -2
  75. package/dist/react/IntlContext.mjs.map +0 -1
  76. package/dist/react/IntlProvider.d.mts +0 -16
  77. package/dist/react/IntlProvider.mjs +0 -2
  78. package/dist/react/IntlProvider.mjs.map +0 -1
  79. package/dist/react/getInitializedConfig.d.mts +0 -24
  80. package/dist/react/getInitializedConfig.mjs +0 -2
  81. package/dist/react/getInitializedConfig.mjs.map +0 -1
  82. package/dist/react/index.d.mts +0 -21
  83. package/dist/react/index.mjs +0 -2
  84. package/dist/react/index.mjs.map +0 -1
  85. package/dist/react/useFormatter.d.mts +0 -12
  86. package/dist/react/useFormatter.mjs +0 -2
  87. package/dist/react/useFormatter.mjs.map +0 -1
  88. package/dist/react/useIntl.d.mts +0 -12
  89. package/dist/react/useIntl.mjs +0 -2
  90. package/dist/react/useIntl.mjs.map +0 -1
  91. package/dist/react/useIntlContext.d.mts +0 -13
  92. package/dist/react/useIntlContext.mjs +0 -2
  93. package/dist/react/useIntlContext.mjs.map +0 -1
  94. package/dist/react/useLocale.d.mts +0 -3
  95. package/dist/react/useLocale.mjs +0 -2
  96. package/dist/react/useLocale.mjs.map +0 -1
  97. package/dist/react/useMessages.d.mts +0 -5
  98. package/dist/react/useMessages.mjs +0 -2
  99. package/dist/react/useMessages.mjs.map +0 -1
  100. package/dist/react/useNow.d.mts +0 -24
  101. package/dist/react/useNow.mjs +0 -2
  102. package/dist/react/useNow.mjs.map +0 -1
  103. package/dist/react/useTimeZone.d.mts +0 -5
  104. package/dist/react/useTimeZone.mjs +0 -2
  105. package/dist/react/useTimeZone.mjs.map +0 -1
  106. package/dist/react/useTranslations.d.mts +0 -50
  107. package/dist/react/useTranslations.mjs +0 -2
  108. package/dist/react/useTranslations.mjs.map +0 -1
  109. package/dist/react/useTranslationsImpl.d.mts +0 -16
  110. package/dist/react/useTranslationsImpl.mjs +0 -2
  111. package/dist/react/useTranslationsImpl.mjs.map +0 -1
  112. package/dist/src/core/AbstractIntlMessages.d.mts +0 -10
  113. package/dist/src/core/AbstractIntlMessages.mjs +0 -1
  114. package/dist/src/core/AbstractIntlMessages.mjs.map +0 -1
  115. package/dist/src/core/DateTimeFormatOptions.d.mts +0 -75
  116. package/dist/src/core/DateTimeFormatOptions.mjs +0 -1
  117. package/dist/src/core/DateTimeFormatOptions.mjs.map +0 -1
  118. package/dist/src/core/Formats.d.mts +0 -11
  119. package/dist/src/core/Formats.mjs +0 -1
  120. package/dist/src/core/Formats.mjs.map +0 -1
  121. package/dist/src/core/IntlConfig.d.mts +0 -60
  122. package/dist/src/core/IntlConfig.mjs +0 -1
  123. package/dist/src/core/IntlConfig.mjs.map +0 -1
  124. package/dist/src/core/IntlError.d.mts +0 -15
  125. package/dist/src/core/IntlError.mjs +0 -2
  126. package/dist/src/core/IntlError.mjs.map +0 -1
  127. package/dist/src/core/NumberFormatOptions.d.mts +0 -2
  128. package/dist/src/core/NumberFormatOptions.mjs +0 -2
  129. package/dist/src/core/NumberFormatOptions.mjs.map +0 -1
  130. package/dist/src/core/TimeZone.d.mts +0 -3
  131. package/dist/src/core/TimeZone.mjs +0 -1
  132. package/dist/src/core/TimeZone.mjs.map +0 -1
  133. package/dist/src/core/TranslationValues.d.mts +0 -7
  134. package/dist/src/core/TranslationValues.mjs +0 -1
  135. package/dist/src/core/TranslationValues.mjs.map +0 -1
  136. package/dist/src/core/convertFormatsToIntlMessageFormat.d.mts +0 -16
  137. package/dist/src/core/convertFormatsToIntlMessageFormat.mjs +0 -2
  138. package/dist/src/core/convertFormatsToIntlMessageFormat.mjs.map +0 -1
  139. package/dist/src/core/createBaseTranslator.d.mts +0 -32
  140. package/dist/src/core/createBaseTranslator.mjs +0 -2
  141. package/dist/src/core/createBaseTranslator.mjs.map +0 -1
  142. package/dist/src/core/createFormatter.d.mts +0 -21
  143. package/dist/src/core/createFormatter.mjs +0 -2
  144. package/dist/src/core/createFormatter.mjs.map +0 -1
  145. package/dist/src/core/createIntl.d.mts +0 -15
  146. package/dist/src/core/createIntl.mjs +0 -2
  147. package/dist/src/core/createIntl.mjs.map +0 -1
  148. package/dist/src/core/createTranslator.d.mts +0 -57
  149. package/dist/src/core/createTranslator.mjs +0 -2
  150. package/dist/src/core/createTranslator.mjs.map +0 -1
  151. package/dist/src/core/createTranslatorImpl.d.mts +0 -25
  152. package/dist/src/core/createTranslatorImpl.mjs +0 -2
  153. package/dist/src/core/createTranslatorImpl.mjs.map +0 -1
  154. package/dist/src/core/defaults.d.mts +0 -14
  155. package/dist/src/core/defaults.mjs +0 -2
  156. package/dist/src/core/defaults.mjs.map +0 -1
  157. package/dist/src/core/index.d.mts +0 -17
  158. package/dist/src/core/index.mjs +0 -2
  159. package/dist/src/core/index.mjs.map +0 -1
  160. package/dist/src/core/resolveNamespace.d.mts +0 -7
  161. package/dist/src/core/resolveNamespace.mjs +0 -2
  162. package/dist/src/core/resolveNamespace.mjs.map +0 -1
  163. package/dist/src/core/utils/MessageKeys.d.mts +0 -7
  164. package/dist/src/core/utils/MessageKeys.mjs +0 -1
  165. package/dist/src/core/utils/MessageKeys.mjs.map +0 -1
  166. package/dist/src/core/utils/NamespaceKeys.d.mts +0 -7
  167. package/dist/src/core/utils/NamespaceKeys.mjs +0 -1
  168. package/dist/src/core/utils/NamespaceKeys.mjs.map +0 -1
  169. package/dist/src/core/utils/NestedKeyOf.d.mts +0 -5
  170. package/dist/src/core/utils/NestedKeyOf.mjs +0 -1
  171. package/dist/src/core/utils/NestedKeyOf.mjs.map +0 -1
  172. package/dist/src/core/utils/NestedValueOf.d.mts +0 -3
  173. package/dist/src/core/utils/NestedValueOf.mjs +0 -1
  174. package/dist/src/core/utils/NestedValueOf.mjs.map +0 -1
  175. package/dist/src/core/validateMessages.d.mts +0 -6
  176. package/dist/src/core/validateMessages.mjs +0 -34
  177. package/dist/src/core/validateMessages.mjs.map +0 -1
  178. package/dist/src/index.d.mts +0 -25
  179. package/dist/src/index.mjs +0 -2
  180. package/dist/src/index.mjs.map +0 -1
  181. package/dist/src/react/IntlContext.d.mts +0 -13
  182. package/dist/src/react/IntlContext.mjs +0 -2
  183. package/dist/src/react/IntlContext.mjs.map +0 -1
  184. package/dist/src/react/IntlProvider.d.mts +0 -16
  185. package/dist/src/react/IntlProvider.mjs +0 -2
  186. package/dist/src/react/IntlProvider.mjs.map +0 -1
  187. package/dist/src/react/getInitializedConfig.d.mts +0 -24
  188. package/dist/src/react/getInitializedConfig.mjs +0 -2
  189. package/dist/src/react/getInitializedConfig.mjs.map +0 -1
  190. package/dist/src/react/index.d.mts +0 -21
  191. package/dist/src/react/index.mjs +0 -2
  192. package/dist/src/react/index.mjs.map +0 -1
  193. package/dist/src/react/useFormatter.d.mts +0 -12
  194. package/dist/src/react/useFormatter.mjs +0 -2
  195. package/dist/src/react/useFormatter.mjs.map +0 -1
  196. package/dist/src/react/useIntl.d.mts +0 -12
  197. package/dist/src/react/useIntl.mjs +0 -2
  198. package/dist/src/react/useIntl.mjs.map +0 -1
  199. package/dist/src/react/useIntlContext.d.mts +0 -13
  200. package/dist/src/react/useIntlContext.mjs +0 -2
  201. package/dist/src/react/useIntlContext.mjs.map +0 -1
  202. package/dist/src/react/useLocale.d.mts +0 -3
  203. package/dist/src/react/useLocale.mjs +0 -2
  204. package/dist/src/react/useLocale.mjs.map +0 -1
  205. package/dist/src/react/useMessages.d.mts +0 -5
  206. package/dist/src/react/useMessages.mjs +0 -2
  207. package/dist/src/react/useMessages.mjs.map +0 -1
  208. package/dist/src/react/useNow.d.mts +0 -24
  209. package/dist/src/react/useNow.mjs +0 -2
  210. package/dist/src/react/useNow.mjs.map +0 -1
  211. package/dist/src/react/useTimeZone.d.mts +0 -5
  212. package/dist/src/react/useTimeZone.mjs +0 -2
  213. package/dist/src/react/useTimeZone.mjs.map +0 -1
  214. package/dist/src/react/useTranslations.d.mts +0 -50
  215. package/dist/src/react/useTranslations.mjs +0 -2
  216. package/dist/src/react/useTranslations.mjs.map +0 -1
  217. package/dist/src/react/useTranslationsImpl.d.mts +0 -16
  218. package/dist/src/react/useTranslationsImpl.mjs +0 -2
  219. package/dist/src/react/useTranslationsImpl.mjs.map +0 -1
@@ -1,25 +0,0 @@
1
- import Formats from './Formats.mjs';
2
- import TranslationValues, { TranslationValue } from './TranslationValues.mjs';
3
- import MessageKeys from './utils/MessageKeys.mjs';
4
- import NestedValueOf from './utils/NestedValueOf.mjs';
5
- import AbstractIntlMessages from './AbstractIntlMessages.mjs';
6
- import { InitializedIntlConfig } from './IntlConfig.mjs';
7
- import NestedKeyOf from './utils/NestedKeyOf.mjs';
8
- import './DateTimeFormatOptions.mjs';
9
- import './TimeZone.mjs';
10
- import '@formatjs/ecma402-abstract/types/number';
11
- import 'react';
12
- import './IntlError.mjs';
13
-
14
- type CoreRichTranslationValues = Record<string, TranslationValue | ((chunks: string) => string)>;
15
- type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & {
16
- namespace: string;
17
- messages: Messages;
18
- };
19
- declare function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ getMessageFallback, messages, namespace, onError, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): {
20
- (key: MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>, values?: TranslationValues | undefined, formats?: Partial<Formats> | undefined): string;
21
- rich(key: string, values: CoreRichTranslationValues, formats?: Partial<Formats> | undefined): string;
22
- raw: (key: string) => any;
23
- };
24
-
25
- export { CoreRichTranslationValues, CreateTranslatorImplProps, createTranslatorImpl as default };
@@ -1,2 +0,0 @@
1
- import u,{IntlErrorCode as d}from"./IntlError.mjs";import h,{getMessagesOrError as I}from"./createBaseTranslator.mjs";import T from"./resolveNamespace.mjs";function R({getMessageFallback:o,messages:s,namespace:r,onError:t,...g},i){s=s[i],r=T(r,i);const a=h({...g,onError:t,getMessageFallback:o,messagesOrError:I({messages:s,namespace:r,onError:t})}),f=a.rich;function n(...e){return a(...e)}return n.rich=(e,p,m)=>{const l=f(e,p,m);if(typeof l!="string"){const c=new u(d.FORMATTING_ERROR,process.env.NODE_ENV!=="production"?"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})":void 0);return t(c),o({error:c,key:e,namespace:r})}return l},n.raw=a.raw,n}export{R as default};
2
- //# sourceMappingURL=createTranslatorImpl.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/createTranslatorImpl.tsx"],"sourcesContent":["import AbstractIntlMessages from './AbstractIntlMessages';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport {RichTranslationValues, TranslationValue} from './TranslationValues';\nimport createBaseTranslator, {getMessagesOrError} from './createBaseTranslator';\nimport resolveNamespace from './resolveNamespace';\nimport NestedKeyOf from './utils/NestedKeyOf';\n\nexport type CoreRichTranslationValues = Record<\n string,\n TranslationValue | ((chunks: string) => string)\n>;\n\nexport type CreateTranslatorImplProps<Messages> = Omit<\n InitializedIntlConfig,\n 'messages'\n> & {\n namespace: string;\n messages: Messages;\n};\n\nexport default function createTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(\n {\n getMessageFallback,\n messages,\n namespace,\n onError,\n ...rest\n }: CreateTranslatorImplProps<Messages>,\n namespacePrefix: string\n) {\n // The `namespacePrefix` is part of the type system.\n // See the comment in the function invocation.\n messages = messages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const translator = createBaseTranslator<Messages, NestedKey>({\n ...rest,\n onError,\n getMessageFallback,\n messagesOrError: getMessagesOrError({\n messages,\n namespace,\n onError\n }) as Messages | IntlError\n });\n\n const originalRich = translator.rich;\n\n function base(...args: Parameters<typeof translator>) {\n return translator(...args);\n }\n\n // Augment `t.rich` to return plain strings\n base.rich = (\n key: Parameters<typeof originalRich>[0],\n /** Key value pairs for values to interpolate into the message. */\n values: CoreRichTranslationValues,\n formats?: Parameters<typeof originalRich>[2]\n ): string => {\n // `chunks` is returned as a string when no React element\n // is used, therefore it's safe to cast this type.\n const result = originalRich(key, values as RichTranslationValues, formats);\n\n // When only string chunks are provided to the parser, only strings should be returned here.\n if (typeof result !== 'string') {\n const error = new IntlError(\n IntlErrorCode.FORMATTING_ERROR,\n process.env.NODE_ENV !== 'production'\n ? \"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\\n\\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})\"\n : undefined\n );\n\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n return result;\n };\n\n base.raw = translator.raw;\n\n return base;\n}\n"],"mappings":"AAEA,OAAOA,GAAY,iBAAAC,MAAoB,cAEvC,OAAOC,GAAuB,sBAAAC,MAAyB,yBACvD,OAAOC,MAAsB,qBAgBd,SAARC,EAIL,CACE,mBAAAC,EACA,SAAAC,EACA,UAAAC,EACA,QAAAC,EACA,GAAGC,CACL,EACAC,EACA,CAGAJ,EAAWA,EAASI,CAAe,EACnCH,EAAYJ,EAAiBI,EAAWG,CAAe,EAEvD,MAAMC,EAAaV,EAA0C,CAC3D,GAAGQ,EACH,QAAAD,EACA,mBAAAH,EACA,gBAAiBH,EAAmB,CAClC,SAAAI,EACA,UAAAC,EACA,QAAAC,CACF,CAAC,CACH,CAAC,EAEKI,EAAeD,EAAW,KAEhC,SAASE,KAAQC,EAAqC,CACpD,OAAOH,EAAW,GAAGG,CAAI,CAC3B,CAGA,OAAAD,EAAK,KAAO,CACVE,EAEAC,EACAC,IACW,CAGX,MAAMC,EAASN,EAAaG,EAAKC,EAAiCC,CAAO,EAGzE,GAAI,OAAOC,GAAW,SAAU,CAC9B,MAAMC,EAAQ,IAAIpB,EAChBC,EAAc,iBACd,QAAQ,IAAI,WAAa,aACrB,kKACA,MACN,EAEA,OAAAQ,EAAQW,CAAK,EACNd,EAAmB,CAAC,MAAAc,EAAO,IAAAJ,EAAK,UAAAR,CAAS,CAAC,CACnD,CAEA,OAAOW,CACT,EAEAL,EAAK,IAAMF,EAAW,IAEfE,CACT","names":["IntlError","IntlErrorCode","createBaseTranslator","getMessagesOrError","resolveNamespace","createTranslatorImpl","getMessageFallback","messages","namespace","onError","rest","namespacePrefix","translator","originalRich","base","args","key","values","formats","result","error"]}
@@ -1,14 +0,0 @@
1
- import IntlError from './IntlError.mjs';
2
-
3
- /**
4
- * Contains defaults that are used for all entry points into the core.
5
- * See also `InitializedIntlConfiguration`.
6
- */
7
- declare function defaultGetMessageFallback(props: {
8
- error: IntlError;
9
- key: string;
10
- namespace?: string;
11
- }): string;
12
- declare function defaultOnError(error: IntlError): void;
13
-
14
- export { defaultGetMessageFallback, defaultOnError };
@@ -1,2 +0,0 @@
1
- function o(r){return[r.namespace,r.key].filter(e=>e!=null).join(".")}function l(r){console.error(r)}export{o as defaultGetMessageFallback,l as defaultOnError};
2
- //# sourceMappingURL=defaults.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/defaults.tsx"],"sourcesContent":["import IntlError from './IntlError';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return [props.namespace, props.key].filter((part) => part != null).join('.');\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n"],"mappings":"AAOO,SAASA,EAA0BC,EAIvC,CACD,MAAO,CAACA,EAAM,UAAWA,EAAM,GAAG,EAAE,OAAQC,GAASA,GAAQ,IAAI,EAAE,KAAK,GAAG,CAC7E,CAEO,SAASC,EAAeC,EAAkB,CAC/C,QAAQ,MAAMA,CAAK,CACrB","names":["defaultGetMessageFallback","props","part","defaultOnError","error"]}
@@ -1,17 +0,0 @@
1
- export { default as AbstractIntlMessages } from './AbstractIntlMessages.mjs';
2
- export { RichTranslationValues, default as TranslationValues } from './TranslationValues.mjs';
3
- export { default as Formats } from './Formats.mjs';
4
- export { default as DateTimeFormatOptions } from './DateTimeFormatOptions.mjs';
5
- export { NumberFormatOptions } from '@formatjs/ecma402-abstract/types/number';
6
- export { default as IntlError, IntlErrorCode } from './IntlError.mjs';
7
- export { default as createTranslator } from './createTranslator.mjs';
8
- export { default as createFormatter } from './createFormatter.mjs';
9
- export { default as createIntl } from './createIntl.mjs';
10
- import 'react';
11
- import './TimeZone.mjs';
12
- import './IntlConfig.mjs';
13
- import './createTranslatorImpl.mjs';
14
- import './utils/MessageKeys.mjs';
15
- import './utils/NestedValueOf.mjs';
16
- import './utils/NestedKeyOf.mjs';
17
- import './utils/NamespaceKeys.mjs';
@@ -1,2 +0,0 @@
1
- import{default as e,IntlErrorCode as r}from"./IntlError.mjs";import{default as s}from"./createTranslator.mjs";import{default as m}from"./createFormatter.mjs";import{default as p}from"./createIntl.mjs";export{e as IntlError,r as IntlErrorCode,m as createFormatter,p as createIntl,s as createTranslator};
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/index.tsx"],"sourcesContent":["export type {default as AbstractIntlMessages} from './AbstractIntlMessages';\nexport type {\n default as TranslationValues,\n RichTranslationValues\n} from './TranslationValues';\nexport type {default as Formats} from './Formats';\nexport type {default as DateTimeFormatOptions} from './DateTimeFormatOptions';\nexport type {default as NumberFormatOptions} from './NumberFormatOptions';\nexport {default as IntlError, IntlErrorCode} from './IntlError';\nexport {default as createTranslator} from './createTranslator';\nexport {default as createFormatter} from './createFormatter';\n\n// TODO: Remove in next major version\nexport {default as createIntl} from './createIntl';\n"],"mappings":"AAQA,OAAmB,WAAXA,EAAsB,iBAAAC,MAAoB,cAClD,OAAmB,WAAXD,MAAkC,qBAC1C,OAAmB,WAAXA,MAAiC,oBAGzC,OAAmB,WAAXA,MAA4B","names":["default","IntlErrorCode"]}
@@ -1,7 +0,0 @@
1
- /**
2
- * For the strictly typed messages to work we have to wrap the namespace into
3
- * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045
4
- */
5
- declare function resolveNamespace(namespace: string, namespacePrefix: string): string | undefined;
6
-
7
- export { resolveNamespace as default };
@@ -1,2 +0,0 @@
1
- function n(t,e){return t===e?void 0:t.slice((e+".").length)}export{n as default};
2
- //# sourceMappingURL=resolveNamespace.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/resolveNamespace.tsx"],"sourcesContent":["/**\n * For the strictly typed messages to work we have to wrap the namespace into\n * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045\n */\nexport default function resolveNamespace(\n namespace: string,\n namespacePrefix: string\n) {\n return namespace === namespacePrefix\n ? undefined\n : namespace.slice((namespacePrefix + '.').length);\n}\n"],"mappings":"AAIe,SAARA,EACLC,EACAC,EACA,CACA,OAAOD,IAAcC,EACjB,OACAD,EAAU,OAAOC,EAAkB,KAAK,MAAM,CACpD","names":["resolveNamespace","namespace","namespacePrefix"]}
@@ -1,7 +0,0 @@
1
- import NestedValueOf from './NestedValueOf.mjs';
2
-
3
- type MessageKeys<ObjectType, Keys extends string> = {
4
- [Property in Keys]: NestedValueOf<ObjectType, Property> extends string ? Property : never;
5
- }[Keys];
6
-
7
- export { MessageKeys as default };
@@ -1 +0,0 @@
1
- //# sourceMappingURL=MessageKeys.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,7 +0,0 @@
1
- import NestedValueOf from './NestedValueOf.mjs';
2
-
3
- type NamespaceKeys<ObjectType, Keys extends string> = {
4
- [Property in Keys]: NestedValueOf<ObjectType, Property> extends string ? never : Property;
5
- }[Keys];
6
-
7
- export { NamespaceKeys as default };
@@ -1 +0,0 @@
1
- //# sourceMappingURL=NamespaceKeys.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,5 +0,0 @@
1
- type NestedKeyOf<ObjectType> = ObjectType extends object ? {
2
- [Key in keyof ObjectType]: `${Key & string}` | `${Key & string}.${NestedKeyOf<ObjectType[Key]>}`;
3
- }[keyof ObjectType] : never;
4
-
5
- export { NestedKeyOf as default };
@@ -1 +0,0 @@
1
- //# sourceMappingURL=NestedKeyOf.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +0,0 @@
1
- type NestedValueOf<ObjectType, Property extends string> = Property extends `${infer Key}.${infer Rest}` ? Key extends keyof ObjectType ? NestedValueOf<ObjectType[Key], Rest> : never : Property extends keyof ObjectType ? ObjectType[Property] : never;
2
-
3
- export { NestedValueOf as default };
@@ -1 +0,0 @@
1
- //# sourceMappingURL=NestedValueOf.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +0,0 @@
1
- import AbstractIntlMessages from './AbstractIntlMessages.mjs';
2
- import IntlError from './IntlError.mjs';
3
-
4
- declare function validateMessages(messages: AbstractIntlMessages, onError: (error: IntlError) => void): void;
5
-
6
- export { validateMessages as default };
@@ -1,34 +0,0 @@
1
- import a,{IntlErrorCode as c}from"./IntlError.mjs";function i(n,t,e){Object.entries(n).forEach(([r,s])=>{if(r.includes(".")){let o=r;e&&(o+=` (at ${e})`),t.push(o)}s!=null&&typeof s=="object"&&i(s,t,[e,r].filter(o=>o!=null).join("."))})}function l(n,t){const e=[];i(n,e),e.length>0&&t(new a(c.INVALID_KEY,process.env.NODE_ENV!=="production"?`Namespace keys can not contain the character "." as this is used to express nesting. Please remove it or replace it with another character.
2
-
3
- Invalid ${e.length===1?"key":"keys"}: ${e.join(", ")}
4
-
5
- If you're migrating from a flat structure, you can convert your messages as follows:
6
-
7
- import {set} from "lodash";
8
-
9
- const input = {
10
- "one.one": "1.1",
11
- "one.two": "1.2",
12
- "two.one.one": "2.1.1"
13
- };
14
-
15
- const output = Object.entries(input).reduce(
16
- (acc, [key, value]) => set(acc, key, value),
17
- {}
18
- );
19
-
20
- // Output:
21
- //
22
- // {
23
- // "one": {
24
- // "one": "1.1",
25
- // "two": "1.2"
26
- // },
27
- // "two": {
28
- // "one": {
29
- // "one": "2.1.1"
30
- // }
31
- // }
32
- // }
33
- `:void 0))}export{l as default};
34
- //# sourceMappingURL=validateMessages.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/validateMessages.tsx"],"sourcesContent":["import AbstractIntlMessages from './AbstractIntlMessages';\nimport IntlError, {IntlErrorCode} from './IntlError';\n\nfunction validateMessagesSegment(\n messages: AbstractIntlMessages,\n invalidKeyLabels: Array<string>,\n parentPath?: string\n) {\n Object.entries(messages).forEach(([key, messageOrMessages]) => {\n if (key.includes('.')) {\n let keyLabel = key;\n if (parentPath) keyLabel += ` (at ${parentPath})`;\n invalidKeyLabels.push(keyLabel);\n }\n\n if (messageOrMessages != null && typeof messageOrMessages === 'object') {\n validateMessagesSegment(\n messageOrMessages,\n invalidKeyLabels,\n [parentPath, key].filter((part) => part != null).join('.')\n );\n }\n });\n}\n\nexport default function validateMessages(\n messages: AbstractIntlMessages,\n onError: (error: IntlError) => void\n) {\n const invalidKeyLabels: Array<string> = [];\n validateMessagesSegment(messages, invalidKeyLabels);\n\n if (invalidKeyLabels.length > 0) {\n onError(\n new IntlError(\n IntlErrorCode.INVALID_KEY,\n process.env.NODE_ENV !== 'production'\n ? `Namespace keys can not contain the character \".\" as this is used to express nesting. Please remove it or replace it with another character.\n\nInvalid ${\n invalidKeyLabels.length === 1 ? 'key' : 'keys'\n }: ${invalidKeyLabels.join(', ')}\n\nIf you're migrating from a flat structure, you can convert your messages as follows:\n\nimport {set} from \"lodash\";\n\nconst input = {\n \"one.one\": \"1.1\",\n \"one.two\": \"1.2\",\n \"two.one.one\": \"2.1.1\"\n};\n\nconst output = Object.entries(input).reduce(\n (acc, [key, value]) => set(acc, key, value),\n {}\n);\n\n// Output:\n//\n// {\n// \"one\": {\n// \"one\": \"1.1\",\n// \"two\": \"1.2\"\n// },\n// \"two\": {\n// \"one\": {\n// \"one\": \"2.1.1\"\n// }\n// }\n// }\n`\n : undefined\n )\n );\n }\n}\n"],"mappings":"AACA,OAAOA,GAAY,iBAAAC,MAAoB,cAEvC,SAASC,EACPC,EACAC,EACAC,EACA,CACA,OAAO,QAAQF,CAAQ,EAAE,QAAQ,CAAC,CAACG,EAAKC,CAAiB,IAAM,CAC7D,GAAID,EAAI,SAAS,GAAG,EAAG,CACrB,IAAIE,EAAWF,EACXD,IAAYG,GAAY,QAAQH,CAAU,KAC9CD,EAAiB,KAAKI,CAAQ,CAChC,CAEID,GAAqB,MAAQ,OAAOA,GAAsB,UAC5DL,EACEK,EACAH,EACA,CAACC,EAAYC,CAAG,EAAE,OAAQG,GAASA,GAAQ,IAAI,EAAE,KAAK,GAAG,CAC3D,CAEJ,CAAC,CACH,CAEe,SAARC,EACLP,EACAQ,EACA,CACA,MAAMP,EAAkC,CAAC,EACzCF,EAAwBC,EAAUC,CAAgB,EAE9CA,EAAiB,OAAS,GAC5BO,EACE,IAAIX,EACFC,EAAc,YACd,QAAQ,IAAI,WAAa,aACrB;AAAA;AAAA,UAGEG,EAAiB,SAAW,EAAI,MAAQ,MAC1C,KAAKA,EAAiB,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+BhC,MACN,CACF,CAEJ","names":["IntlError","IntlErrorCode","validateMessagesSegment","messages","invalidKeyLabels","parentPath","key","messageOrMessages","keyLabel","part","validateMessages","onError"]}
package/dist/index.d.mts DELETED
@@ -1,25 +0,0 @@
1
- export { default as AbstractIntlMessages } from './core/AbstractIntlMessages.mjs';
2
- export { RichTranslationValues, default as TranslationValues } from './core/TranslationValues.mjs';
3
- export { default as Formats } from './core/Formats.mjs';
4
- export { default as DateTimeFormatOptions } from './core/DateTimeFormatOptions.mjs';
5
- export { NumberFormatOptions } from '@formatjs/ecma402-abstract/types/number';
6
- export { default as IntlError, IntlErrorCode } from './core/IntlError.mjs';
7
- export { default as createTranslator } from './core/createTranslator.mjs';
8
- export { default as createFormatter } from './core/createFormatter.mjs';
9
- export { default as createIntl } from './core/createIntl.mjs';
10
- export { default as IntlProvider } from './react/IntlProvider.mjs';
11
- export { default as useTranslations } from './react/useTranslations.mjs';
12
- export { default as useLocale } from './react/useLocale.mjs';
13
- export { default as useNow } from './react/useNow.mjs';
14
- export { default as useTimeZone } from './react/useTimeZone.mjs';
15
- export { default as useMessages } from './react/useMessages.mjs';
16
- export { default as useFormatter } from './react/useFormatter.mjs';
17
- export { default as useIntl } from './react/useIntl.mjs';
18
- import 'react';
19
- import './core/TimeZone.mjs';
20
- import './core/IntlConfig.mjs';
21
- import './core/createTranslatorImpl.mjs';
22
- import './core/utils/MessageKeys.mjs';
23
- import './core/utils/NestedValueOf.mjs';
24
- import './core/utils/NestedKeyOf.mjs';
25
- import './core/utils/NamespaceKeys.mjs';
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- export*from"./core/index.mjs";export*from"./react/index.mjs";
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["export * from './core';\nexport * from './react';\n"],"mappings":"AAAA,WAAc,SACd,WAAc","names":[]}
@@ -1,13 +0,0 @@
1
- import * as react from 'react';
2
- import AbstractIntlMessages from '../core/AbstractIntlMessages.mjs';
3
- import { InitializedIntlConfig } from '../core/IntlConfig.mjs';
4
- import '../core/Formats.mjs';
5
- import '../core/DateTimeFormatOptions.mjs';
6
- import '../core/TimeZone.mjs';
7
- import '@formatjs/ecma402-abstract/types/number';
8
- import '../core/IntlError.mjs';
9
- import '../core/TranslationValues.mjs';
10
-
11
- declare const IntlContext: react.Context<InitializedIntlConfig<AbstractIntlMessages> | undefined>;
12
-
13
- export { IntlContext as default };
@@ -1,2 +0,0 @@
1
- import{createContext as t}from"react";const n=t(void 0);var d=n;export{d as default};
2
- //# sourceMappingURL=IntlContext.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/react/IntlContext.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport {InitializedIntlConfig} from '../core/IntlConfig';\n\nconst IntlContext = createContext<InitializedIntlConfig | undefined>(undefined);\n\nexport default IntlContext;\n"],"mappings":"AAAA,OAAQ,iBAAAA,MAAoB,QAG5B,MAAMC,EAAcD,EAAiD,MAAS,EAE9E,IAAOE,EAAQD","names":["createContext","IntlContext","IntlContext_default"]}
@@ -1,16 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import IntlConfig from '../core/IntlConfig.mjs';
3
- import '../core/Formats.mjs';
4
- import '../core/DateTimeFormatOptions.mjs';
5
- import '../core/TimeZone.mjs';
6
- import '@formatjs/ecma402-abstract/types/number';
7
- import '../core/IntlError.mjs';
8
- import '../core/AbstractIntlMessages.mjs';
9
- import '../core/TranslationValues.mjs';
10
-
11
- type Props = IntlConfig & {
12
- children: ReactNode;
13
- };
14
- declare function IntlProvider({ children, ...props }: Props): JSX.Element;
15
-
16
- export { IntlProvider as default };
@@ -1,2 +0,0 @@
1
- import r from"react";import e from"./IntlContext.mjs";import i from"./getInitializedConfig.mjs";function n({children:o,...t}){return r.createElement(e.Provider,{value:i(t)},o)}export{n as default};
2
- //# sourceMappingURL=IntlProvider.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/react/IntlProvider.tsx"],"sourcesContent":["import React, {ReactNode} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport IntlContext from './IntlContext';\nimport getInitializedConfig from './getInitializedConfig';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...props}: Props) {\n return (\n <IntlContext.Provider value={getInitializedConfig(props)}>\n {children}\n </IntlContext.Provider>\n );\n}\n"],"mappings":"AAAA,OAAOA,MAAwB,QAE/B,OAAOC,MAAiB,gBACxB,OAAOC,MAA0B,yBAMlB,SAARC,EAA8B,CAAC,SAAAC,EAAU,GAAGC,CAAK,EAAU,CAChE,OACEL,EAAA,cAACC,EAAY,SAAZ,CAAqB,MAAOC,EAAqBG,CAAK,GACpDD,CACH,CAEJ","names":["React","IntlContext","getInitializedConfig","IntlProvider","children","props"]}
@@ -1,24 +0,0 @@
1
- import AbstractIntlMessages from '../core/AbstractIntlMessages.mjs';
2
- import IntlError from '../core/IntlError.mjs';
3
- import IntlConfig from '../core/IntlConfig.mjs';
4
- import '../core/Formats.mjs';
5
- import '../core/DateTimeFormatOptions.mjs';
6
- import '../core/TimeZone.mjs';
7
- import '@formatjs/ecma402-abstract/types/number';
8
- import '../core/TranslationValues.mjs';
9
- import 'react';
10
-
11
- /**
12
- * Enhances the incoming props with defaults.
13
- */
14
- declare function getInitializedConfig<Props extends Omit<IntlConfig, 'children'>>({ getMessageFallback, messages, onError, ...rest }: Props): Omit<Props, "onError" | "getMessageFallback" | "messages"> & {
15
- messages: AbstractIntlMessages | undefined;
16
- onError: (error: IntlError) => void;
17
- getMessageFallback: (info: {
18
- error: IntlError;
19
- key: string;
20
- namespace?: string | undefined;
21
- }) => string;
22
- };
23
-
24
- export { getInitializedConfig as default };
@@ -1,2 +0,0 @@
1
- import{defaultGetMessageFallback as a,defaultOnError as l}from"../core/defaults.mjs";import f from"../core/validateMessages.mjs";function s({getMessageFallback:t,messages:r,onError:e,...n}){const o=e||l,i=t||a;return process.env.NODE_ENV!=="production"&&r&&f(r,o),{...n,messages:r,onError:o,getMessageFallback:i}}export{s as default};
2
- //# sourceMappingURL=getInitializedConfig.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/react/getInitializedConfig.tsx"],"sourcesContent":["import IntlConfig from '../core/IntlConfig';\nimport {defaultGetMessageFallback, defaultOnError} from '../core/defaults';\nimport validateMessages from '../core/validateMessages';\n\n/**\n * Enhances the incoming props with defaults.\n */\nexport default function getInitializedConfig<\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<IntlConfig, '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"],"mappings":"AACA,OAAQ,6BAAAA,EAA2B,kBAAAC,MAAqB,mBACxD,OAAOC,MAAsB,2BAKd,SAARC,EAIL,CAAC,mBAAAC,EAAoB,SAAAC,EAAU,QAAAC,EAAS,GAAGC,CAAI,EAAU,CACzD,MAAMC,EAAeF,GAAWL,EAC1BQ,EACJL,GAAsBJ,EAExB,OAAI,QAAQ,IAAI,WAAa,cACvBK,GACFH,EAAiBG,EAAUG,CAAY,EAIpC,CACL,GAAGD,EACH,SAAAF,EACA,QAASG,EACT,mBAAoBC,CACtB,CACF","names":["defaultGetMessageFallback","defaultOnError","validateMessages","getInitializedConfig","getMessageFallback","messages","onError","rest","finalOnError","finalGetMessageFallback"]}
@@ -1,21 +0,0 @@
1
- export { default as IntlProvider } from './IntlProvider.mjs';
2
- export { default as useTranslations } from './useTranslations.mjs';
3
- export { default as useLocale } from './useLocale.mjs';
4
- export { default as useNow } from './useNow.mjs';
5
- export { default as useTimeZone } from './useTimeZone.mjs';
6
- export { default as useMessages } from './useMessages.mjs';
7
- export { default as useFormatter } from './useFormatter.mjs';
8
- export { default as useIntl } from './useIntl.mjs';
9
- import 'react';
10
- import '../core/IntlConfig.mjs';
11
- import '../core/Formats.mjs';
12
- import '../core/DateTimeFormatOptions.mjs';
13
- import '../core/TimeZone.mjs';
14
- import '@formatjs/ecma402-abstract/types/number';
15
- import '../core/IntlError.mjs';
16
- import '../core/AbstractIntlMessages.mjs';
17
- import '../core/TranslationValues.mjs';
18
- import '../core/utils/MessageKeys.mjs';
19
- import '../core/utils/NestedValueOf.mjs';
20
- import '../core/utils/NamespaceKeys.mjs';
21
- import '../core/utils/NestedKeyOf.mjs';
@@ -1,2 +0,0 @@
1
- import{default as a}from"./IntlProvider.mjs";import{default as t}from"./useTranslations.mjs";import{default as f}from"./useLocale.mjs";import{default as l}from"./useNow.mjs";import{default as d}from"./useTimeZone.mjs";import{default as x}from"./useMessages.mjs";import{default as i}from"./useFormatter.mjs";import{default as T}from"./useIntl.mjs";export{a as IntlProvider,i as useFormatter,T as useIntl,f as useLocale,x as useMessages,l as useNow,d as useTimeZone,t as useTranslations};
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/react/index.tsx"],"sourcesContent":["export {default as IntlProvider} from './IntlProvider';\nexport {default as useTranslations} from './useTranslations';\nexport {default as useLocale} from './useLocale';\nexport {default as useNow} from './useNow';\nexport {default as useTimeZone} from './useTimeZone';\nexport {default as useMessages} from './useMessages';\nexport {default as useFormatter} from './useFormatter';\n\n// TODO: Remove in next major version\nexport {default as useIntl} from './useIntl';\n"],"mappings":"AAAA,OAAmB,WAAXA,MAA8B,iBACtC,OAAmB,WAAXA,MAAiC,oBACzC,OAAmB,WAAXA,MAA2B,cACnC,OAAmB,WAAXA,MAAwB,WAChC,OAAmB,WAAXA,MAA6B,gBACrC,OAAmB,WAAXA,MAA6B,gBACrC,OAAmB,WAAXA,MAA8B,iBAGtC,OAAmB,WAAXA,MAAyB","names":["default"]}
@@ -1,12 +0,0 @@
1
- import * as _formatjs_ecma402_abstract_types_number from '@formatjs/ecma402-abstract/types/number';
2
- import DateTimeFormatOptions from '../core/DateTimeFormatOptions.mjs';
3
- import '../core/TimeZone.mjs';
4
-
5
- declare function useFormatter(): {
6
- dateTime: (value: number | Date, formatOrOptions?: string | DateTimeFormatOptions | undefined) => string;
7
- number: (value: number | bigint, formatOrOptions?: string | _formatjs_ecma402_abstract_types_number.NumberFormatOptions | undefined) => string;
8
- relativeTime: (date: number | Date, now?: number | Date | undefined) => string;
9
- list: (value: Iterable<string>, formatOrOptions?: string | Intl.ListFormatOptions | undefined) => string;
10
- };
11
-
12
- export { useFormatter as default };
@@ -1,2 +0,0 @@
1
- import{useMemo as n}from"react";import a from"../core/createFormatter.mjs";import f from"./useIntlContext.mjs";function l(){const{formats:o,locale:r,now:t,onError:e,timeZone:m}=f();return n(()=>a({formats:o,locale:r,now:t,onError:e,timeZone:m}),[o,t,r,e,m])}export{l as default};
2
- //# sourceMappingURL=useFormatter.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"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"],"mappings":"AAAA,OAAQ,WAAAA,MAAc,QACtB,OAAOC,MAAqB,0BAC5B,OAAOC,MAAoB,mBAEZ,SAARC,GAAgC,CACrC,KAAM,CAAC,QAAAC,EAAS,OAAAC,EAAQ,IAAKC,EAAW,QAAAC,EAAS,SAAAC,CAAQ,EAAIN,EAAe,EAE5E,OAAOF,EACL,IACEC,EAAgB,CACd,QAAAG,EACA,OAAAC,EACA,IAAKC,EACL,QAAAC,EACA,SAAAC,CACF,CAAC,EACH,CAACJ,EAASE,EAAWD,EAAQE,EAASC,CAAQ,CAChD,CACF","names":["useMemo","createFormatter","useIntlContext","useFormatter","formats","locale","globalNow","onError","timeZone"]}
@@ -1,12 +0,0 @@
1
- import * as _formatjs_ecma402_abstract_types_number from '@formatjs/ecma402-abstract/types/number';
2
- import DateTimeFormatOptions from '../core/DateTimeFormatOptions.mjs';
3
- import '../core/TimeZone.mjs';
4
-
5
- /** @deprecated Switch to `useFormatter` instead. */
6
- declare function useIntl(): {
7
- formatDateTime: (value: number | Date, formatOrOptions?: string | DateTimeFormatOptions | undefined) => string;
8
- formatNumber: (value: number | bigint, formatOrOptions?: string | _formatjs_ecma402_abstract_types_number.NumberFormatOptions | undefined) => string;
9
- formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
10
- };
11
-
12
- export { useIntl as default };
@@ -1,2 +0,0 @@
1
- import{useMemo as a}from"react";import s from"../core/createIntl.mjs";import m from"./useIntlContext.mjs";let l=!1;function i(){const{formats:e,locale:o,now:t,onError:r,timeZone:n}=m();return l||(l=!0,console.warn("`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.")),a(()=>s({formats:e,locale:o,now:t,onError:r,timeZone:n}),[e,t,o,r,n])}export{i as default};
2
- //# sourceMappingURL=useIntl.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"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"],"mappings":"AAAA,OAAQ,WAAAA,MAAc,QACtB,OAAOC,MAAgB,qBACvB,OAAOC,MAAoB,mBAE3B,IAAIC,EAAY,GAGD,SAARC,GAA2B,CAChC,KAAM,CAAC,QAAAC,EAAS,OAAAC,EAAQ,IAAKC,EAAW,QAAAC,EAAS,SAAAC,CAAQ,EAAIP,EAAe,EAE5E,OAAKC,IACHA,EAAY,GACZ,QAAQ,KACN,6GACF,GAGKH,EACL,IACEC,EAAW,CACT,QAAAI,EACA,OAAAC,EACA,IAAKC,EACL,QAAAC,EACA,SAAAC,CACF,CAAC,EACH,CAACJ,EAASE,EAAWD,EAAQE,EAASC,CAAQ,CAChD,CACF","names":["useMemo","createIntl","useIntlContext","hasWarned","useIntl","formats","locale","globalNow","onError","timeZone"]}
@@ -1,13 +0,0 @@
1
- import { InitializedIntlConfig } from '../core/IntlConfig.mjs';
2
- import AbstractIntlMessages from '../core/AbstractIntlMessages.mjs';
3
- import '../core/Formats.mjs';
4
- import '../core/DateTimeFormatOptions.mjs';
5
- import '../core/TimeZone.mjs';
6
- import '@formatjs/ecma402-abstract/types/number';
7
- import '../core/IntlError.mjs';
8
- import '../core/TranslationValues.mjs';
9
- import 'react';
10
-
11
- declare function useIntlContext(): InitializedIntlConfig<AbstractIntlMessages>;
12
-
13
- export { useIntlContext as default };
@@ -1,2 +0,0 @@
1
- import{useContext as o}from"react";import e from"./IntlContext.mjs";function n(){const t=o(e);if(!t)throw new Error(process.env.NODE_ENV!=="production"?"No intl context found. Have you configured the provider?":void 0);return t}export{n as default};
2
- //# sourceMappingURL=useIntlContext.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"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"],"mappings":"AAAA,OAAQ,cAAAA,MAAiB,QACzB,OAAOC,MAAiB,gBAET,SAARC,GAAkC,CACvC,MAAMC,EAAUH,EAAWC,CAAW,EAEtC,GAAI,CAACE,EACH,MAAM,IAAI,MACR,QAAQ,IAAI,WAAa,aACrB,2DACA,MACN,EAGF,OAAOA,CACT","names":["useContext","IntlContext","useIntlContext","context"]}
@@ -1,3 +0,0 @@
1
- declare function useLocale(): string;
2
-
3
- export { useLocale as default };
@@ -1,2 +0,0 @@
1
- import e from"./useIntlContext.mjs";function t(){return e().locale}export{t as default};
2
- //# sourceMappingURL=useLocale.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/react/useLocale.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n"],"mappings":"AAAA,OAAOA,MAAoB,mBAEZ,SAARC,GAA6B,CAClC,OAAOD,EAAe,EAAE,MAC1B","names":["useIntlContext","useLocale"]}
@@ -1,5 +0,0 @@
1
- import AbstractIntlMessages from '../core/AbstractIntlMessages.mjs';
2
-
3
- declare function useMessages(): AbstractIntlMessages | undefined;
4
-
5
- export { useMessages as default };
@@ -1,2 +0,0 @@
1
- import e from"./useIntlContext.mjs";function s(){return e().messages}export{s as default};
2
- //# sourceMappingURL=useMessages.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/react/useMessages.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useMessages() {\n return useIntlContext().messages;\n}\n"],"mappings":"AAAA,OAAOA,MAAoB,mBAEZ,SAARC,GAA+B,CACpC,OAAOD,EAAe,EAAE,QAC1B","names":["useIntlContext","useMessages"]}
@@ -1,24 +0,0 @@
1
- type Options = {
2
- updateInterval?: number;
3
- };
4
- /**
5
- * Reading the current date via `new Date()` in components should be avoided, as
6
- * it causes components to be impure and can lead to flaky tests. Instead, this
7
- * hook can be used.
8
- *
9
- * By default, it returns the time when the component mounts. If `updateInterval`
10
- * is specified, the value will be updated based on the interval.
11
- *
12
- * You can however also return a static value from this hook, if you
13
- * configure the `now` parameter on the context provider. Note however,
14
- * that if `updateInterval` is configured in this case, the component
15
- * will initialize with the global value, but will afterwards update
16
- * continuously based on the interval.
17
- *
18
- * For unit tests, this can be mocked to a constant value. For end-to-end
19
- * testing, an environment parameter can be passed to the `now` parameter
20
- * of the provider to mock this to a static value.
21
- */
22
- declare function useNow(options?: Options): Date;
23
-
24
- export { useNow as default };
@@ -1,2 +0,0 @@
1
- import{useState as s,useEffect as l}from"react";import p from"./useIntlContext.mjs";function n(){return new Date}function c(o){const t=o?.updateInterval,{now:e}=p(),[r,u]=s(e||n());return l(()=>{if(!t)return;const a=setInterval(()=>{u(n())},t);return()=>{clearInterval(a)}},[e,t]),r}export{c as default};
2
- //# sourceMappingURL=useNow.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"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"],"mappings":"AAAA,OAAQ,YAAAA,EAAU,aAAAC,MAAgB,QAClC,OAAOC,MAAoB,mBAM3B,SAASC,GAAS,CAChB,OAAO,IAAI,IACb,CAoBe,SAARC,EAAwBC,EAAmB,CAChD,MAAMC,EAAiBD,GAAS,eAE1B,CAAC,IAAKE,CAAS,EAAIL,EAAe,EAClC,CAACM,EAAKC,CAAM,EAAIT,EAASO,GAAaJ,EAAO,CAAC,EAEpD,OAAAF,EAAU,IAAM,CACd,GAAI,CAACK,EAAgB,OAErB,MAAMI,EAAa,YAAY,IAAM,CACnCD,EAAON,EAAO,CAAC,CACjB,EAAGG,CAAc,EAEjB,MAAO,IAAM,CACX,cAAcI,CAAU,CAC1B,CACF,EAAG,CAACH,EAAWD,CAAc,CAAC,EAEvBE,CACT","names":["useState","useEffect","useIntlContext","getNow","useNow","options","updateInterval","globalNow","now","setNow","intervalId"]}
@@ -1,5 +0,0 @@
1
- import TimeZone from '../core/TimeZone.mjs';
2
-
3
- declare function useTimeZone(): TimeZone | undefined;
4
-
5
- export { useTimeZone as default };
@@ -1,2 +0,0 @@
1
- import e from"./useIntlContext.mjs";function t(){return e().timeZone}export{t as default};
2
- //# sourceMappingURL=useTimeZone.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/react/useTimeZone.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"mappings":"AAAA,OAAOA,MAAoB,mBAEZ,SAARC,GAA+B,CACpC,OAAOD,EAAe,EAAE,QAC1B","names":["useIntlContext","useTimeZone"]}
@@ -1,50 +0,0 @@
1
- import { ReactElement, ReactNodeArray } from 'react';
2
- import Formats from '../core/Formats.mjs';
3
- import TranslationValues, { RichTranslationValues } from '../core/TranslationValues.mjs';
4
- import MessageKeys from '../core/utils/MessageKeys.mjs';
5
- import NamespaceKeys from '../core/utils/NamespaceKeys.mjs';
6
- import NestedKeyOf from '../core/utils/NestedKeyOf.mjs';
7
- import NestedValueOf from '../core/utils/NestedValueOf.mjs';
8
- import '../core/DateTimeFormatOptions.mjs';
9
- import '../core/TimeZone.mjs';
10
- import '@formatjs/ecma402-abstract/types/number';
11
-
12
- /**
13
- * Translates messages from the given namespace by using the ICU syntax.
14
- * See https://formatjs.io/docs/core-concepts/icu-syntax.
15
- *
16
- * If no namespace is provided, all available messages are returned.
17
- * The namespace can also indicate nesting by using a dot
18
- * (e.g. `namespace.Component`).
19
- */
20
- declare function useTranslations<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>(namespace?: NestedKey): {
21
- <TargetKey extends MessageKeys<NestedValueOf<{
22
- '!': IntlMessages;
23
- }, [
24
- NestedKey
25
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
26
- '!': IntlMessages;
27
- }, [
28
- NestedKey
29
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
30
- rich<TargetKey extends MessageKeys<NestedValueOf<{
31
- '!': IntlMessages;
32
- }, [
33
- NestedKey
34
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
35
- '!': IntlMessages;
36
- }, [
37
- NestedKey
38
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: RichTranslationValues, formats?: Partial<Formats>): string | ReactElement | ReactNodeArray;
39
- raw<TargetKey extends MessageKeys<NestedValueOf<{
40
- '!': IntlMessages;
41
- }, [
42
- NestedKey
43
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
44
- '!': IntlMessages;
45
- }, [
46
- NestedKey
47
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
48
- };
49
-
50
- export { useTranslations as default };
@@ -1,2 +0,0 @@
1
- import t from"./useIntlContext.mjs";import a from"./useTranslationsImpl.mjs";function r(e){const s=t().messages;return a({"!":s},e?`!.${e}`:"!","!")}export{r as default};
2
- //# sourceMappingURL=useTranslations.mjs.map