use-intl 3.25.0 → 4.0.0-beta-00a79d4

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 (119) hide show
  1. package/core.d.ts +2 -1
  2. package/dist/esm/development/core.js +82 -0
  3. package/dist/esm/development/index.js +7 -0
  4. package/dist/{development/createFormatter-D2v4ATzl.js → esm/development/initializeConfig-DSmAVNvj.js} +277 -129
  5. package/dist/esm/development/react.js +184 -0
  6. package/dist/esm/production/core.js +1 -0
  7. package/dist/esm/production/index.js +1 -0
  8. package/dist/esm/production/initializeConfig-BE7tJS3N.js +1 -0
  9. package/dist/esm/production/react.js +1 -0
  10. package/dist/types/{src/core → core}/AbstractIntlMessages.d.ts +3 -2
  11. package/dist/types/core/AppConfig.d.ts +25 -0
  12. package/dist/types/{src/core → core}/DateTimeFormatOptions.d.ts +1 -1
  13. package/dist/types/{src/core → core}/Formats.d.ts +2 -2
  14. package/dist/types/core/ICUArgs.d.ts +3 -0
  15. package/dist/types/core/ICUTags.d.ts +2 -0
  16. package/dist/types/{src/core → core}/IntlConfig.d.ts +6 -13
  17. package/dist/types/core/IntlError.d.ts +6 -0
  18. package/dist/types/{src/core/IntlError.d.ts → core/IntlErrorCode.d.ts} +2 -6
  19. package/dist/types/core/MessageKeys.d.ts +10 -0
  20. package/dist/types/core/TranslationValues.d.ts +9 -0
  21. package/dist/types/{src/core → core}/convertFormatsToIntlMessageFormat.d.ts +4 -4
  22. package/dist/types/{src/core → core}/createBaseTranslator.d.ts +9 -12
  23. package/dist/types/core/createFormatter.d.ts +28 -0
  24. package/dist/types/core/createTranslator.d.ts +52 -0
  25. package/dist/types/core/createTranslatorImpl.d.ts +17 -0
  26. package/dist/types/{src/core → core}/defaults.d.ts +1 -1
  27. package/dist/types/{src/core → core}/formatters.d.ts +1 -1
  28. package/dist/types/core/hasLocale.d.ts +10 -0
  29. package/dist/types/core/index.d.ts +20 -0
  30. package/dist/types/{src/core → core}/initializeConfig.d.ts +4 -4
  31. package/dist/types/core/types.d.ts +3 -0
  32. package/dist/types/{src/core → core}/validateMessages.d.ts +2 -2
  33. package/dist/types/core.d.ts +1 -0
  34. package/dist/types/index.d.ts +2 -0
  35. package/dist/types/{src/react → react}/IntlContext.d.ts +2 -2
  36. package/dist/types/react/IntlProvider.d.ts +7 -0
  37. package/dist/types/react/index.d.ts +7 -0
  38. package/dist/types/{src/react → react}/useFormatter.d.ts +1 -1
  39. package/dist/types/{src/react → react}/useIntlContext.d.ts +1 -1
  40. package/dist/types/react/useLocale.d.ts +2 -0
  41. package/dist/types/react/useMessages.d.ts +2 -0
  42. package/dist/types/react/useNow.d.ts +8 -0
  43. package/dist/types/react/useTimeZone.d.ts +1 -0
  44. package/dist/types/react/useTranslations.d.ts +12 -0
  45. package/dist/types/react/useTranslationsImpl.d.ts +9 -0
  46. package/dist/types/react.d.ts +1 -0
  47. package/package.json +18 -24
  48. package/react.d.ts +2 -1
  49. package/_IntlProvider.d.ts +0 -1
  50. package/_useLocale.d.ts +0 -1
  51. package/dist/_IntlProvider.js +0 -7
  52. package/dist/_useLocale.js +0 -7
  53. package/dist/core.js +0 -7
  54. package/dist/development/IntlContext-BKfsnzBx.js +0 -7
  55. package/dist/development/_IntlProvider.js +0 -61
  56. package/dist/development/_useLocale-0Rl9uR82.js +0 -19
  57. package/dist/development/_useLocale.js +0 -11
  58. package/dist/development/core.js +0 -69
  59. package/dist/development/index.js +0 -31
  60. package/dist/development/initializeConfig-BhfMSHP7.js +0 -185
  61. package/dist/development/react.js +0 -151
  62. package/dist/esm/IntlContext-DoS4CDM3.js +0 -1
  63. package/dist/esm/_IntlProvider.js +0 -1
  64. package/dist/esm/_useLocale-v-ZT5JoE.js +0 -1
  65. package/dist/esm/_useLocale.js +0 -1
  66. package/dist/esm/core.js +0 -1
  67. package/dist/esm/createFormatter-zqPbsiYR.js +0 -1
  68. package/dist/esm/index.js +0 -1
  69. package/dist/esm/initializeConfig-D2A8plWf.js +0 -1
  70. package/dist/esm/react.js +0 -1
  71. package/dist/index.js +0 -7
  72. package/dist/production/IntlContext-DcFt0tgW.js +0 -1
  73. package/dist/production/_IntlProvider.js +0 -1
  74. package/dist/production/_useLocale-CpTrqBDt.js +0 -1
  75. package/dist/production/_useLocale.js +0 -1
  76. package/dist/production/core.js +0 -1
  77. package/dist/production/createFormatter-CZeYe_QF.js +0 -1
  78. package/dist/production/index.js +0 -1
  79. package/dist/production/initializeConfig-AbYTngyP.js +0 -1
  80. package/dist/production/react.js +0 -1
  81. package/dist/react.js +0 -7
  82. package/dist/types/src/_IntlProvider.d.ts +0 -1
  83. package/dist/types/src/_useLocale.d.ts +0 -1
  84. package/dist/types/src/core/TranslationValues.d.ts +0 -6
  85. package/dist/types/src/core/createFormatter.d.ts +0 -27
  86. package/dist/types/src/core/createFormatter.test.d.ts +0 -1
  87. package/dist/types/src/core/createTranslator.d.ts +0 -71
  88. package/dist/types/src/core/createTranslator.test.d.ts +0 -1
  89. package/dist/types/src/core/createTranslatorImpl.d.ts +0 -17
  90. package/dist/types/src/core/index.d.ts +0 -18
  91. package/dist/types/src/core/utils/MessageKeys.d.ts +0 -5
  92. package/dist/types/src/core/utils/NamespaceKeys.d.ts +0 -5
  93. package/dist/types/src/core/utils/NestedKeyOf.d.ts +0 -4
  94. package/dist/types/src/core/utils/NestedValueOf.d.ts +0 -2
  95. package/dist/types/src/core.d.ts +0 -1
  96. package/dist/types/src/index.d.ts +0 -2
  97. package/dist/types/src/react/IntlProvider.d.ts +0 -7
  98. package/dist/types/src/react/IntlProvider.test.d.ts +0 -1
  99. package/dist/types/src/react/index.d.ts +0 -7
  100. package/dist/types/src/react/index.test.d.ts +0 -1
  101. package/dist/types/src/react/useFormatter.test.d.ts +0 -1
  102. package/dist/types/src/react/useLocale.d.ts +0 -1
  103. package/dist/types/src/react/useLocale.test.d.ts +0 -1
  104. package/dist/types/src/react/useMessages.d.ts +0 -2
  105. package/dist/types/src/react/useMessages.test.d.ts +0 -1
  106. package/dist/types/src/react/useNow.d.ts +0 -23
  107. package/dist/types/src/react/useNow.test.d.ts +0 -1
  108. package/dist/types/src/react/useTimeZone.d.ts +0 -1
  109. package/dist/types/src/react/useTimeZone.test.d.ts +0 -1
  110. package/dist/types/src/react/useTranslations.d.ts +0 -62
  111. package/dist/types/src/react/useTranslations.test.d.ts +0 -1
  112. package/dist/types/src/react/useTranslationsImpl.d.ts +0 -9
  113. package/dist/types/src/react.d.ts +0 -1
  114. package/dist/types/test/setup.d.ts +0 -1
  115. /package/dist/types/{src/core → core}/NumberFormatOptions.d.ts +0 -0
  116. /package/dist/types/{src/core → core}/RelativeTimeFormatOptions.d.ts +0 -0
  117. /package/dist/types/{src/core → core}/TimeZone.d.ts +0 -0
  118. /package/dist/types/{src/core → core}/joinPath.d.ts +0 -0
  119. /package/dist/types/{src/core → core}/resolveNamespace.d.ts +0 -0
