use-intl 2.17.4 → 2.17.5

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 (484) hide show
  1. package/dist/_virtual/use-intl.esm.js +102 -0
  2. package/dist/_virtual/use-intl.esm.js.map +1 -0
  3. package/dist/core/AbstractIntlMessages.d.ts +9 -10
  4. package/dist/core/DateTimeFormatOptions.d.ts +73 -75
  5. package/dist/core/Formats.d.ts +8 -11
  6. package/dist/core/IntlConfig.d.ts +54 -60
  7. package/dist/core/IntlError.d.ts +13 -15
  8. package/dist/core/NumberFormatOptions.d.ts +2 -2
  9. package/dist/core/TimeZone.d.ts +2 -3
  10. package/dist/core/TranslationValues.d.ts +5 -7
  11. package/dist/core/convertFormatsToIntlMessageFormat.d.ts +11 -16
  12. package/dist/core/createBaseTranslator.d.ts +26 -32
  13. package/dist/core/createFormatter.d.ts +19 -21
  14. package/dist/core/createIntl.d.ts +7 -15
  15. package/dist/core/createTranslator.d.ts +48 -57
  16. package/dist/core/createTranslatorImpl.d.ts +14 -25
  17. package/dist/core/defaults.d.ts +11 -14
  18. package/dist/core/index.d.ts +9 -17
  19. package/dist/core/resolveNamespace.d.ts +5 -7
  20. package/dist/core/use-intl.esm.js +33 -0
  21. package/dist/core/use-intl.esm.js.map +1 -0
  22. package/dist/core/use-intl.esm10.js +32 -0
  23. package/dist/core/use-intl.esm10.js.map +1 -0
  24. package/dist/core/use-intl.esm2.js +37 -0
  25. package/dist/core/use-intl.esm2.js.map +1 -0
  26. package/dist/core/use-intl.esm3.js +138 -0
  27. package/dist/core/use-intl.esm3.js.map +1 -0
  28. package/dist/core/use-intl.esm4.js +14 -0
  29. package/dist/core/use-intl.esm4.js.map +1 -0
  30. package/dist/core/use-intl.esm5.js +53 -0
  31. package/dist/core/use-intl.esm5.js.map +1 -0
  32. package/dist/core/use-intl.esm6.js +15 -0
  33. package/dist/core/use-intl.esm6.js.map +1 -0
  34. package/dist/core/use-intl.esm7.js +191 -0
  35. package/dist/core/use-intl.esm7.js.map +1 -0
  36. package/dist/core/use-intl.esm8.js +10 -0
  37. package/dist/core/use-intl.esm8.js.map +1 -0
  38. package/dist/core/use-intl.esm9.js +28 -0
  39. package/dist/core/use-intl.esm9.js.map +1 -0
  40. package/dist/core/utils/MessageKeys.d.ts +5 -7
  41. package/dist/core/utils/NamespaceKeys.d.ts +5 -7
  42. package/dist/core/utils/NestedKeyOf.d.ts +4 -5
  43. package/dist/core/utils/NestedValueOf.d.ts +2 -3
  44. package/dist/core/validateMessages.d.ts +3 -6
  45. package/dist/index.d.ts +2 -25
  46. package/dist/index.js +8 -2
  47. package/dist/react/IntlContext.d.ts +4 -13
  48. package/dist/react/IntlProvider.d.ts +7 -16
  49. package/dist/react/getInitializedConfig.d.ts +13 -24
  50. package/dist/react/index.d.ts +8 -21
  51. package/dist/react/use-intl.esm.js +16 -0
  52. package/dist/react/use-intl.esm.js.map +1 -0
  53. package/dist/react/use-intl.esm10.js +29 -0
  54. package/dist/react/use-intl.esm10.js.map +1 -0
  55. package/dist/react/use-intl.esm11.js +13 -0
  56. package/dist/react/use-intl.esm11.js.map +1 -0
  57. package/dist/react/use-intl.esm12.js +43 -0
  58. package/dist/react/use-intl.esm12.js.map +1 -0
  59. package/dist/react/use-intl.esm2.js +26 -0
  60. package/dist/react/use-intl.esm2.js.map +1 -0
  61. package/dist/react/use-intl.esm3.js +8 -0
  62. package/dist/react/use-intl.esm3.js.map +1 -0
  63. package/dist/react/{useNow.d.mts → use-intl.esm4.js} +42 -21
  64. package/dist/react/use-intl.esm4.js.map +1 -0
  65. package/dist/react/use-intl.esm5.js +8 -0
  66. package/dist/react/use-intl.esm5.js.map +1 -0
  67. package/dist/react/use-intl.esm6.js +8 -0
  68. package/dist/react/use-intl.esm6.js.map +1 -0
  69. package/dist/react/use-intl.esm7.js +24 -0
  70. package/dist/react/use-intl.esm7.js.map +1 -0
  71. package/dist/react/use-intl.esm8.js +30 -0
  72. package/dist/react/use-intl.esm8.js.map +1 -0
  73. package/dist/react/use-intl.esm9.js +6 -0
  74. package/dist/react/use-intl.esm9.js.map +1 -0
  75. package/dist/react/useFormatter.d.ts +6 -12
  76. package/dist/react/useIntl.d.ts +6 -12
  77. package/dist/react/useIntlContext.d.ts +1 -13
  78. package/dist/react/useLocale.d.ts +1 -3
  79. package/dist/react/useMessages.d.ts +1 -5
  80. package/dist/react/useNow.d.ts +23 -24
  81. package/dist/react/useTimeZone.d.ts +1 -5
  82. package/dist/react/useTranslations.d.ts +44 -50
  83. package/dist/react/useTranslationsImpl.d.ts +8 -16
  84. package/dist/src/core/AbstractIntlMessages.d.ts +1 -2
  85. package/dist/src/core/AbstractIntlMessages.js +1 -1
  86. package/dist/src/core/AbstractIntlMessages.js.map +1 -1
  87. package/dist/src/core/DateTimeFormatOptions.d.ts +2 -4
  88. package/dist/src/core/DateTimeFormatOptions.js +2 -1
  89. package/dist/src/core/DateTimeFormatOptions.js.map +1 -1
  90. package/dist/src/core/Formats.d.ts +3 -6
  91. package/dist/src/core/Formats.js +1 -1
  92. package/dist/src/core/Formats.js.map +1 -1
  93. package/dist/src/core/IntlConfig.d.ts +6 -12
  94. package/dist/src/core/IntlConfig.js +1 -1
  95. package/dist/src/core/IntlConfig.js.map +1 -1
  96. package/dist/src/core/IntlError.d.ts +2 -4
  97. package/dist/src/core/IntlError.js +22 -1
  98. package/dist/src/core/IntlError.js.map +1 -1
  99. package/dist/src/core/NumberFormatOptions.d.ts +2 -2
  100. package/dist/src/core/NumberFormatOptions.js +1 -1
  101. package/dist/src/core/NumberFormatOptions.js.map +1 -1
  102. package/dist/src/core/TimeZone.d.ts +1 -2
  103. package/dist/src/core/TimeZone.js +1 -1
  104. package/dist/src/core/TimeZone.js.map +1 -1
  105. package/dist/src/core/TranslationValues.d.ts +3 -5
  106. package/dist/src/core/TranslationValues.js +1 -1
  107. package/dist/src/core/TranslationValues.js.map +1 -1
  108. package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +4 -9
  109. package/dist/src/core/convertFormatsToIntlMessageFormat.js +30 -1
  110. package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +1 -1
  111. package/dist/src/core/createBaseTranslator.d.ts +11 -17
  112. package/dist/src/core/createBaseTranslator.js +205 -1
  113. package/dist/src/core/createBaseTranslator.js.map +1 -1
  114. package/dist/src/core/createFormatter.d.ts +7 -9
  115. package/dist/src/core/createFormatter.js +128 -1
  116. package/dist/src/core/createFormatter.js.map +1 -1
  117. package/dist/src/core/createIntl.d.ts +4 -12
  118. package/dist/src/core/createIntl.js +10 -1
  119. package/dist/src/core/createIntl.js.map +1 -1
  120. package/dist/src/core/createTranslator.d.ts +9 -18
  121. package/dist/src/core/createTranslator.js +23 -1
  122. package/dist/src/core/createTranslator.js.map +1 -1
  123. package/dist/src/core/createTranslatorImpl.d.ts +9 -20
  124. package/dist/src/core/createTranslatorImpl.js +42 -1
  125. package/dist/src/core/createTranslatorImpl.js.map +1 -1
  126. package/dist/src/core/defaults.d.ts +3 -6
  127. package/dist/src/core/defaults.js +10 -1
  128. package/dist/src/core/defaults.js.map +1 -1
  129. package/dist/src/core/index.d.ts +9 -17
  130. package/dist/src/core/index.js +5 -1
  131. package/dist/src/core/index.js.map +1 -1
  132. package/dist/src/core/resolveNamespace.d.ts +1 -3
  133. package/dist/src/core/resolveNamespace.js +9 -1
  134. package/dist/src/core/resolveNamespace.js.map +1 -1
  135. package/dist/src/core/utils/MessageKeys.d.ts +2 -4
  136. package/dist/src/core/utils/MessageKeys.js +1 -1
  137. package/dist/src/core/utils/MessageKeys.js.map +1 -1
  138. package/dist/src/core/utils/NamespaceKeys.d.ts +2 -4
  139. package/dist/src/core/utils/NamespaceKeys.js +1 -1
  140. package/dist/src/core/utils/NamespaceKeys.js.map +1 -1
  141. package/dist/src/core/utils/NestedKeyOf.d.ts +1 -2
  142. package/dist/src/core/utils/NestedKeyOf.js +1 -1
  143. package/dist/src/core/utils/NestedKeyOf.js.map +1 -1
  144. package/dist/src/core/utils/NestedValueOf.d.ts +1 -2
  145. package/dist/src/core/utils/NestedValueOf.js +1 -1
  146. package/dist/src/core/utils/NestedValueOf.js.map +1 -1
  147. package/dist/src/core/validateMessages.d.ts +3 -6
  148. package/dist/src/core/validateMessages.js +25 -3
  149. package/dist/src/core/validateMessages.js.map +1 -1
  150. package/dist/src/index.d.ts +2 -25
  151. package/dist/src/index.js +2 -1
  152. package/dist/src/index.js.map +1 -1
  153. package/dist/src/react/IntlContext.d.ts +4 -13
  154. package/dist/src/react/IntlContext.js +3 -1
  155. package/dist/src/react/IntlContext.js.map +1 -1
  156. package/dist/src/react/IntlProvider.d.ts +3 -12
  157. package/dist/src/react/IntlProvider.js +6 -1
  158. package/dist/src/react/IntlProvider.js.map +1 -1
  159. package/dist/src/react/getInitializedConfig.d.ts +5 -16
  160. package/dist/src/react/getInitializedConfig.js +20 -1
  161. package/dist/src/react/getInitializedConfig.js.map +1 -1
  162. package/dist/src/react/index.d.ts +8 -21
  163. package/dist/src/react/index.js +9 -1
  164. package/dist/src/react/index.js.map +1 -1
  165. package/dist/src/react/useFormatter.d.ts +3 -9
  166. package/dist/src/react/useFormatter.js +13 -1
  167. package/dist/src/react/useFormatter.js.map +1 -1
  168. package/dist/src/react/useIntl.d.ts +3 -9
  169. package/dist/src/react/useIntl.js +19 -1
  170. package/dist/src/react/useIntl.js.map +1 -1
  171. package/dist/src/react/useIntlContext.d.ts +1 -13
  172. package/dist/src/react/useIntlContext.js +11 -1
  173. package/dist/src/react/useIntlContext.js.map +1 -1
  174. package/dist/src/react/useLocale.d.ts +1 -3
  175. package/dist/src/react/useLocale.js +4 -1
  176. package/dist/src/react/useLocale.js.map +1 -1
  177. package/dist/src/react/useMessages.d.ts +1 -5
  178. package/dist/src/react/useMessages.js +4 -1
  179. package/dist/src/react/useMessages.js.map +1 -1
  180. package/dist/src/react/useNow.d.ts +2 -3
  181. package/dist/src/react/useNow.js +39 -1
  182. package/dist/src/react/useNow.js.map +1 -1
  183. package/dist/src/react/useTimeZone.d.ts +1 -5
  184. package/dist/src/react/useTimeZone.js +4 -1
  185. package/dist/src/react/useTimeZone.js.map +1 -1
  186. package/dist/src/react/useTranslations.d.ts +7 -13
  187. package/dist/src/react/useTranslations.js +20 -1
  188. package/dist/src/react/useTranslations.js.map +1 -1
  189. package/dist/src/react/useTranslationsImpl.d.ts +6 -14
  190. package/dist/src/react/useTranslationsImpl.js +34 -1
  191. package/dist/src/react/useTranslationsImpl.js.map +1 -1
  192. package/dist/use-intl.cjs.development.js +821 -0
  193. package/dist/use-intl.cjs.development.js.map +1 -0
  194. package/dist/use-intl.cjs.production.min.js +2 -0
  195. package/dist/use-intl.cjs.production.min.js.map +1 -0
  196. package/dist/use-intl.esm.js +13 -0
  197. package/dist/use-intl.esm.js.map +1 -0
  198. package/package.json +21 -6
  199. package/dist/core/AbstractIntlMessages.d.mts +0 -10
  200. package/dist/core/AbstractIntlMessages.js +0 -2
  201. package/dist/core/AbstractIntlMessages.js.map +0 -1
  202. package/dist/core/AbstractIntlMessages.mjs +0 -1
  203. package/dist/core/AbstractIntlMessages.mjs.map +0 -1
  204. package/dist/core/DateTimeFormatOptions.d.mts +0 -75
  205. package/dist/core/DateTimeFormatOptions.js +0 -2
  206. package/dist/core/DateTimeFormatOptions.js.map +0 -1
  207. package/dist/core/DateTimeFormatOptions.mjs +0 -1
  208. package/dist/core/DateTimeFormatOptions.mjs.map +0 -1
  209. package/dist/core/Formats.d.mts +0 -11
  210. package/dist/core/Formats.js +0 -2
  211. package/dist/core/Formats.js.map +0 -1
  212. package/dist/core/Formats.mjs +0 -1
  213. package/dist/core/Formats.mjs.map +0 -1
  214. package/dist/core/IntlConfig.d.mts +0 -60
  215. package/dist/core/IntlConfig.js +0 -2
  216. package/dist/core/IntlConfig.js.map +0 -1
  217. package/dist/core/IntlConfig.mjs +0 -1
  218. package/dist/core/IntlConfig.mjs.map +0 -1
  219. package/dist/core/IntlError.d.mts +0 -15
  220. package/dist/core/IntlError.js +0 -2
  221. package/dist/core/IntlError.js.map +0 -1
  222. package/dist/core/IntlError.mjs +0 -2
  223. package/dist/core/IntlError.mjs.map +0 -1
  224. package/dist/core/NumberFormatOptions.d.mts +0 -2
  225. package/dist/core/NumberFormatOptions.js +0 -2
  226. package/dist/core/NumberFormatOptions.js.map +0 -1
  227. package/dist/core/NumberFormatOptions.mjs +0 -2
  228. package/dist/core/NumberFormatOptions.mjs.map +0 -1
  229. package/dist/core/TimeZone.d.mts +0 -3
  230. package/dist/core/TimeZone.js +0 -2
  231. package/dist/core/TimeZone.js.map +0 -1
  232. package/dist/core/TimeZone.mjs +0 -1
  233. package/dist/core/TimeZone.mjs.map +0 -1
  234. package/dist/core/TranslationValues.d.mts +0 -7
  235. package/dist/core/TranslationValues.js +0 -2
  236. package/dist/core/TranslationValues.js.map +0 -1
  237. package/dist/core/TranslationValues.mjs +0 -1
  238. package/dist/core/TranslationValues.mjs.map +0 -1
  239. package/dist/core/convertFormatsToIntlMessageFormat.d.mts +0 -16
  240. package/dist/core/convertFormatsToIntlMessageFormat.js +0 -2
  241. package/dist/core/convertFormatsToIntlMessageFormat.js.map +0 -1
  242. package/dist/core/convertFormatsToIntlMessageFormat.mjs +0 -2
  243. package/dist/core/convertFormatsToIntlMessageFormat.mjs.map +0 -1
  244. package/dist/core/createBaseTranslator.d.mts +0 -32
  245. package/dist/core/createBaseTranslator.js +0 -2
  246. package/dist/core/createBaseTranslator.js.map +0 -1
  247. package/dist/core/createBaseTranslator.mjs +0 -2
  248. package/dist/core/createBaseTranslator.mjs.map +0 -1
  249. package/dist/core/createFormatter.d.mts +0 -21
  250. package/dist/core/createFormatter.js +0 -2
  251. package/dist/core/createFormatter.js.map +0 -1
  252. package/dist/core/createFormatter.mjs +0 -2
  253. package/dist/core/createFormatter.mjs.map +0 -1
  254. package/dist/core/createIntl.d.mts +0 -15
  255. package/dist/core/createIntl.js +0 -2
  256. package/dist/core/createIntl.js.map +0 -1
  257. package/dist/core/createIntl.mjs +0 -2
  258. package/dist/core/createIntl.mjs.map +0 -1
  259. package/dist/core/createTranslator.d.mts +0 -57
  260. package/dist/core/createTranslator.js +0 -2
  261. package/dist/core/createTranslator.js.map +0 -1
  262. package/dist/core/createTranslator.mjs +0 -2
  263. package/dist/core/createTranslator.mjs.map +0 -1
  264. package/dist/core/createTranslatorImpl.d.mts +0 -25
  265. package/dist/core/createTranslatorImpl.js +0 -2
  266. package/dist/core/createTranslatorImpl.js.map +0 -1
  267. package/dist/core/createTranslatorImpl.mjs +0 -2
  268. package/dist/core/createTranslatorImpl.mjs.map +0 -1
  269. package/dist/core/defaults.d.mts +0 -14
  270. package/dist/core/defaults.js +0 -2
  271. package/dist/core/defaults.js.map +0 -1
  272. package/dist/core/defaults.mjs +0 -2
  273. package/dist/core/defaults.mjs.map +0 -1
  274. package/dist/core/index.d.mts +0 -17
  275. package/dist/core/index.js +0 -2
  276. package/dist/core/index.js.map +0 -1
  277. package/dist/core/index.mjs +0 -2
  278. package/dist/core/index.mjs.map +0 -1
  279. package/dist/core/resolveNamespace.d.mts +0 -7
  280. package/dist/core/resolveNamespace.js +0 -2
  281. package/dist/core/resolveNamespace.js.map +0 -1
  282. package/dist/core/resolveNamespace.mjs +0 -2
  283. package/dist/core/resolveNamespace.mjs.map +0 -1
  284. package/dist/core/utils/MessageKeys.d.mts +0 -7
  285. package/dist/core/utils/MessageKeys.js +0 -2
  286. package/dist/core/utils/MessageKeys.js.map +0 -1
  287. package/dist/core/utils/MessageKeys.mjs +0 -1
  288. package/dist/core/utils/MessageKeys.mjs.map +0 -1
  289. package/dist/core/utils/NamespaceKeys.d.mts +0 -7
  290. package/dist/core/utils/NamespaceKeys.js +0 -2
  291. package/dist/core/utils/NamespaceKeys.js.map +0 -1
  292. package/dist/core/utils/NamespaceKeys.mjs +0 -1
  293. package/dist/core/utils/NamespaceKeys.mjs.map +0 -1
  294. package/dist/core/utils/NestedKeyOf.d.mts +0 -5
  295. package/dist/core/utils/NestedKeyOf.js +0 -2
  296. package/dist/core/utils/NestedKeyOf.js.map +0 -1
  297. package/dist/core/utils/NestedKeyOf.mjs +0 -1
  298. package/dist/core/utils/NestedKeyOf.mjs.map +0 -1
  299. package/dist/core/utils/NestedValueOf.d.mts +0 -3
  300. package/dist/core/utils/NestedValueOf.js +0 -2
  301. package/dist/core/utils/NestedValueOf.js.map +0 -1
  302. package/dist/core/utils/NestedValueOf.mjs +0 -1
  303. package/dist/core/utils/NestedValueOf.mjs.map +0 -1
  304. package/dist/core/validateMessages.d.mts +0 -6
  305. package/dist/core/validateMessages.js +0 -34
  306. package/dist/core/validateMessages.js.map +0 -1
  307. package/dist/core/validateMessages.mjs +0 -34
  308. package/dist/core/validateMessages.mjs.map +0 -1
  309. package/dist/index.d.mts +0 -25
  310. package/dist/index.js.map +0 -1
  311. package/dist/index.mjs +0 -2
  312. package/dist/index.mjs.map +0 -1
  313. package/dist/react/IntlContext.d.mts +0 -13
  314. package/dist/react/IntlContext.js +0 -2
  315. package/dist/react/IntlContext.js.map +0 -1
  316. package/dist/react/IntlContext.mjs +0 -2
  317. package/dist/react/IntlContext.mjs.map +0 -1
  318. package/dist/react/IntlProvider.d.mts +0 -16
  319. package/dist/react/IntlProvider.js +0 -2
  320. package/dist/react/IntlProvider.js.map +0 -1
  321. package/dist/react/IntlProvider.mjs +0 -2
  322. package/dist/react/IntlProvider.mjs.map +0 -1
  323. package/dist/react/getInitializedConfig.d.mts +0 -24
  324. package/dist/react/getInitializedConfig.js +0 -2
  325. package/dist/react/getInitializedConfig.js.map +0 -1
  326. package/dist/react/getInitializedConfig.mjs +0 -2
  327. package/dist/react/getInitializedConfig.mjs.map +0 -1
  328. package/dist/react/index.d.mts +0 -21
  329. package/dist/react/index.js +0 -2
  330. package/dist/react/index.js.map +0 -1
  331. package/dist/react/index.mjs +0 -2
  332. package/dist/react/index.mjs.map +0 -1
  333. package/dist/react/useFormatter.d.mts +0 -12
  334. package/dist/react/useFormatter.js +0 -2
  335. package/dist/react/useFormatter.js.map +0 -1
  336. package/dist/react/useFormatter.mjs +0 -2
  337. package/dist/react/useFormatter.mjs.map +0 -1
  338. package/dist/react/useIntl.d.mts +0 -12
  339. package/dist/react/useIntl.js +0 -2
  340. package/dist/react/useIntl.js.map +0 -1
  341. package/dist/react/useIntl.mjs +0 -2
  342. package/dist/react/useIntl.mjs.map +0 -1
  343. package/dist/react/useIntlContext.d.mts +0 -13
  344. package/dist/react/useIntlContext.js +0 -2
  345. package/dist/react/useIntlContext.js.map +0 -1
  346. package/dist/react/useIntlContext.mjs +0 -2
  347. package/dist/react/useIntlContext.mjs.map +0 -1
  348. package/dist/react/useLocale.d.mts +0 -3
  349. package/dist/react/useLocale.js +0 -2
  350. package/dist/react/useLocale.js.map +0 -1
  351. package/dist/react/useLocale.mjs +0 -2
  352. package/dist/react/useLocale.mjs.map +0 -1
  353. package/dist/react/useMessages.d.mts +0 -5
  354. package/dist/react/useMessages.js +0 -2
  355. package/dist/react/useMessages.js.map +0 -1
  356. package/dist/react/useMessages.mjs +0 -2
  357. package/dist/react/useMessages.mjs.map +0 -1
  358. package/dist/react/useNow.js +0 -2
  359. package/dist/react/useNow.js.map +0 -1
  360. package/dist/react/useNow.mjs +0 -2
  361. package/dist/react/useNow.mjs.map +0 -1
  362. package/dist/react/useTimeZone.d.mts +0 -5
  363. package/dist/react/useTimeZone.js +0 -2
  364. package/dist/react/useTimeZone.js.map +0 -1
  365. package/dist/react/useTimeZone.mjs +0 -2
  366. package/dist/react/useTimeZone.mjs.map +0 -1
  367. package/dist/react/useTranslations.d.mts +0 -50
  368. package/dist/react/useTranslations.js +0 -2
  369. package/dist/react/useTranslations.js.map +0 -1
  370. package/dist/react/useTranslations.mjs +0 -2
  371. package/dist/react/useTranslations.mjs.map +0 -1
  372. package/dist/react/useTranslationsImpl.d.mts +0 -16
  373. package/dist/react/useTranslationsImpl.js +0 -2
  374. package/dist/react/useTranslationsImpl.js.map +0 -1
  375. package/dist/react/useTranslationsImpl.mjs +0 -2
  376. package/dist/react/useTranslationsImpl.mjs.map +0 -1
  377. package/dist/src/core/AbstractIntlMessages.d.mts +0 -10
  378. package/dist/src/core/AbstractIntlMessages.mjs +0 -1
  379. package/dist/src/core/AbstractIntlMessages.mjs.map +0 -1
  380. package/dist/src/core/DateTimeFormatOptions.d.mts +0 -75
  381. package/dist/src/core/DateTimeFormatOptions.mjs +0 -1
  382. package/dist/src/core/DateTimeFormatOptions.mjs.map +0 -1
  383. package/dist/src/core/Formats.d.mts +0 -11
  384. package/dist/src/core/Formats.mjs +0 -1
  385. package/dist/src/core/Formats.mjs.map +0 -1
  386. package/dist/src/core/IntlConfig.d.mts +0 -60
  387. package/dist/src/core/IntlConfig.mjs +0 -1
  388. package/dist/src/core/IntlConfig.mjs.map +0 -1
  389. package/dist/src/core/IntlError.d.mts +0 -15
  390. package/dist/src/core/IntlError.mjs +0 -2
  391. package/dist/src/core/IntlError.mjs.map +0 -1
  392. package/dist/src/core/NumberFormatOptions.d.mts +0 -2
  393. package/dist/src/core/NumberFormatOptions.mjs +0 -2
  394. package/dist/src/core/NumberFormatOptions.mjs.map +0 -1
  395. package/dist/src/core/TimeZone.d.mts +0 -3
  396. package/dist/src/core/TimeZone.mjs +0 -1
  397. package/dist/src/core/TimeZone.mjs.map +0 -1
  398. package/dist/src/core/TranslationValues.d.mts +0 -7
  399. package/dist/src/core/TranslationValues.mjs +0 -1
  400. package/dist/src/core/TranslationValues.mjs.map +0 -1
  401. package/dist/src/core/convertFormatsToIntlMessageFormat.d.mts +0 -16
  402. package/dist/src/core/convertFormatsToIntlMessageFormat.mjs +0 -2
  403. package/dist/src/core/convertFormatsToIntlMessageFormat.mjs.map +0 -1
  404. package/dist/src/core/createBaseTranslator.d.mts +0 -32
  405. package/dist/src/core/createBaseTranslator.mjs +0 -2
  406. package/dist/src/core/createBaseTranslator.mjs.map +0 -1
  407. package/dist/src/core/createFormatter.d.mts +0 -21
  408. package/dist/src/core/createFormatter.mjs +0 -2
  409. package/dist/src/core/createFormatter.mjs.map +0 -1
  410. package/dist/src/core/createIntl.d.mts +0 -15
  411. package/dist/src/core/createIntl.mjs +0 -2
  412. package/dist/src/core/createIntl.mjs.map +0 -1
  413. package/dist/src/core/createTranslator.d.mts +0 -57
  414. package/dist/src/core/createTranslator.mjs +0 -2
  415. package/dist/src/core/createTranslator.mjs.map +0 -1
  416. package/dist/src/core/createTranslatorImpl.d.mts +0 -25
  417. package/dist/src/core/createTranslatorImpl.mjs +0 -2
  418. package/dist/src/core/createTranslatorImpl.mjs.map +0 -1
  419. package/dist/src/core/defaults.d.mts +0 -14
  420. package/dist/src/core/defaults.mjs +0 -2
  421. package/dist/src/core/defaults.mjs.map +0 -1
  422. package/dist/src/core/index.d.mts +0 -17
  423. package/dist/src/core/index.mjs +0 -2
  424. package/dist/src/core/index.mjs.map +0 -1
  425. package/dist/src/core/resolveNamespace.d.mts +0 -7
  426. package/dist/src/core/resolveNamespace.mjs +0 -2
  427. package/dist/src/core/resolveNamespace.mjs.map +0 -1
  428. package/dist/src/core/utils/MessageKeys.d.mts +0 -7
  429. package/dist/src/core/utils/MessageKeys.mjs +0 -1
  430. package/dist/src/core/utils/MessageKeys.mjs.map +0 -1
  431. package/dist/src/core/utils/NamespaceKeys.d.mts +0 -7
  432. package/dist/src/core/utils/NamespaceKeys.mjs +0 -1
  433. package/dist/src/core/utils/NamespaceKeys.mjs.map +0 -1
  434. package/dist/src/core/utils/NestedKeyOf.d.mts +0 -5
  435. package/dist/src/core/utils/NestedKeyOf.mjs +0 -1
  436. package/dist/src/core/utils/NestedKeyOf.mjs.map +0 -1
  437. package/dist/src/core/utils/NestedValueOf.d.mts +0 -3
  438. package/dist/src/core/utils/NestedValueOf.mjs +0 -1
  439. package/dist/src/core/utils/NestedValueOf.mjs.map +0 -1
  440. package/dist/src/core/validateMessages.d.mts +0 -6
  441. package/dist/src/core/validateMessages.mjs +0 -34
  442. package/dist/src/core/validateMessages.mjs.map +0 -1
  443. package/dist/src/index.d.mts +0 -25
  444. package/dist/src/index.mjs +0 -2
  445. package/dist/src/index.mjs.map +0 -1
  446. package/dist/src/react/IntlContext.d.mts +0 -13
  447. package/dist/src/react/IntlContext.mjs +0 -2
  448. package/dist/src/react/IntlContext.mjs.map +0 -1
  449. package/dist/src/react/IntlProvider.d.mts +0 -16
  450. package/dist/src/react/IntlProvider.mjs +0 -2
  451. package/dist/src/react/IntlProvider.mjs.map +0 -1
  452. package/dist/src/react/getInitializedConfig.d.mts +0 -24
  453. package/dist/src/react/getInitializedConfig.mjs +0 -2
  454. package/dist/src/react/getInitializedConfig.mjs.map +0 -1
  455. package/dist/src/react/index.d.mts +0 -21
  456. package/dist/src/react/index.mjs +0 -2
  457. package/dist/src/react/index.mjs.map +0 -1
  458. package/dist/src/react/useFormatter.d.mts +0 -12
  459. package/dist/src/react/useFormatter.mjs +0 -2
  460. package/dist/src/react/useFormatter.mjs.map +0 -1
  461. package/dist/src/react/useIntl.d.mts +0 -12
  462. package/dist/src/react/useIntl.mjs +0 -2
  463. package/dist/src/react/useIntl.mjs.map +0 -1
  464. package/dist/src/react/useIntlContext.d.mts +0 -13
  465. package/dist/src/react/useIntlContext.mjs +0 -2
  466. package/dist/src/react/useIntlContext.mjs.map +0 -1
  467. package/dist/src/react/useLocale.d.mts +0 -3
  468. package/dist/src/react/useLocale.mjs +0 -2
  469. package/dist/src/react/useLocale.mjs.map +0 -1
  470. package/dist/src/react/useMessages.d.mts +0 -5
  471. package/dist/src/react/useMessages.mjs +0 -2
  472. package/dist/src/react/useMessages.mjs.map +0 -1
  473. package/dist/src/react/useNow.d.mts +0 -24
  474. package/dist/src/react/useNow.mjs +0 -2
  475. package/dist/src/react/useNow.mjs.map +0 -1
  476. package/dist/src/react/useTimeZone.d.mts +0 -5
  477. package/dist/src/react/useTimeZone.mjs +0 -2
  478. package/dist/src/react/useTimeZone.mjs.map +0 -1
  479. package/dist/src/react/useTranslations.d.mts +0 -50
  480. package/dist/src/react/useTranslations.mjs +0 -2
  481. package/dist/src/react/useTranslations.mjs.map +0 -1
  482. package/dist/src/react/useTranslationsImpl.d.mts +0 -16
  483. package/dist/src/react/useTranslationsImpl.mjs +0 -2
  484. package/dist/src/react/useTranslationsImpl.mjs.map +0 -1
