use-intl 2.20.0 → 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 (273) hide show
  1. package/core.d.ts +1 -0
  2. package/dist/_virtual/_rollupPluginBabelHelpers.esm.js +102 -0
  3. package/dist/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -0
  4. package/dist/core/IntlError.esm.js +33 -0
  5. package/dist/core/IntlError.esm.js.map +1 -0
  6. package/dist/core/TranslationValues.d.ts +1 -0
  7. package/dist/core/convertFormatsToIntlMessageFormat.esm.js +37 -0
  8. package/dist/core/convertFormatsToIntlMessageFormat.esm.js.map +1 -0
  9. package/dist/core/createBaseTranslator.d.ts +3 -8
  10. package/dist/core/createBaseTranslator.esm.js +210 -0
  11. package/dist/core/createBaseTranslator.esm.js.map +1 -0
  12. package/dist/core/createFormatter.esm.js +138 -0
  13. package/dist/core/createFormatter.esm.js.map +1 -0
  14. package/dist/core/createIntl.esm.js +14 -0
  15. package/dist/core/createIntl.esm.js.map +1 -0
  16. package/dist/core/createTranslator.d.ts +2 -3
  17. package/dist/core/createTranslator.esm.js +37 -0
  18. package/dist/core/createTranslator.esm.js.map +1 -0
  19. package/dist/core/createTranslatorImpl.d.ts +2 -3
  20. package/dist/core/createTranslatorImpl.esm.js +50 -0
  21. package/dist/core/createTranslatorImpl.esm.js.map +1 -0
  22. package/dist/core/defaults.esm.js +15 -0
  23. package/dist/core/defaults.esm.js.map +1 -0
  24. package/dist/core/index.d.ts +8 -1
  25. package/dist/core/initializeConfig.d.ts +13 -0
  26. package/dist/core/initializeConfig.esm.js +29 -0
  27. package/dist/core/initializeConfig.esm.js.map +1 -0
  28. package/dist/core/resolveNamespace.esm.js +10 -0
  29. package/dist/core/resolveNamespace.esm.js.map +1 -0
  30. package/dist/core/use-intl.esm10.js +23 -32
  31. package/dist/core/use-intl.esm10.js.map +1 -1
  32. package/dist/core/use-intl.esm11.js +10 -0
  33. package/dist/core/use-intl.esm11.js.map +1 -0
  34. package/dist/core/use-intl.esm2.js +204 -31
  35. package/dist/core/use-intl.esm2.js.map +1 -1
  36. package/dist/core/use-intl.esm3.js +31 -132
  37. package/dist/core/use-intl.esm3.js.map +1 -1
  38. package/dist/core/use-intl.esm4.js +1 -1
  39. package/dist/core/use-intl.esm5.js +19 -43
  40. package/dist/core/use-intl.esm5.js.map +1 -1
  41. package/dist/core/use-intl.esm6.js +134 -11
  42. package/dist/core/use-intl.esm6.js.map +1 -1
  43. package/dist/core/use-intl.esm7.js +29 -192
  44. package/dist/core/use-intl.esm7.js.map +1 -1
  45. package/dist/core/use-intl.esm8.js +10 -5
  46. package/dist/core/use-intl.esm8.js.map +1 -1
  47. package/dist/core/use-intl.esm9.js +44 -22
  48. package/dist/core/use-intl.esm9.js.map +1 -1
  49. package/dist/core/validateMessages.esm.js +28 -0
  50. package/dist/core/validateMessages.esm.js.map +1 -0
  51. package/dist/core.cjs.development.js +93 -0
  52. package/dist/core.cjs.development.js.map +1 -0
  53. package/dist/core.cjs.production.min.js +2 -0
  54. package/dist/core.cjs.production.min.js.map +1 -0
  55. package/dist/core.d.ts +1 -0
  56. package/dist/core.esm.js +7 -0
  57. package/dist/core.esm.js.map +1 -0
  58. package/dist/core.js +8 -0
  59. package/dist/createIntl-34d4281e.js +592 -0
  60. package/dist/createIntl-34d4281e.js.map +1 -0
  61. package/dist/createIntl-bc325740.js +2 -0
  62. package/dist/createIntl-bc325740.js.map +1 -0
  63. package/dist/react/IntlContext.esm.js +6 -0
  64. package/dist/react/IntlContext.esm.js.map +1 -0
  65. package/dist/react/IntlProvider.d.ts +1 -1
  66. package/dist/react/IntlProvider.esm.js +22 -0
  67. package/dist/react/IntlProvider.esm.js.map +1 -0
  68. package/dist/react/getInitializedConfig.d.ts +1 -13
  69. package/dist/react/use-intl.esm.js +22 -18
  70. package/dist/react/use-intl.esm.js.map +1 -1
  71. package/dist/react/use-intl.esm10.js +8 -24
  72. package/dist/react/use-intl.esm10.js.map +1 -1
  73. package/dist/react/use-intl.esm11.js +3 -10
  74. package/dist/react/use-intl.esm11.js.map +1 -1
  75. package/dist/react/use-intl.esm2.js +4 -22
  76. package/dist/react/use-intl.esm2.js.map +1 -1
  77. package/dist/react/use-intl.esm3.js +26 -4
  78. package/dist/react/use-intl.esm3.js.map +1 -1
  79. package/dist/react/use-intl.esm4.js +18 -41
  80. package/dist/react/use-intl.esm4.js.map +1 -1
  81. package/dist/react/use-intl.esm5.js +20 -4
  82. package/dist/react/use-intl.esm5.js.map +1 -1
  83. package/dist/react/use-intl.esm6.js +41 -4
  84. package/dist/react/use-intl.esm6.js.map +1 -1
  85. package/dist/react/use-intl.esm7.js +4 -20
  86. package/dist/react/use-intl.esm7.js.map +1 -1
  87. package/dist/react/use-intl.esm8.js +4 -26
  88. package/dist/react/use-intl.esm8.js.map +1 -1
  89. package/dist/react/use-intl.esm9.js +33 -3
  90. package/dist/react/use-intl.esm9.js.map +1 -1
  91. package/dist/react/useFormatter.esm.js +24 -0
  92. package/dist/react/useFormatter.esm.js.map +1 -0
  93. package/dist/react/useIntl.esm.js +30 -0
  94. package/dist/react/useIntl.esm.js.map +1 -0
  95. package/dist/react/useIntlContext.esm.js +13 -0
  96. package/dist/react/useIntlContext.esm.js.map +1 -0
  97. package/dist/react/useLocale.esm.js +8 -0
  98. package/dist/react/useLocale.esm.js.map +1 -0
  99. package/dist/react/useMessages.esm.js +8 -0
  100. package/dist/react/useMessages.esm.js.map +1 -0
  101. package/{src/react/useNow.tsx → dist/react/useNow.esm.js} +32 -36
  102. package/dist/react/useNow.esm.js.map +1 -0
  103. package/dist/react/useTimeZone.esm.js +8 -0
  104. package/dist/react/useTimeZone.esm.js.map +1 -0
  105. package/dist/react/useTranslations.esm.js +26 -0
  106. package/dist/react/useTranslations.esm.js.map +1 -0
  107. package/dist/react/{use-intl.esm12.js → useTranslationsImpl.esm.js} +6 -13
  108. package/dist/react/useTranslationsImpl.esm.js.map +1 -0
  109. package/dist/react.cjs.development.js +190 -0
  110. package/dist/react.cjs.development.js.map +1 -0
  111. package/dist/react.cjs.production.min.js +2 -0
  112. package/dist/react.cjs.production.min.js.map +1 -0
  113. package/dist/react.d.ts +1 -0
  114. package/dist/react.esm.js +9 -0
  115. package/dist/react.esm.js.map +1 -0
  116. package/dist/react.js +8 -0
  117. package/dist/test/setup.d.ts +1 -0
  118. package/dist/use-intl.cjs.development.js +32 -30
  119. package/dist/use-intl.cjs.development.js.map +1 -1
  120. package/dist/use-intl.cjs.production.min.js +1 -1
  121. package/dist/use-intl.cjs.production.min.js.map +1 -1
  122. package/dist/use-intl.esm.js +12 -10
  123. package/dist/use-intl.esm.js.map +1 -1
  124. package/package.json +17 -15
  125. package/react.d.ts +1 -0
  126. package/dist/react/use-intl.esm12.js.map +0 -1
  127. package/dist/src/core/AbstractIntlMessages.d.ts +0 -9
  128. package/dist/src/core/AbstractIntlMessages.js +0 -2
  129. package/dist/src/core/AbstractIntlMessages.js.map +0 -1
  130. package/dist/src/core/DateTimeFormatOptions.d.ts +0 -73
  131. package/dist/src/core/DateTimeFormatOptions.js +0 -3
  132. package/dist/src/core/DateTimeFormatOptions.js.map +0 -1
  133. package/dist/src/core/Formats.d.ts +0 -8
  134. package/dist/src/core/Formats.js +0 -2
  135. package/dist/src/core/Formats.js.map +0 -1
  136. package/dist/src/core/IntlConfig.d.ts +0 -54
  137. package/dist/src/core/IntlConfig.js +0 -2
  138. package/dist/src/core/IntlConfig.js.map +0 -1
  139. package/dist/src/core/IntlError.d.ts +0 -13
  140. package/dist/src/core/IntlError.js +0 -23
  141. package/dist/src/core/IntlError.js.map +0 -1
  142. package/dist/src/core/MessageFormatCache.d.ts +0 -5
  143. package/dist/src/core/MessageFormatCache.js +0 -2
  144. package/dist/src/core/MessageFormatCache.js.map +0 -1
  145. package/dist/src/core/NumberFormatOptions.d.ts +0 -2
  146. package/dist/src/core/NumberFormatOptions.js +0 -2
  147. package/dist/src/core/NumberFormatOptions.js.map +0 -1
  148. package/dist/src/core/TimeZone.d.ts +0 -2
  149. package/dist/src/core/TimeZone.js +0 -2
  150. package/dist/src/core/TimeZone.js.map +0 -1
  151. package/dist/src/core/TranslationValues.d.ts +0 -5
  152. package/dist/src/core/TranslationValues.js +0 -2
  153. package/dist/src/core/TranslationValues.js.map +0 -1
  154. package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +0 -11
  155. package/dist/src/core/convertFormatsToIntlMessageFormat.js +0 -47
  156. package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +0 -1
  157. package/dist/src/core/createBaseTranslator.d.ts +0 -26
  158. package/dist/src/core/createBaseTranslator.js +0 -218
  159. package/dist/src/core/createBaseTranslator.js.map +0 -1
  160. package/dist/src/core/createFormatter.d.ts +0 -19
  161. package/dist/src/core/createFormatter.js +0 -129
  162. package/dist/src/core/createFormatter.js.map +0 -1
  163. package/dist/src/core/createIntl.d.ts +0 -7
  164. package/dist/src/core/createIntl.js +0 -11
  165. package/dist/src/core/createIntl.js.map +0 -1
  166. package/dist/src/core/createTranslator.d.ts +0 -48
  167. package/dist/src/core/createTranslator.js +0 -24
  168. package/dist/src/core/createTranslator.js.map +0 -1
  169. package/dist/src/core/createTranslatorImpl.d.ts +0 -14
  170. package/dist/src/core/createTranslatorImpl.js +0 -43
  171. package/dist/src/core/createTranslatorImpl.js.map +0 -1
  172. package/dist/src/core/defaults.d.ts +0 -11
  173. package/dist/src/core/defaults.js +0 -11
  174. package/dist/src/core/defaults.js.map +0 -1
  175. package/dist/src/core/index.d.ts +0 -9
  176. package/dist/src/core/index.js +0 -6
  177. package/dist/src/core/index.js.map +0 -1
  178. package/dist/src/core/resolveNamespace.d.ts +0 -5
  179. package/dist/src/core/resolveNamespace.js +0 -10
  180. package/dist/src/core/resolveNamespace.js.map +0 -1
  181. package/dist/src/core/utils/MessageKeys.d.ts +0 -5
  182. package/dist/src/core/utils/MessageKeys.js +0 -2
  183. package/dist/src/core/utils/MessageKeys.js.map +0 -1
  184. package/dist/src/core/utils/NamespaceKeys.d.ts +0 -5
  185. package/dist/src/core/utils/NamespaceKeys.js +0 -2
  186. package/dist/src/core/utils/NamespaceKeys.js.map +0 -1
  187. package/dist/src/core/utils/NestedKeyOf.d.ts +0 -4
  188. package/dist/src/core/utils/NestedKeyOf.js +0 -2
  189. package/dist/src/core/utils/NestedKeyOf.js.map +0 -1
  190. package/dist/src/core/utils/NestedValueOf.d.ts +0 -2
  191. package/dist/src/core/utils/NestedValueOf.js +0 -2
  192. package/dist/src/core/utils/NestedValueOf.js.map +0 -1
  193. package/dist/src/core/validateMessages.d.ts +0 -3
  194. package/dist/src/core/validateMessages.js +0 -56
  195. package/dist/src/core/validateMessages.js.map +0 -1
  196. package/dist/src/index.d.ts +0 -2
  197. package/dist/src/index.js +0 -3
  198. package/dist/src/index.js.map +0 -1
  199. package/dist/src/react/IntlContext.d.ts +0 -13
  200. package/dist/src/react/IntlContext.js +0 -4
  201. package/dist/src/react/IntlContext.js.map +0 -1
  202. package/dist/src/react/IntlProvider.d.ts +0 -7
  203. package/dist/src/react/IntlProvider.js +0 -11
  204. package/dist/src/react/IntlProvider.js.map +0 -1
  205. package/dist/src/react/getInitializedConfig.d.ts +0 -13
  206. package/dist/src/react/getInitializedConfig.js +0 -21
  207. package/dist/src/react/getInitializedConfig.js.map +0 -1
  208. package/dist/src/react/index.d.ts +0 -8
  209. package/dist/src/react/index.js +0 -10
  210. package/dist/src/react/index.js.map +0 -1
  211. package/dist/src/react/useFormatter.d.ts +0 -6
  212. package/dist/src/react/useFormatter.js +0 -14
  213. package/dist/src/react/useFormatter.js.map +0 -1
  214. package/dist/src/react/useIntl.d.ts +0 -6
  215. package/dist/src/react/useIntl.js +0 -20
  216. package/dist/src/react/useIntl.js.map +0 -1
  217. package/dist/src/react/useIntlContext.d.ts +0 -10
  218. package/dist/src/react/useIntlContext.js +0 -12
  219. package/dist/src/react/useIntlContext.js.map +0 -1
  220. package/dist/src/react/useLocale.d.ts +0 -1
  221. package/dist/src/react/useLocale.js +0 -5
  222. package/dist/src/react/useLocale.js.map +0 -1
  223. package/dist/src/react/useMessages.d.ts +0 -1
  224. package/dist/src/react/useMessages.js +0 -5
  225. package/dist/src/react/useMessages.js.map +0 -1
  226. package/dist/src/react/useNow.d.ts +0 -23
  227. package/dist/src/react/useNow.js +0 -40
  228. package/dist/src/react/useNow.js.map +0 -1
  229. package/dist/src/react/useTimeZone.d.ts +0 -1
  230. package/dist/src/react/useTimeZone.js +0 -5
  231. package/dist/src/react/useTimeZone.js.map +0 -1
  232. package/dist/src/react/useTranslations.d.ts +0 -44
  233. package/dist/src/react/useTranslations.js +0 -21
  234. package/dist/src/react/useTranslations.js.map +0 -1
  235. package/dist/src/react/useTranslationsImpl.d.ts +0 -8
  236. package/dist/src/react/useTranslationsImpl.js +0 -35
  237. package/dist/src/react/useTranslationsImpl.js.map +0 -1
  238. package/src/core/AbstractIntlMessages.tsx +0 -10
  239. package/src/core/DateTimeFormatOptions.tsx +0 -130
  240. package/src/core/Formats.tsx +0 -10
  241. package/src/core/IntlConfig.tsx +0 -59
  242. package/src/core/IntlError.tsx +0 -26
  243. package/src/core/MessageFormatCache.tsx +0 -10
  244. package/src/core/NumberFormatOptions.tsx +0 -3
  245. package/src/core/TimeZone.tsx +0 -426
  246. package/src/core/TranslationValues.tsx +0 -22
  247. package/src/core/convertFormatsToIntlMessageFormat.tsx +0 -63
  248. package/src/core/createBaseTranslator.tsx +0 -352
  249. package/src/core/createFormatter.tsx +0 -191
  250. package/src/core/createIntl.tsx +0 -13
  251. package/src/core/createTranslator.tsx +0 -112
  252. package/src/core/createTranslatorImpl.tsx +0 -87
  253. package/src/core/defaults.tsx +0 -18
  254. package/src/core/index.tsx +0 -14
  255. package/src/core/resolveNamespace.tsx +0 -12
  256. package/src/core/utils/MessageKeys.tsx +0 -9
  257. package/src/core/utils/NamespaceKeys.tsx +0 -9
  258. package/src/core/utils/NestedKeyOf.tsx +0 -9
  259. package/src/core/utils/NestedValueOf.tsx +0 -12
  260. package/src/core/validateMessages.tsx +0 -77
  261. package/src/index.tsx +0 -2
  262. package/src/react/IntlContext.tsx +0 -12
  263. package/src/react/IntlProvider.tsx +0 -23
  264. package/src/react/getInitializedConfig.tsx +0 -29
  265. package/src/react/index.tsx +0 -10
  266. package/src/react/useFormatter.tsx +0 -19
  267. package/src/react/useIntl.tsx +0 -29
  268. package/src/react/useIntlContext.tsx +0 -16
  269. package/src/react/useLocale.tsx +0 -5
  270. package/src/react/useMessages.tsx +0 -5
  271. package/src/react/useTimeZone.tsx +0 -5
  272. package/src/react/useTranslations.tsx +0 -103
  273. package/src/react/useTranslationsImpl.tsx +0 -61
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTranslator.js","sourceRoot":"","sources":["../../../src/core/createTranslator.tsx"],"names":[],"mappings":"AAGA,OAAO,oBAEN,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAMrE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAKtC,EACA,kBAAkB,GAAG,yBAAyB,EAC9C,QAAQ,EACR,SAAS,EACT,OAAO,GAAG,cAAc,EACxB,GAAG,IAAI,EAIR;IA4DC,6EAA6E;IAC7E,6EAA6E;IAC7E,iCAAiC;IACjC,OAAO,oBAAoB,CAIzB;QACE,GAAG,IAAI;QACP,OAAO;QACP,kBAAkB;QAClB,QAAQ,EAAE,EAAC,GAAG,EAAE,QAAQ,EAAC;QACzB,aAAa;QACb,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG;KAC9C,EACD,GAAG,CACJ,CAAC;AACJ,CAAC"}
@@ -1,14 +0,0 @@
1
- import AbstractIntlMessages from './AbstractIntlMessages';
2
- import { InitializedIntlConfig } from './IntlConfig';
3
- import { TranslationValue } from './TranslationValues';
4
- import NestedKeyOf from './utils/NestedKeyOf';
5
- export type CoreRichTranslationValues = Record<string, TranslationValue | ((chunks: string) => string)>;
6
- export type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & {
7
- namespace: string;
8
- messages: Messages;
9
- };
10
- export default function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ getMessageFallback, messages, namespace, onError, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): {
11
- (key: import("./utils/MessageKeys").default<import("./utils/NestedValueOf").default<Messages, NestedKey>, NestedKeyOf<import("./utils/NestedValueOf").default<Messages, NestedKey>>>, values?: import("./TranslationValues").default | undefined, formats?: Partial<import("./Formats").default> | undefined): string;
12
- rich(key: string, values: CoreRichTranslationValues, formats?: Partial<import("./Formats").default> | undefined): string;
13
- raw: (key: string) => any;
14
- };
@@ -1,43 +0,0 @@
1
- import IntlError, { IntlErrorCode } from './IntlError';
2
- import createBaseTranslator, { getMessagesOrError } from './createBaseTranslator';
3
- import resolveNamespace from './resolveNamespace';
4
- export default function createTranslatorImpl({ getMessageFallback, messages, namespace, onError, ...rest }, namespacePrefix) {
5
- // The `namespacePrefix` is part of the type system.
6
- // See the comment in the function invocation.
7
- messages = messages[namespacePrefix];
8
- namespace = resolveNamespace(namespace, namespacePrefix);
9
- const translator = createBaseTranslator({
10
- ...rest,
11
- onError,
12
- getMessageFallback,
13
- messagesOrError: getMessagesOrError({
14
- messages,
15
- namespace,
16
- onError
17
- })
18
- });
19
- const originalRich = translator.rich;
20
- function base(...args) {
21
- return translator(...args);
22
- }
23
- // Augment `t.rich` to return plain strings
24
- base.rich = (key,
25
- /** Key value pairs for values to interpolate into the message. */
26
- values, formats) => {
27
- // `chunks` is returned as a string when no React element
28
- // is used, therefore it's safe to cast this type.
29
- const result = originalRich(key, values, formats);
30
- // When only string chunks are provided to the parser, only strings should be returned here.
31
- if (typeof result !== 'string') {
32
- const error = new IntlError(IntlErrorCode.FORMATTING_ERROR, process.env.NODE_ENV !== 'production'
33
- ? "`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})"
34
- : undefined);
35
- onError(error);
36
- return getMessageFallback({ error, key, namespace });
37
- }
38
- return result;
39
- };
40
- base.raw = translator.raw;
41
- return base;
42
- }
43
- //# sourceMappingURL=createTranslatorImpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTranslatorImpl.js","sourceRoot":"","sources":["../../../src/core/createTranslatorImpl.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAErD,OAAO,oBAAoB,EAAE,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAChF,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAgBlD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAI1C,EACE,kBAAkB,EAClB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,GAAG,IAAI,EAC6B,EACtC,eAAuB;IAEvB,oDAAoD;IACpD,8CAA8C;IAC9C,QAAQ,GAAG,QAAQ,CAAC,eAAe,CAAa,CAAC;IACjD,SAAS,GAAG,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAc,CAAC;IAEtE,MAAM,UAAU,GAAG,oBAAoB,CAAsB;QAC3D,GAAG,IAAI;QACP,OAAO;QACP,kBAAkB;QAClB,eAAe,EAAE,kBAAkB,CAAC;YAClC,QAAQ;YACR,SAAS;YACT,OAAO;SACR,CAAyB;KAC3B,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC;IAErC,SAAS,IAAI,CAAC,GAAG,IAAmC;QAClD,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,2CAA2C;IAC3C,IAAI,CAAC,IAAI,GAAG,CACV,GAAuC;IACvC,kEAAkE;IAClE,MAAiC,EACjC,OAA4C,EACpC,EAAE;QACV,yDAAyD;QACzD,kDAAkD;QAClD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,EAAE,MAA+B,EAAE,OAAO,CAAC,CAAC;QAE3E,4FAA4F;QAC5F,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,MAAM,KAAK,GAAG,IAAI,SAAS,CACzB,aAAa,CAAC,gBAAgB,EAC9B,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;gBACnC,CAAC,CAAC,iKAAiK;gBACnK,CAAC,CAAC,SAAS,CACd,CAAC;YAEF,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,OAAO,kBAAkB,CAAC,EAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAC,CAAC,CAAC;SACpD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;IAE1B,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,11 +0,0 @@
1
- import IntlError from './IntlError';
2
- /**
3
- * Contains defaults that are used for all entry points into the core.
4
- * See also `InitializedIntlConfiguration`.
5
- */
6
- export declare function defaultGetMessageFallback(props: {
7
- error: IntlError;
8
- key: string;
9
- namespace?: string;
10
- }): string;
11
- export declare function defaultOnError(error: IntlError): void;
@@ -1,11 +0,0 @@
1
- /**
2
- * Contains defaults that are used for all entry points into the core.
3
- * See also `InitializedIntlConfiguration`.
4
- */
5
- export function defaultGetMessageFallback(props) {
6
- return [props.namespace, props.key].filter((part) => part != null).join('.');
7
- }
8
- export function defaultOnError(error) {
9
- console.error(error);
10
- }
11
- //# sourceMappingURL=defaults.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../src/core/defaults.tsx"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,MAAM,UAAU,yBAAyB,CAAC,KAIzC;IACC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAgB;IAC7C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
@@ -1,9 +0,0 @@
1
- export type { default as AbstractIntlMessages } from './AbstractIntlMessages';
2
- export type { default as TranslationValues, RichTranslationValues } from './TranslationValues';
3
- export type { default as Formats } from './Formats';
4
- export type { default as DateTimeFormatOptions } from './DateTimeFormatOptions';
5
- export type { default as NumberFormatOptions } from './NumberFormatOptions';
6
- export { default as IntlError, IntlErrorCode } from './IntlError';
7
- export { default as createTranslator } from './createTranslator';
8
- export { default as createFormatter } from './createFormatter';
9
- export { default as createIntl } from './createIntl';
@@ -1,6 +0,0 @@
1
- export { default as IntlError, IntlErrorCode } from './IntlError';
2
- export { default as createTranslator } from './createTranslator';
3
- export { default as createFormatter } from './createFormatter';
4
- // TODO: Remove in next major version
5
- export { default as createIntl } from './createIntl';
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAC,OAAO,IAAI,SAAS,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAChE,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAE7D,qCAAqC;AACrC,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,cAAc,CAAC"}
@@ -1,5 +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
- export default function resolveNamespace(namespace: string, namespacePrefix: string): string | undefined;
@@ -1,10 +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
- export default function resolveNamespace(namespace, namespacePrefix) {
6
- return namespace === namespacePrefix
7
- ? undefined
8
- : namespace.slice((namespacePrefix + '.').length);
9
- }
10
- //# sourceMappingURL=resolveNamespace.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveNamespace.js","sourceRoot":"","sources":["../../../src/core/resolveNamespace.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,SAAiB,EACjB,eAAuB;IAEvB,OAAO,SAAS,KAAK,eAAe;QAClC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,eAAe,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC"}
@@ -1,5 +0,0 @@
1
- import NestedValueOf from './NestedValueOf';
2
- type MessageKeys<ObjectType, Keys extends string> = {
3
- [Property in Keys]: NestedValueOf<ObjectType, Property> extends string ? Property : never;
4
- }[Keys];
5
- export default MessageKeys;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=MessageKeys.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessageKeys.js","sourceRoot":"","sources":["../../../../src/core/utils/MessageKeys.tsx"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import NestedValueOf from './NestedValueOf';
2
- type NamespaceKeys<ObjectType, Keys extends string> = {
3
- [Property in Keys]: NestedValueOf<ObjectType, Property> extends string ? never : Property;
4
- }[Keys];
5
- export default NamespaceKeys;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=NamespaceKeys.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NamespaceKeys.js","sourceRoot":"","sources":["../../../../src/core/utils/NamespaceKeys.tsx"],"names":[],"mappings":""}
@@ -1,4 +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
- export default NestedKeyOf;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=NestedKeyOf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NestedKeyOf.js","sourceRoot":"","sources":["../../../../src/core/utils/NestedKeyOf.tsx"],"names":[],"mappings":""}
@@ -1,2 +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
- export default NestedValueOf;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=NestedValueOf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NestedValueOf.js","sourceRoot":"","sources":["../../../../src/core/utils/NestedValueOf.tsx"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import AbstractIntlMessages from './AbstractIntlMessages';
2
- import IntlError from './IntlError';
3
- export default function validateMessages(messages: AbstractIntlMessages, onError: (error: IntlError) => void): void;
@@ -1,56 +0,0 @@
1
- import IntlError, { IntlErrorCode } from './IntlError';
2
- function validateMessagesSegment(messages, invalidKeyLabels, parentPath) {
3
- Object.entries(messages).forEach(([key, messageOrMessages]) => {
4
- if (key.includes('.')) {
5
- let keyLabel = key;
6
- if (parentPath)
7
- keyLabel += ` (at ${parentPath})`;
8
- invalidKeyLabels.push(keyLabel);
9
- }
10
- if (messageOrMessages != null && typeof messageOrMessages === 'object') {
11
- validateMessagesSegment(messageOrMessages, invalidKeyLabels, [parentPath, key].filter((part) => part != null).join('.'));
12
- }
13
- });
14
- }
15
- export default function validateMessages(messages, onError) {
16
- const invalidKeyLabels = [];
17
- validateMessagesSegment(messages, invalidKeyLabels);
18
- if (invalidKeyLabels.length > 0) {
19
- onError(new IntlError(IntlErrorCode.INVALID_KEY, process.env.NODE_ENV !== 'production'
20
- ? `Namespace keys can not contain the character "." as this is used to express nesting. Please remove it or replace it with another character.
21
-
22
- Invalid ${invalidKeyLabels.length === 1 ? 'key' : 'keys'}: ${invalidKeyLabels.join(', ')}
23
-
24
- If you're migrating from a flat structure, you can convert your messages as follows:
25
-
26
- import {set} from "lodash";
27
-
28
- const input = {
29
- "one.one": "1.1",
30
- "one.two": "1.2",
31
- "two.one.one": "2.1.1"
32
- };
33
-
34
- const output = Object.entries(input).reduce(
35
- (acc, [key, value]) => set(acc, key, value),
36
- {}
37
- );
38
-
39
- // Output:
40
- //
41
- // {
42
- // "one": {
43
- // "one": "1.1",
44
- // "two": "1.2"
45
- // },
46
- // "two": {
47
- // "one": {
48
- // "one": "2.1.1"
49
- // }
50
- // }
51
- // }
52
- `
53
- : undefined));
54
- }
55
- }
56
- //# sourceMappingURL=validateMessages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateMessages.js","sourceRoot":"","sources":["../../../src/core/validateMessages.tsx"],"names":[],"mappings":"AACA,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAErD,SAAS,uBAAuB,CAC9B,QAA8B,EAC9B,gBAA+B,EAC/B,UAAmB;IAEnB,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,iBAAiB,CAAC,EAAE,EAAE;QAC5D,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACrB,IAAI,QAAQ,GAAG,GAAG,CAAC;YACnB,IAAI,UAAU;gBAAE,QAAQ,IAAI,QAAQ,UAAU,GAAG,CAAC;YAClD,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACjC;QAED,IAAI,iBAAiB,IAAI,IAAI,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;YACtE,uBAAuB,CACrB,iBAAiB,EACjB,gBAAgB,EAChB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAC3D,CAAC;SACH;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,QAA8B,EAC9B,OAAmC;IAEnC,MAAM,gBAAgB,GAAkB,EAAE,CAAC;IAC3C,uBAAuB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IAEpD,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;QAC/B,OAAO,CACL,IAAI,SAAS,CACX,aAAa,CAAC,WAAW,EACzB,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YACnC,CAAC,CAAC;;UAGE,gBAAgB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAC1C,KAAK,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8B3C;YACS,CAAC,CAAC,SAAS,CACd,CACF,CAAC;KACH;AACH,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './core';
2
- export * from './react';
package/dist/src/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from './core';
2
- export * from './react';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
@@ -1,13 +0,0 @@
1
- /// <reference types="react" />
2
- import MessageFormatCache from '../core/MessageFormatCache';
3
- declare const IntlContext: import("react").Context<(import("../core/IntlConfig").default<import("../core/AbstractIntlMessages").default> & {
4
- onError: (error: import("..").IntlError) => void;
5
- getMessageFallback: (info: {
6
- error: import("..").IntlError;
7
- key: string;
8
- namespace?: string | undefined;
9
- }) => string;
10
- } & {
11
- messageFormatCache?: MessageFormatCache | undefined;
12
- }) | undefined>;
13
- export default IntlContext;
@@ -1,4 +0,0 @@
1
- import { createContext } from 'react';
2
- const IntlContext = createContext(undefined);
3
- export default IntlContext;
4
- //# sourceMappingURL=IntlContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlContext.js","sourceRoot":"","sources":["../../../src/react/IntlContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAIpC,MAAM,WAAW,GAAG,aAAa,CAK/B,SAAS,CAAC,CAAC;AAEb,eAAe,WAAW,CAAC"}
@@ -1,7 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import IntlConfig from '../core/IntlConfig';
3
- type Props = IntlConfig & {
4
- children: ReactNode;
5
- };
6
- export default function IntlProvider({ children, ...props }: Props): JSX.Element;
7
- export {};
@@ -1,11 +0,0 @@
1
- import React, { useState } from 'react';
2
- import IntlContext from './IntlContext';
3
- import getInitializedConfig from './getInitializedConfig';
4
- export default function IntlProvider({ children, ...props }) {
5
- const [messageFormatCache] = useState(() => new Map());
6
- return (React.createElement(IntlContext.Provider, { value: {
7
- ...getInitializedConfig(props),
8
- messageFormatCache
9
- } }, children));
10
- }
11
- //# sourceMappingURL=IntlProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../../src/react/IntlProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAY,QAAQ,EAAC,MAAM,OAAO,CAAC;AAEjD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAM1D,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAC,QAAQ,EAAE,GAAG,KAAK,EAAQ;IAC9D,MAAM,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IAEvD,OAAO,CACL,oBAAC,WAAW,CAAC,QAAQ,IACnB,KAAK,EAAE;YACL,GAAG,oBAAoB,CAAC,KAAK,CAAC;YAC9B,kBAAkB;SACnB,IAEA,QAAQ,CACY,CACxB,CAAC;AACJ,CAAC"}
@@ -1,13 +0,0 @@
1
- import IntlConfig from '../core/IntlConfig';
2
- /**
3
- * Enhances the incoming props with defaults.
4
- */
5
- export default function getInitializedConfig<Props extends Omit<IntlConfig, 'children'>>({ getMessageFallback, messages, onError, ...rest }: Props): Omit<Props, "onError" | "getMessageFallback" | "messages"> & {
6
- messages: import("../core/AbstractIntlMessages").default | undefined;
7
- onError: (error: import("..").IntlError) => void;
8
- getMessageFallback: (info: {
9
- error: import("..").IntlError;
10
- key: string;
11
- namespace?: string | undefined;
12
- }) => string;
13
- };
@@ -1,21 +0,0 @@
1
- import { defaultGetMessageFallback, defaultOnError } from '../core/defaults';
2
- import validateMessages from '../core/validateMessages';
3
- /**
4
- * Enhances the incoming props with defaults.
5
- */
6
- export default function getInitializedConfig({ getMessageFallback, messages, onError, ...rest }) {
7
- const finalOnError = onError || defaultOnError;
8
- const finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
9
- if (process.env.NODE_ENV !== 'production') {
10
- if (messages) {
11
- validateMessages(messages, finalOnError);
12
- }
13
- }
14
- return {
15
- ...rest,
16
- messages,
17
- onError: finalOnError,
18
- getMessageFallback: finalGetMessageFallback
19
- };
20
- }
21
- //# sourceMappingURL=getInitializedConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getInitializedConfig.js","sourceRoot":"","sources":["../../../src/react/getInitializedConfig.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC3E,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAI1C,EAAC,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,EAAQ;IACvD,MAAM,YAAY,GAAG,OAAO,IAAI,cAAc,CAAC;IAC/C,MAAM,uBAAuB,GAC3B,kBAAkB,IAAI,yBAAyB,CAAC;IAElD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAI,QAAQ,EAAE;YACZ,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;SAC1C;KACF;IAED,OAAO;QACL,GAAG,IAAI;QACP,QAAQ;QACR,OAAO,EAAE,YAAY;QACrB,kBAAkB,EAAE,uBAAuB;KAC5C,CAAC;AACJ,CAAC"}
@@ -1,8 +0,0 @@
1
- export { default as IntlProvider } from './IntlProvider';
2
- export { default as useTranslations } from './useTranslations';
3
- export { default as useLocale } from './useLocale';
4
- export { default as useNow } from './useNow';
5
- export { default as useTimeZone } from './useTimeZone';
6
- export { default as useMessages } from './useMessages';
7
- export { default as useFormatter } from './useFormatter';
8
- export { default as useIntl } from './useIntl';
@@ -1,10 +0,0 @@
1
- export { default as IntlProvider } from './IntlProvider';
2
- export { default as useTranslations } from './useTranslations';
3
- export { default as useLocale } from './useLocale';
4
- export { default as useNow } from './useNow';
5
- export { default as useTimeZone } from './useTimeZone';
6
- export { default as useMessages } from './useMessages';
7
- export { default as useFormatter } from './useFormatter';
8
- // TODO: Remove in next major version
9
- export { default as useIntl } from './useIntl';
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAEvD,qCAAqC;AACrC,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC"}
@@ -1,6 +0,0 @@
1
- export default function useFormatter(): {
2
- dateTime: (value: number | Date, formatOrOptions?: string | import("../core/DateTimeFormatOptions").default | undefined) => string;
3
- number: (value: number | bigint, formatOrOptions?: string | import("@formatjs/ecma402-abstract/types/number").NumberFormatOptions | undefined) => string;
4
- relativeTime: (date: number | Date, now?: number | Date | undefined) => string;
5
- list: (value: Iterable<string>, formatOrOptions?: string | Intl.ListFormatOptions | undefined) => string;
6
- };
@@ -1,14 +0,0 @@
1
- import { useMemo } from 'react';
2
- import createFormatter from '../core/createFormatter';
3
- import useIntlContext from './useIntlContext';
4
- export default function useFormatter() {
5
- const { formats, locale, now: globalNow, onError, timeZone } = useIntlContext();
6
- return useMemo(() => createFormatter({
7
- formats,
8
- locale,
9
- now: globalNow,
10
- onError,
11
- timeZone
12
- }), [formats, globalNow, locale, onError, timeZone]);
13
- }
14
- //# sourceMappingURL=useFormatter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFormatter.js","sourceRoot":"","sources":["../../../src/react/useFormatter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,YAAY;IAClC,MAAM,EAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,GAAG,cAAc,EAAE,CAAC;IAE9E,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,eAAe,CAAC;QACd,OAAO;QACP,MAAM;QACN,GAAG,EAAE,SAAS;QACd,OAAO;QACP,QAAQ;KACT,CAAC,EACJ,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAChD,CAAC;AACJ,CAAC"}
@@ -1,6 +0,0 @@
1
- /** @deprecated Switch to `useFormatter` instead. */
2
- export default function useIntl(): {
3
- formatDateTime: (value: number | Date, formatOrOptions?: string | import("../core/DateTimeFormatOptions").default | undefined) => string;
4
- formatNumber: (value: number | bigint, formatOrOptions?: string | import("@formatjs/ecma402-abstract/types/number").NumberFormatOptions | undefined) => string;
5
- formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
6
- };
@@ -1,20 +0,0 @@
1
- import { useMemo } from 'react';
2
- import createIntl from '../core/createIntl';
3
- import useIntlContext from './useIntlContext';
4
- let hasWarned = false;
5
- /** @deprecated Switch to `useFormatter` instead. */
6
- export default function useIntl() {
7
- const { formats, locale, now: globalNow, onError, timeZone } = useIntlContext();
8
- if (!hasWarned) {
9
- hasWarned = true;
10
- console.warn('`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.');
11
- }
12
- return useMemo(() => createIntl({
13
- formats,
14
- locale,
15
- now: globalNow,
16
- onError,
17
- timeZone
18
- }), [formats, globalNow, locale, onError, timeZone]);
19
- }
20
- //# sourceMappingURL=useIntl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIntl.js","sourceRoot":"","sources":["../../../src/react/useIntl.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,oDAAoD;AACpD,MAAM,CAAC,OAAO,UAAU,OAAO;IAC7B,MAAM,EAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,GAAG,cAAc,EAAE,CAAC;IAE9E,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,IAAI,CAAC;QACjB,OAAO,CAAC,IAAI,CACV,6GAA6G,CAC9G,CAAC;KACH;IAED,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,UAAU,CAAC;QACT,OAAO;QACP,MAAM;QACN,GAAG,EAAE,SAAS;QACd,OAAO;QACP,QAAQ;KACT,CAAC,EACJ,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAChD,CAAC;AACJ,CAAC"}
@@ -1,10 +0,0 @@
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,12 +0,0 @@
1
- import { useContext } from 'react';
2
- import IntlContext from './IntlContext';
3
- export default function useIntlContext() {
4
- const context = useContext(IntlContext);
5
- if (!context) {
6
- throw new Error(process.env.NODE_ENV !== 'production'
7
- ? 'No intl context found. Have you configured the provider?'
8
- : undefined);
9
- }
10
- return context;
11
- }
12
- //# sourceMappingURL=useIntlContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIntlContext.js","sourceRoot":"","sources":["../../../src/react/useIntlContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,cAAc;IACpC,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAExC,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YACnC,CAAC,CAAC,0DAA0D;YAC5D,CAAC,CAAC,SAAS,CACd,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1 +0,0 @@
1
- export default function useLocale(): string;
@@ -1,5 +0,0 @@
1
- import useIntlContext from './useIntlContext';
2
- export default function useLocale() {
3
- return useIntlContext().locale;
4
- }
5
- //# sourceMappingURL=useLocale.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLocale.js","sourceRoot":"","sources":["../../../src/react/useLocale.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,OAAO,cAAc,EAAE,CAAC,MAAM,CAAC;AACjC,CAAC"}
@@ -1 +0,0 @@
1
- export default function useMessages(): import("../core/AbstractIntlMessages").default | undefined;
@@ -1,5 +0,0 @@
1
- import useIntlContext from './useIntlContext';
2
- export default function useMessages() {
3
- return useIntlContext().messages;
4
- }
5
- //# sourceMappingURL=useMessages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMessages.js","sourceRoot":"","sources":["../../../src/react/useMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,WAAW;IACjC,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC;AACnC,CAAC"}
@@ -1,23 +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
- export default function useNow(options?: Options): Date;
23
- export {};
@@ -1,40 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- import useIntlContext from './useIntlContext';
3
- function getNow() {
4
- return new Date();
5
- }
6
- /**
7
- * Reading the current date via `new Date()` in components should be avoided, as
8
- * it causes components to be impure and can lead to flaky tests. Instead, this
9
- * hook can be used.
10
- *
11
- * By default, it returns the time when the component mounts. If `updateInterval`
12
- * is specified, the value will be updated based on the interval.
13
- *
14
- * You can however also return a static value from this hook, if you
15
- * configure the `now` parameter on the context provider. Note however,
16
- * that if `updateInterval` is configured in this case, the component
17
- * will initialize with the global value, but will afterwards update
18
- * continuously based on the interval.
19
- *
20
- * For unit tests, this can be mocked to a constant value. For end-to-end
21
- * testing, an environment parameter can be passed to the `now` parameter
22
- * of the provider to mock this to a static value.
23
- */
24
- export default function useNow(options) {
25
- const updateInterval = options?.updateInterval;
26
- const { now: globalNow } = useIntlContext();
27
- const [now, setNow] = useState(globalNow || getNow());
28
- useEffect(() => {
29
- if (!updateInterval)
30
- return;
31
- const intervalId = setInterval(() => {
32
- setNow(getNow());
33
- }, updateInterval);
34
- return () => {
35
- clearInterval(intervalId);
36
- };
37
- }, [globalNow, updateInterval]);
38
- return now;
39
- }
40
- //# sourceMappingURL=useNow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useNow.js","sourceRoot":"","sources":["../../../src/react/useNow.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAM9C,SAAS,MAAM;IACb,OAAO,IAAI,IAAI,EAAE,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAiB;IAC9C,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc,CAAC;IAE/C,MAAM,EAAC,GAAG,EAAE,SAAS,EAAC,GAAG,cAAc,EAAE,CAAC;IAC1C,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,SAAS,IAAI,MAAM,EAAE,CAAC,CAAC;IAEtD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,cAAc;YAAE,OAAO;QAE5B,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;YAClC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACnB,CAAC,EAAE,cAAc,CAAC,CAAC;QAEnB,OAAO,GAAG,EAAE;YACV,aAAa,CAAC,UAAU,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAEhC,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1 +0,0 @@
1
- export default function useTimeZone(): import("../core/TimeZone").default | undefined;
@@ -1,5 +0,0 @@
1
- import useIntlContext from './useIntlContext';
2
- export default function useTimeZone() {
3
- return useIntlContext().timeZone;
4
- }
5
- //# sourceMappingURL=useTimeZone.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTimeZone.js","sourceRoot":"","sources":["../../../src/react/useTimeZone.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,WAAW;IACjC,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC;AACnC,CAAC"}