@@ -0,0 +1,184 @@
1
+ import { createContext, useContext, useMemo, useState, useEffect } from 'react';
2
+ import { d as createCache, b as createIntlFormatters, i as initializeConfig, r as resolveNamespace, I as IntlError, a as IntlErrorCode, e as createBaseTranslator, c as createFormatter } from './initializeConfig-DSmAVNvj.js';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+
6
+
7
+ const IntlContext = /*#__PURE__*/createContext(undefined);
8
+
9
+ function IntlProvider({
10
+ children,
11
+ formats,
12
+ getMessageFallback,
13
+ locale,
14
+ messages,
15
+ now,
16
+ onError,
17
+ timeZone
18
+ }) {
19
+ const prevContext = useContext(IntlContext);
20
+
21
+ // The formatter cache is released when the locale changes. For
22
+ // long-running apps with a persistent `IntlProvider` at the root,
23
+ // this can reduce the memory footprint (e.g. in React Native).
24
+ const cache = useMemo(() => {
25
+ return prevContext?.cache || createCache();
26
+ }, [locale, prevContext?.cache]);
27
+ const formatters = useMemo(() => prevContext?.formatters || createIntlFormatters(cache), [cache, prevContext?.formatters]);
28
+
29
+ // Memoizing this value helps to avoid triggering a re-render of all
30
+ // context consumers in case the configuration didn't change. However,
31
+ // if some of the non-primitive values change, a re-render will still
32
+ // be triggered. Note that there's no need to put `memo` on `IntlProvider`
33
+ // itself, because the `children` typically change on every render.
34
+ // There's some burden on the consumer side if it's important to reduce
35
+ // re-renders, put that's how React works.
36
+ // See: https://blog.isquaredsoftware.com/2020/05/blogged-answers-a-mostly-complete-guide-to-react-rendering-behavior/#context-updates-and-render-optimizations
37
+ const value = useMemo(() => ({
38
+ ...initializeConfig({
39
+ locale,
40
+ // (required by provider)
41
+ formats: formats || prevContext?.formats,
42
+ getMessageFallback: getMessageFallback || prevContext?.getMessageFallback,
43
+ messages: messages || prevContext?.messages,
44
+ now: now || prevContext?.now,
45
+ onError: onError || prevContext?.onError,
46
+ timeZone: timeZone || prevContext?.timeZone
47
+ }),
48
+ formatters,
49
+ cache
50
+ }), [cache, formats, formatters, getMessageFallback, locale, messages, now, onError, prevContext, timeZone]);
51
+ return /*#__PURE__*/jsx(IntlContext.Provider, {
52
+ value: value,
53
+ children: children
54
+ });
55
+ }
56
+
57
+ function useIntlContext() {
58
+ const context = useContext(IntlContext);
59
+ if (!context) {
60
+ throw new Error('No intl context found. Have you configured the provider? See https://next-intl-docs.vercel.app/docs/usage/configuration#server-client-components' );
61
+ }
62
+ return context;
63
+ }
64
+
65
+ let hasWarnedForMissingTimezone = false;
66
+ const isServer = typeof window === 'undefined';
67
+ function useTranslationsImpl(allMessagesPrefixed, namespacePrefixed, namespacePrefix) {
68
+ const {
69
+ cache,
70
+ formats: globalFormats,
71
+ formatters,
72
+ getMessageFallback,
73
+ locale,
74
+ onError,
75
+ timeZone
76
+ } = useIntlContext();
77
+
78
+ // The `namespacePrefix` is part of the type system.
79
+ // See the comment in the hook invocation.
80
+ const allMessages = allMessagesPrefixed[namespacePrefix];
81
+ const namespace = resolveNamespace(namespacePrefixed, namespacePrefix);
82
+ if (!timeZone && !hasWarnedForMissingTimezone && isServer) {
83
+ // eslint-disable-next-line react-compiler/react-compiler
84
+ hasWarnedForMissingTimezone = true;
85
+ onError(new IntlError(IntlErrorCode.ENVIRONMENT_FALLBACK, `There is no \`timeZone\` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl-docs.vercel.app/docs/configuration#time-zone` ));
86
+ }
87
+ const translate = useMemo(() => createBaseTranslator({
88
+ cache,
89
+ formatters,
90
+ getMessageFallback,
91
+ messages: allMessages,
92
+ namespace,
93
+ onError,
94
+ formats: globalFormats,
95
+ locale,
96
+ timeZone
97
+ }), [cache, formatters, getMessageFallback, allMessages, namespace, onError, globalFormats, locale, timeZone]);
98
+ return translate;
99
+ }
100
+
101
+ /**
102
+ * Translates messages from the given namespace by using the ICU syntax.
103
+ * See https://formatjs.io/docs/core-concepts/icu-syntax.
104
+ *
105
+ * If no namespace is provided, all available messages are returned.
106
+ * The namespace can also indicate nesting by using a dot
107
+ * (e.g. `namespace.Component`).
108
+ */
109
+ function useTranslations(namespace) {
110
+ const context = useIntlContext();
111
+ const messages = context.messages;
112
+
113
+ // We have to wrap the actual hook so the type inference for the optional
114
+ // namespace works correctly. See https://stackoverflow.com/a/71529575/343045
115
+ // The prefix ("!") is arbitrary.
116
+ // @ts-expect-error Use the explicit annotation instead
117
+ return useTranslationsImpl({
118
+ '!': messages
119
+ },
120
+ // @ts-expect-error
121
+ namespace ? `!.${namespace}` : '!', '!');
122
+ }
123
+
124
+ function useLocale() {
125
+ return useIntlContext().locale;
126
+ }
127
+
128
+ function getNow() {
129
+ return new Date();
130
+ }
131
+
132
+ /**
133
+ * @see https://next-intl-docs.vercel.app/docs/usage/dates-times#relative-times-usenow
134
+ */
135
+ function useNow(options) {
136
+ const updateInterval = options?.updateInterval;
137
+ const {
138
+ now: globalNow
139
+ } = useIntlContext();
140
+ const [now, setNow] = useState(globalNow || getNow());
141
+ useEffect(() => {
142
+ if (!updateInterval) return;
143
+ const intervalId = setInterval(() => {
144
+ setNow(getNow());
145
+ }, updateInterval);
146
+ return () => {
147
+ clearInterval(intervalId);
148
+ };
149
+ }, [globalNow, updateInterval]);
150
+ return updateInterval == null && globalNow ? globalNow : now;
151
+ }
152
+
153
+ function useTimeZone() {
154
+ return useIntlContext().timeZone;
155
+ }
156
+
157
+ function useMessages() {
158
+ const context = useIntlContext();
159
+ if (!context.messages) {
160
+ throw new Error('No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages' );
161
+ }
162
+ return context.messages;
163
+ }
164
+
165
+ function useFormatter() {
166
+ const {
167
+ formats,
168
+ formatters,
169
+ locale,
170
+ now: globalNow,
171
+ onError,
172
+ timeZone
173
+ } = useIntlContext();
174
+ return useMemo(() => createFormatter({
175
+ formats,
176
+ locale,
177
+ now: globalNow,
178
+ onError,
179
+ timeZone,
180
+ _formatters: formatters
181
+ }), [formats, formatters, globalNow, locale, onError, timeZone]);
182
+ }
183
+
184
+ export { IntlProvider, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
@@ -0,0 +1 @@
1
+ import{r as e,e as s,d as r,b as t,f as o,g as n}from"./initializeConfig-BE7tJS3N.js";export{I as IntlError,a as IntlErrorCode,c as createFormatter,i as initializeConfig}from"./initializeConfig-BE7tJS3N.js";function m({_cache:a=r(),_formatters:i=t(a),getMessageFallback:m=o,messages:c,namespace:f,onError:g=n,...l}){return function({messages:a,namespace:r,...t},o){return a=a[o],r=e(r,o),s({...t,messages:a,namespace:r})}({...l,onError:g,cache:a,formatters:i,getMessageFallback:m,messages:{"!":c},namespace:f?`!.${f}`:"!"},"!")}function f(e,a){return e.includes(a)}export{r as _createCache,t as _createIntlFormatters,m as createTranslator,f as hasLocale};
@@ -0,0 +1 @@
1
+ export{I as IntlError,a as IntlErrorCode,d as _createCache,b as _createIntlFormatters,c as createFormatter,i as initializeConfig}from"./initializeConfig-BE7tJS3N.js";export{createTranslator,hasLocale}from"./core.js";export{IntlProvider,useFormatter,useLocale,useMessages,useNow,useTimeZone,useTranslations}from"./react.js";
@@ -0,0 +1 @@
1
+ import{IntlMessageFormat as e}from"intl-messageformat";import{isValidElement as t,cloneElement as r}from"react";import{memoize as n,strategies as o}from"@formatjs/fast-memoize";class a extends Error{constructor(e,t){let r=e;t&&(r+=": "+t),super(r),this.code=e,t&&(this.originalMessage=t)}}var s=function(e){return e.MISSING_MESSAGE="MISSING_MESSAGE",e.MISSING_FORMAT="MISSING_FORMAT",e.ENVIRONMENT_FALLBACK="ENVIRONMENT_FALLBACK",e.INSUFFICIENT_PATH="INSUFFICIENT_PATH",e.INVALID_MESSAGE="INVALID_MESSAGE",e.INVALID_KEY="INVALID_KEY",e.FORMATTING_ERROR="FORMATTING_ERROR",e}(s||{});function i(...e){return e.filter(Boolean).join(".")}function u(e){return i(e.namespace,e.key)}function c(e){console.error(e)}function m(){return{dateTime:{},number:{},message:{},relativeTime:{},pluralRules:{},list:{},displayNames:{}}}function f(e,t){return n(e,{cache:(r=t,{create:()=>({get:e=>r[e],set(e,t){r[e]=t}})}),strategy:o.variadic});var r}function l(e,t){return f(((...t)=>new e(...t)),t)}function g(e){return{getDateTimeFormat:l(Intl.DateTimeFormat,e.dateTime),getNumberFormat:l(Intl.NumberFormat,e.number),getPluralRules:l(Intl.PluralRules,e.pluralRules),getRelativeTimeFormat:l(Intl.RelativeTimeFormat,e.relativeTime),getListFormat:l(Intl.ListFormat,e.list),getDisplayNames:l(Intl.DisplayNames,e.displayNames)}}function I(e,t,r,n){const o=i(n,r);if(!t)throw new Error(o);let a=t;return r.split(".").forEach((t=>{const r=a[t];if(null==t||null==r)throw new Error(o+` (${e})`);a=r})),a}function E(n){const o=function(e,t,r,n=c){try{if(!t)throw new Error(void 0);const n=r?I(e,t,r):t;if(!n)throw new Error(r);return n}catch(e){const t=new a(s.MISSING_MESSAGE,e.message);return n(t),t}}(n.locale,n.messages,n.namespace,n.onError);return function({cache:n,formats:o,formatters:i,getMessageFallback:c=u,locale:m,messagesOrError:l,namespace:g,onError:E,timeZone:S}){const T=l instanceof a;function N(e,t,r){const n=new a(t,r);return E(n),c({error:n,key:e,namespace:g})}function y(a,u,E){if(T)return c({error:l,key:a,namespace:g});const y=l;let A,M;try{A=I(m,y,a,g)}catch(e){return N(a,s.MISSING_MESSAGE,e.message)}if("object"==typeof A){let e,t;return e=Array.isArray(A)?s.INVALID_MESSAGE:s.INSUFFICIENT_PATH,N(a,e,t)}const F=function(e,t){return t?void 0:e}(A,u);if(F)return F;i.getMessageFormat||(i.getMessageFormat=function(t,r){return f(((...t)=>new e(t[0],t[1],t[2],{formatters:r,...t[3]})),t.message)}(n,i));try{M=i.getMessageFormat(A,m,function(t,r,n){const o=e.formats.date,a=e.formats.time,s={...t?.dateTime,...r?.dateTime},i={date:{...o,...s},time:{...a,...s},number:{...t?.number,...r?.number}};return n&&["date","time"].forEach((e=>{const t=i[e];for(const[e,r]of Object.entries(t))t[e]={timeZone:n,...r}})),i}(o,E,S),{formatters:{...i,getDateTimeFormat:(e,t)=>i.getDateTimeFormat(e,{timeZone:S,...t})}})}catch(e){const t=e;return N(a,s.INVALID_MESSAGE,t.message)}try{const e=M.format(u?function(e){const n={};return Object.keys(e).forEach((o=>{let a=0;const s=e[o];let i;i="function"==typeof s?e=>{const n=s(e);return t(n)?r(n,{key:o+a++}):n}:s,n[o]=i})),n}(u):u);if(null==e)throw new Error(void 0);return t(e)||Array.isArray(e)||"string"==typeof e?e:String(e)}catch(e){return N(a,s.FORMATTING_ERROR,e.message)}}function A(e,t,r){const n=y(e,t,r);return"string"!=typeof n?N(e,s.INVALID_MESSAGE,void 0):n}return A.rich=y,A.markup=(e,t,r)=>y(e,t,r),A.raw=e=>{if(T)return c({error:l,key:e,namespace:g});const t=l;try{return I(m,t,e,g)}catch(t){return N(e,s.MISSING_MESSAGE,t.message)}},A.has=e=>{if(T)return!1;try{return I(m,l,e,g),!0}catch{return!1}},A}({...n,messagesOrError:o})}function S(e,t){return e===t?void 0:e.slice((t+".").length)}const T=3600,N=86400,y=7*N,A=2628e3,M=7884e3,F=365*N,R={second:1,seconds:1,minute:60,minutes:60,hour:T,hours:T,day:N,days:N,week:y,weeks:y,month:A,months:A,quarter:M,quarters:M,year:F,years:F};function h(e){const{_cache:t=m(),_formatters:r=g(t),formats:n,locale:o,onError:i=c,timeZone:u}=e;function f(e){return e?.timeZone||(u?e={...e,timeZone:u}:i(new a(s.ENVIRONMENT_FALLBACK,void 0))),e}function l(e,t,r,n){let o;try{o=function(e,t){let r;if("string"==typeof t){const n=t;if(r=e?.[n],!r){const e=new a(s.MISSING_FORMAT,void 0);throw i(e),e}}else r=t;return r}(t,e)}catch{return n()}try{return r(o)}catch(e){return i(new a(s.FORMATTING_ERROR,e.message)),n()}}function I(e,t){return l(t,n?.dateTime,(t=>(t=f(t),r.getDateTimeFormat(o,t).format(e))),(()=>String(e)))}function E(){return e.now?e.now:(i(new a(s.ENVIRONMENT_FALLBACK,void 0)),new Date)}return{dateTime:I,number:function(e,t){return l(t,n?.number,(t=>r.getNumberFormat(o,t).format(e)),(()=>String(e)))},relativeTime:function(e,t){try{let n,a;const s={};t instanceof Date||"number"==typeof t?n=new Date(t):t&&(n=null!=t.now?new Date(t.now):E(),a=t.unit,s.style=t.style,s.numberingSystem=t.numberingSystem),n||(n=E());const i=(new Date(e).getTime()-n.getTime())/1e3;a||(a=function(e){const t=Math.abs(e);return t<60?"second":t<T?"minute":t<N?"hour":t<y?"day":t<A?"week":t<F?"month":"year"}(i)),s.numeric="second"===a?"auto":"always";const u=function(e,t){return Math.round(e/R[t])}(i,a);return r.getRelativeTimeFormat(o,s).format(u,a)}catch(t){return i(new a(s.FORMATTING_ERROR,t.message)),String(e)}},list:function(e,t){const a=[],s=new Map;let i=0;for(const t of e){let e;"object"==typeof t?(e=String(i),s.set(e,t)):e=String(t),a.push(e),i++}return l(t,n?.list,(e=>{const t=r.getListFormat(o,e).formatToParts(a).map((e=>"literal"===e.type?e.value:s.get(e.value)||e.value));return s.size>0?t:t.join("")}),(()=>String(e)))},dateTimeRange:function(e,t,a){return l(a,n?.dateTime,(n=>(n=f(n),r.getDateTimeFormat(o,n).formatRange(e,t))),(()=>[I(e),I(t)].join(" – ")))}}}function w({getMessageFallback:e,messages:t,onError:r,...n}){return{...n,messages:t,onError:r||c,getMessageFallback:e||u}}export{a as I,s as a,g as b,h as c,m as d,E as e,u as f,c as g,w as i,S as r};
@@ -0,0 +1 @@
1
+ import{createContext as e,useContext as r,useMemo as o,useState as t,useEffect as n}from"react";import{d as a,b as s,i as c,r as i,I as m,a as f,e as l,c as u}from"./initializeConfig-BE7tJS3N.js";import{jsx as g}from"react/jsx-runtime";const w=e(void 0);function d({children:e,formats:t,getMessageFallback:n,locale:i,messages:m,now:f,onError:l,timeZone:u}){const d=r(w),E=o((()=>d?.cache||a()),[i,d?.cache]),h=o((()=>d?.formatters||s(E)),[E,d?.formatters]),p=o((()=>({...c({locale:i,formats:t||d?.formats,getMessageFallback:n||d?.getMessageFallback,messages:m||d?.messages,now:f||d?.now,onError:l||d?.onError,timeZone:u||d?.timeZone}),formatters:h,cache:E})),[E,t,h,n,i,m,f,l,d,u]);return g(w.Provider,{value:p,children:e})}function E(){const e=r(w);if(!e)throw new Error(void 0);return e}let h=!1;const p="undefined"==typeof window;function v(e){return function(e,r,t){const{cache:n,formats:a,formatters:s,getMessageFallback:c,locale:u,onError:g,timeZone:w}=E(),d=e[t],v=i(r,t);return w||h||!p||(h=!0,g(new m(f.ENVIRONMENT_FALLBACK,void 0))),o((()=>l({cache:n,formatters:s,getMessageFallback:c,messages:d,namespace:v,onError:g,formats:a,locale:u,timeZone:w})),[n,s,c,d,v,g,a,u,w])}({"!":E().messages},e?`!.${e}`:"!","!")}function Z(){return E().locale}function b(){return new Date}function F(e){const r=e?.updateInterval,{now:o}=E(),[a,s]=t(o||b());return n((()=>{if(!r)return;const e=setInterval((()=>{s(b())}),r);return()=>{clearInterval(e)}}),[o,r]),null==r&&o?o:a}function M(){return E().timeZone}function k(){const e=E();if(!e.messages)throw new Error(void 0);return e.messages}function I(){const{formats:e,formatters:r,locale:t,now:n,onError:a,timeZone:s}=E();return o((()=>u({formats:e,locale:t,now:n,onError:a,timeZone:s,_formatters:r})),[e,r,n,t,a,s])}export{d as IntlProvider,I as useFormatter,Z as useLocale,k as useMessages,F as useNow,M as useTimeZone,v as useTranslations};
@@ -1,6 +1,7 @@
1
- /** A generic type that describes the shape of messages.
1
+ /**
2
+ * A generic type that describes the shape of messages.
2
3
  *
3
- * Optionally `IntlMessages` can be provided to get type safety for message
4
+ * Optionally, messages can be strictly-typed in order to get type safety for message
4
5
  * namespaces and keys. See https://next-intl-docs.vercel.app/docs/usage/typescript
5
6
  */
6
7
  type AbstractIntlMessages = {
@@ -0,0 +1,25 @@
1
+ export default interface AppConfig {
2
+ }
3
+ export type Locale = AppConfig extends {
4
+ Locale: infer AppLocale;
5
+ } ? AppLocale : string;
6
+ export type FormatNames = AppConfig extends {
7
+ Formats: infer AppFormats;
8
+ } ? {
9
+ dateTime: AppFormats extends {
10
+ dateTime: infer AppDateTimeFormats;
11
+ } ? keyof AppDateTimeFormats : string;
12
+ number: AppFormats extends {
13
+ number: infer AppNumberFormats;
14
+ } ? keyof AppNumberFormats : string;
15
+ list: AppFormats extends {
16
+ list: infer AppListFormats;
17
+ } ? keyof AppListFormats : string;
18
+ } : {
19
+ dateTime: string;
20
+ number: string;
21
+ list: string;
22
+ };
23
+ export type Messages = AppConfig extends {
24
+ Messages: infer AppMessages;
25
+ } ? AppMessages : Record<string, any>;
@@ -1,4 +1,4 @@
1
- import TimeZone from './TimeZone';
1
+ import type TimeZone from './TimeZone.tsx';
2
2
  /**
3
3
  * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
4
4
  */
@@ -1,5 +1,5 @@
1
- import DateTimeFormatOptions from './DateTimeFormatOptions';
2
- import NumberFormatOptions from './NumberFormatOptions';
1
+ import type DateTimeFormatOptions from './DateTimeFormatOptions.tsx';
2
+ import type NumberFormatOptions from './NumberFormatOptions.tsx';
3
3
  type Formats = {
4
4
  number?: Record<string, NumberFormatOptions>;
5
5
  dateTime?: Record<string, DateTimeFormatOptions>;
@@ -0,0 +1,3 @@
1
+ import type { GetICUArgs, GetICUArgsOptions } from '@schummar/icu-type-parser';
2
+ type ICUArgs<Message extends string, Options extends GetICUArgsOptions> = string extends Message ? {} : GetICUArgs<Message, Options>;
3
+ export default ICUArgs;
@@ -0,0 +1,2 @@
1
+ type ICUTags<MessageString extends string, TagsFn> = MessageString extends `${infer Prefix}<${infer TagName}>${infer Content}</${string}>${infer Tail}` ? Record<TagName, TagsFn> & ICUTags<`${Prefix}${Content}${Tail}`, TagsFn> : {};
2
+ export default ICUTags;
@@ -1,14 +1,14 @@
1
- import type AbstractIntlMessages from './AbstractIntlMessages';
2
- import type Formats from './Formats';
3
- import type IntlError from './IntlError';
4
- import type TimeZone from './TimeZone';
5
- import type { RichTranslationValues } from './TranslationValues';
1
+ import type AbstractIntlMessages from './AbstractIntlMessages.tsx';
2
+ import type { Locale } from './AppConfig.tsx';
3
+ import type Formats from './Formats.tsx';
4
+ import type IntlError from './IntlError.tsx';
5
+ import type TimeZone from './TimeZone.tsx';
6
6
  /**
7
7
  * Should be used for entry points that configure the library.
8
8
  */
9
9
  type IntlConfig<Messages = AbstractIntlMessages> = {
10
10
  /** A valid Unicode locale tag (e.g. "en" or "en-GB"). */
11
- locale: string;
11
+ locale: Locale;
12
12
  /** Global formats can be provided to achieve consistent
13
13
  * formatting across components. */
14
14
  formats?: Formats;
@@ -39,13 +39,6 @@ type IntlConfig<Messages = AbstractIntlMessages> = {
39
39
  now?: Date;
40
40
  /** All messages that will be available. */
41
41
  messages?: Messages;
42
- /** Global default values for translation values and rich text elements.
43
- * Can be used for consistent usage or styling of rich text elements.
44
- * Defaults will be overidden by locally provided values.
45
- *
46
- * @deprecated See https://next-intl-docs.vercel.app/docs/usage/messages#rich-text-reuse-tags
47
- **/
48
- defaultTranslationValues?: RichTranslationValues;
49
42
  };
50
43
  /**
51
44
  * A stricter set of the configuration that should be used internally
@@ -0,0 +1,6 @@
1
+ import type IntlErrorCode from './IntlErrorCode.tsx';
2
+ export default class IntlError extends Error {
3
+ readonly code: IntlErrorCode;
4
+ readonly originalMessage: string | undefined;
5
+ constructor(code: IntlErrorCode, originalMessage?: string);
6
+ }
@@ -1,4 +1,4 @@
1
- export declare enum IntlErrorCode {
1
+ declare const enum IntlErrorCode {
2
2
  MISSING_MESSAGE = "MISSING_MESSAGE",
3
3
  MISSING_FORMAT = "MISSING_FORMAT",
4
4
  ENVIRONMENT_FALLBACK = "ENVIRONMENT_FALLBACK",
@@ -7,8 +7,4 @@ export declare enum IntlErrorCode {
7
7
  INVALID_KEY = "INVALID_KEY",
8
8
  FORMATTING_ERROR = "FORMATTING_ERROR"
9
9
  }
10
- export default class IntlError extends Error {
11
- readonly code: IntlErrorCode;
12
- readonly originalMessage: string | undefined;
13
- constructor(code: IntlErrorCode, originalMessage?: string);
14
- }
10
+ export default IntlErrorCode;
@@ -0,0 +1,10 @@
1
+ export type NestedKeyOf<ObjectType> = ObjectType extends object ? {
2
+ [Property in keyof ObjectType]: `${Property & string}` | `${Property & string}.${NestedKeyOf<ObjectType[Property]>}`;
3
+ }[keyof ObjectType] : never;
4
+ export type NestedValueOf<ObjectType, Path extends string> = Path extends `${infer Cur}.${infer Rest}` ? Cur extends keyof ObjectType ? NestedValueOf<ObjectType[Cur], Rest> : never : Path extends keyof ObjectType ? ObjectType[Path] : never;
5
+ export type NamespaceKeys<ObjectType, AllKeys extends string> = {
6
+ [PropertyPath in AllKeys]: NestedValueOf<ObjectType, PropertyPath> extends string ? never : PropertyPath;
7
+ }[AllKeys];
8
+ export type MessageKeys<ObjectType, AllKeys extends string> = {
9
+ [PropertyPath in AllKeys]: NestedValueOf<ObjectType, PropertyPath> extends string ? PropertyPath : never;
10
+ }[AllKeys];
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ export type ICUArg = string | number | boolean | Date;
3
+ export type ICUNumber = number;
4
+ export type ICUDate = Date | number | string;
5
+ export type TranslationValues = Record<string, ICUArg>;
6
+ export type RichTagsFunction = (chunks: ReactNode) => ReactNode;
7
+ export type MarkupTagsFunction = (chunks: string) => string;
8
+ export type RichTranslationValues = Record<string, ICUArg | RichTagsFunction>;
9
+ export type MarkupTranslationValues = Record<string, ICUArg | MarkupTagsFunction>;
@@ -1,6 +1,6 @@
1
- import { Formats as IntlFormats } from 'intl-messageformat';
2
- import Formats from './Formats';
3
- import TimeZone from './TimeZone';
1
+ import { type Formats as IntlFormats } from 'intl-messageformat';
2
+ import type Formats from './Formats.tsx';
3
+ import type TimeZone from './TimeZone.tsx';
4
4
  /**
5
5
  * `intl-messageformat` uses separate keys for `date` and `time`, but there's
6
6
  * only one native API: `Intl.DateTimeFormat`. Additionally you might want to
@@ -8,4 +8,4 @@ import TimeZone from './TimeZone';
8
8
  * seem so useful. We offer a single `dateTime` namespace instead, but we have
9
9
  * to convert the format before `intl-messageformat` can be used.
10
10
  */
11
- export default function convertFormatsToIntlMessageFormat(formats: Formats, timeZone?: TimeZone): Partial<IntlFormats>;
11
+ export default function convertFormatsToIntlMessageFormat(globalFormats?: Formats, inlineFormats?: Formats, timeZone?: TimeZone): Partial<IntlFormats>;
@@ -1,17 +1,14 @@
1
- import { ReactNode } from 'react';
2
- import AbstractIntlMessages from './AbstractIntlMessages';
3
- import Formats from './Formats';
4
- import { InitializedIntlConfig } from './IntlConfig';
5
- import IntlError from './IntlError';
6
- import TranslationValues, { MarkupTranslationValues, RichTranslationValues } from './TranslationValues';
7
- import { Formatters, IntlCache } from './formatters';
8
- import MessageKeys from './utils/MessageKeys';
9
- import NestedKeyOf from './utils/NestedKeyOf';
10
- import NestedValueOf from './utils/NestedValueOf';
1
+ import { type ReactNode } from 'react';
2
+ import type AbstractIntlMessages from './AbstractIntlMessages.tsx';
3
+ import type Formats from './Formats.tsx';
4
+ import type { InitializedIntlConfig } from './IntlConfig.tsx';
5
+ import IntlError from './IntlError.tsx';
6
+ import type { MessageKeys, NestedKeyOf, NestedValueOf } from './MessageKeys.tsx';
7
+ import type { MarkupTranslationValues, RichTranslationValues, TranslationValues } from './TranslationValues.tsx';
8
+ import { type Formatters, type IntlCache } from './formatters.tsx';
11
9
  export type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {
12
10
  cache: IntlCache;
13
11
  formatters: Formatters;
14
- defaultTranslationValues?: RichTranslationValues;
15
12
  namespace?: string;
16
13
  messagesOrError: Messages | IntlError;
17
14
  };
@@ -20,5 +17,5 @@ export default function createBaseTranslator<Messages extends AbstractIntlMessag
20
17
  rich: (key: string, values?: RichTranslationValues, formats?: Formats) => ReactNode;
21
18
  markup(key: Parameters<(key: string, values?: RichTranslationValues, formats?: Formats) => ReactNode>[0], values: MarkupTranslationValues, formats?: Parameters<(key: string, values?: RichTranslationValues, formats?: Formats) => ReactNode>[2]): string;
22
19
  raw(key: string): any;
23
- has(key: Parameters<(key: string, values?: RichTranslationValues, formats?: Formats) => ReactNode>[0]): boolean;
20
+ has(key: string): boolean;
24
21
  };
@@ -0,0 +1,28 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { FormatNames, Locale } from './AppConfig.tsx';
3
+ import type DateTimeFormatOptions from './DateTimeFormatOptions.tsx';
4
+ import type Formats from './Formats.tsx';
5
+ import IntlError from './IntlError.tsx';
6
+ import type NumberFormatOptions from './NumberFormatOptions.tsx';
7
+ import type RelativeTimeFormatOptions from './RelativeTimeFormatOptions.tsx';
8
+ import type TimeZone from './TimeZone.tsx';
9
+ import { type Formatters, type IntlCache } from './formatters.tsx';
10
+ type Props = {
11
+ locale: Locale;
12
+ timeZone?: TimeZone;
13
+ onError?(error: IntlError): void;
14
+ formats?: Formats;
15
+ now?: Date;
16
+ /** @private */
17
+ _formatters?: Formatters;
18
+ /** @private */
19
+ _cache?: IntlCache;
20
+ };
21
+ export default function createFormatter(props: Props): {
22
+ dateTime: (value: Date | number, formatOrOptions?: FormatNames["dateTime"] | DateTimeFormatOptions) => string;
23
+ number: (value: number | bigint, formatOrOptions?: FormatNames["number"] | NumberFormatOptions) => string;
24
+ relativeTime: (date: number | Date, nowOrOptions?: RelativeTimeFormatOptions["now"] | RelativeTimeFormatOptions) => string;
25
+ list: <Value extends string | ReactElement<any, string | import("react").JSXElementConstructor<any>>>(value: Iterable<Value>, formatOrOptions?: FormatNames["list"] | Intl.ListFormatOptions) => Value extends string ? string : Iterable<ReactElement>;
26
+ dateTimeRange: (start: Date | number, end: Date | number, formatOrOptions?: FormatNames["dateTime"] | DateTimeFormatOptions) => string;
27
+ };
28
+ export {};
@@ -0,0 +1,52 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { Messages } from './AppConfig.tsx';
3
+ import type Formats from './Formats.tsx';
4
+ import type ICUArgs from './ICUArgs.tsx';
5
+ import type ICUTags from './ICUTags.tsx';
6
+ import type IntlConfig from './IntlConfig.tsx';
7
+ import type { MessageKeys, NamespaceKeys, NestedKeyOf, NestedValueOf } from './MessageKeys.tsx';
8
+ import type { ICUArg, ICUDate, ICUNumber, MarkupTagsFunction, RichTagsFunction } from './TranslationValues.tsx';
9
+ import { type Formatters, type IntlCache } from './formatters.tsx';
10
+ import type { Prettify } from './types.tsx';
11
+ type ICUArgsWithTags<MessageString extends string, TagsFn extends RichTagsFunction | MarkupTagsFunction = never> = ICUArgs<MessageString, {
12
+ ICUArgument: ICUArg;
13
+ ICUNumberArgument: ICUNumber;
14
+ ICUDateArgument: ICUDate;
15
+ }> & ([TagsFn] extends [never] ? {} : ICUTags<MessageString, TagsFn>);
16
+ type OnlyOptional<T> = Partial<T> extends T ? true : false;
17
+ type TranslateArgs<Value extends string, TagsFn extends RichTagsFunction | MarkupTagsFunction = never> = string extends Value ? [values?: Record<string, ICUArg | TagsFn>, formats?: Formats] : (Value extends any ? (key: ICUArgsWithTags<Value, TagsFn>) => void : never) extends (key: infer Args) => void ? OnlyOptional<Args> extends true ? [values?: undefined, formats?: Formats] : [values: Prettify<Args>, formats?: Formats] : never;
18
+ type NamespacedMessageKeys<TranslatorMessages extends Messages, Namespace extends NamespaceKeys<TranslatorMessages, NestedKeyOf<TranslatorMessages>> = never> = MessageKeys<NestedValueOf<{
19
+ '!': TranslatorMessages;
20
+ }, [
21
+ Namespace
22
+ ] extends [never] ? '!' : `!.${Namespace}`>, NestedKeyOf<NestedValueOf<{
23
+ '!': TranslatorMessages;
24
+ }, [
25
+ Namespace
26
+ ] extends [never] ? '!' : `!.${Namespace}`>>>;
27
+ type NamespacedValue<TranslatorMessages extends Messages, Namespace extends NamespaceKeys<TranslatorMessages, NestedKeyOf<TranslatorMessages>>, TargetKey extends NamespacedMessageKeys<TranslatorMessages, Namespace>> = NestedValueOf<TranslatorMessages, [
28
+ Namespace
29
+ ] extends [never] ? TargetKey : `${Namespace}.${TargetKey}`>;
30
+ /**
31
+ * Translates messages from the given namespace by using the ICU syntax.
32
+ * See https://formatjs.io/docs/core-concepts/icu-syntax.
33
+ *
34
+ * If no namespace is provided, all available messages are returned.
35
+ * The namespace can also indicate nesting by using a dot
36
+ * (e.g. `namespace.Component`).
37
+ */
38
+ export default function createTranslator<const TranslatorMessages extends Messages = Messages, const Namespace extends NamespaceKeys<TranslatorMessages, NestedKeyOf<TranslatorMessages>> = never>({ _cache, _formatters, getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<TranslatorMessages>, 'messages'> & {
39
+ messages?: TranslatorMessages;
40
+ namespace?: Namespace;
41
+ /** @private */
42
+ _formatters?: Formatters;
43
+ /** @private */
44
+ _cache?: IntlCache;
45
+ }): {
46
+ <TargetKey extends NamespacedMessageKeys<TranslatorMessages, Namespace>>(key: TargetKey, ...args: TranslateArgs<NamespacedValue<TranslatorMessages, Namespace, TargetKey>>): string;
47
+ rich<TargetKey extends NamespacedMessageKeys<TranslatorMessages, Namespace>>(key: TargetKey, ...args: TranslateArgs<NamespacedValue<TranslatorMessages, Namespace, TargetKey>, RichTagsFunction>): ReactNode;
48
+ markup<TargetKey extends NamespacedMessageKeys<TranslatorMessages, Namespace>>(key: TargetKey, ...args: TranslateArgs<NamespacedValue<TranslatorMessages, Namespace, TargetKey>, MarkupTagsFunction>): string;
49
+ raw<TargetKey extends NamespacedMessageKeys<TranslatorMessages, Namespace>>(key: TargetKey): any;
50
+ has<TargetKey extends NamespacedMessageKeys<TranslatorMessages, Namespace>>(key: TargetKey): boolean;
51
+ };
52
+ export {};
@@ -0,0 +1,17 @@
1
+ import type AbstractIntlMessages from './AbstractIntlMessages.tsx';
2
+ import type { InitializedIntlConfig } from './IntlConfig.tsx';
3
+ import type { NestedKeyOf } from './MessageKeys.tsx';
4
+ import type { Formatters, IntlCache } from './formatters.tsx';
5
+ export type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & {
6
+ namespace: string;
7
+ messages: Messages;
8
+ formatters: Formatters;
9
+ cache: IntlCache;
10
+ };
11
+ export default function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ messages, namespace, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): {
12
+ <TargetKey extends import("./MessageKeys.tsx").MessageKeys<import("./MessageKeys.tsx").NestedValueOf<Messages, NestedKey>, NestedKeyOf<import("./MessageKeys.tsx").NestedValueOf<Messages, NestedKey>>>>(key: TargetKey, values?: import("./TranslationValues.tsx").TranslationValues, formats?: import("./Formats.tsx").default): string;
13
+ rich: (key: string, values?: import("./TranslationValues.tsx").RichTranslationValues, formats?: import("./Formats.tsx").default) => import("react").ReactNode;
14
+ markup(key: Parameters<(key: string, values?: import("./TranslationValues.tsx").RichTranslationValues, formats?: import("./Formats.tsx").default) => import("react").ReactNode>[0], values: import("./TranslationValues.tsx").MarkupTranslationValues, formats?: Parameters<(key: string, values?: import("./TranslationValues.tsx").RichTranslationValues, formats?: import("./Formats.tsx").default) => import("react").ReactNode>[2]): string;
15
+ raw(key: string): any;
16
+ has(key: string): boolean;
17
+ };
@@ -1,4 +1,4 @@
1
- import IntlError from './IntlError';
1
+ import type IntlError from './IntlError.tsx';
2
2
  /**
3
3
  * Contains defaults that are used for all entry points into the core.
4
4
  * See also `InitializedIntlConfiguration`.
@@ -1,4 +1,4 @@
1
- import type IntlMessageFormat from 'intl-messageformat';
1
+ import type { IntlMessageFormat } from 'intl-messageformat';
2
2
  export type IntlCache = {
3
3
  dateTime: Record<string, Intl.DateTimeFormat>;
4
4
  number: Record<string, Intl.NumberFormat>;
@@ -0,0 +1,10 @@
1
+ import type { Locale } from './AppConfig.tsx';
2
+ /**
3
+ * Checks if a locale exists in a list of locales.
4
+ *
5
+ * Additionally, in development, the provided locales are validated to
6
+ * ensure they follow the Unicode language identifier standard.
7
+ *
8
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale
9
+ */
10
+ export default function hasLocale<LocaleType extends Locale>(locales: ReadonlyArray<LocaleType>, candidate?: string | null): candidate is LocaleType;
@@ -0,0 +1,20 @@
1
+ export type { default as AbstractIntlMessages } from './AbstractIntlMessages.tsx';
2
+ export type { TranslationValues, RichTranslationValues, MarkupTranslationValues, ICUArg, ICUNumber, ICUDate, RichTagsFunction, MarkupTagsFunction } from './TranslationValues.tsx';
3
+ export type { default as Formats } from './Formats.tsx';
4
+ export type { default as IntlConfig } from './IntlConfig.tsx';
5
+ export type { default as DateTimeFormatOptions } from './DateTimeFormatOptions.tsx';
6
+ export type { default as NumberFormatOptions } from './NumberFormatOptions.tsx';
7
+ export { default as IntlError } from './IntlError.tsx';
8
+ export { default as IntlErrorCode } from './IntlErrorCode.tsx';
9
+ export { default as createTranslator } from './createTranslator.tsx';
10
+ export { default as createFormatter } from './createFormatter.tsx';
11
+ export { default as initializeConfig } from './initializeConfig.tsx';
12
+ export type { MessageKeys, NamespaceKeys, NestedKeyOf, NestedValueOf } from './MessageKeys.tsx';
13
+ export { createIntlFormatters as _createIntlFormatters } from './formatters.tsx';
14
+ export { createCache as _createCache } from './formatters.tsx';
15
+ export type { default as AppConfig, Locale, Messages } from './AppConfig.tsx';
16
+ export { default as hasLocale } from './hasLocale.tsx';
17
+ export type { default as RelativeTimeFormatOptions } from './RelativeTimeFormatOptions.tsx';
18
+ export type { default as Timezone } from './TimeZone.tsx';
19
+ export type { default as ICUArgs } from './ICUArgs.tsx';
20
+ export type { default as ICUTags } from './ICUTags.tsx';
@@ -1,12 +1,12 @@
1
- import IntlConfig from './IntlConfig';
1
+ import type IntlConfig from './IntlConfig.tsx';
2
2
  /**
3
3
  * Enhances the incoming props with defaults.
4
4
  */
5
5
  export default function initializeConfig<Props extends IntlConfig>({ getMessageFallback, messages, onError, ...rest }: Props): Omit<Props, "onError" | "getMessageFallback" | "messages"> & {
6
- messages: import("./AbstractIntlMessages").default | undefined;
7
- onError: (error: import("./IntlError").default) => void;
6
+ messages: import("./AbstractIntlMessages.tsx").default | undefined;
7
+ onError: (error: import("./IntlError.tsx").default) => void;
8
8
  getMessageFallback: (info: {
9
- error: import("./IntlError").default;
9
+ error: import("./IntlError.tsx").default;
10
10
  key: string;
11
11
  namespace?: string;
12
12
  }) => string;
@@ -0,0 +1,3 @@
1
+ export type Prettify<T> = {
2
+ [K in keyof T]: T[K];
3
+ } & {};
@@ -1,3 +1,3 @@
1
- import AbstractIntlMessages from './AbstractIntlMessages';
2
- import IntlError from './IntlError';
1
+ import type AbstractIntlMessages from './AbstractIntlMessages.tsx';
2
+ import IntlError from './IntlError.tsx';
3
3
  export default function validateMessages(messages: AbstractIntlMessages, onError: (error: IntlError) => void): void;
@@ -0,0 +1 @@
1
+ export * from './core/index.tsx';
@@ -0,0 +1,2 @@
1
+ export * from './core.tsx';
2
+ export * from './react.tsx';
@@ -1,5 +1,5 @@
1
- import type { InitializedIntlConfig } from '../core/IntlConfig';
2
- import type { Formatters, IntlCache } from '../core/formatters';
1
+ import type { InitializedIntlConfig } from '../core/IntlConfig.tsx';
2
+ import type { Formatters, IntlCache } from '../core/formatters.tsx';
3
3
  export type IntlContextValue = InitializedIntlConfig & {
4
4
  formatters: Formatters;
5
5
  cache: IntlCache;
@@ -0,0 +1,7 @@
1
+ import { type ReactNode } from 'react';
2
+ import type IntlConfig from '../core/IntlConfig.tsx';
3
+ type Props = IntlConfig & {
4
+ children: ReactNode;
5
+ };
6
+ export default function IntlProvider({ children, formats, getMessageFallback, locale, messages, now, onError, timeZone }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ export { default as IntlProvider } from './IntlProvider.tsx';
2
+ export { default as useTranslations } from './useTranslations.tsx';
3
+ export { default as useLocale } from './useLocale.tsx';
4
+ export { default as useNow } from './useNow.tsx';
5
+ export { default as useTimeZone } from './useTimeZone.tsx';
6
+ export { default as useMessages } from './useMessages.tsx';
7
+ export { default as useFormatter } from './useFormatter.tsx';
@@ -1,2 +1,2 @@
1
- import createFormatter from '../core/createFormatter';
1
+ import createFormatter from '../core/createFormatter.tsx';
2
2
  export default function useFormatter(): ReturnType<typeof createFormatter>;