use-intl 2.19.1 → 3.0.0-beta.1

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 (270) 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 +32 -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 +201 -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.esm.js +34 -30
  31. package/dist/core/use-intl.esm.js.map +1 -1
  32. package/dist/core/use-intl.esm10.js +23 -27
  33. package/dist/core/use-intl.esm10.js.map +1 -1
  34. package/dist/core/use-intl.esm11.js +10 -0
  35. package/dist/core/use-intl.esm11.js.map +1 -0
  36. package/dist/core/use-intl.esm2.js +30 -34
  37. package/dist/core/use-intl.esm2.js.map +1 -1
  38. package/dist/core/use-intl.esm3.js +8 -132
  39. package/dist/core/use-intl.esm3.js.map +1 -1
  40. package/dist/core/use-intl.esm4.js +196 -9
  41. package/dist/core/use-intl.esm4.js.map +1 -1
  42. package/dist/core/use-intl.esm5.js +19 -43
  43. package/dist/core/use-intl.esm5.js.map +1 -1
  44. package/dist/core/use-intl.esm6.js +134 -11
  45. package/dist/core/use-intl.esm6.js.map +1 -1
  46. package/dist/core/use-intl.esm7.js +10 -5
  47. package/dist/core/use-intl.esm7.js.map +1 -1
  48. package/dist/core/use-intl.esm8.js +37 -178
  49. package/dist/core/use-intl.esm8.js.map +1 -1
  50. package/dist/core/use-intl.esm9.js +27 -23
  51. package/dist/core/use-intl.esm9.js.map +1 -1
  52. package/dist/core/validateMessages.esm.js +28 -0
  53. package/dist/core/validateMessages.esm.js.map +1 -0
  54. package/dist/core.cjs.development.js +93 -0
  55. package/dist/core.cjs.development.js.map +1 -0
  56. package/dist/core.cjs.production.min.js +2 -0
  57. package/dist/core.cjs.production.min.js.map +1 -0
  58. package/dist/core.d.ts +1 -0
  59. package/dist/core.esm.js +7 -0
  60. package/dist/core.esm.js.map +1 -0
  61. package/dist/core.js +8 -0
  62. package/dist/createIntl-8a2b87eb.js +579 -0
  63. package/dist/createIntl-8a2b87eb.js.map +1 -0
  64. package/dist/createIntl-f7979de1.js +2 -0
  65. package/dist/createIntl-f7979de1.js.map +1 -0
  66. package/dist/react/IntlContext.esm.js +6 -0
  67. package/dist/react/IntlContext.esm.js.map +1 -0
  68. package/dist/react/IntlProvider.d.ts +1 -1
  69. package/dist/react/IntlProvider.esm.js +16 -0
  70. package/dist/react/IntlProvider.esm.js.map +1 -0
  71. package/dist/react/getInitializedConfig.d.ts +1 -13
  72. package/dist/react/use-intl.esm.js +22 -12
  73. package/dist/react/use-intl.esm.js.map +1 -1
  74. package/dist/react/use-intl.esm10.js +8 -24
  75. package/dist/react/use-intl.esm10.js.map +1 -1
  76. package/dist/react/use-intl.esm11.js +3 -10
  77. package/dist/react/use-intl.esm11.js.map +1 -1
  78. package/dist/react/use-intl.esm2.js +20 -22
  79. package/dist/react/use-intl.esm2.js.map +1 -1
  80. package/dist/react/use-intl.esm3.js +41 -4
  81. package/dist/react/use-intl.esm3.js.map +1 -1
  82. package/dist/react/use-intl.esm4.js +12 -41
  83. package/dist/react/use-intl.esm4.js.map +1 -1
  84. package/dist/react/use-intl.esm5.js +1 -1
  85. package/dist/react/use-intl.esm6.js +1 -1
  86. package/dist/react/use-intl.esm7.js +11 -5
  87. package/dist/react/use-intl.esm7.js.map +1 -1
  88. package/dist/react/use-intl.esm8.js +4 -26
  89. package/dist/react/use-intl.esm8.js.map +1 -1
  90. package/dist/react/use-intl.esm9.js +33 -3
  91. package/dist/react/use-intl.esm9.js.map +1 -1
  92. package/dist/react/useFormatter.esm.js +24 -0
  93. package/dist/react/useFormatter.esm.js.map +1 -0
  94. package/dist/react/useIntl.esm.js +30 -0
  95. package/dist/react/useIntl.esm.js.map +1 -0
  96. package/dist/react/useIntlContext.esm.js +13 -0
  97. package/dist/react/useIntlContext.esm.js.map +1 -0
  98. package/dist/react/useLocale.esm.js +8 -0
  99. package/dist/react/useLocale.esm.js.map +1 -0
  100. package/dist/react/useMessages.esm.js +8 -0
  101. package/dist/react/useMessages.esm.js.map +1 -0
  102. package/{src/react/useNow.tsx → dist/react/useNow.esm.js} +32 -36
  103. package/dist/react/useNow.esm.js.map +1 -0
  104. package/dist/react/useTimeZone.esm.js +8 -0
  105. package/dist/react/useTimeZone.esm.js.map +1 -0
  106. package/dist/react/useTranslations.esm.js +26 -0
  107. package/dist/react/useTranslations.esm.js.map +1 -0
  108. package/dist/react/{use-intl.esm12.js → useTranslationsImpl.esm.js} +6 -13
  109. package/dist/react/useTranslationsImpl.esm.js.map +1 -0
  110. package/dist/react.cjs.development.js +184 -0
  111. package/dist/react.cjs.development.js.map +1 -0
  112. package/dist/react.cjs.production.min.js +2 -0
  113. package/dist/react.cjs.production.min.js.map +1 -0
  114. package/dist/react.d.ts +1 -0
  115. package/dist/react.esm.js +9 -0
  116. package/dist/react.esm.js.map +1 -0
  117. package/dist/react.js +8 -0
  118. package/dist/test/setup.d.ts +1 -0
  119. package/dist/use-intl.cjs.development.js +32 -30
  120. package/dist/use-intl.cjs.development.js.map +1 -1
  121. package/dist/use-intl.cjs.production.min.js +1 -1
  122. package/dist/use-intl.cjs.production.min.js.map +1 -1
  123. package/dist/use-intl.esm.js +12 -10
  124. package/dist/use-intl.esm.js.map +1 -1
  125. package/package.json +17 -15
  126. package/react.d.ts +1 -0
  127. package/dist/react/use-intl.esm12.js.map +0 -1
  128. package/dist/src/core/AbstractIntlMessages.d.ts +0 -9
  129. package/dist/src/core/AbstractIntlMessages.js +0 -2
  130. package/dist/src/core/AbstractIntlMessages.js.map +0 -1
  131. package/dist/src/core/DateTimeFormatOptions.d.ts +0 -73
  132. package/dist/src/core/DateTimeFormatOptions.js +0 -3
  133. package/dist/src/core/DateTimeFormatOptions.js.map +0 -1
  134. package/dist/src/core/Formats.d.ts +0 -8
  135. package/dist/src/core/Formats.js +0 -2
  136. package/dist/src/core/Formats.js.map +0 -1
  137. package/dist/src/core/IntlConfig.d.ts +0 -54
  138. package/dist/src/core/IntlConfig.js +0 -2
  139. package/dist/src/core/IntlConfig.js.map +0 -1
  140. package/dist/src/core/IntlError.d.ts +0 -13
  141. package/dist/src/core/IntlError.js +0 -23
  142. package/dist/src/core/IntlError.js.map +0 -1
  143. package/dist/src/core/NumberFormatOptions.d.ts +0 -2
  144. package/dist/src/core/NumberFormatOptions.js +0 -2
  145. package/dist/src/core/NumberFormatOptions.js.map +0 -1
  146. package/dist/src/core/TimeZone.d.ts +0 -2
  147. package/dist/src/core/TimeZone.js +0 -2
  148. package/dist/src/core/TimeZone.js.map +0 -1
  149. package/dist/src/core/TranslationValues.d.ts +0 -5
  150. package/dist/src/core/TranslationValues.js +0 -2
  151. package/dist/src/core/TranslationValues.js.map +0 -1
  152. package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +0 -11
  153. package/dist/src/core/convertFormatsToIntlMessageFormat.js +0 -31
  154. package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +0 -1
  155. package/dist/src/core/createBaseTranslator.d.ts +0 -26
  156. package/dist/src/core/createBaseTranslator.js +0 -206
  157. package/dist/src/core/createBaseTranslator.js.map +0 -1
  158. package/dist/src/core/createFormatter.d.ts +0 -19
  159. package/dist/src/core/createFormatter.js +0 -129
  160. package/dist/src/core/createFormatter.js.map +0 -1
  161. package/dist/src/core/createIntl.d.ts +0 -7
  162. package/dist/src/core/createIntl.js +0 -11
  163. package/dist/src/core/createIntl.js.map +0 -1
  164. package/dist/src/core/createTranslator.d.ts +0 -48
  165. package/dist/src/core/createTranslator.js +0 -24
  166. package/dist/src/core/createTranslator.js.map +0 -1
  167. package/dist/src/core/createTranslatorImpl.d.ts +0 -14
  168. package/dist/src/core/createTranslatorImpl.js +0 -43
  169. package/dist/src/core/createTranslatorImpl.js.map +0 -1
  170. package/dist/src/core/defaults.d.ts +0 -11
  171. package/dist/src/core/defaults.js +0 -11
  172. package/dist/src/core/defaults.js.map +0 -1
  173. package/dist/src/core/index.d.ts +0 -9
  174. package/dist/src/core/index.js +0 -6
  175. package/dist/src/core/index.js.map +0 -1
  176. package/dist/src/core/resolveNamespace.d.ts +0 -5
  177. package/dist/src/core/resolveNamespace.js +0 -10
  178. package/dist/src/core/resolveNamespace.js.map +0 -1
  179. package/dist/src/core/utils/MessageKeys.d.ts +0 -5
  180. package/dist/src/core/utils/MessageKeys.js +0 -2
  181. package/dist/src/core/utils/MessageKeys.js.map +0 -1
  182. package/dist/src/core/utils/NamespaceKeys.d.ts +0 -5
  183. package/dist/src/core/utils/NamespaceKeys.js +0 -2
  184. package/dist/src/core/utils/NamespaceKeys.js.map +0 -1
  185. package/dist/src/core/utils/NestedKeyOf.d.ts +0 -4
  186. package/dist/src/core/utils/NestedKeyOf.js +0 -2
  187. package/dist/src/core/utils/NestedKeyOf.js.map +0 -1
  188. package/dist/src/core/utils/NestedValueOf.d.ts +0 -2
  189. package/dist/src/core/utils/NestedValueOf.js +0 -2
  190. package/dist/src/core/utils/NestedValueOf.js.map +0 -1
  191. package/dist/src/core/validateMessages.d.ts +0 -3
  192. package/dist/src/core/validateMessages.js +0 -56
  193. package/dist/src/core/validateMessages.js.map +0 -1
  194. package/dist/src/index.d.ts +0 -2
  195. package/dist/src/index.js +0 -3
  196. package/dist/src/index.js.map +0 -1
  197. package/dist/src/react/IntlContext.d.ts +0 -4
  198. package/dist/src/react/IntlContext.js +0 -4
  199. package/dist/src/react/IntlContext.js.map +0 -1
  200. package/dist/src/react/IntlProvider.d.ts +0 -7
  201. package/dist/src/react/IntlProvider.js +0 -7
  202. package/dist/src/react/IntlProvider.js.map +0 -1
  203. package/dist/src/react/getInitializedConfig.d.ts +0 -13
  204. package/dist/src/react/getInitializedConfig.js +0 -21
  205. package/dist/src/react/getInitializedConfig.js.map +0 -1
  206. package/dist/src/react/index.d.ts +0 -8
  207. package/dist/src/react/index.js +0 -10
  208. package/dist/src/react/index.js.map +0 -1
  209. package/dist/src/react/useFormatter.d.ts +0 -6
  210. package/dist/src/react/useFormatter.js +0 -14
  211. package/dist/src/react/useFormatter.js.map +0 -1
  212. package/dist/src/react/useIntl.d.ts +0 -6
  213. package/dist/src/react/useIntl.js +0 -20
  214. package/dist/src/react/useIntl.js.map +0 -1
  215. package/dist/src/react/useIntlContext.d.ts +0 -1
  216. package/dist/src/react/useIntlContext.js +0 -12
  217. package/dist/src/react/useIntlContext.js.map +0 -1
  218. package/dist/src/react/useLocale.d.ts +0 -1
  219. package/dist/src/react/useLocale.js +0 -5
  220. package/dist/src/react/useLocale.js.map +0 -1
  221. package/dist/src/react/useMessages.d.ts +0 -1
  222. package/dist/src/react/useMessages.js +0 -5
  223. package/dist/src/react/useMessages.js.map +0 -1
  224. package/dist/src/react/useNow.d.ts +0 -23
  225. package/dist/src/react/useNow.js +0 -40
  226. package/dist/src/react/useNow.js.map +0 -1
  227. package/dist/src/react/useTimeZone.d.ts +0 -1
  228. package/dist/src/react/useTimeZone.js +0 -5
  229. package/dist/src/react/useTimeZone.js.map +0 -1
  230. package/dist/src/react/useTranslations.d.ts +0 -44
  231. package/dist/src/react/useTranslations.js +0 -21
  232. package/dist/src/react/useTranslations.js.map +0 -1
  233. package/dist/src/react/useTranslationsImpl.d.ts +0 -8
  234. package/dist/src/react/useTranslationsImpl.js +0 -35
  235. package/dist/src/react/useTranslationsImpl.js.map +0 -1
  236. package/src/core/AbstractIntlMessages.tsx +0 -10
  237. package/src/core/DateTimeFormatOptions.tsx +0 -130
  238. package/src/core/Formats.tsx +0 -10
  239. package/src/core/IntlConfig.tsx +0 -59
  240. package/src/core/IntlError.tsx +0 -26
  241. package/src/core/NumberFormatOptions.tsx +0 -3
  242. package/src/core/TimeZone.tsx +0 -426
  243. package/src/core/TranslationValues.tsx +0 -22
  244. package/src/core/convertFormatsToIntlMessageFormat.tsx +0 -46
  245. package/src/core/createBaseTranslator.tsx +0 -335
  246. package/src/core/createFormatter.tsx +0 -191
  247. package/src/core/createIntl.tsx +0 -13
  248. package/src/core/createTranslator.tsx +0 -112
  249. package/src/core/createTranslatorImpl.tsx +0 -87
  250. package/src/core/defaults.tsx +0 -18
  251. package/src/core/index.tsx +0 -14
  252. package/src/core/resolveNamespace.tsx +0 -12
  253. package/src/core/utils/MessageKeys.tsx +0 -9
  254. package/src/core/utils/NamespaceKeys.tsx +0 -9
  255. package/src/core/utils/NestedKeyOf.tsx +0 -9
  256. package/src/core/utils/NestedValueOf.tsx +0 -12
  257. package/src/core/validateMessages.tsx +0 -77
  258. package/src/index.tsx +0 -2
  259. package/src/react/IntlContext.tsx +0 -6
  260. package/src/react/IntlProvider.tsx +0 -16
  261. package/src/react/getInitializedConfig.tsx +0 -29
  262. package/src/react/index.tsx +0 -10
  263. package/src/react/useFormatter.tsx +0 -19
  264. package/src/react/useIntl.tsx +0 -29
  265. package/src/react/useIntlContext.tsx +0 -16
  266. package/src/react/useLocale.tsx +0 -5
  267. package/src/react/useMessages.tsx +0 -5
  268. package/src/react/useTimeZone.tsx +0 -5
  269. package/src/react/useTranslations.tsx +0 -103
  270. package/src/react/useTranslationsImpl.tsx +0 -65