@@ -1,32 +1,26 @@
1
- import IntlMessageFormat from 'intl-messageformat';
2
- import { ReactElement, ReactNodeArray } from 'react';
3
- import AbstractIntlMessages from './AbstractIntlMessages.js';
4
- import Formats from './Formats.js';
5
- import { InitializedIntlConfig } from './IntlConfig.js';
6
- import IntlError from './IntlError.js';
7
- import TranslationValues, { RichTranslationValues } from './TranslationValues.js';
8
- import MessageKeys from './utils/MessageKeys.js';
9
- import NestedKeyOf from './utils/NestedKeyOf.js';
10
- import NestedValueOf from './utils/NestedValueOf.js';
11
- import './DateTimeFormatOptions.js';
12
- import './TimeZone.js';
13
- import '@formatjs/ecma402-abstract/types/number';
14
-
15
- declare function getMessagesOrError<Messages extends AbstractIntlMessages>({ messages, namespace, onError }: {
16
- messages: Messages;
17
- namespace?: string;
18
- onError?(error: IntlError): void;
19
- }): AbstractIntlMessages | IntlError;
20
- type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {
21
- cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;
22
- defaultTranslationValues?: RichTranslationValues;
23
- namespace?: string;
24
- messagesOrError: Messages | IntlError;
25
- };
26
- declare function createBaseTranslator<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ cachedFormatsByLocale, defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messagesOrError, namespace, onError, timeZone }: CreateBaseTranslatorProps<Messages>): {
27
- <TargetKey extends MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
28
- rich: (key: string, values?: RichTranslationValues, formats?: Partial<Formats>) => string | ReactElement | ReactNodeArray;
29
- raw(key: string): any;
30
- };
31
-
32
- export { CreateBaseTranslatorProps, createBaseTranslator as default, getMessagesOrError };
1
+ import IntlMessageFormat from 'intl-messageformat';
2
+ import { ReactElement, ReactNodeArray } from 'react';
3
+ import AbstractIntlMessages from './AbstractIntlMessages';
4
+ import Formats from './Formats';
5
+ import { InitializedIntlConfig } from './IntlConfig';
6
+ import IntlError from './IntlError';
7
+ import TranslationValues, { RichTranslationValues } from './TranslationValues';
8
+ import MessageKeys from './utils/MessageKeys';
9
+ import NestedKeyOf from './utils/NestedKeyOf';
10
+ import NestedValueOf from './utils/NestedValueOf';
11
+ export declare function getMessagesOrError<Messages extends AbstractIntlMessages>({ messages, namespace, onError }: {
12
+ messages: Messages;
13
+ namespace?: string;
14
+ onError?(error: IntlError): void;
15
+ }): AbstractIntlMessages | IntlError;
16
+ export type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {
17
+ cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;
18
+ defaultTranslationValues?: RichTranslationValues;
19
+ namespace?: string;
20
+ messagesOrError: Messages | IntlError;
21
+ };
22
+ export default function createBaseTranslator<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ cachedFormatsByLocale, defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messagesOrError, namespace, onError, timeZone }: CreateBaseTranslatorProps<Messages>): {
23
+ <TargetKey extends MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
24
+ rich: (key: string, values?: RichTranslationValues, formats?: Partial<Formats>) => string | ReactElement | ReactNodeArray;
25
+ raw(key: string): any;
26
+ };
@@ -1,21 +1,19 @@
1
- import DateTimeFormatOptions from './DateTimeFormatOptions.js';
2
- import Formats from './Formats.js';
3
- import IntlError from './IntlError.js';
4
- import { NumberFormatOptions } from '@formatjs/ecma402-abstract/types/number';
5
- import TimeZone from './TimeZone.js';
6
-
7
- type Props = {
8
- locale: string;
9
- timeZone?: TimeZone;
10
- onError?(error: IntlError): void;
11
- formats?: Partial<Formats>;
12
- now?: Date;
13
- };
14
- declare function createFormatter({ formats, locale, now: globalNow, onError, timeZone }: Props): {
15
- dateTime: (value: Date | number, formatOrOptions?: string | DateTimeFormatOptions) => string;
16
- number: (value: number | bigint, formatOrOptions?: string | NumberFormatOptions) => string;
17
- relativeTime: (date: number | Date, now?: number | Date) => string;
18
- list: (value: Iterable<string>, formatOrOptions?: string | Intl.ListFormatOptions) => string;
19
- };
20
-
21
- export { createFormatter as default };
1
+ import DateTimeFormatOptions from './DateTimeFormatOptions';
2
+ import Formats from './Formats';
3
+ import IntlError from './IntlError';
4
+ import NumberFormatOptions from './NumberFormatOptions';
5
+ import TimeZone from './TimeZone';
6
+ type Props = {
7
+ locale: string;
8
+ timeZone?: TimeZone;
9
+ onError?(error: IntlError): void;
10
+ formats?: Partial<Formats>;
11
+ now?: Date;
12
+ };
13
+ export default function createFormatter({ formats, locale, now: globalNow, onError, timeZone }: Props): {
14
+ dateTime: (value: Date | number, formatOrOptions?: string | DateTimeFormatOptions) => string;
15
+ number: (value: number | bigint, formatOrOptions?: string | NumberFormatOptions) => string;
16
+ relativeTime: (date: number | Date, now?: number | Date) => string;
17
+ list: (value: Iterable<string>, formatOrOptions?: string | Intl.ListFormatOptions) => string;
18
+ };
19
+ export {};
@@ -1,15 +1,7 @@
1
- import * as _formatjs_ecma402_abstract_types_number from '@formatjs/ecma402-abstract/types/number';
2
- import DateTimeFormatOptions from './DateTimeFormatOptions.js';
3
- import createFormatter from './createFormatter.js';
4
- import './TimeZone.js';
5
- import './Formats.js';
6
- import './IntlError.js';
7
-
8
- /** @deprecated Switch to `createFormatter` */
9
- declare function createIntl(...args: Parameters<typeof createFormatter>): {
10
- formatDateTime: (value: number | Date, formatOrOptions?: string | DateTimeFormatOptions | undefined) => string;
11
- formatNumber: (value: number | bigint, formatOrOptions?: string | _formatjs_ecma402_abstract_types_number.NumberFormatOptions | undefined) => string;
12
- formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
13
- };
14
-
15
- export { createIntl as default };
1
+ import createFormatter from './createFormatter';
2
+ /** @deprecated Switch to `createFormatter` */
3
+ export default function createIntl(...args: Parameters<typeof createFormatter>): {
4
+ formatDateTime: (value: number | Date, formatOrOptions?: string | import("./DateTimeFormatOptions").default | undefined) => string;
5
+ formatNumber: (value: number | bigint, formatOrOptions?: string | import("@formatjs/ecma402-abstract/types/number").NumberFormatOptions | undefined) => string;
6
+ formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
7
+ };
@@ -1,57 +1,48 @@
1
- import Formats from './Formats.js';
2
- import IntlConfig from './IntlConfig.js';
3
- import TranslationValues from './TranslationValues.js';
4
- import { CoreRichTranslationValues } from './createTranslatorImpl.js';
5
- import MessageKeys from './utils/MessageKeys.js';
6
- import NamespaceKeys from './utils/NamespaceKeys.js';
7
- import NestedKeyOf from './utils/NestedKeyOf.js';
8
- import NestedValueOf from './utils/NestedValueOf.js';
9
- import './DateTimeFormatOptions.js';
10
- import './TimeZone.js';
11
- import '@formatjs/ecma402-abstract/types/number';
12
- import './IntlError.js';
13
- import './AbstractIntlMessages.js';
14
- import 'react';
15
-
16
- /**
17
- * Translates messages from the given namespace by using the ICU syntax.
18
- * See https://formatjs.io/docs/core-concepts/icu-syntax.
19
- *
20
- * If no namespace is provided, all available messages are returned.
21
- * The namespace can also indicate nesting by using a dot
22
- * (e.g. `namespace.Component`).
23
- */
24
- declare function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
25
- messages: NonNullable<IntlConfig<IntlMessages>['messages']>;
26
- namespace?: NestedKey;
27
- }): {
28
- <TargetKey extends MessageKeys<NestedValueOf<{
29
- '!': IntlMessages;
30
- }, [
31
- NestedKey
32
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
33
- '!': IntlMessages;
34
- }, [
35
- NestedKey
36
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
37
- rich<TargetKey extends MessageKeys<NestedValueOf<{
38
- '!': IntlMessages;
39
- }, [
40
- NestedKey
41
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
42
- '!': IntlMessages;
43
- }, [
44
- NestedKey
45
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: CoreRichTranslationValues, formats?: Partial<Formats>): string;
46
- raw<TargetKey extends MessageKeys<NestedValueOf<{
47
- '!': IntlMessages;
48
- }, [
49
- NestedKey
50
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
51
- '!': IntlMessages;
52
- }, [
53
- NestedKey
54
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
55
- };
56
-
57
- export { createTranslator as default };
1
+ import Formats from './Formats';
2
+ import IntlConfig from './IntlConfig';
3
+ import TranslationValues from './TranslationValues';
4
+ import { CoreRichTranslationValues } from './createTranslatorImpl';
5
+ import MessageKeys from './utils/MessageKeys';
6
+ import NamespaceKeys from './utils/NamespaceKeys';
7
+ import NestedKeyOf from './utils/NestedKeyOf';
8
+ import NestedValueOf from './utils/NestedValueOf';
9
+ /**
10
+ * Translates messages from the given namespace by using the ICU syntax.
11
+ * See https://formatjs.io/docs/core-concepts/icu-syntax.
12
+ *
13
+ * If no namespace is provided, all available messages are returned.
14
+ * The namespace can also indicate nesting by using a dot
15
+ * (e.g. `namespace.Component`).
16
+ */
17
+ export default function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
18
+ messages: NonNullable<IntlConfig<IntlMessages>['messages']>;
19
+ namespace?: NestedKey;
20
+ }): {
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?: CoreRichTranslationValues, formats?: Partial<Formats>): string;
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
+ };
@@ -1,25 +1,14 @@
1
- import Formats from './Formats.js';
2
- import TranslationValues, { TranslationValue } from './TranslationValues.js';
3
- import MessageKeys from './utils/MessageKeys.js';
4
- import NestedValueOf from './utils/NestedValueOf.js';
5
- import AbstractIntlMessages from './AbstractIntlMessages.js';
6
- import { InitializedIntlConfig } from './IntlConfig.js';
7
- import NestedKeyOf from './utils/NestedKeyOf.js';
8
- import './DateTimeFormatOptions.js';
9
- import './TimeZone.js';
10
- import '@formatjs/ecma402-abstract/types/number';
11
- import 'react';
12
- import './IntlError.js';
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
+ 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,14 +1,11 @@
1
- import IntlError from './IntlError.js';
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
+ 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,17 +1,9 @@
1
- export { default as AbstractIntlMessages } from './AbstractIntlMessages.js';
2
- export { RichTranslationValues, default as TranslationValues } from './TranslationValues.js';
3
- export { default as Formats } from './Formats.js';
4
- export { default as DateTimeFormatOptions } from './DateTimeFormatOptions.js';
5
- export { NumberFormatOptions } from '@formatjs/ecma402-abstract/types/number';
6
- export { default as IntlError, IntlErrorCode } from './IntlError.js';
7
- export { default as createTranslator } from './createTranslator.js';
8
- export { default as createFormatter } from './createFormatter.js';
9
- export { default as createIntl } from './createIntl.js';
10
- import 'react';
11
- import './TimeZone.js';
12
- import './IntlConfig.js';
13
- import './createTranslatorImpl.js';
14
- import './utils/MessageKeys.js';
15
- import './utils/NestedValueOf.js';
16
- import './utils/NestedKeyOf.js';
17
- import './utils/NamespaceKeys.js';
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,7 +1,5 @@
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
+ * 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;
@@ -0,0 +1,33 @@
1
+ import { inheritsLoose as _inheritsLoose, wrapNativeSuper as _wrapNativeSuper } from '../_virtual/use-intl.esm.js';
2
+
3
+ var IntlErrorCode;
4
+ (function (IntlErrorCode) {
5
+ IntlErrorCode["MISSING_MESSAGE"] = "MISSING_MESSAGE";
6
+ IntlErrorCode["MISSING_FORMAT"] = "MISSING_FORMAT";
7
+ IntlErrorCode["INSUFFICIENT_PATH"] = "INSUFFICIENT_PATH";
8
+ IntlErrorCode["INVALID_MESSAGE"] = "INVALID_MESSAGE";
9
+ IntlErrorCode["INVALID_KEY"] = "INVALID_KEY";
10
+ IntlErrorCode["FORMATTING_ERROR"] = "FORMATTING_ERROR";
11
+ })(IntlErrorCode || (IntlErrorCode = {}));
12
+ var IntlError = /*#__PURE__*/function (_Error) {
13
+ _inheritsLoose(IntlError, _Error);
14
+ function IntlError(code, originalMessage) {
15
+ var _this;
16
+ var message = code;
17
+ if (originalMessage) {
18
+ message += ': ' + originalMessage;
19
+ }
20
+ _this = _Error.call(this, message) || this;
21
+ _this.code = void 0;
22
+ _this.originalMessage = void 0;
23
+ _this.code = code;
24
+ if (originalMessage) {
25
+ _this.originalMessage = originalMessage;
26
+ }
27
+ return _this;
28
+ }
29
+ return IntlError;
30
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
31
+
32
+ export { IntlErrorCode, IntlError as default };
33
+ //# sourceMappingURL=use-intl.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-intl.esm.js","sources":["../../src/core/IntlError.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n"],"names":["IntlErrorCode","IntlError","_Error","_inheritsLoose","code","originalMessage","_this","message","call","_wrapNativeSuper","Error"],"mappings":";;IAAYA,cAOX;AAPD,CAAA,UAAYA,aAAa,EAAA;AACvBA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnCA,EAAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,gBAAiC,CAAA;AACjCA,EAAAA,aAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC,CAAA;AACvCA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnCA,EAAAA,aAAA,CAAA,aAAA,CAAA,GAAA,aAA2B,CAAA;AAC3BA,EAAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC,CAAA;AACvC,CAAC,EAPWA,aAAa,KAAbA,aAAa,GAOxB,EAAA,CAAA,CAAA,CAAA;AAEoBC,IAAAA,SAAU,0BAAAC,MAAA,EAAA;EAAAC,cAAA,CAAAF,SAAA,EAAAC,MAAA,CAAA,CAAA;AAI7B,EAAA,SAAAD,SAAYG,CAAAA,IAAmB,EAAEC,eAAwB,EAAA;AAAA,IAAA,IAAAC,KAAA,CAAA;IACvD,IAAIC,OAAO,GAAWH,IAAI,CAAA;AAC1B,IAAA,IAAIC,eAAe,EAAE;MACnBE,OAAO,IAAI,IAAI,GAAGF,eAAe,CAAA;AAClC,KAAA;AACDC,IAAAA,KAAA,GAAAJ,MAAA,CAAAM,IAAA,CAAA,IAAA,EAAMD,OAAO,CAAC,IAAA,IAAA,CAAA;AAACD,IAAAA,KAAA,CARDF,IAAI,GAAA,KAAA,CAAA,CAAA;AAAAE,IAAAA,KAAA,CACJD,eAAe,GAAA,KAAA,CAAA,CAAA;IAS7BC,KAAA,CAAKF,IAAI,GAAGA,IAAI,CAAA;AAChB,IAAA,IAAIC,eAAe,EAAE;MACnBC,KAAA,CAAKD,eAAe,GAAGA,eAAe,CAAA;AACvC,KAAA;AAAA,IAAA,OAAAC,KAAA,CAAA;AACH,GAAA;AAAC,EAAA,OAAAL,SAAA,CAAA;AAAA,CAAAQ,eAAAA,gBAAA,CAfoCC,KAAK,CAAA;;;;"}
@@ -0,0 +1,32 @@
1
+ import { extends as _extends } from '../_virtual/use-intl.esm.js';
2
+
3
+ function setTimeZoneInFormats(formats, timeZone) {
4
+ if (!formats) return formats;
5
+ // The only way to set a time zone with `intl-messageformat` is to merge it into the formats
6
+ // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15
7
+ return Object.keys(formats).reduce(function (acc, key) {
8
+ acc[key] = _extends({
9
+ timeZone: timeZone
10
+ }, formats[key]);
11
+ return acc;
12
+ }, {});
13
+ }
14
+ /**
15
+ * `intl-messageformat` uses separate keys for `date` and `time`, but there's
16
+ * only one native API: `Intl.DateTimeFormat`. Additionally you might want to
17
+ * include both a time and a date in a value, therefore the separation doesn't
18
+ * seem so useful. We offer a single `dateTime` namespace instead, but we have
19
+ * to convert the format before `intl-messageformat` can be used.
20
+ */
21
+ function convertFormatsToIntlMessageFormat(formats, timeZone) {
22
+ var formatsWithTimeZone = timeZone ? _extends({}, formats, {
23
+ dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)
24
+ }) : formats;
25
+ return _extends({}, formatsWithTimeZone, {
26
+ date: formatsWithTimeZone == null ? void 0 : formatsWithTimeZone.dateTime,
27
+ time: formatsWithTimeZone == null ? void 0 : formatsWithTimeZone.dateTime
28
+ });
29
+ }
30
+
31
+ export { convertFormatsToIntlMessageFormat as default };
32
+ //# sourceMappingURL=use-intl.esm10.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-intl.esm10.js","sources":["../../src/core/convertFormatsToIntlMessageFormat.tsx"],"sourcesContent":["import {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport TimeZone from './TimeZone';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: TimeZone\n) {\n if (!formats) return formats;\n\n // The only way to set a time zone with `intl-messageformat` is to merge it into the formats\n // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15\n return Object.keys(formats).reduce(\n (acc: Record<string, DateTimeFormatOptions>, key) => {\n acc[key] = {\n timeZone,\n ...formats[key]\n };\n return acc;\n },\n {}\n );\n}\n\n/**\n * `intl-messageformat` uses separate keys for `date` and `time`, but there's\n * only one native API: `Intl.DateTimeFormat`. Additionally you might want to\n * include both a time and a date in a value, therefore the separation doesn't\n * seem so useful. We offer a single `dateTime` namespace instead, but we have\n * to convert the format before `intl-messageformat` can be used.\n */\nexport default function convertFormatsToIntlMessageFormat(\n formats: Partial<Formats>,\n timeZone?: TimeZone\n): Partial<IntlFormats> {\n const formatsWithTimeZone = timeZone\n ? {...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)}\n : formats;\n\n return {\n ...formatsWithTimeZone,\n date: formatsWithTimeZone?.dateTime,\n time: formatsWithTimeZone?.dateTime\n };\n}\n"],"names":["setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","key","_extends","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","date","time"],"mappings":";;AAKA,SAASA,oBAAoBA,CAC3BC,OAA0D,EAC1DC,QAAkB,EAAA;AAElB,EAAA,IAAI,CAACD,OAAO,EAAE,OAAOA,OAAO,CAAA;AAE5B;AACA;AACA,EAAA,OAAOE,MAAM,CAACC,IAAI,CAACH,OAAO,CAAC,CAACI,MAAM,CAChC,UAACC,GAA0C,EAAEC,GAAG,EAAI;AAClDD,IAAAA,GAAG,CAACC,GAAG,CAAC,GAAAC,QAAA,CAAA;AACNN,MAAAA,QAAQ,EAARA,QAAAA;AAAQ,KAAA,EACLD,OAAO,CAACM,GAAG,CAAC,CAChB,CAAA;AACD,IAAA,OAAOD,GAAG,CAAA;GACX,EACD,EAAE,CACH,CAAA;AACH,CAAA;AAEA;;;;;;AAMG;AACW,SAAUG,iCAAiCA,CACvDR,OAAyB,EACzBC,QAAmB,EAAA;AAEnB,EAAA,IAAMQ,mBAAmB,GAAGR,QAAQ,GAAAM,QAAA,KAC5BP,OAAO,EAAA;AAAEU,IAAAA,QAAQ,EAAEX,oBAAoB,CAACC,OAAO,CAACU,QAAQ,EAAET,QAAQ,CAAA;AAAC,GAAA,CAAA,GACvED,OAAO,CAAA;EAEX,OAAAO,QAAA,KACKE,mBAAmB,EAAA;AACtBE,IAAAA,IAAI,EAAEF,mBAAmB,IAAnBA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,mBAAmB,CAAEC,QAAQ;AACnCE,IAAAA,IAAI,EAAEH,mBAAmB,IAAnBA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,mBAAmB,CAAEC,QAAAA;AAAQ,GAAA,CAAA,CAAA;AAEvC;;;;"}
@@ -0,0 +1,37 @@
1
+ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
2
+ import createTranslatorImpl from './use-intl.esm5.js';
3
+ import { defaultGetMessageFallback, defaultOnError } from './use-intl.esm6.js';
4
+
5
+ var _excluded = ["getMessageFallback", "messages", "namespace", "onError"];
6
+ /**
7
+ * Translates messages from the given namespace by using the ICU syntax.
8
+ * See https://formatjs.io/docs/core-concepts/icu-syntax.
9
+ *
10
+ * If no namespace is provided, all available messages are returned.
11
+ * The namespace can also indicate nesting by using a dot
12
+ * (e.g. `namespace.Component`).
13
+ */
14
+ function createTranslator(_ref) {
15
+ var _ref$getMessageFallba = _ref.getMessageFallback,
16
+ getMessageFallback = _ref$getMessageFallba === void 0 ? defaultGetMessageFallback : _ref$getMessageFallba,
17
+ messages = _ref.messages,
18
+ namespace = _ref.namespace,
19
+ _ref$onError = _ref.onError,
20
+ onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
21
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
22
+ // We have to wrap the actual function so the type inference for the optional
23
+ // namespace works correctly. See https://stackoverflow.com/a/71529575/343045
24
+ // The prefix ("!") is arbitrary.
25
+ return createTranslatorImpl(_extends({}, rest, {
26
+ onError: onError,
27
+ getMessageFallback: getMessageFallback,
28
+ messages: {
29
+ '!': messages
30
+ },
31
+ // @ts-ignore
32
+ namespace: namespace ? "!." + namespace : '!'
33
+ }), '!');
34
+ }
35
+
36
+ export { createTranslator as default };
37
+ //# sourceMappingURL=use-intl.esm2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-intl.esm2.js","sources":["../../src/core/createTranslator.tsx"],"sourcesContent":["import Formats from './Formats';\nimport IntlConfig from './IntlConfig';\nimport TranslationValues from './TranslationValues';\nimport createTranslatorImpl, {\n CoreRichTranslationValues\n} from './createTranslatorImpl';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function createTranslator<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>({\n getMessageFallback = defaultGetMessageFallback,\n messages,\n namespace,\n onError = defaultOnError,\n ...rest\n}: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {\n messages: NonNullable<IntlConfig<IntlMessages>['messages']>;\n namespace?: NestedKey;\n}): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: CoreRichTranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n // We have to wrap the actual function so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return createTranslatorImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {\n ...rest,\n onError,\n getMessageFallback,\n messages: {'!': messages},\n // @ts-ignore\n namespace: namespace ? `!.${namespace}` : '!'\n },\n '!'\n );\n}\n"],"names":["createTranslator","_ref","_ref$getMessageFallba","getMessageFallback","defaultGetMessageFallback","messages","namespace","_ref$onError","onError","defaultOnError","rest","_objectWithoutPropertiesLoose","_excluded","createTranslatorImpl","_extends"],"mappings":";;;;;AAYA;;;;;;;AAOG;AACqB,SAAAA,gBAAgBA,CAAAC,IAAA,EAcvC;AAAA,EAAA,IAAAC,qBAAA,GAAAD,IAAA,CARCE,kBAAkB;AAAlBA,IAAAA,kBAAkB,GAAAD,qBAAA,KAAGE,KAAAA,CAAAA,GAAAA,yBAAyB,GAAAF,qBAAA;IAC9CG,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IACRC,SAAS,GAAAL,IAAA,CAATK,SAAS;IAAAC,YAAA,GAAAN,IAAA,CACTO,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAGE,KAAAA,CAAAA,GAAAA,cAAc,GAAAF,YAAA;AACrBG,IAAAA,IAAI,GAAAC,6BAAA,CAAAV,IAAA,EAAAW,SAAA,CAAA,CAAA;AAgEP;AACA;AACA;AACA,EAAA,OAAOC,oBAAoB,CAAAC,QAAA,CAAA,EAAA,EAKpBJ,IAAI,EAAA;AACPF,IAAAA,OAAO,EAAPA,OAAO;AACPL,IAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBE,IAAAA,QAAQ,EAAE;AAAC,MAAA,GAAG,EAAEA,QAAAA;KAAS;AACzB;AACAC,IAAAA,SAAS,EAAEA,SAAS,GAAQA,IAAAA,GAAAA,SAAS,GAAK,GAAA;AAAG,GAAA,CAAA,EAE/C,GAAG,CACJ,CAAA;AACH;;;;"}
@@ -0,0 +1,138 @@
1
+ import { extends as _extends } from '../_virtual/use-intl.esm.js';
2
+ import IntlError, { IntlErrorCode } from './use-intl.esm.js';
3
+ import { defaultOnError } from './use-intl.esm6.js';
4
+
5
+ var MINUTE = 60;
6
+ var HOUR = MINUTE * 60;
7
+ var DAY = HOUR * 24;
8
+ var WEEK = DAY * 7;
9
+ var MONTH = DAY * (365 / 12); // Approximation
10
+ var YEAR = DAY * 365;
11
+ function getRelativeTimeFormatConfig(seconds) {
12
+ var absValue = Math.abs(seconds);
13
+ var value, unit;
14
+ // We have to round the resulting values, as `Intl.RelativeTimeFormat`
15
+ // will include fractions like '2.1 hours ago'.
16
+ if (absValue < MINUTE) {
17
+ unit = 'second';
18
+ value = Math.round(seconds);
19
+ } else if (absValue < HOUR) {
20
+ unit = 'minute';
21
+ value = Math.round(seconds / MINUTE);
22
+ } else if (absValue < DAY) {
23
+ unit = 'hour';
24
+ value = Math.round(seconds / HOUR);
25
+ } else if (absValue < WEEK) {
26
+ unit = 'day';
27
+ value = Math.round(seconds / DAY);
28
+ } else if (absValue < MONTH) {
29
+ unit = 'week';
30
+ value = Math.round(seconds / WEEK);
31
+ } else if (absValue < YEAR) {
32
+ unit = 'month';
33
+ value = Math.round(seconds / MONTH);
34
+ } else {
35
+ unit = 'year';
36
+ value = Math.round(seconds / YEAR);
37
+ }
38
+ return {
39
+ value: value,
40
+ unit: unit
41
+ };
42
+ }
43
+ function createFormatter(_ref) {
44
+ var formats = _ref.formats,
45
+ locale = _ref.locale,
46
+ globalNow = _ref.now,
47
+ _ref$onError = _ref.onError,
48
+ onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
49
+ timeZone = _ref.timeZone;
50
+ function resolveFormatOrOptions(typeFormats, formatOrOptions) {
51
+ var options;
52
+ if (typeof formatOrOptions === 'string') {
53
+ var formatName = formatOrOptions;
54
+ options = typeFormats == null ? void 0 : typeFormats[formatName];
55
+ if (!options) {
56
+ var error = new IntlError(IntlErrorCode.MISSING_FORMAT, process.env.NODE_ENV !== 'production' ? "Format `" + formatName + "` is not available. You can configure it on the provider or provide custom options." : undefined);
57
+ onError(error);
58
+ throw error;
59
+ }
60
+ } else {
61
+ options = formatOrOptions;
62
+ }
63
+ return options;
64
+ }
65
+ function getFormattedValue(value, formatOrOptions, typeFormats, formatter) {
66
+ var options;
67
+ try {
68
+ options = resolveFormatOrOptions(typeFormats, formatOrOptions);
69
+ } catch (error) {
70
+ return String(value);
71
+ }
72
+ try {
73
+ return formatter(options);
74
+ } catch (error) {
75
+ onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
76
+ return String(value);
77
+ }
78
+ }
79
+ function dateTime( /** If a number is supplied, this is interpreted as a UTC timestamp. */
80
+ value,
81
+ /** If a time zone is supplied, the `value` is converted to that time zone.
82
+ * Otherwise the user time zone will be used. */
83
+ formatOrOptions) {
84
+ return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.dateTime, function (options) {
85
+ var _options;
86
+ if (timeZone && !((_options = options) != null && _options.timeZone)) {
87
+ options = _extends({}, options, {
88
+ timeZone: timeZone
89
+ });
90
+ }
91
+ return new Intl.DateTimeFormat(locale, options).format(value);
92
+ });
93
+ }
94
+ function number(value, formatOrOptions) {
95
+ return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.number, function (options) {
96
+ return new Intl.NumberFormat(locale, options).format(value);
97
+ });
98
+ }
99
+ function relativeTime( /** The date time that needs to be formatted. */
100
+ date, /** The reference point in time to which `date` will be formatted in relation to. */
101
+ now) {
102
+ try {
103
+ if (!now) {
104
+ if (globalNow) {
105
+ now = globalNow;
106
+ } else {
107
+ throw new Error(process.env.NODE_ENV !== 'production' ? "The `now` parameter wasn't provided and there was no global fallback configured on the provider." : undefined);
108
+ }
109
+ }
110
+ var dateDate = date instanceof Date ? date : new Date(date);
111
+ var nowDate = now instanceof Date ? now : new Date(now);
112
+ var seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;
113
+ var _getRelativeTimeForma = getRelativeTimeFormatConfig(seconds),
114
+ unit = _getRelativeTimeForma.unit,
115
+ value = _getRelativeTimeForma.value;
116
+ return new Intl.RelativeTimeFormat(locale, {
117
+ numeric: 'auto'
118
+ }).format(value, unit);
119
+ } catch (error) {
120
+ onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
121
+ return String(date);
122
+ }
123
+ }
124
+ function list(value, formatOrOptions) {
125
+ return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.list, function (options) {
126
+ return new Intl.ListFormat(locale, options).format(value);
127
+ });
128
+ }
129
+ return {
130
+ dateTime: dateTime,
131
+ number: number,
132
+ relativeTime: relativeTime,
133
+ list: list
134
+ };
135
+ }
136
+
137
+ export { createFormatter as default };
138
+ //# sourceMappingURL=use-intl.esm3.js.map