use-intl 3.0.0-beta.1 → 3.0.0-beta.3

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 (206) hide show
  1. package/_IntlProvider.d.ts +1 -0
  2. package/_useLocale.d.ts +1 -0
  3. package/core.d.ts +1 -1
  4. package/dist/_IntlProvider.js +7 -0
  5. package/dist/_useLocale.js +7 -0
  6. package/dist/core.js +3 -4
  7. package/dist/development/IntlContext-b5cc6be8.js +8 -0
  8. package/dist/development/_IntlProvider.js +27 -0
  9. package/dist/development/_useLocale-321e619f.js +19 -0
  10. package/dist/development/_useLocale.js +11 -0
  11. package/dist/development/core.js +92 -0
  12. package/dist/development/createIntl-dfba4462.js +421 -0
  13. package/dist/development/index.js +31 -0
  14. package/dist/development/initializeConfig-cde42612.js +119 -0
  15. package/dist/development/react.js +160 -0
  16. package/dist/esm/IntlContext-381f3ce4.js +1 -0
  17. package/dist/esm/_IntlProvider.js +1 -0
  18. package/dist/esm/_useLocale-89b32eb9.js +1 -0
  19. package/dist/esm/_useLocale.js +1 -0
  20. package/dist/esm/core.js +1 -0
  21. package/dist/esm/createIntl-164a7766.js +1 -0
  22. package/dist/esm/index.js +1 -0
  23. package/dist/esm/initializeConfig-c316f266.js +1 -0
  24. package/dist/esm/react.js +1 -0
  25. package/dist/index.js +3 -4
  26. package/dist/production/IntlContext-381f3ce4.js +1 -0
  27. package/dist/production/_IntlProvider.js +1 -0
  28. package/dist/production/_useLocale-8e23751a.js +1 -0
  29. package/dist/production/_useLocale.js +1 -0
  30. package/dist/production/core.js +1 -0
  31. package/dist/production/createIntl-e408cd5c.js +1 -0
  32. package/dist/production/index.js +1 -0
  33. package/dist/production/initializeConfig-984a566d.js +1 -0
  34. package/dist/production/react.js +1 -0
  35. package/dist/react.js +3 -4
  36. package/dist/types/src/_IntlProvider.d.ts +1 -0
  37. package/dist/types/src/_useLocale.d.ts +1 -0
  38. package/dist/{core → types/src/core}/AbstractIntlMessages.d.ts +9 -9
  39. package/dist/{core → types/src/core}/DateTimeFormatOptions.d.ts +73 -73
  40. package/dist/{core → types/src/core}/Formats.d.ts +8 -8
  41. package/dist/{core → types/src/core}/IntlConfig.d.ts +54 -54
  42. package/dist/{core → types/src/core}/IntlError.d.ts +13 -13
  43. package/dist/types/src/core/MessageFormatCache.d.ts +5 -0
  44. package/dist/{core → types/src/core}/NumberFormatOptions.d.ts +2 -2
  45. package/dist/{core → types/src/core}/TimeZone.d.ts +2 -2
  46. package/dist/{core → types/src/core}/TranslationValues.d.ts +6 -6
  47. package/dist/{core → types/src/core}/convertFormatsToIntlMessageFormat.d.ts +11 -11
  48. package/dist/{core → types/src/core}/createBaseTranslator.d.ts +21 -21
  49. package/dist/{core → types/src/core}/createFormatter.d.ts +19 -19
  50. package/dist/{core → types/src/core}/createIntl.d.ts +7 -7
  51. package/dist/{core → types/src/core}/createTranslator.d.ts +47 -47
  52. package/dist/{core → types/src/core}/createTranslatorImpl.d.ts +13 -13
  53. package/dist/{core → types/src/core}/defaults.d.ts +11 -11
  54. package/dist/{core → types/src/core}/index.d.ts +16 -16
  55. package/dist/{core → types/src/core}/initializeConfig.d.ts +14 -13
  56. package/dist/{core → types/src/core}/resolveNamespace.d.ts +5 -5
  57. package/dist/{core → types/src/core}/utils/MessageKeys.d.ts +5 -5
  58. package/dist/{core → types/src/core}/utils/NamespaceKeys.d.ts +5 -5
  59. package/dist/{core → types/src/core}/utils/NestedKeyOf.d.ts +4 -4
  60. package/dist/{core → types/src/core}/utils/NestedValueOf.d.ts +2 -2
  61. package/dist/{core → types/src/core}/validateMessages.d.ts +3 -3
  62. package/dist/{core.d.ts → types/src/core.d.ts} +1 -1
  63. package/dist/{index.d.ts → types/src/index.d.ts} +2 -2
  64. package/dist/types/src/react/IntlContext.d.ts +13 -0
  65. package/dist/{react → types/src/react}/IntlProvider.d.ts +7 -7
  66. package/dist/{react → types/src/react}/getInitializedConfig.d.ts +1 -1
  67. package/dist/{react → types/src/react}/index.d.ts +8 -8
  68. package/dist/{react → types/src/react}/useFormatter.d.ts +6 -6
  69. package/dist/{react → types/src/react}/useIntl.d.ts +6 -6
  70. package/dist/types/src/react/useIntlContext.d.ts +10 -0
  71. package/dist/{react → types/src/react}/useLocale.d.ts +1 -1
  72. package/dist/{react → types/src/react}/useMessages.d.ts +1 -1
  73. package/dist/{react → types/src/react}/useNow.d.ts +23 -23
  74. package/dist/{react → types/src/react}/useTimeZone.d.ts +1 -1
  75. package/dist/{react → types/src/react}/useTranslations.d.ts +44 -44
  76. package/dist/{react → types/src/react}/useTranslationsImpl.d.ts +8 -8
  77. package/dist/{react.d.ts → types/src/react.d.ts} +1 -1
  78. package/dist/types/test/core/createFormatter.test.d.ts +1 -0
  79. package/dist/types/test/core/createIntl.test.d.ts +1 -0
  80. package/dist/types/test/core/createTranslator.test.d.ts +1 -0
  81. package/dist/types/test/react/useFormatter.test.d.ts +1 -0
  82. package/dist/types/test/react/useIntl.test.d.ts +1 -0
  83. package/dist/types/test/react/useLocale.test.d.ts +1 -0
  84. package/dist/types/test/react/useMessages.test.d.ts +1 -0
  85. package/dist/types/test/react/useNow.test.d.ts +1 -0
  86. package/dist/types/test/react/useTimeZone.test.d.ts +1 -0
  87. package/dist/types/test/react/useTranslations.test.d.ts +1 -0
  88. package/dist/{test → types/test}/setup.d.ts +1 -1
  89. package/package.json +33 -21
  90. package/react.d.ts +1 -1
  91. package/dist/_virtual/_rollupPluginBabelHelpers.esm.js +0 -102
  92. package/dist/_virtual/_rollupPluginBabelHelpers.esm.js.map +0 -1
  93. package/dist/_virtual/use-intl.esm.js +0 -102
  94. package/dist/_virtual/use-intl.esm.js.map +0 -1
  95. package/dist/core/IntlError.esm.js +0 -33
  96. package/dist/core/IntlError.esm.js.map +0 -1
  97. package/dist/core/convertFormatsToIntlMessageFormat.esm.js +0 -32
  98. package/dist/core/convertFormatsToIntlMessageFormat.esm.js.map +0 -1
  99. package/dist/core/createBaseTranslator.esm.js +0 -201
  100. package/dist/core/createBaseTranslator.esm.js.map +0 -1
  101. package/dist/core/createFormatter.esm.js +0 -138
  102. package/dist/core/createFormatter.esm.js.map +0 -1
  103. package/dist/core/createIntl.esm.js +0 -14
  104. package/dist/core/createIntl.esm.js.map +0 -1
  105. package/dist/core/createTranslator.esm.js +0 -37
  106. package/dist/core/createTranslator.esm.js.map +0 -1
  107. package/dist/core/createTranslatorImpl.esm.js +0 -50
  108. package/dist/core/createTranslatorImpl.esm.js.map +0 -1
  109. package/dist/core/defaults.esm.js +0 -15
  110. package/dist/core/defaults.esm.js.map +0 -1
  111. package/dist/core/initializeConfig.esm.js +0 -29
  112. package/dist/core/initializeConfig.esm.js.map +0 -1
  113. package/dist/core/resolveNamespace.esm.js +0 -10
  114. package/dist/core/resolveNamespace.esm.js.map +0 -1
  115. package/dist/core/use-intl.esm.js +0 -37
  116. package/dist/core/use-intl.esm.js.map +0 -1
  117. package/dist/core/use-intl.esm10.js +0 -28
  118. package/dist/core/use-intl.esm10.js.map +0 -1
  119. package/dist/core/use-intl.esm11.js +0 -10
  120. package/dist/core/use-intl.esm11.js.map +0 -1
  121. package/dist/core/use-intl.esm2.js +0 -33
  122. package/dist/core/use-intl.esm2.js.map +0 -1
  123. package/dist/core/use-intl.esm3.js +0 -14
  124. package/dist/core/use-intl.esm3.js.map +0 -1
  125. package/dist/core/use-intl.esm4.js +0 -201
  126. package/dist/core/use-intl.esm4.js.map +0 -1
  127. package/dist/core/use-intl.esm5.js +0 -29
  128. package/dist/core/use-intl.esm5.js.map +0 -1
  129. package/dist/core/use-intl.esm6.js +0 -138
  130. package/dist/core/use-intl.esm6.js.map +0 -1
  131. package/dist/core/use-intl.esm7.js +0 -15
  132. package/dist/core/use-intl.esm7.js.map +0 -1
  133. package/dist/core/use-intl.esm8.js +0 -50
  134. package/dist/core/use-intl.esm8.js.map +0 -1
  135. package/dist/core/use-intl.esm9.js +0 -32
  136. package/dist/core/use-intl.esm9.js.map +0 -1
  137. package/dist/core/validateMessages.esm.js +0 -28
  138. package/dist/core/validateMessages.esm.js.map +0 -1
  139. package/dist/core.cjs.development.js +0 -93
  140. package/dist/core.cjs.development.js.map +0 -1
  141. package/dist/core.cjs.production.min.js +0 -2
  142. package/dist/core.cjs.production.min.js.map +0 -1
  143. package/dist/core.esm.js +0 -7
  144. package/dist/core.esm.js.map +0 -1
  145. package/dist/createIntl-8a2b87eb.js +0 -579
  146. package/dist/createIntl-8a2b87eb.js.map +0 -1
  147. package/dist/createIntl-f7979de1.js +0 -2
  148. package/dist/createIntl-f7979de1.js.map +0 -1
  149. package/dist/react/IntlContext.d.ts +0 -4
  150. package/dist/react/IntlContext.esm.js +0 -6
  151. package/dist/react/IntlContext.esm.js.map +0 -1
  152. package/dist/react/IntlProvider.esm.js +0 -16
  153. package/dist/react/IntlProvider.esm.js.map +0 -1
  154. package/dist/react/use-intl.esm.js +0 -26
  155. package/dist/react/use-intl.esm.js.map +0 -1
  156. package/dist/react/use-intl.esm10.js +0 -13
  157. package/dist/react/use-intl.esm10.js.map +0 -1
  158. package/dist/react/use-intl.esm11.js +0 -6
  159. package/dist/react/use-intl.esm11.js.map +0 -1
  160. package/dist/react/use-intl.esm2.js +0 -24
  161. package/dist/react/use-intl.esm2.js.map +0 -1
  162. package/dist/react/use-intl.esm3.js +0 -45
  163. package/dist/react/use-intl.esm3.js.map +0 -1
  164. package/dist/react/use-intl.esm4.js +0 -16
  165. package/dist/react/use-intl.esm4.js.map +0 -1
  166. package/dist/react/use-intl.esm5.js +0 -8
  167. package/dist/react/use-intl.esm5.js.map +0 -1
  168. package/dist/react/use-intl.esm6.js +0 -8
  169. package/dist/react/use-intl.esm6.js.map +0 -1
  170. package/dist/react/use-intl.esm7.js +0 -30
  171. package/dist/react/use-intl.esm7.js.map +0 -1
  172. package/dist/react/use-intl.esm8.js +0 -8
  173. package/dist/react/use-intl.esm8.js.map +0 -1
  174. package/dist/react/use-intl.esm9.js +0 -36
  175. package/dist/react/use-intl.esm9.js.map +0 -1
  176. package/dist/react/useFormatter.esm.js +0 -24
  177. package/dist/react/useFormatter.esm.js.map +0 -1
  178. package/dist/react/useIntl.esm.js +0 -30
  179. package/dist/react/useIntl.esm.js.map +0 -1
  180. package/dist/react/useIntlContext.d.ts +0 -1
  181. package/dist/react/useIntlContext.esm.js +0 -13
  182. package/dist/react/useIntlContext.esm.js.map +0 -1
  183. package/dist/react/useLocale.esm.js +0 -8
  184. package/dist/react/useLocale.esm.js.map +0 -1
  185. package/dist/react/useMessages.esm.js +0 -8
  186. package/dist/react/useMessages.esm.js.map +0 -1
  187. package/dist/react/useNow.esm.js +0 -45
  188. package/dist/react/useNow.esm.js.map +0 -1
  189. package/dist/react/useTimeZone.esm.js +0 -8
  190. package/dist/react/useTimeZone.esm.js.map +0 -1
  191. package/dist/react/useTranslations.esm.js +0 -26
  192. package/dist/react/useTranslations.esm.js.map +0 -1
  193. package/dist/react/useTranslationsImpl.esm.js +0 -36
  194. package/dist/react/useTranslationsImpl.esm.js.map +0 -1
  195. package/dist/react.cjs.development.js +0 -184
  196. package/dist/react.cjs.development.js.map +0 -1
  197. package/dist/react.cjs.production.min.js +0 -2
  198. package/dist/react.cjs.production.min.js.map +0 -1
  199. package/dist/react.esm.js +0 -9
  200. package/dist/react.esm.js.map +0 -1
  201. package/dist/use-intl.cjs.development.js +0 -823
  202. package/dist/use-intl.cjs.development.js.map +0 -1
  203. package/dist/use-intl.cjs.production.min.js +0 -2
  204. package/dist/use-intl.cjs.production.min.js.map +0 -1
  205. package/dist/use-intl.esm.js +0 -15
  206. package/dist/use-intl.esm.js.map +0 -1