@@ -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,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { InitializedIntlConfig } from '../core/IntlConfig';
3
- declare const IntlContext: import("react").Context<InitializedIntlConfig | undefined>;
4
- 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;AAGpC,MAAM,WAAW,GAAG,aAAa,CAAoC,SAAS,CAAC,CAAC;AAEhF,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,7 +0,0 @@
1
- import React from 'react';
2
- import IntlContext from './IntlContext';
3
- import getInitializedConfig from './getInitializedConfig';
4
- export default function IntlProvider({ children, ...props }) {
5
- return (React.createElement(IntlContext.Provider, { value: getInitializedConfig(props) }, children));
6
- }
7
- //# sourceMappingURL=IntlProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../../src/react/IntlProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,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,OAAO,CACL,oBAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,IACrD,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 +0,0 @@
1
- export default function useIntlContext(): import("../core/IntlConfig").InitializedIntlConfig;
@@ -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"}
@@ -1,44 +0,0 @@
1
- import { ReactElement, ReactNodeArray } from 'react';
2
- import Formats from '../core/Formats';
3
- import TranslationValues, { RichTranslationValues } from '../core/TranslationValues';
4
- import MessageKeys from '../core/utils/MessageKeys';
5
- import NamespaceKeys from '../core/utils/NamespaceKeys';
6
- import NestedKeyOf from '../core/utils/NestedKeyOf';
7
- import NestedValueOf from '../core/utils/NestedValueOf';
8
- /**
9
- * Translates messages from the given namespace by using the ICU syntax.
10
- * See https://formatjs.io/docs/core-concepts/icu-syntax.
11
- *
12
- * If no namespace is provided, all available messages are returned.
13
- * The namespace can also indicate nesting by using a dot
14
- * (e.g. `namespace.Component`).
15
- */
16
- export default function useTranslations<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>(namespace?: NestedKey): {
17
- <TargetKey extends MessageKeys<NestedValueOf<{
18
- '!': IntlMessages;
19
- }, [
20
- NestedKey
21
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
22
- '!': IntlMessages;
23
- }, [
24
- NestedKey
25
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
26
- rich<TargetKey extends MessageKeys<NestedValueOf<{
27
- '!': IntlMessages;
28
- }, [
29
- NestedKey
30
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
31
- '!': IntlMessages;
32
- }, [
33
- NestedKey
34
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: RichTranslationValues, formats?: Partial<Formats>): string | ReactElement | ReactNodeArray;
35
- raw<TargetKey extends MessageKeys<NestedValueOf<{
36
- '!': IntlMessages;
37
- }, [
38
- NestedKey
39
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
40
- '!': IntlMessages;
41
- }, [
42
- NestedKey
43
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
44
- };