@@ -1,2 +0,0 @@
1
- "use strict";var r=require("intl-messageformat"),e=require("react");function t(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var n,o=t(r);function a(){return a=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},a.apply(this,arguments)}function i(r){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},i(r)}function u(r,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},u(r,e)}function c(r,e,t){return c=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(r){return!1}}()?Reflect.construct.bind():function(r,e,t){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(r,n));return t&&u(o,t.prototype),o},c.apply(null,arguments)}function s(r){var e="function"==typeof Map?new Map:void 0;return s=function(r){if(null===r||-1===Function.toString.call(r).indexOf("[native code]"))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(r))return e.get(r);e.set(r,t)}function t(){return c(r,arguments,i(this).constructor)}return t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),u(t,r)},s(r)}function l(r,e){if(null==r)return{};var t,n,o={},a=Object.keys(r);for(n=0;n<a.length;n++)e.indexOf(t=a[n])>=0||(o[t]=r[t]);return o}exports.IntlErrorCode=void 0,(n=exports.IntlErrorCode||(exports.IntlErrorCode={})).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";var f=function(r){var e,t;function n(e,t){var n,o=e;return t&&(o+=": "+t),(n=r.call(this,o)||this).code=void 0,n.originalMessage=void 0,n.code=e,t&&(n.originalMessage=t),n}return t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,u(e,t),n}(s(Error));function p(r,e){return r?Object.keys(r).reduce((function(t,n){return t[n]=a({timeZone:e},r[n]),t}),{}):r}function d(r){return[r.namespace,r.key].filter((function(r){return null!=r})).join(".")}function m(r){console.error(r)}function v(r,e,t){if(!r)throw new Error(void 0);var n=r;return e.split(".").forEach((function(r){var e=n[r];if(null==r||null==e)throw new Error(void 0);n=e})),n}var E=86400,I=7*E,y=2628e3,g=365*E;function S(r){var e=r.formats,t=r.locale,n=r.now,o=r.onError,i=void 0===o?m:o,u=r.timeZone;function c(r,e,t,n){var o;try{o=function(r,e){var t;if("string"==typeof e){if(!(t=null==r?void 0:r[e])){var n=new f(exports.IntlErrorCode.MISSING_FORMAT,void 0);throw i(n),n}}else t=e;return t}(t,e)}catch(e){return String(r)}try{return n(o)}catch(e){return i(new f(exports.IntlErrorCode.FORMATTING_ERROR,e.message)),String(r)}}return{dateTime:function(r,n){return c(r,n,null==e?void 0:e.dateTime,(function(e){var n;return!u||null!=(n=e)&&n.timeZone||(e=a({},e,{timeZone:u})),new Intl.DateTimeFormat(t,e).format(r)}))},number:function(r,n){return c(r,n,null==e?void 0:e.number,(function(e){return new Intl.NumberFormat(t,e).format(r)}))},relativeTime:function(r,e){try{if(!e){if(!n)throw new Error(void 0);e=n}var o=r instanceof Date?r:new Date(r),a=e instanceof Date?e:new Date(e),u=function(r){var e,t,n=Math.abs(r);return n<60?(t="second",e=Math.round(r)):n<3600?(t="minute",e=Math.round(r/60)):n<E?(t="hour",e=Math.round(r/3600)):n<I?(t="day",e=Math.round(r/E)):n<y?(t="week",e=Math.round(r/I)):n<g?(t="month",e=Math.round(r/y)):(t="year",e=Math.round(r/g)),{value:e,unit:t}}((o.getTime()-a.getTime())/1e3),c=u.unit,s=u.value;return new Intl.RelativeTimeFormat(t,{numeric:"auto"}).format(s,c)}catch(e){return i(new f(exports.IntlErrorCode.FORMATTING_ERROR,e.message)),String(r)}},list:function(r,n){return c(r,n,null==e?void 0:e.list,(function(e){return new Intl.ListFormat(t,e).format(r)}))}}}var h=["getMessageFallback","messages","onError"];exports.IntlError=f,exports._extends=a,exports._objectWithoutPropertiesLoose=l,exports.createBaseTranslator=function(r){return function(r){var t=r.cachedFormatsByLocale,n=r.defaultTranslationValues,i=r.formats,u=r.getMessageFallback,c=void 0===u?d:u,s=r.locale,l=r.messagesOrError,m=r.namespace,E=r.onError,I=r.timeZone;function y(r,e,t){var n=new f(e,t);return E(n),c({error:n,key:r,namespace:m})}function g(r,u,d){var E;if(l instanceof f)return c({error:l,key:r,namespace:m});var g,S=l;try{g=v(S,r)}catch(e){return y(r,exports.IntlErrorCode.MISSING_MESSAGE,e.message)}var h,M=[m,r,String(g)].filter((function(r){return null!=r})).join(".");if(null!=t&&null!=(E=t[s])&&E[M])h=null==t?void 0:t[s][M];else{if("object"==typeof g)return y(r,Array.isArray(g)?exports.IntlErrorCode.INVALID_MESSAGE:exports.IntlErrorCode.INSUFFICIENT_PATH,void 0);try{h=new o.default(g,s,function(r,e){var t=e?a({},r,{dateTime:p(r.dateTime,e)}):r;return a({},t,{date:null==t?void 0:t.dateTime,time:null==t?void 0:t.dateTime})}(a({},i,d),I))}catch(e){return y(r,exports.IntlErrorCode.INVALID_MESSAGE,e.message)}t&&(t[s]||(t[s]={}),t[s][M]=h)}try{var O=h.format(function(r){if(0!==Object.keys(r).length){var t={};return Object.keys(r).forEach((function(n){var o=0,a=r[n];t[n]="function"==typeof a?function(r){var t=a(r);return e.isValidElement(t)?e.cloneElement(t,{key:n+o++}):t}:a})),t}}(a({},n,u)));if(null==O)throw new Error(void 0);return e.isValidElement(O)||Array.isArray(O)||"string"==typeof O?O:String(O)}catch(e){return y(r,exports.IntlErrorCode.FORMATTING_ERROR,e.message)}}function S(r,e,t){var n=g(r,e,t);return"string"!=typeof n?y(r,exports.IntlErrorCode.INVALID_MESSAGE,void 0):n}return S.rich=g,S.raw=function(r){if(l instanceof f)return c({error:l,key:r,namespace:m});var e=l;try{return v(e,r)}catch(e){return y(r,exports.IntlErrorCode.MISSING_MESSAGE,e.message)}},S}(a({},r,{messagesOrError:function(r){var e=r.messages,t=r.namespace,n=r.onError,o=void 0===n?m:n;try{if(!e)throw new Error(void 0);var a=t?v(e,t):e;if(!a)throw new Error(void 0);return a}catch(r){var i=new f(exports.IntlErrorCode.MISSING_MESSAGE,r.message);return o(i),i}}({messages:r.messages,namespace:r.namespace,onError:r.onError})}))},exports.createFormatter=S,exports.createIntl=function(){var r=S.apply(void 0,arguments);return{formatDateTime:r.dateTime,formatNumber:r.number,formatRelativeTime:r.relativeTime}},exports.defaultGetMessageFallback=d,exports.defaultOnError=m,exports.initializeConfig=function(r){var e=r.getMessageFallback,t=r.messages,n=r.onError;return a({},l(r,h),{messages:t,onError:n||m,getMessageFallback:e||d})},exports.resolveNamespace=function(r,e){return r===e?void 0:r.slice((e+".").length)};
2
- //# sourceMappingURL=createIntl-f7979de1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createIntl-f7979de1.js","sources":["../src/core/IntlError.tsx","../src/core/convertFormatsToIntlMessageFormat.tsx","../src/core/defaults.tsx","../src/core/createBaseTranslator.tsx","../src/core/createFormatter.tsx","../src/core/createIntl.tsx","../src/core/initializeConfig.tsx","../src/core/resolveNamespace.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","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","import IntlError from './IntlError';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return [props.namespace, props.key].filter((part) => part != null).join('.');\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n","// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray\n} from 'react';\nimport AbstractIntlMessages from './AbstractIntlMessages';\nimport Formats from './Formats';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: AbstractIntlMessages | undefined,\n key: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages available at \\`${namespace}\\`.`\n : undefined\n );\n }\n\n let message = messages;\n\n key.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Could not resolve \\`${key}\\` in ${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }.`\n : undefined\n );\n }\n\n message = next;\n });\n\n return message;\n}\n\nfunction prepareTranslationValues(values: RichTranslationValues) {\n if (Object.keys(values).length === 0) return undefined;\n\n // Workaround for https://github.com/formatjs/formatjs/issues/1467\n const transformedValues: RichTranslationValues = {};\n Object.keys(values).forEach((key) => {\n let index = 0;\n const value = values[key];\n\n let transformed;\n if (typeof value === 'function') {\n transformed = (chunks: ReactNode) => {\n const result = value(chunks);\n\n return isValidElement(result)\n ? cloneElement(result, {key: key + index++})\n : result;\n };\n } else {\n transformed = value;\n }\n\n transformedValues[key] = transformed;\n });\n\n return transformedValues;\n}\n\nfunction getMessagesOrError<Messages extends AbstractIntlMessages>({\n messages,\n namespace,\n onError = defaultOnError\n}: {\n messages?: Messages;\n namespace?: string;\n onError?(error: IntlError): void;\n}) {\n try {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages were configured on the provider.`\n : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(messages, namespace)\n : messages;\n\n if (!retrievedMessages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages for namespace \\`${namespace}\\` found.`\n : undefined\n );\n }\n\n return retrievedMessages;\n } catch (error) {\n const intlError = new IntlError(\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n onError(intlError);\n return intlError;\n }\n}\n\nexport type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {\n cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;\n defaultTranslationValues?: RichTranslationValues;\n namespace?: string;\n messagesOrError: Messages | IntlError;\n};\n\nexport default function createBaseTranslator<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(config: Omit<CreateBaseTranslatorProps<Messages>, 'messagesOrError'>) {\n const messagesOrError = getMessagesOrError({\n messages: config.messages,\n namespace: config.namespace,\n onError: config.onError\n }) as Messages | IntlError;\n\n return createBaseTranslatorImpl<Messages, NestedKey>({\n ...config,\n messagesOrError\n });\n}\n\nfunction createBaseTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>({\n cachedFormatsByLocale,\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback = defaultGetMessageFallback,\n locale,\n messagesOrError,\n namespace,\n onError,\n timeZone\n}: CreateBaseTranslatorProps<Messages>) {\n function getFallbackFromErrorAndNotify(\n key: string,\n code: IntlErrorCode,\n message?: string\n ) {\n const error = new IntlError(code, message);\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n function translateBaseFn(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string,\n /** Key value pairs for values to interpolate into the message. */\n values?: RichTranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n let message;\n try {\n message = resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n\n function joinPath(parts: Array<string | undefined>) {\n return parts.filter((part) => part != null).join('.');\n }\n\n const cacheKey = joinPath([namespace, key, String(message)]);\n\n let messageFormat;\n if (cachedFormatsByLocale?.[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale?.[locale][cacheKey];\n } else {\n if (typeof message === 'object') {\n let code, errorMessage;\n if (Array.isArray(message)) {\n code = IntlErrorCode.INVALID_MESSAGE;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;\n }\n } else {\n code = IntlErrorCode.INSUFFICIENT_PATH;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an object, but only strings are supported. Use a \\`.\\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`;\n }\n }\n\n return getFallbackFromErrorAndNotify(key, code, errorMessage);\n }\n\n try {\n messageFormat = new IntlMessageFormat(\n message,\n locale,\n convertFormatsToIntlMessageFormat(\n {...globalFormats, ...formats},\n timeZone\n )\n );\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n (error as Error).message\n );\n }\n\n if (cachedFormatsByLocale) {\n if (!cachedFormatsByLocale[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n }\n\n try {\n const formattedMessage = messageFormat.format(\n // @ts-ignore `intl-messageformat` expects a different format\n // for rich text elements since a recent minor update. This\n // needs to be evaluated in detail, possibly also in regards\n // to be able to format to parts.\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Unable to format \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n }`\n : undefined\n );\n }\n\n // Limit the function signature to return strings or React elements\n return isValidElement(formattedMessage) ||\n // Arrays of React elements\n Array.isArray(formattedMessage) ||\n typeof formattedMessage === 'string'\n ? formattedMessage\n : String(formattedMessage);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.FORMATTING_ERROR,\n (error as Error).message\n );\n }\n }\n\n function translateFn<\n TargetKey extends MessageKeys<\n NestedValueOf<Messages, NestedKey>,\n NestedKeyOf<NestedValueOf<Messages, NestedKey>>\n >\n >(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: TargetKey,\n /** Key value pairs for values to interpolate into the message. */\n values?: TranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string {\n const result = translateBaseFn(key, values, formats);\n\n if (typeof result !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n process.env.NODE_ENV !== 'production'\n ? `The message \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n } didn't resolve to a string. If you want to format rich text, use \\`t.rich\\` instead.`\n : undefined\n );\n }\n\n return result;\n }\n\n translateFn.rich = translateBaseFn;\n\n translateFn.raw = (\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string\n ): any => {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n try {\n return resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n };\n\n return translateFn;\n}\n","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n","import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n","import IntlConfig from './IntlConfig';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport validateMessages from './validateMessages';\n\n/**\n * Enhances the incoming props with defaults.\n */\nexport default function initializeConfig<\n // This is a generic to allow for stricter typing. E.g.\n // the RSC integration always provides a `now` value.\n Props extends Omit<IntlConfig, 'children'>\n>({getMessageFallback, messages, onError, ...rest}: Props) {\n const finalOnError = onError || defaultOnError;\n const finalGetMessageFallback =\n getMessageFallback || defaultGetMessageFallback;\n\n if (process.env.NODE_ENV !== 'production') {\n if (messages) {\n validateMessages(messages, finalOnError);\n }\n }\n\n return {\n ...rest,\n messages,\n onError: finalOnError,\n getMessageFallback: finalGetMessageFallback\n };\n}\n","/**\n * For the strictly typed messages to work we have to wrap the namespace into\n * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045\n */\nexport default function resolveNamespace(\n namespace: string,\n namespacePrefix: string\n) {\n return namespace === namespacePrefix\n ? undefined\n : namespace.slice((namespacePrefix + '.').length);\n}\n"],"names":["IntlErrorCode","IntlError","_Error","code","originalMessage","_this","message","call","this","_wrapNativeSuper","Error","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","key","_extends","defaultGetMessageFallback","props","namespace","filter","part","join","defaultOnError","error","console","resolvePath","messages","undefined","split","forEach","next","DAY","HOUR","WEEK","MONTH","YEAR","createFormatter","_ref","locale","globalNow","now","_ref$onError","onError","getFormattedValue","value","formatOrOptions","typeFormats","formatter","options","MISSING_FORMAT","resolveFormatOrOptions","String","FORMATTING_ERROR","dateTime","_options","Intl","DateTimeFormat","format","number","NumberFormat","relativeTime","date","dateDate","Date","nowDate","_getRelativeTimeForma","seconds","unit","absValue","Math","abs","round","MINUTE","getRelativeTimeFormatConfig","getTime","RelativeTimeFormat","numeric","list","ListFormat","config","_ref2","cachedFormatsByLocale","defaultTranslationValues","globalFormats","_ref2$getMessageFallb","getMessageFallback","messagesOrError","getFallbackFromErrorAndNotify","translateBaseFn","values","_cachedFormatsByLocal","MISSING_MESSAGE","messageFormat","cacheKey","Array","isArray","INVALID_MESSAGE","INSUFFICIENT_PATH","errorMessage","IntlMessageFormat","formatsWithTimeZone","time","convertFormatsToIntlMessageFormat","formattedMessage","length","transformedValues","index","chunks","result","isValidElement","cloneElement","prepareTranslationValues","translateFn","rich","raw","createBaseTranslatorImpl","retrievedMessages","intlError","getMessagesOrError","apply","arguments","formatDateTime","formatNumber","formatRelativeTime","_objectWithoutPropertiesLoose","_excluded","namespacePrefix","slice"],"mappings":"gJAAYA,yhDAAAA,QAOXA,mBAAA,GAPWA,EAAAA,wBAAAA,QAAAA,cAOX,CAAA,IANC,gBAAA,kBACAA,EAAA,eAAA,iBACAA,EAAA,kBAAA,oBACAA,EAAA,gBAAA,kBACAA,EAAA,YAAA,cACAA,EAAA,iBAAA,mBAGmBC,IAAAA,WAAUC,WAI7B,SAAAD,EAAYE,EAAqBC,GAAwB,IAAAC,EACnDC,EAAkBH,EASrB,OARGC,IACFE,GAAW,KAAOF,IAEpBC,EAAAH,EAAAK,KAAAC,KAAMF,IAAQE,MARAL,UAAI,EAAAE,EACJD,qBAAe,EAS7BC,EAAKF,KAAOA,EACRC,IACFC,EAAKD,gBAAkBA,GACxBC,CACH,CAAC,SAf4BH,KAAAD,yEAe5BA,CAAA,EAAAQ,EAfoCC,QCJvC,SAASC,EACPC,EACAC,GAEA,OAAKD,EAIEE,OAAOC,KAAKH,GAASI,QAC1B,SAACC,EAA4CC,GAK3C,OAJAD,EAAIC,GAAIC,EAAA,CACNN,SAAAA,GACGD,EAAQM,IAEND,CACR,GACD,CAAE,GAZiBL,CAcvB,CChBM,SAAUQ,EAA0BC,GAKxC,MAAO,CAACA,EAAMC,UAAWD,EAAMH,KAAKK,QAAO,SAACC,GAAI,OAAa,MAARA,CAAY,IAAEC,KAAK,IAC1E,C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DA,CACR,CACH,CAa0BC,CAAmB,CACzC5F,SAAUqD,EAAOrD,SACjBR,UAAW6D,EAAO7D,UAClBwB,QAASqC,EAAOrC,YAOpB,+CE7Ic,WAGZ,IAAMK,EAAYX,EAAemF,WAAA,EAAAC,WACjC,MAAO,CACLC,eAAgB1E,EAAUM,SAC1BqE,aAAc3E,EAAUW,OACxBiE,mBAAoB5E,EAAUa,aAElC,wFCLwB,SAAgBvB,GAIiB,IAAtDgD,EAAkBhD,EAAlBgD,mBAAoB3D,EAAQW,EAARX,SAAUgB,EAAOL,EAAPK,QAW/B,OAAA3B,KAX+C6G,EAAAvF,EAAAwF,GAYtC,CACPnG,SAAAA,EACAgB,QAbmBA,GAAWpB,EAc9B+D,mBAZAA,GAAsBrE,GAc1B,2BCxBc,SACZE,EACA4G,GAEA,OAAO5G,IAAc4G,OACjBnG,EACAT,EAAU6G,OAAOD,EAAkB,KAAKtB,OAC9C"}
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { InitializedIntlConfig } from '../core/IntlConfig';
3
- declare const IntlContext: import("react").Context<InitializedIntlConfig<import("../core/AbstractIntlMessages").default> | undefined>;
4
- export default IntlContext;
@@ -1,6 +0,0 @@
1
- import { createContext } from 'react';
2
-
3
- var IntlContext = /*#__PURE__*/createContext(undefined);
4
-
5
- export { IntlContext as default };
6
- //# sourceMappingURL=IntlContext.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlContext.esm.js","sources":["../../src/react/IntlContext.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport {InitializedIntlConfig} from '../core/IntlConfig';\n\nconst IntlContext = createContext<InitializedIntlConfig | undefined>(undefined);\n\nexport default IntlContext;\n"],"names":["IntlContext","createContext","undefined"],"mappings":";;AAGA,IAAMA,WAAW,gBAAGC,aAAa,CAAoCC,SAAS;;;;"}
@@ -1,16 +0,0 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../_virtual/_rollupPluginBabelHelpers.esm.js';
2
- import React from 'react';
3
- import initializeConfig from '../core/initializeConfig.esm.js';
4
- import IntlContext from './IntlContext.esm.js';
5
-
6
- var _excluded = ["children"];
7
- function IntlProvider(_ref) {
8
- var children = _ref.children,
9
- config = _objectWithoutPropertiesLoose(_ref, _excluded);
10
- return React.createElement(IntlContext.Provider, {
11
- value: initializeConfig(config)
12
- }, children);
13
- }
14
-
15
- export { IntlProvider as default };
16
- //# sourceMappingURL=IntlProvider.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlProvider.esm.js","sources":["../../src/react/IntlProvider.tsx"],"sourcesContent":["import React, {ReactNode} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport initializeConfig from '../core/initializeConfig';\nimport IntlContext from './IntlContext';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...config}: Props) {\n return (\n <IntlContext.Provider value={initializeConfig(config)}>\n {children}\n </IntlContext.Provider>\n );\n}\n"],"names":["IntlProvider","_ref","children","config","_objectWithoutPropertiesLoose","_excluded","React","createElement","IntlContext","Provider","value","initializeConfig"],"mappings":";;;;;;AASc,SAAUA,YAAYA,CAAAC,IAAA,EAA6B;AAAA,EAAA,IAA3BC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;AAAKC,IAAAA,MAAM,GAAAC,6BAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;AACvD,EAAA,OACEC,KAAC,CAAAC,aAAA,CAAAC,WAAW,CAACC,QAAQ;IAACC,KAAK,EAAEC,gBAAgB,CAACR,MAAM,CAAA;GAAC,EAClDD,QAAQ,CACY,CAAA;AAE3B;;;;"}
@@ -1,26 +0,0 @@
1
- import useIntlContext from './use-intl.esm10.js';
2
- import useTranslationsImpl from './use-intl.esm9.js';
3
-
4
- /**
5
- * Translates messages from the given namespace by using the ICU syntax.
6
- * See https://formatjs.io/docs/core-concepts/icu-syntax.
7
- *
8
- * If no namespace is provided, all available messages are returned.
9
- * The namespace can also indicate nesting by using a dot
10
- * (e.g. `namespace.Component`).
11
- */
12
- function useTranslations(namespace) {
13
- var context = useIntlContext();
14
- var messages = context.messages;
15
- // We have to wrap the actual hook so the type inference for the optional
16
- // namespace works correctly. See https://stackoverflow.com/a/71529575/343045
17
- // The prefix ("!") is arbitrary.
18
- return useTranslationsImpl({
19
- '!': messages
20
- },
21
- // @ts-ignore
22
- namespace ? "!." + namespace : '!', '!');
23
- }
24
-
25
- export { useTranslations as default };
26
- //# sourceMappingURL=use-intl.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm.js","sources":["../../src/react/useTranslations.tsx"],"sourcesContent":["import {ReactElement, ReactNodeArray} from 'react';\nimport Formats from '../core/Formats';\nimport TranslationValues, {\n RichTranslationValues\n} from '../core/TranslationValues';\nimport MessageKeys from '../core/utils/MessageKeys';\nimport NamespaceKeys from '../core/utils/NamespaceKeys';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport NestedValueOf from '../core/utils/NestedValueOf';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function useTranslations<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>(\n namespace?: NestedKey\n): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: RichTranslationValues,\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n const context = useIntlContext();\n const messages = context.messages as IntlMessages;\n\n // We have to wrap the actual hook so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return useTranslationsImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {'!': messages},\n // @ts-ignore\n namespace ? `!.${namespace}` : '!',\n '!'\n );\n}\n"],"names":["useTranslations","namespace","context","useIntlContext","messages","useTranslationsImpl"],"mappings":";;;AAYA;;;;;;;AAOG;AACqB,SAAAA,eAAeA,CAMrCC,SAAqB,EAAA;AA6DrB,EAAA,IAAMC,OAAO,GAAGC,cAAc,EAAE,CAAA;AAChC,EAAA,IAAMC,QAAQ,GAAGF,OAAO,CAACE,QAAwB,CAAA;AAEjD;AACA;AACA;AACA,EAAA,OAAOC,mBAAmB,CAIxB;AAAC,IAAA,GAAG,EAAED,QAAAA;GAAS;AACf;AACAH,EAAAA,SAAS,UAAQA,SAAS,GAAK,GAAG,EAClC,GAAG,CACJ,CAAA;AACH;;;;"}
@@ -1,13 +0,0 @@
1
- import { useContext } from 'react';
2
- import IntlContext from './use-intl.esm11.js';
3
-
4
- function useIntlContext() {
5
- var context = useContext(IntlContext);
6
- if (!context) {
7
- throw new Error(process.env.NODE_ENV !== 'production' ? 'No intl context found. Have you configured the provider?' : undefined);
8
- }
9
- return context;
10
- }
11
-
12
- export { useIntlContext as default };
13
- //# sourceMappingURL=use-intl.esm10.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm10.js","sources":["../../src/react/useIntlContext.tsx"],"sourcesContent":["import {useContext} from 'react';\nimport IntlContext from './IntlContext';\n\nexport default function useIntlContext() {\n const context = useContext(IntlContext);\n\n if (!context) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n"],"names":["useIntlContext","context","useContext","IntlContext","Error","process","env","NODE_ENV","undefined"],"mappings":";;;AAGc,SAAUA,cAAcA,GAAA;AACpC,EAAA,IAAMC,OAAO,GAAGC,UAAU,CAACC,WAAW,CAAC,CAAA;EAEvC,IAAI,CAACF,OAAO,EAAE;AACZ,IAAA,MAAM,IAAIG,KAAK,CACbC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,0DAA0D,GAC1DC,SAAS,CACd,CAAA;AACF,GAAA;AAED,EAAA,OAAOP,OAAO,CAAA;AAChB;;;;"}
@@ -1,6 +0,0 @@
1
- import { createContext } from 'react';
2
-
3
- var IntlContext = /*#__PURE__*/createContext(undefined);
4
-
5
- export { IntlContext as default };
6
- //# sourceMappingURL=use-intl.esm11.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm11.js","sources":["../../src/react/IntlContext.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport {InitializedIntlConfig} from '../core/IntlConfig';\n\nconst IntlContext = createContext<InitializedIntlConfig | undefined>(undefined);\n\nexport default IntlContext;\n"],"names":["IntlContext","createContext","undefined"],"mappings":";;AAGA,IAAMA,WAAW,gBAAGC,aAAa,CAAoCC,SAAS;;;;"}
@@ -1,24 +0,0 @@
1
- import { useMemo } from 'react';
2
- import createFormatter from '../core/use-intl.esm6.js';
3
- import useIntlContext from './use-intl.esm10.js';
4
-
5
- function useFormatter() {
6
- var _useIntlContext = useIntlContext(),
7
- formats = _useIntlContext.formats,
8
- locale = _useIntlContext.locale,
9
- globalNow = _useIntlContext.now,
10
- onError = _useIntlContext.onError,
11
- timeZone = _useIntlContext.timeZone;
12
- return useMemo(function () {
13
- return createFormatter({
14
- formats: formats,
15
- locale: locale,
16
- now: globalNow,
17
- onError: onError,
18
- timeZone: timeZone
19
- });
20
- }, [formats, globalNow, locale, onError, timeZone]);
21
- }
22
-
23
- export { useFormatter as default };
24
- //# sourceMappingURL=use-intl.esm2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm2.js","sources":["../../src/react/useFormatter.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport createFormatter from '../core/createFormatter';\nimport useIntlContext from './useIntlContext';\n\nexport default function useFormatter() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n return useMemo(\n () =>\n createFormatter({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n"],"names":["useFormatter","_useIntlContext","useIntlContext","formats","locale","globalNow","now","onError","timeZone","useMemo","createFormatter"],"mappings":";;;;AAIc,SAAUA,YAAYA,GAAA;AAClC,EAAA,IAAAC,eAAA,GAA6DC,cAAc,EAAE;IAAtEC,OAAO,GAAAF,eAAA,CAAPE,OAAO;IAAEC,MAAM,GAAAH,eAAA,CAANG,MAAM;IAAOC,SAAS,GAAAJ,eAAA,CAAdK,GAAG;IAAaC,OAAO,GAAAN,eAAA,CAAPM,OAAO;IAAEC,QAAQ,GAAAP,eAAA,CAARO,QAAQ,CAAA;AAEzD,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,eAAe,CAAC;AACdP,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,MAAM,EAANA,MAAM;AACNE,MAAAA,GAAG,EAAED,SAAS;AACdE,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;GACJ,EAAA,CAACL,OAAO,EAAEE,SAAS,EAAED,MAAM,EAAEG,OAAO,EAAEC,QAAQ,CAAC,CAChD,CAAA;AACH;;;;"}
@@ -1,45 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- import useIntlContext from './use-intl.esm10.js';
3
-
4
- function getNow() {
5
- return new Date();
6
- }
7
- /**
8
- * Reading the current date via `new Date()` in components should be avoided, as
9
- * it causes components to be impure and can lead to flaky tests. Instead, this
10
- * hook can be used.
11
- *
12
- * By default, it returns the time when the component mounts. If `updateInterval`
13
- * is specified, the value will be updated based on the interval.
14
- *
15
- * You can however also return a static value from this hook, if you
16
- * configure the `now` parameter on the context provider. Note however,
17
- * that if `updateInterval` is configured in this case, the component
18
- * will initialize with the global value, but will afterwards update
19
- * continuously based on the interval.
20
- *
21
- * For unit tests, this can be mocked to a constant value. For end-to-end
22
- * testing, an environment parameter can be passed to the `now` parameter
23
- * of the provider to mock this to a static value.
24
- */
25
- function useNow(options) {
26
- var updateInterval = options == null ? void 0 : options.updateInterval;
27
- var _useIntlContext = useIntlContext(),
28
- globalNow = _useIntlContext.now;
29
- var _useState = useState(globalNow || getNow()),
30
- now = _useState[0],
31
- setNow = _useState[1];
32
- useEffect(function () {
33
- if (!updateInterval) return;
34
- var intervalId = setInterval(function () {
35
- setNow(getNow());
36
- }, updateInterval);
37
- return function () {
38
- clearInterval(intervalId);
39
- };
40
- }, [globalNow, updateInterval]);
41
- return now;
42
- }
43
-
44
- export { useNow as default };
45
- //# sourceMappingURL=use-intl.esm3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm3.js","sources":["../../src/react/useNow.tsx"],"sourcesContent":["import {useState, useEffect} from 'react';\nimport useIntlContext from './useIntlContext';\n\ntype Options = {\n updateInterval?: number;\n};\n\nfunction getNow() {\n return new Date();\n}\n\n/**\n * Reading the current date via `new Date()` in components should be avoided, as\n * it causes components to be impure and can lead to flaky tests. Instead, this\n * hook can be used.\n *\n * By default, it returns the time when the component mounts. If `updateInterval`\n * is specified, the value will be updated based on the interval.\n *\n * You can however also return a static value from this hook, if you\n * configure the `now` parameter on the context provider. Note however,\n * that if `updateInterval` is configured in this case, the component\n * will initialize with the global value, but will afterwards update\n * continuously based on the interval.\n *\n * For unit tests, this can be mocked to a constant value. For end-to-end\n * testing, an environment parameter can be passed to the `now` parameter\n * of the provider to mock this to a static value.\n */\nexport default function useNow(options?: Options) {\n const updateInterval = options?.updateInterval;\n\n const {now: globalNow} = useIntlContext();\n const [now, setNow] = useState(globalNow || getNow());\n\n useEffect(() => {\n if (!updateInterval) return;\n\n const intervalId = setInterval(() => {\n setNow(getNow());\n }, updateInterval);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [globalNow, updateInterval]);\n\n return now;\n}\n"],"names":["getNow","Date","useNow","options","updateInterval","_useIntlContext","useIntlContext","globalNow","now","_useState","useState","setNow","useEffect","intervalId","setInterval","clearInterval"],"mappings":";;;AAOA,SAASA,MAAMA,GAAA;EACb,OAAO,IAAIC,IAAI,EAAE,CAAA;AACnB,CAAA;AAEA;;;;;;;;;;;;;;;;;AAiBG;AACqB,SAAAC,MAAMA,CAACC,OAAiB,EAAA;AAC9C,EAAA,IAAMC,cAAc,GAAGD,OAAO,IAAPA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAAEC,cAAc,CAAA;AAE9C,EAAA,IAAAC,eAAA,GAAyBC,cAAc,EAAE;IAA7BC,SAAS,GAAAF,eAAA,CAAdG,GAAG,CAAA;EACV,IAAAC,SAAA,GAAsBC,QAAQ,CAACH,SAAS,IAAIP,MAAM,EAAE,CAAC;AAA9CQ,IAAAA,GAAG,GAAAC,SAAA,CAAA,CAAA,CAAA;AAAEE,IAAAA,MAAM,GAAAF,SAAA,CAAA,CAAA,CAAA,CAAA;AAElBG,EAAAA,SAAS,CAAC,YAAK;IACb,IAAI,CAACR,cAAc,EAAE,OAAA;AAErB,IAAA,IAAMS,UAAU,GAAGC,WAAW,CAAC,YAAK;AAClCH,MAAAA,MAAM,CAACX,MAAM,EAAE,CAAC,CAAA;KACjB,EAAEI,cAAc,CAAC,CAAA;AAElB,IAAA,OAAO,YAAK;MACVW,aAAa,CAACF,UAAU,CAAC,CAAA;KAC1B,CAAA;AACH,GAAC,EAAE,CAACN,SAAS,EAAEH,cAAc,CAAC,CAAC,CAAA;AAE/B,EAAA,OAAOI,GAAG,CAAA;AACZ;;;;"}
@@ -1,16 +0,0 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../_virtual/use-intl.esm.js';
2
- import React from 'react';
3
- import initializeConfig from '../core/use-intl.esm5.js';
4
- import IntlContext from './use-intl.esm11.js';
5
-
6
- var _excluded = ["children"];
7
- function IntlProvider(_ref) {
8
- var children = _ref.children,
9
- config = _objectWithoutPropertiesLoose(_ref, _excluded);
10
- return React.createElement(IntlContext.Provider, {
11
- value: initializeConfig(config)
12
- }, children);
13
- }
14
-
15
- export { IntlProvider as default };
16
- //# sourceMappingURL=use-intl.esm4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/IntlProvider.tsx"],"sourcesContent":["import React, {ReactNode} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport initializeConfig from '../core/initializeConfig';\nimport IntlContext from './IntlContext';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...config}: Props) {\n return (\n <IntlContext.Provider value={initializeConfig(config)}>\n {children}\n </IntlContext.Provider>\n );\n}\n"],"names":["IntlProvider","_ref","children","config","_objectWithoutPropertiesLoose","_excluded","React","createElement","IntlContext","Provider","value","initializeConfig"],"mappings":";;;;;;AASc,SAAUA,YAAYA,CAAAC,IAAA,EAA6B;AAAA,EAAA,IAA3BC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;AAAKC,IAAAA,MAAM,GAAAC,6BAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;AACvD,EAAA,OACEC,KAAC,CAAAC,aAAA,CAAAC,WAAW,CAACC,QAAQ;IAACC,KAAK,EAAEC,gBAAgB,CAACR,MAAM,CAAA;GAAC,EAClDD,QAAQ,CACY,CAAA;AAE3B;;;;"}
@@ -1,8 +0,0 @@
1
- import useIntlContext from './use-intl.esm10.js';
2
-
3
- function useTimeZone() {
4
- return useIntlContext().timeZone;
5
- }
6
-
7
- export { useTimeZone as default };
8
- //# sourceMappingURL=use-intl.esm5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm5.js","sources":["../../src/react/useTimeZone.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"names":["useTimeZone","useIntlContext","timeZone"],"mappings":";;AAEc,SAAUA,WAAWA,GAAA;AACjC,EAAA,OAAOC,cAAc,EAAE,CAACC,QAAQ,CAAA;AAClC;;;;"}
@@ -1,8 +0,0 @@
1
- import useIntlContext from './use-intl.esm10.js';
2
-
3
- function useMessages() {
4
- return useIntlContext().messages;
5
- }
6
-
7
- export { useMessages as default };
8
- //# sourceMappingURL=use-intl.esm6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm6.js","sources":["../../src/react/useMessages.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useMessages() {\n return useIntlContext().messages;\n}\n"],"names":["useMessages","useIntlContext","messages"],"mappings":";;AAEc,SAAUA,WAAWA,GAAA;AACjC,EAAA,OAAOC,cAAc,EAAE,CAACC,QAAQ,CAAA;AAClC;;;;"}
@@ -1,30 +0,0 @@
1
- import { useMemo } from 'react';
2
- import createIntl from '../core/use-intl.esm3.js';
3
- import useIntlContext from './use-intl.esm10.js';
4
-
5
- var hasWarned = false;
6
- /** @deprecated Switch to `useFormatter` instead. */
7
- function useIntl() {
8
- var _useIntlContext = useIntlContext(),
9
- formats = _useIntlContext.formats,
10
- locale = _useIntlContext.locale,
11
- globalNow = _useIntlContext.now,
12
- onError = _useIntlContext.onError,
13
- timeZone = _useIntlContext.timeZone;
14
- if (!hasWarned) {
15
- hasWarned = true;
16
- console.warn('`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.');
17
- }
18
- return useMemo(function () {
19
- return createIntl({
20
- formats: formats,
21
- locale: locale,
22
- now: globalNow,
23
- onError: onError,
24
- timeZone: timeZone
25
- });
26
- }, [formats, globalNow, locale, onError, timeZone]);
27
- }
28
-
29
- export { useIntl as default };
30
- //# sourceMappingURL=use-intl.esm7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm7.js","sources":["../../src/react/useIntl.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport createIntl from '../core/createIntl';\nimport useIntlContext from './useIntlContext';\n\nlet hasWarned = false;\n\n/** @deprecated Switch to `useFormatter` instead. */\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n if (!hasWarned) {\n hasWarned = true;\n console.warn(\n '`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.'\n );\n }\n\n return useMemo(\n () =>\n createIntl({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n"],"names":["hasWarned","useIntl","_useIntlContext","useIntlContext","formats","locale","globalNow","now","onError","timeZone","console","warn","useMemo","createIntl"],"mappings":";;;;AAIA,IAAIA,SAAS,GAAG,KAAK,CAAA;AAErB;AACc,SAAUC,OAAOA,GAAA;AAC7B,EAAA,IAAAC,eAAA,GAA6DC,cAAc,EAAE;IAAtEC,OAAO,GAAAF,eAAA,CAAPE,OAAO;IAAEC,MAAM,GAAAH,eAAA,CAANG,MAAM;IAAOC,SAAS,GAAAJ,eAAA,CAAdK,GAAG;IAAaC,OAAO,GAAAN,eAAA,CAAPM,OAAO;IAAEC,QAAQ,GAAAP,eAAA,CAARO,QAAQ,CAAA;EAEzD,IAAI,CAACT,SAAS,EAAE;AACdA,IAAAA,SAAS,GAAG,IAAI,CAAA;AAChBU,IAAAA,OAAO,CAACC,IAAI,CACV,6GAA6G,CAC9G,CAAA;AACF,GAAA;AAED,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,UAAU,CAAC;AACTT,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,MAAM,EAANA,MAAM;AACNE,MAAAA,GAAG,EAAED,SAAS;AACdE,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;GACJ,EAAA,CAACL,OAAO,EAAEE,SAAS,EAAED,MAAM,EAAEG,OAAO,EAAEC,QAAQ,CAAC,CAChD,CAAA;AACH;;;;"}
@@ -1,8 +0,0 @@
1
- import useIntlContext from './use-intl.esm10.js';
2
-
3
- function useLocale() {
4
- return useIntlContext().locale;
5
- }
6
-
7
- export { useLocale as default };
8
- //# sourceMappingURL=use-intl.esm8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm8.js","sources":["../../src/react/useLocale.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n"],"names":["useLocale","useIntlContext","locale"],"mappings":";;AAEc,SAAUA,SAASA,GAAA;AAC/B,EAAA,OAAOC,cAAc,EAAE,CAACC,MAAM,CAAA;AAChC;;;;"}
@@ -1,36 +0,0 @@
1
- import { useRef, useMemo } from 'react';
2
- import createBaseTranslator from '../core/use-intl.esm4.js';
3
- import resolveNamespace from '../core/use-intl.esm11.js';
4
- import useIntlContext from './use-intl.esm10.js';
5
-
6
- function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
7
- var _useIntlContext = useIntlContext(),
8
- defaultTranslationValues = _useIntlContext.defaultTranslationValues,
9
- globalFormats = _useIntlContext.formats,
10
- getMessageFallback = _useIntlContext.getMessageFallback,
11
- locale = _useIntlContext.locale,
12
- onError = _useIntlContext.onError,
13
- timeZone = _useIntlContext.timeZone;
14
- // The `namespacePrefix` is part of the type system.
15
- // See the comment in the hook invocation.
16
- allMessages = allMessages[namespacePrefix];
17
- namespace = resolveNamespace(namespace, namespacePrefix);
18
- var cachedFormatsByLocaleRef = useRef({});
19
- var translate = useMemo(function () {
20
- return createBaseTranslator({
21
- cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
22
- getMessageFallback: getMessageFallback,
23
- messages: allMessages,
24
- defaultTranslationValues: defaultTranslationValues,
25
- namespace: namespace,
26
- onError: onError,
27
- formats: globalFormats,
28
- locale: locale,
29
- timeZone: timeZone
30
- });
31
- }, [getMessageFallback, allMessages, namespace, onError, defaultTranslationValues, globalFormats, locale, timeZone]);
32
- return translate;
33
- }
34
-
35
- export { useTranslationsImpl as default };
36
- //# sourceMappingURL=use-intl.esm9.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm9.js","sources":["../../src/react/useTranslationsImpl.tsx"],"sourcesContent":["// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {useMemo, useRef} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport createBaseTranslator from '../core/createBaseTranslator';\nimport resolveNamespace from '../core/resolveNamespace';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport useIntlContext from './useIntlContext';\n\nexport default function useTranslationsImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey, namespacePrefix: string) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n // The `namespacePrefix` is part of the type system.\n // See the comment in the hook invocation.\n allMessages = allMessages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const translate = useMemo(\n () =>\n createBaseTranslator({\n cachedFormatsByLocale: cachedFormatsByLocaleRef.current,\n getMessageFallback,\n messages: allMessages,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n getMessageFallback,\n allMessages,\n namespace,\n onError,\n defaultTranslationValues,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n"],"names":["useTranslationsImpl","allMessages","namespace","namespacePrefix","_useIntlContext","useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","onError","timeZone","resolveNamespace","cachedFormatsByLocaleRef","useRef","translate","useMemo","createBaseTranslator","cachedFormatsByLocale","current","messages"],"mappings":";;;;;AASwB,SAAAA,mBAAmBA,CAGzCC,WAAqB,EAAEC,SAAoB,EAAEC,eAAuB,EAAA;AACpE,EAAA,IAAAC,eAAA,GAOIC,cAAc,EAAE;IANlBC,wBAAwB,GAAAF,eAAA,CAAxBE,wBAAwB;IACfC,aAAa,GAAAH,eAAA,CAAtBI,OAAO;IACPC,kBAAkB,GAAAL,eAAA,CAAlBK,kBAAkB;IAClBC,MAAM,GAAAN,eAAA,CAANM,MAAM;IACNC,OAAO,GAAAP,eAAA,CAAPO,OAAO;IACPC,QAAQ,GAAAR,eAAA,CAARQ,QAAQ,CAAA;AAGV;AACA;AACAX,EAAAA,WAAW,GAAGA,WAAW,CAACE,eAAe,CAAa,CAAA;AACtDD,EAAAA,SAAS,GAAGW,gBAAgB,CAACX,SAAS,EAAEC,eAAe,CAAc,CAAA;AAErE,EAAA,IAAMW,wBAAwB,GAAGC,MAAM,CAErC,EAAE,CAAC,CAAA;EAEL,IAAMC,SAAS,GAAGC,OAAO,CACvB,YAAA;AAAA,IAAA,OACEC,oBAAoB,CAAC;MACnBC,qBAAqB,EAAEL,wBAAwB,CAACM,OAAO;AACvDX,MAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBY,MAAAA,QAAQ,EAAEpB,WAAW;AACrBK,MAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBJ,MAAAA,SAAS,EAATA,SAAS;AACTS,MAAAA,OAAO,EAAPA,OAAO;AACPH,MAAAA,OAAO,EAAED,aAAa;AACtBG,MAAAA,MAAM,EAANA,MAAM;AACNE,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;AAAA,GAAA,EACJ,CACEH,kBAAkB,EAClBR,WAAW,EACXC,SAAS,EACTS,OAAO,EACPL,wBAAwB,EACxBC,aAAa,EACbG,MAAM,EACNE,QAAQ,CACT,CACF,CAAA;AAED,EAAA,OAAOI,SAAS,CAAA;AAClB;;;;"}
@@ -1,24 +0,0 @@
1
- import { useMemo } from 'react';
2
- import createFormatter from '../core/createFormatter.esm.js';
3
- import useIntlContext from './useIntlContext.esm.js';
4
-
5
- function useFormatter() {
6
- var _useIntlContext = useIntlContext(),
7
- formats = _useIntlContext.formats,
8
- locale = _useIntlContext.locale,
9
- globalNow = _useIntlContext.now,
10
- onError = _useIntlContext.onError,
11
- timeZone = _useIntlContext.timeZone;
12
- return useMemo(function () {
13
- return createFormatter({
14
- formats: formats,
15
- locale: locale,
16
- now: globalNow,
17
- onError: onError,
18
- timeZone: timeZone
19
- });
20
- }, [formats, globalNow, locale, onError, timeZone]);
21
- }
22
-
23
- export { useFormatter as default };
24
- //# sourceMappingURL=useFormatter.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFormatter.esm.js","sources":["../../src/react/useFormatter.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport createFormatter from '../core/createFormatter';\nimport useIntlContext from './useIntlContext';\n\nexport default function useFormatter() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n return useMemo(\n () =>\n createFormatter({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n"],"names":["useFormatter","_useIntlContext","useIntlContext","formats","locale","globalNow","now","onError","timeZone","useMemo","createFormatter"],"mappings":";;;;AAIc,SAAUA,YAAYA,GAAA;AAClC,EAAA,IAAAC,eAAA,GAA6DC,cAAc,EAAE;IAAtEC,OAAO,GAAAF,eAAA,CAAPE,OAAO;IAAEC,MAAM,GAAAH,eAAA,CAANG,MAAM;IAAOC,SAAS,GAAAJ,eAAA,CAAdK,GAAG;IAAaC,OAAO,GAAAN,eAAA,CAAPM,OAAO;IAAEC,QAAQ,GAAAP,eAAA,CAARO,QAAQ,CAAA;AAEzD,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,eAAe,CAAC;AACdP,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,MAAM,EAANA,MAAM;AACNE,MAAAA,GAAG,EAAED,SAAS;AACdE,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;GACJ,EAAA,CAACL,OAAO,EAAEE,SAAS,EAAED,MAAM,EAAEG,OAAO,EAAEC,QAAQ,CAAC,CAChD,CAAA;AACH;;;;"}
@@ -1,30 +0,0 @@
1
- import { useMemo } from 'react';
2
- import createIntl from '../core/createIntl.esm.js';
3
- import useIntlContext from './useIntlContext.esm.js';
4
-
5
- var hasWarned = false;
6
- /** @deprecated Switch to `useFormatter` instead. */
7
- function useIntl() {
8
- var _useIntlContext = useIntlContext(),
9
- formats = _useIntlContext.formats,
10
- locale = _useIntlContext.locale,
11
- globalNow = _useIntlContext.now,
12
- onError = _useIntlContext.onError,
13
- timeZone = _useIntlContext.timeZone;
14
- if (!hasWarned) {
15
- hasWarned = true;
16
- console.warn('`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.');
17
- }
18
- return useMemo(function () {
19
- return createIntl({
20
- formats: formats,
21
- locale: locale,
22
- now: globalNow,
23
- onError: onError,
24
- timeZone: timeZone
25
- });
26
- }, [formats, globalNow, locale, onError, timeZone]);
27
- }
28
-
29
- export { useIntl as default };
30
- //# sourceMappingURL=useIntl.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIntl.esm.js","sources":["../../src/react/useIntl.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport createIntl from '../core/createIntl';\nimport useIntlContext from './useIntlContext';\n\nlet hasWarned = false;\n\n/** @deprecated Switch to `useFormatter` instead. */\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n if (!hasWarned) {\n hasWarned = true;\n console.warn(\n '`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.'\n );\n }\n\n return useMemo(\n () =>\n createIntl({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n"],"names":["hasWarned","useIntl","_useIntlContext","useIntlContext","formats","locale","globalNow","now","onError","timeZone","console","warn","useMemo","createIntl"],"mappings":";;;;AAIA,IAAIA,SAAS,GAAG,KAAK,CAAA;AAErB;AACc,SAAUC,OAAOA,GAAA;AAC7B,EAAA,IAAAC,eAAA,GAA6DC,cAAc,EAAE;IAAtEC,OAAO,GAAAF,eAAA,CAAPE,OAAO;IAAEC,MAAM,GAAAH,eAAA,CAANG,MAAM;IAAOC,SAAS,GAAAJ,eAAA,CAAdK,GAAG;IAAaC,OAAO,GAAAN,eAAA,CAAPM,OAAO;IAAEC,QAAQ,GAAAP,eAAA,CAARO,QAAQ,CAAA;EAEzD,IAAI,CAACT,SAAS,EAAE;AACdA,IAAAA,SAAS,GAAG,IAAI,CAAA;AAChBU,IAAAA,OAAO,CAACC,IAAI,CACV,6GAA6G,CAC9G,CAAA;AACF,GAAA;AAED,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,UAAU,CAAC;AACTT,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,MAAM,EAANA,MAAM;AACNE,MAAAA,GAAG,EAAED,SAAS;AACdE,MAAAA,OAAO,EAAPA,OAAO;AACPC,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;GACJ,EAAA,CAACL,OAAO,EAAEE,SAAS,EAAED,MAAM,EAAEG,OAAO,EAAEC,QAAQ,CAAC,CAChD,CAAA;AACH;;;;"}
@@ -1 +0,0 @@
1
- export default function useIntlContext(): import("../core/IntlConfig").InitializedIntlConfig<import("../core/AbstractIntlMessages").default>;
@@ -1,13 +0,0 @@
1
- import { useContext } from 'react';
2
- import IntlContext from './IntlContext.esm.js';
3
-
4
- function useIntlContext() {
5
- var context = useContext(IntlContext);
6
- if (!context) {
7
- throw new Error(process.env.NODE_ENV !== 'production' ? 'No intl context found. Have you configured the provider?' : undefined);
8
- }
9
- return context;
10
- }
11
-
12
- export { useIntlContext as default };
13
- //# sourceMappingURL=useIntlContext.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIntlContext.esm.js","sources":["../../src/react/useIntlContext.tsx"],"sourcesContent":["import {useContext} from 'react';\nimport IntlContext from './IntlContext';\n\nexport default function useIntlContext() {\n const context = useContext(IntlContext);\n\n if (!context) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n"],"names":["useIntlContext","context","useContext","IntlContext","Error","process","env","NODE_ENV","undefined"],"mappings":";;;AAGc,SAAUA,cAAcA,GAAA;AACpC,EAAA,IAAMC,OAAO,GAAGC,UAAU,CAACC,WAAW,CAAC,CAAA;EAEvC,IAAI,CAACF,OAAO,EAAE;AACZ,IAAA,MAAM,IAAIG,KAAK,CACbC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,0DAA0D,GAC1DC,SAAS,CACd,CAAA;AACF,GAAA;AAED,EAAA,OAAOP,OAAO,CAAA;AAChB;;;;"}
@@ -1,8 +0,0 @@
1
- import useIntlContext from './useIntlContext.esm.js';
2
-
3
- function useLocale() {
4
- return useIntlContext().locale;
5
- }
6
-
7
- export { useLocale as default };
8
- //# sourceMappingURL=useLocale.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLocale.esm.js","sources":["../../src/react/useLocale.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n"],"names":["useLocale","useIntlContext","locale"],"mappings":";;AAEc,SAAUA,SAASA,GAAA;AAC/B,EAAA,OAAOC,cAAc,EAAE,CAACC,MAAM,CAAA;AAChC;;;;"}
@@ -1,8 +0,0 @@
1
- import useIntlContext from './useIntlContext.esm.js';
2
-
3
- function useMessages() {
4
- return useIntlContext().messages;
5
- }
6
-
7
- export { useMessages as default };
8
- //# sourceMappingURL=useMessages.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMessages.esm.js","sources":["../../src/react/useMessages.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useMessages() {\n return useIntlContext().messages;\n}\n"],"names":["useMessages","useIntlContext","messages"],"mappings":";;AAEc,SAAUA,WAAWA,GAAA;AACjC,EAAA,OAAOC,cAAc,EAAE,CAACC,QAAQ,CAAA;AAClC;;;;"}
@@ -1,45 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- import useIntlContext from './useIntlContext.esm.js';
3
-
4
- function getNow() {
5
- return new Date();
6
- }
7
- /**
8
- * Reading the current date via `new Date()` in components should be avoided, as
9
- * it causes components to be impure and can lead to flaky tests. Instead, this
10
- * hook can be used.
11
- *
12
- * By default, it returns the time when the component mounts. If `updateInterval`
13
- * is specified, the value will be updated based on the interval.
14
- *
15
- * You can however also return a static value from this hook, if you
16
- * configure the `now` parameter on the context provider. Note however,
17
- * that if `updateInterval` is configured in this case, the component
18
- * will initialize with the global value, but will afterwards update
19
- * continuously based on the interval.
20
- *
21
- * For unit tests, this can be mocked to a constant value. For end-to-end
22
- * testing, an environment parameter can be passed to the `now` parameter
23
- * of the provider to mock this to a static value.
24
- */
25
- function useNow(options) {
26
- var updateInterval = options == null ? void 0 : options.updateInterval;
27
- var _useIntlContext = useIntlContext(),
28
- globalNow = _useIntlContext.now;
29
- var _useState = useState(globalNow || getNow()),
30
- now = _useState[0],
31
- setNow = _useState[1];
32
- useEffect(function () {
33
- if (!updateInterval) return;
34
- var intervalId = setInterval(function () {
35
- setNow(getNow());
36
- }, updateInterval);
37
- return function () {
38
- clearInterval(intervalId);
39
- };
40
- }, [globalNow, updateInterval]);
41
- return now;
42
- }
43
-
44
- export { useNow as default };
45
- //# sourceMappingURL=useNow.esm.js.map