use-intl 2.4.1-alpha.1 → 2.4.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,2 @@
1
- declare type Unknown = {};
2
- interface GlobalMessages extends Unknown {
1
+ declare interface GlobalMessages {
3
2
  }
4
- export default GlobalMessages;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export { default as IntlProvider } from './IntlProvider';
2
2
  export { default as IntlMessages } from './IntlMessages';
3
- export { default as GlobalMessages } from './GlobalMessages';
4
3
  export { default as useTranslations } from './useTranslations';
5
4
  export { default as TranslationValues, RichTranslationValues } from './TranslationValues';
6
5
  export { default as useIntl } from './useIntl';
@@ -439,6 +439,7 @@ function useTranslationsImpl(allMessages, namespace) {
439
439
  return translate;
440
440
  }
441
441
 
442
+ // import GlobalMessages from './GlobalMessages';
442
443
  /**
443
444
  * Translates messages from the given namespace by using the ICU syntax.
444
445
  * See https://formatjs.io/docs/core-concepts/icu-syntax.
@@ -456,7 +457,8 @@ function useTranslations(namespace) {
456
457
 
457
458
  return useTranslationsImpl({
458
459
  __private: messages
459
- }, namespace ? "__private." + namespace : '__private');
460
+ }, // @ts-ignore
461
+ namespace ? "__private." + namespace : '__private');
460
462
  }
461
463
 
462
464
  var MINUTE = 60;
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.cjs.development.js","sources":["../src/IntlContext.tsx","../src/IntlProvider.tsx","../src/useIntlContext.tsx","../src/IntlError.tsx","../src/convertFormatsToIntlMessageFormat.tsx","../src/useTranslationsImpl.tsx","../src/useTranslations.tsx","../src/useIntl.tsx","../src/useLocale.tsx","../src/useNow.tsx","../src/useTimeZone.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport Formats from './Formats';\nimport IntlError from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\n\nexport type IntlContextShape = {\n messages?: IntlMessages;\n locale: string;\n formats?: Partial<Formats>;\n timeZone?: string;\n onError(error: IntlError): void;\n getMessageFallback(info: {\n error: IntlError;\n key: string;\n namespace?: string;\n }): string;\n now?: Date;\n defaultTranslationValues?: RichTranslationValues;\n};\n\nconst IntlContext = createContext<IntlContextShape | undefined>(undefined);\n\nexport default IntlContext;\n","import React, {ReactNode} from 'react';\nimport Formats from './Formats';\nimport IntlContext from './IntlContext';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\nimport {IntlError} from '.';\n\ntype Props = {\n /** All messages that will be available in your components. */\n messages?: IntlMessages;\n /** A valid Unicode locale tag (e.g. \"en\" or \"en-GB\"). */\n locale: string;\n /** Global formats can be provided to achieve consistent\n * formatting across components. */\n formats?: Partial<Formats>;\n /** A time zone as defined in [the tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) which will be applied when formatting dates and times. If this is absent, the user time zone will be used. You can override this by supplying an explicit time zone to `formatDateTime`. */\n timeZone?: string;\n /** This callback will be invoked when an error is encountered during\n * resolving a message or formatting it. This defaults to `console.error` to\n * keep your app running. You can customize the handling by taking\n * `error.code` into account. */\n onError?(error: IntlError): void;\n /** Will be called when a message couldn't be resolved or formatting it led to\n * an error. This defaults to `${namespace}.${key}` You can use this to\n * customize what will be rendered in this case. */\n getMessageFallback?(info: {\n namespace?: string;\n key: string;\n error: IntlError;\n }): string;\n /** All components that use the provided hooks should be within this tree. */\n children: ReactNode;\n /**\n * Providing this value will have two effects:\n * 1. It will be used as the default for the `now` argument of\n * `useIntl().formatRelativeTime` if no explicit value is provided.\n * 2. It will be returned as a static value from the `useNow` hook. Note\n * however that when `updateInterval` is configured on the `useNow` hook,\n * the global `now` value will only be used for the initial render, but\n * afterwards the current date will be returned continuously.\n */\n now?: Date;\n /** Global default values for translation values and rich text elements.\n * Can be used for consistent usage or styling of rich text elements.\n * Defaults will be overidden by locally provided values. */\n defaultTranslationValues?: RichTranslationValues;\n};\n\nfunction defaultGetMessageFallback({\n key,\n namespace\n}: {\n key: string;\n namespace?: string;\n}) {\n return [namespace, key].filter((part) => part != null).join('.');\n}\n\nfunction defaultOnError(error: IntlError) {\n console.error(error);\n}\n\nexport default function IntlProvider({\n children,\n onError = defaultOnError,\n getMessageFallback = defaultGetMessageFallback,\n ...contextValues\n}: Props) {\n return (\n <IntlContext.Provider\n value={{...contextValues, onError, getMessageFallback}}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n","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 __DEV__\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n","export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\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';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: string\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?: string\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 IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray,\n useMemo,\n useRef\n} from 'react';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport useIntlContext from './useIntlContext';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: IntlMessages | undefined,\n idPath: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n __DEV__ ? `No messages available at \\`${namespace}\\`.` : undefined\n );\n }\n\n let message = messages;\n\n idPath.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n __DEV__\n ? `Could not resolve \\`${idPath}\\` 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 = (children: ReactNode) => {\n const result = value(children);\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\nexport default function useTranslationsImpl<\n Messages extends IntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const messagesOrError = useMemo(() => {\n try {\n if (!allMessages) {\n throw new Error(\n __DEV__ ? `No messages were configured on the provider.` : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(allMessages, namespace)\n : allMessages;\n\n if (!retrievedMessages) {\n throw new Error(\n __DEV__\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 }, [allMessages, namespace, onError]);\n\n const translate = useMemo(() => {\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 const cachedFormatsByLocale = cachedFormatsByLocaleRef.current;\n\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 const cacheKey = [namespace, key]\n .filter((part) => part != null)\n .join('.');\n\n let messageFormat;\n if (cachedFormatsByLocale[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale[locale][cacheKey];\n } else {\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 if (typeof message === 'object') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INSUFFICIENT_PATH,\n __DEV__\n ? `Insufficient path specified for \\`${key}\\` in \\`${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }\\`.`\n : undefined\n );\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[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n\n try {\n const formattedMessage = messageFormat.format(\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n __DEV__\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 message = translateBaseFn(key, values, formats);\n\n if (typeof message !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n __DEV__\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 message;\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 onError,\n getMessageFallback,\n namespace,\n messagesOrError,\n locale,\n globalFormats,\n timeZone,\n defaultTranslationValues\n ]);\n\n return translate;\n}\n","import GlobalMessages from './GlobalMessages';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\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<GlobalMessages, NestedKeyOf<GlobalMessages>>\n>(namespace?: NestedKey) {\n // @ts-ignore\n const messages = useIntlContext().messages as GlobalMessages;\n if (!messages) throw new Error('TODO')\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 return useTranslationsImpl<\n // @ts-ignore\n {__private: GlobalMessages},\n NamespaceKeys<GlobalMessages, NestedKeyOf<GlobalMessages>> extends NestedKey\n ? '__private'\n : `__private.${NestedKey}`\n >(\n {__private: messages},\n namespace ? `__private.${namespace}` : '__private'\n );\n}\n","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport useIntlContext from './useIntlContext';\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\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\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 __DEV__\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 formatDateTime(\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 formatNumber(\n value: number,\n formatOrOptions?: string | Intl.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 formatRelativeTime(\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 __DEV__\n ? `The \\`now\\` parameter wasn't provided to \\`formatRelativeTime\\` 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 return {formatDateTime, formatNumber, formatRelativeTime};\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n","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","import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"names":["IntlContext","createContext","undefined","defaultGetMessageFallback","key","namespace","filter","part","join","defaultOnError","error","console","IntlProvider","children","onError","getMessageFallback","contextValues","React","Provider","value","useIntlContext","context","useContext","Error","IntlErrorCode","IntlError","code","originalMessage","message","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","date","time","resolvePath","messages","idPath","split","forEach","next","prepareTranslationValues","values","length","transformedValues","index","transformed","result","isValidElement","cloneElement","useTranslationsImpl","allMessages","defaultTranslationValues","globalFormats","locale","cachedFormatsByLocaleRef","useRef","messagesOrError","useMemo","retrievedMessages","intlError","MISSING_MESSAGE","translate","getFallbackFromErrorAndNotify","translateBaseFn","cachedFormatsByLocale","current","cacheKey","messageFormat","INSUFFICIENT_PATH","IntlMessageFormat","INVALID_MESSAGE","formattedMessage","format","Array","isArray","String","FORMATTING_ERROR","translateFn","rich","raw","useTranslations","__private","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","Math","abs","unit","round","useIntl","globalNow","now","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","MISSING_FORMAT","getFormattedValue","formatter","formatDateTime","Intl","DateTimeFormat","formatNumber","number","NumberFormat","formatRelativeTime","dateDate","Date","nowDate","getTime","RelativeTimeFormat","numeric","useLocale","getNow","useNow","updateInterval","useState","setNow","useEffect","intervalId","setInterval","clearInterval","useTimeZone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAMA,WAAW,gBAAGC,mBAAa,CAA+BC,SAA/B,CAAjC;;;;AC2BA,SAASC,yBAAT,CAMC,IAAA,EAAA;AAAA,EALCC,IAAAA,GAKD,QALCA,GAKD;AAAA,MAJCC,SAID,QAJCA,SAID,CAAA;AACC,EAAO,OAAA,CAACA,SAAD,EAAYD,GAAZ,EAAiBE,MAAjB,CAAwB,UAACC,IAAD,EAAA;AAAA,IAAUA,OAAAA,IAAI,IAAI,IAAlB,CAAA;AAAA,GAAxB,CAAgDC,CAAAA,IAAhD,CAAqD,GAArD,CAAP,CAAA;AACD,CAAA;;AAED,SAASC,cAAT,CAAwBC,KAAxB,EAAwC;AACtCC,EAAAA,OAAO,CAACD,KAAR,CAAcA,KAAd,CAAA,CAAA;AACD,CAAA;;AAEa,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,MAAYmF,SAAZ,mBAAOC,GAAP,CAAA;;AACA,EAAA,IAAA,SAAA,GAAsB0B,cAAQ,CAAC3B,SAAS,IAAIwB,MAAM,EAApB,CAA9B;AAAA,MAAOvB,GAAP,GAAA,SAAA,CAAA,CAAA,CAAA;AAAA,MAAY2B,MAAZ,GAAA,SAAA,CAAA,CAAA,CAAA,CAAA;;AAEAC,EAAAA,eAAS,CAAC,YAAK;AACb,IAAI,IAAA,CAACH,cAAL,EAAqB,OAAA;AAErB,IAAA,IAAMI,UAAU,GAAGC,WAAW,CAAC,YAAK;AAClCH,MAAAA,MAAM,CAACJ,MAAM,EAAP,CAAN,CAAA;AACD,KAF6B,EAE3BE,cAF2B,CAA9B,CAAA;AAIA,IAAA,OAAO,YAAK;AACVM,MAAAA,aAAa,CAACF,UAAD,CAAb,CAAA;AACD,KAFD,CAAA;AAGD,GAVQ,EAUN,CAAC9B,SAAD,EAAY0B,cAAZ,CAVM,CAAT,CAAA;AAYA,EAAA,OAAOzB,GAAP,CAAA;AACD;;AC9Ca,SAAUgC,WAAV,GAAqB;AACjC,EAAOpH,OAAAA,cAAc,GAAGW,QAAxB,CAAA;AACD;;;;;;;;;;"}
1
+ {"version":3,"file":"use-intl.cjs.development.js","sources":["../src/IntlContext.tsx","../src/IntlProvider.tsx","../src/useIntlContext.tsx","../src/IntlError.tsx","../src/convertFormatsToIntlMessageFormat.tsx","../src/useTranslationsImpl.tsx","../src/useTranslations.tsx","../src/useIntl.tsx","../src/useLocale.tsx","../src/useNow.tsx","../src/useTimeZone.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport Formats from './Formats';\nimport IntlError from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\n\nexport type IntlContextShape = {\n messages?: IntlMessages;\n locale: string;\n formats?: Partial<Formats>;\n timeZone?: string;\n onError(error: IntlError): void;\n getMessageFallback(info: {\n error: IntlError;\n key: string;\n namespace?: string;\n }): string;\n now?: Date;\n defaultTranslationValues?: RichTranslationValues;\n};\n\nconst IntlContext = createContext<IntlContextShape | undefined>(undefined);\n\nexport default IntlContext;\n","import React, {ReactNode} from 'react';\nimport Formats from './Formats';\nimport IntlContext from './IntlContext';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\nimport {IntlError} from '.';\n\ntype Props = {\n /** All messages that will be available in your components. */\n messages?: IntlMessages;\n /** A valid Unicode locale tag (e.g. \"en\" or \"en-GB\"). */\n locale: string;\n /** Global formats can be provided to achieve consistent\n * formatting across components. */\n formats?: Partial<Formats>;\n /** A time zone as defined in [the tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) which will be applied when formatting dates and times. If this is absent, the user time zone will be used. You can override this by supplying an explicit time zone to `formatDateTime`. */\n timeZone?: string;\n /** This callback will be invoked when an error is encountered during\n * resolving a message or formatting it. This defaults to `console.error` to\n * keep your app running. You can customize the handling by taking\n * `error.code` into account. */\n onError?(error: IntlError): void;\n /** Will be called when a message couldn't be resolved or formatting it led to\n * an error. This defaults to `${namespace}.${key}` You can use this to\n * customize what will be rendered in this case. */\n getMessageFallback?(info: {\n namespace?: string;\n key: string;\n error: IntlError;\n }): string;\n /** All components that use the provided hooks should be within this tree. */\n children: ReactNode;\n /**\n * Providing this value will have two effects:\n * 1. It will be used as the default for the `now` argument of\n * `useIntl().formatRelativeTime` if no explicit value is provided.\n * 2. It will be returned as a static value from the `useNow` hook. Note\n * however that when `updateInterval` is configured on the `useNow` hook,\n * the global `now` value will only be used for the initial render, but\n * afterwards the current date will be returned continuously.\n */\n now?: Date;\n /** Global default values for translation values and rich text elements.\n * Can be used for consistent usage or styling of rich text elements.\n * Defaults will be overidden by locally provided values. */\n defaultTranslationValues?: RichTranslationValues;\n};\n\nfunction defaultGetMessageFallback({\n key,\n namespace\n}: {\n key: string;\n namespace?: string;\n}) {\n return [namespace, key].filter((part) => part != null).join('.');\n}\n\nfunction defaultOnError(error: IntlError) {\n console.error(error);\n}\n\nexport default function IntlProvider({\n children,\n onError = defaultOnError,\n getMessageFallback = defaultGetMessageFallback,\n ...contextValues\n}: Props) {\n return (\n <IntlContext.Provider\n value={{...contextValues, onError, getMessageFallback}}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n","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 __DEV__\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n","export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\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';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: string\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?: string\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 IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray,\n useMemo,\n useRef\n} from 'react';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport useIntlContext from './useIntlContext';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: IntlMessages | undefined,\n idPath: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n __DEV__ ? `No messages available at \\`${namespace}\\`.` : undefined\n );\n }\n\n let message = messages;\n\n idPath.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n __DEV__\n ? `Could not resolve \\`${idPath}\\` 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 = (children: ReactNode) => {\n const result = value(children);\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\nexport default function useTranslationsImpl<\n Messages extends IntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const messagesOrError = useMemo(() => {\n try {\n if (!allMessages) {\n throw new Error(\n __DEV__ ? `No messages were configured on the provider.` : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(allMessages, namespace)\n : allMessages;\n\n if (!retrievedMessages) {\n throw new Error(\n __DEV__\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 }, [allMessages, namespace, onError]);\n\n const translate = useMemo(() => {\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 const cachedFormatsByLocale = cachedFormatsByLocaleRef.current;\n\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 const cacheKey = [namespace, key]\n .filter((part) => part != null)\n .join('.');\n\n let messageFormat;\n if (cachedFormatsByLocale[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale[locale][cacheKey];\n } else {\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 if (typeof message === 'object') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INSUFFICIENT_PATH,\n __DEV__\n ? `Insufficient path specified for \\`${key}\\` in \\`${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }\\`.`\n : undefined\n );\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[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n\n try {\n const formattedMessage = messageFormat.format(\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n __DEV__\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 message = translateBaseFn(key, values, formats);\n\n if (typeof message !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n __DEV__\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 message;\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 onError,\n getMessageFallback,\n namespace,\n messagesOrError,\n locale,\n globalFormats,\n timeZone,\n defaultTranslationValues\n ]);\n\n return translate;\n}\n","// import GlobalMessages from './GlobalMessages';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\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<GlobalMessages, NestedKeyOf<GlobalMessages>>\n>(namespace?: NestedKey) {\n // @ts-ignore\n const messages = useIntlContext().messages as GlobalMessages;\n if (!messages) throw new Error('TODO')\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 return useTranslationsImpl<\n // @ts-ignore\n {__private: GlobalMessages},\n NamespaceKeys<GlobalMessages, NestedKeyOf<GlobalMessages>> extends NestedKey\n ? '__private'\n : `__private.${NestedKey}`\n >(\n {__private: messages},\n // @ts-ignore\n namespace ? `__private.${namespace}` : '__private'\n );\n}\n","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport useIntlContext from './useIntlContext';\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\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\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 __DEV__\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 formatDateTime(\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 formatNumber(\n value: number,\n formatOrOptions?: string | Intl.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 formatRelativeTime(\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 __DEV__\n ? `The \\`now\\` parameter wasn't provided to \\`formatRelativeTime\\` 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 return {formatDateTime, formatNumber, formatRelativeTime};\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n","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","import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"names":["IntlContext","createContext","undefined","defaultGetMessageFallback","key","namespace","filter","part","join","defaultOnError","error","console","IntlProvider","children","onError","getMessageFallback","contextValues","React","Provider","value","useIntlContext","context","useContext","Error","IntlErrorCode","IntlError","code","originalMessage","message","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","date","time","resolvePath","messages","idPath","split","forEach","next","prepareTranslationValues","values","length","transformedValues","index","transformed","result","isValidElement","cloneElement","useTranslationsImpl","allMessages","defaultTranslationValues","globalFormats","locale","cachedFormatsByLocaleRef","useRef","messagesOrError","useMemo","retrievedMessages","intlError","MISSING_MESSAGE","translate","getFallbackFromErrorAndNotify","translateBaseFn","cachedFormatsByLocale","current","cacheKey","messageFormat","INSUFFICIENT_PATH","IntlMessageFormat","INVALID_MESSAGE","formattedMessage","format","Array","isArray","String","FORMATTING_ERROR","translateFn","rich","raw","useTranslations","__private","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","Math","abs","unit","round","useIntl","globalNow","now","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","MISSING_FORMAT","getFormattedValue","formatter","formatDateTime","Intl","DateTimeFormat","formatNumber","number","NumberFormat","formatRelativeTime","dateDate","Date","nowDate","getTime","RelativeTimeFormat","numeric","useLocale","getNow","useNow","updateInterval","useState","setNow","useEffect","intervalId","setInterval","clearInterval","useTimeZone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAMA,WAAW,gBAAGC,mBAAa,CAA+BC,SAA/B,CAAjC;;;;AC2BA,SAASC,yBAAT,CAMC,IAAA,EAAA;AAAA,EALCC,IAAAA,GAKD,QALCA,GAKD;AAAA,MAJCC,SAID,QAJCA,SAID,CAAA;AACC,EAAO,OAAA,CAACA,SAAD,EAAYD,GAAZ,EAAiBE,MAAjB,CAAwB,UAACC,IAAD,EAAA;AAAA,IAAUA,OAAAA,IAAI,IAAI,IAAlB,CAAA;AAAA,GAAxB,CAAgDC,CAAAA,IAAhD,CAAqD,GAArD,CAAP,CAAA;AACD,CAAA;;AAED,SAASC,cAAT,CAAwBC,KAAxB,EAAwC;AACtCC,EAAAA,OAAO,CAACD,KAAR,CAAcA,KAAd,CAAA,CAAA;AACD,CAAA;;AAEa,SAAUE,YAAV,CAKN,KAAA,EAAA;AAAA,EAJNC,IAAAA,QAIM,SAJNA,QAIM;AAAA,MAAA,aAAA,GAA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AC3B,SAAS,IAAIwB,MAAM,EAApB,CAA9B;AAAA,MAAOvB,GAAP,GAAA,SAAA,CAAA,CAAA,CAAA;AAAA,MAAY2B,MAAZ,GAAA,SAAA,CAAA,CAAA,CAAA,CAAA;;AAEAC,EAAAA,eAAS,CAAC,YAAK;AACb,IAAI,IAAA,CAACH,cAAL,EAAqB,OAAA;AAErB,IAAA,IAAMI,UAAU,GAAGC,WAAW,CAAC,YAAK;AAClCH,MAAAA,MAAM,CAACJ,MAAM,EAAP,CAAN,CAAA;AACD,KAF6B,EAE3BE,cAF2B,CAA9B,CAAA;AAIA,IAAA,OAAO,YAAK;AACVM,MAAAA,aAAa,CAACF,UAAD,CAAb,CAAA;AACD,KAFD,CAAA;AAGD,GAVQ,EAUN,CAAC9B,SAAD,EAAY0B,cAAZ,CAVM,CAAT,CAAA;AAYA,EAAA,OAAOzB,GAAP,CAAA;AACD;;AC9Ca,SAAUgC,WAAV,GAAqB;AACjC,EAAOpH,OAAAA,cAAc,GAAGW,QAAxB,CAAA;AACD;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.cjs.production.min.js","sources":["../src/IntlContext.tsx","../src/IntlError.tsx","../src/IntlProvider.tsx","../src/useIntlContext.tsx","../src/convertFormatsToIntlMessageFormat.tsx","../src/useTranslationsImpl.tsx","../src/useNow.tsx","../src/useIntl.tsx","../src/useLocale.tsx","../src/useTimeZone.tsx","../src/useTranslations.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport Formats from './Formats';\nimport IntlError from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\n\nexport type IntlContextShape = {\n messages?: IntlMessages;\n locale: string;\n formats?: Partial<Formats>;\n timeZone?: string;\n onError(error: IntlError): void;\n getMessageFallback(info: {\n error: IntlError;\n key: string;\n namespace?: string;\n }): string;\n now?: Date;\n defaultTranslationValues?: RichTranslationValues;\n};\n\nconst IntlContext = createContext<IntlContextShape | undefined>(undefined);\n\nexport default IntlContext;\n","export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\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 React, {ReactNode} from 'react';\nimport Formats from './Formats';\nimport IntlContext from './IntlContext';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\nimport {IntlError} from '.';\n\ntype Props = {\n /** All messages that will be available in your components. */\n messages?: IntlMessages;\n /** A valid Unicode locale tag (e.g. \"en\" or \"en-GB\"). */\n locale: string;\n /** Global formats can be provided to achieve consistent\n * formatting across components. */\n formats?: Partial<Formats>;\n /** A time zone as defined in [the tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) which will be applied when formatting dates and times. If this is absent, the user time zone will be used. You can override this by supplying an explicit time zone to `formatDateTime`. */\n timeZone?: string;\n /** This callback will be invoked when an error is encountered during\n * resolving a message or formatting it. This defaults to `console.error` to\n * keep your app running. You can customize the handling by taking\n * `error.code` into account. */\n onError?(error: IntlError): void;\n /** Will be called when a message couldn't be resolved or formatting it led to\n * an error. This defaults to `${namespace}.${key}` You can use this to\n * customize what will be rendered in this case. */\n getMessageFallback?(info: {\n namespace?: string;\n key: string;\n error: IntlError;\n }): string;\n /** All components that use the provided hooks should be within this tree. */\n children: ReactNode;\n /**\n * Providing this value will have two effects:\n * 1. It will be used as the default for the `now` argument of\n * `useIntl().formatRelativeTime` if no explicit value is provided.\n * 2. It will be returned as a static value from the `useNow` hook. Note\n * however that when `updateInterval` is configured on the `useNow` hook,\n * the global `now` value will only be used for the initial render, but\n * afterwards the current date will be returned continuously.\n */\n now?: Date;\n /** Global default values for translation values and rich text elements.\n * Can be used for consistent usage or styling of rich text elements.\n * Defaults will be overidden by locally provided values. */\n defaultTranslationValues?: RichTranslationValues;\n};\n\nfunction defaultGetMessageFallback({\n key,\n namespace\n}: {\n key: string;\n namespace?: string;\n}) {\n return [namespace, key].filter((part) => part != null).join('.');\n}\n\nfunction defaultOnError(error: IntlError) {\n console.error(error);\n}\n\nexport default function IntlProvider({\n children,\n onError = defaultOnError,\n getMessageFallback = defaultGetMessageFallback,\n ...contextValues\n}: Props) {\n return (\n <IntlContext.Provider\n value={{...contextValues, onError, getMessageFallback}}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n","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 __DEV__\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n","import {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: string\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?: string\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 IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray,\n useMemo,\n useRef\n} from 'react';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport useIntlContext from './useIntlContext';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: IntlMessages | undefined,\n idPath: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n __DEV__ ? `No messages available at \\`${namespace}\\`.` : undefined\n );\n }\n\n let message = messages;\n\n idPath.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n __DEV__\n ? `Could not resolve \\`${idPath}\\` 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 = (children: ReactNode) => {\n const result = value(children);\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\nexport default function useTranslationsImpl<\n Messages extends IntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const messagesOrError = useMemo(() => {\n try {\n if (!allMessages) {\n throw new Error(\n __DEV__ ? `No messages were configured on the provider.` : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(allMessages, namespace)\n : allMessages;\n\n if (!retrievedMessages) {\n throw new Error(\n __DEV__\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 }, [allMessages, namespace, onError]);\n\n const translate = useMemo(() => {\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 const cachedFormatsByLocale = cachedFormatsByLocaleRef.current;\n\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 const cacheKey = [namespace, key]\n .filter((part) => part != null)\n .join('.');\n\n let messageFormat;\n if (cachedFormatsByLocale[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale[locale][cacheKey];\n } else {\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 if (typeof message === 'object') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INSUFFICIENT_PATH,\n __DEV__\n ? `Insufficient path specified for \\`${key}\\` in \\`${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }\\`.`\n : undefined\n );\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[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n\n try {\n const formattedMessage = messageFormat.format(\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n __DEV__\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 message = translateBaseFn(key, values, formats);\n\n if (typeof message !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n __DEV__\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 message;\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 onError,\n getMessageFallback,\n namespace,\n messagesOrError,\n locale,\n globalFormats,\n timeZone,\n defaultTranslationValues\n ]);\n\n return translate;\n}\n","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","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport useIntlContext from './useIntlContext';\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\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\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 __DEV__\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 formatDateTime(\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 formatNumber(\n value: number,\n formatOrOptions?: string | Intl.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 formatRelativeTime(\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 __DEV__\n ? `The \\`now\\` parameter wasn't provided to \\`formatRelativeTime\\` 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 return {formatDateTime, formatNumber, formatRelativeTime};\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n","import GlobalMessages from './GlobalMessages';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\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<GlobalMessages, NestedKeyOf<GlobalMessages>>\n>(namespace?: NestedKey) {\n // @ts-ignore\n const messages = useIntlContext().messages as GlobalMessages;\n if (!messages) throw new Error('TODO')\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 return useTranslationsImpl<\n // @ts-ignore\n {__private: GlobalMessages},\n NamespaceKeys<GlobalMessages, NestedKeyOf<GlobalMessages>> extends NestedKey\n ? '__private'\n : `__private.${NestedKey}`\n >(\n {__private: messages},\n namespace ? `__private.${namespace}` : '__private'\n );\n}\n"],"names":["IntlErrorCode","IntlContext","createContext","undefined","defaultGetMessageFallback","_ref","namespace","key","filter","part","join","defaultOnError","error","console","useIntlContext","context","useContext","Error","IntlError","code","originalMessage","_this","message","_Error","call","this","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","_extends","resolvePath","messages","idPath","split","forEach","next","getNow","Date","_ref2","children","_ref2$onError","onError","_ref2$getMessageFallb","getMessageFallback","contextValues","_objectWithoutPropertiesLoose","_excluded","React","Provider","value","_useIntlContext","locale","globalNow","now","getFormattedValue","formatOrOptions","typeFormats","formatter","options","MISSING_FORMAT","resolveFormatOrOptions","String","FORMATTING_ERROR","formatDateTime","dateTime","_options","Intl","DateTimeFormat","format","formatNumber","number","NumberFormat","formatRelativeTime","date","dateDate","nowDate","getRelativeTimeFormatConfig","seconds","unit","absValue","Math","abs","round","MINUTE","HOUR","DAY","getTime","RelativeTimeFormat","numeric","updateInterval","_useState","useState","setNow","useEffect","intervalId","setInterval","clearInterval","allMessages","defaultTranslationValues","globalFormats","cachedFormatsByLocaleRef","useRef","messagesOrError","useMemo","retrievedMessages","intlError","MISSING_MESSAGE","getFallbackFromErrorAndNotify","translateBaseFn","values","_cachedFormatsByLocal","cachedFormatsByLocale","current","messageFormat","cacheKey","INSUFFICIENT_PATH","IntlMessageFormat","formatsWithTimeZone","time","convertFormatsToIntlMessageFormat","INVALID_MESSAGE","formattedMessage","length","transformedValues","index","result","isValidElement","cloneElement","prepareTranslationValues","Array","isArray","translateFn","rich","raw","useTranslationsImpl","__private"],"mappings":"siDAqBA,ICrBYA,EDqBNC,EAAcC,EAAaA,mBAA+BC,iDE2BhE,SAASC,EAMRC,GACQ,MAAA,GALPC,YADAC,KAMwBC,QAAO,SAACC,GAASA,OAAQ,MAARA,KAAcC,KAAK,KAG9D,SAASC,EAAeC,GACtBC,QAAQD,MAAMA,GCxDF,SAAUE,IACtB,IAAMC,EAAUC,aAAWf,GAEvB,IAACc,EACH,MAAM,IAAIE,WAGJd,GAIR,OAAOY,EFdGf,QAAZA,mBAAA,GAAYA,EAAAA,wBAAAA,QAAAA,cAMX,KALC,gBAAA,kBACAA,EAAA,eAAA,iBACAA,EAAA,kBAAA,oBACAA,EAAA,gBAAA,kBACAA,EAAA,iBAAA,uBAGmBkB,sBAIPC,SAAAA,EAAAA,EAAqBC,GAAwB,IAAAC,EACnDC,EAAkBH,EADiC,OAEnDC,IACFE,GAAW,KAAOF,IAEpBC,EAAAE,EAAAC,KAAAC,KAAMH,IAANG,MARcN,UAGyC,EAAAE,EAFzCD,qBAEyC,EAOlDD,EAAAA,KAAOA,EACRC,IACGA,EAAAA,gBAAkBA,GAT8BC,8FAJpBJ,QGJvC,SAASS,EACPC,EACAC,GAEA,OAAKD,EAIEE,OAAOC,KAAKH,GAASI,QAC1B,SAACC,EAA4CzB,GAK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EAAS,aAAgBA,EAAc"}
1
+ {"version":3,"file":"use-intl.cjs.production.min.js","sources":["../src/IntlContext.tsx","../src/IntlError.tsx","../src/IntlProvider.tsx","../src/useIntlContext.tsx","../src/convertFormatsToIntlMessageFormat.tsx","../src/useTranslationsImpl.tsx","../src/useNow.tsx","../src/useIntl.tsx","../src/useLocale.tsx","../src/useTimeZone.tsx","../src/useTranslations.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport Formats from './Formats';\nimport IntlError from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\n\nexport type IntlContextShape = {\n messages?: IntlMessages;\n locale: string;\n formats?: Partial<Formats>;\n timeZone?: string;\n onError(error: IntlError): void;\n getMessageFallback(info: {\n error: IntlError;\n key: string;\n namespace?: string;\n }): string;\n now?: Date;\n defaultTranslationValues?: RichTranslationValues;\n};\n\nconst IntlContext = createContext<IntlContextShape | undefined>(undefined);\n\nexport default IntlContext;\n","export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\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 React, {ReactNode} from 'react';\nimport Formats from './Formats';\nimport IntlContext from './IntlContext';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\nimport {IntlError} from '.';\n\ntype Props = {\n /** All messages that will be available in your components. */\n messages?: IntlMessages;\n /** A valid Unicode locale tag (e.g. \"en\" or \"en-GB\"). */\n locale: string;\n /** Global formats can be provided to achieve consistent\n * formatting across components. */\n formats?: Partial<Formats>;\n /** A time zone as defined in [the tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) which will be applied when formatting dates and times. If this is absent, the user time zone will be used. You can override this by supplying an explicit time zone to `formatDateTime`. */\n timeZone?: string;\n /** This callback will be invoked when an error is encountered during\n * resolving a message or formatting it. This defaults to `console.error` to\n * keep your app running. You can customize the handling by taking\n * `error.code` into account. */\n onError?(error: IntlError): void;\n /** Will be called when a message couldn't be resolved or formatting it led to\n * an error. This defaults to `${namespace}.${key}` You can use this to\n * customize what will be rendered in this case. */\n getMessageFallback?(info: {\n namespace?: string;\n key: string;\n error: IntlError;\n }): string;\n /** All components that use the provided hooks should be within this tree. */\n children: ReactNode;\n /**\n * Providing this value will have two effects:\n * 1. It will be used as the default for the `now` argument of\n * `useIntl().formatRelativeTime` if no explicit value is provided.\n * 2. It will be returned as a static value from the `useNow` hook. Note\n * however that when `updateInterval` is configured on the `useNow` hook,\n * the global `now` value will only be used for the initial render, but\n * afterwards the current date will be returned continuously.\n */\n now?: Date;\n /** Global default values for translation values and rich text elements.\n * Can be used for consistent usage or styling of rich text elements.\n * Defaults will be overidden by locally provided values. */\n defaultTranslationValues?: RichTranslationValues;\n};\n\nfunction defaultGetMessageFallback({\n key,\n namespace\n}: {\n key: string;\n namespace?: string;\n}) {\n return [namespace, key].filter((part) => part != null).join('.');\n}\n\nfunction defaultOnError(error: IntlError) {\n console.error(error);\n}\n\nexport default function IntlProvider({\n children,\n onError = defaultOnError,\n getMessageFallback = defaultGetMessageFallback,\n ...contextValues\n}: Props) {\n return (\n <IntlContext.Provider\n value={{...contextValues, onError, getMessageFallback}}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n","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 __DEV__\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n","import {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: string\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?: string\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 IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray,\n useMemo,\n useRef\n} from 'react';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport useIntlContext from './useIntlContext';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: IntlMessages | undefined,\n idPath: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n __DEV__ ? `No messages available at \\`${namespace}\\`.` : undefined\n );\n }\n\n let message = messages;\n\n idPath.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n __DEV__\n ? `Could not resolve \\`${idPath}\\` 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 = (children: ReactNode) => {\n const result = value(children);\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\nexport default function useTranslationsImpl<\n Messages extends IntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const messagesOrError = useMemo(() => {\n try {\n if (!allMessages) {\n throw new Error(\n __DEV__ ? `No messages were configured on the provider.` : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(allMessages, namespace)\n : allMessages;\n\n if (!retrievedMessages) {\n throw new Error(\n __DEV__\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 }, [allMessages, namespace, onError]);\n\n const translate = useMemo(() => {\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 const cachedFormatsByLocale = cachedFormatsByLocaleRef.current;\n\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 const cacheKey = [namespace, key]\n .filter((part) => part != null)\n .join('.');\n\n let messageFormat;\n if (cachedFormatsByLocale[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale[locale][cacheKey];\n } else {\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 if (typeof message === 'object') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INSUFFICIENT_PATH,\n __DEV__\n ? `Insufficient path specified for \\`${key}\\` in \\`${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }\\`.`\n : undefined\n );\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[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n\n try {\n const formattedMessage = messageFormat.format(\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n __DEV__\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 message = translateBaseFn(key, values, formats);\n\n if (typeof message !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n __DEV__\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 message;\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 onError,\n getMessageFallback,\n namespace,\n messagesOrError,\n locale,\n globalFormats,\n timeZone,\n defaultTranslationValues\n ]);\n\n return translate;\n}\n","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","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport useIntlContext from './useIntlContext';\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\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\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 __DEV__\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 formatDateTime(\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 formatNumber(\n value: number,\n formatOrOptions?: string | Intl.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 formatRelativeTime(\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 __DEV__\n ? `The \\`now\\` parameter wasn't provided to \\`formatRelativeTime\\` 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 return {formatDateTime, formatNumber, formatRelativeTime};\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n","// import GlobalMessages from './GlobalMessages';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\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<GlobalMessages, NestedKeyOf<GlobalMessages>>\n>(namespace?: NestedKey) {\n // @ts-ignore\n const messages = useIntlContext().messages as GlobalMessages;\n if (!messages) throw new Error('TODO')\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 return useTranslationsImpl<\n // @ts-ignore\n {__private: GlobalMessages},\n NamespaceKeys<GlobalMessages, NestedKeyOf<GlobalMessages>> extends NestedKey\n ? '__private'\n : `__private.${NestedKey}`\n >(\n {__private: messages},\n // @ts-ignore\n namespace ? `__private.${namespace}` : '__private'\n );\n}\n"],"names":["IntlErrorCode","IntlContext","createContext","undefined","defaultGetMessageFallback","_ref","namespace","key","filter","part","join","defaultOnError","error","console","useIntlContext","context","useContext","Error","IntlError","code","originalMessage","_this","message","_Error","call","this","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","_extends","resolvePath","messages","idPath","split","forEach","next","getNow","Date","_ref2","children","_ref2$onError","onError","_ref2$getMessageFallb","getMessageFallback","contextValues","_objectWithoutPropertiesLoose","_excluded","React","Provider","value","_useIntlContext","locale","globalNow","now","getFormattedValue","formatOrOptions","typeFormats","formatter","options","MISSING_FORMAT","resolveFormatOrOptions","String","FORMATTING_ERROR","formatDateTime","dateTime","_options","Intl","DateTimeFormat","format","formatNumber","number","NumberFormat","formatRelativeTime","date","dateDate","nowDate","getRelativeTimeFormatConfig","seconds","unit","absValue","Math","abs","round","MINUTE","HOUR","DAY","getTime","RelativeTimeFormat","numeric","updateInterval","_useState","useState","setNow","useEffect","intervalId","setInterval","clearInterval","allMessages","defaultTranslationValues","globalFormats","cachedFormatsByLocaleRef","useRef","messagesOrError","useMemo","retrievedMessages","intlError","MISSING_MESSAGE","getFallbackFromErrorAndNotify","translateBaseFn","values","_cachedFormatsByLocal","cachedFormatsByLocale","current","messageFormat","cacheKey","INSUFFICIENT_PATH","IntlMessageFormat","formatsWithTimeZone","time","convertFormatsToIntlMessageFormat","INVALID_MESSAGE","formattedMessage","length","transformedValues","index","result","isValidElement","cloneElement","prepareTranslationValues","Array","isArray","translateFn","rich","raw","useTranslationsImpl","__private"],"mappings":"siDAqBA,ICrBYA,EDqBNC,EAAcC,EAAaA,mBAA+BC,iDE2BhE,SAASC,EAMRC,GACQ,MAAA,GALPC,YADAC,KAMwBC,QAAO,SAACC,GAASA,OAAQ,MAARA,KAAcC,KAAK,KAG9D,SAASC,EAAeC,GACtBC,QAAQD,M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EACAP,QAAAA,cAAckE,iBACbtD,EAAgBU,UAKvB,SAASiH,EAOPhI,EAEA0G,EAEAtF,GAEML,IAAAA,EAAU0F,EAAgBzG,EAAK0G,EAAQtF,GAE7C,MAAuB,iBAAZL,EACFyF,EACLxG,EACAP,QAAaA,cAAC4H,qBAKVzH,GAIDmB,EA8BT,OA3BAiH,EAAYC,KAAOxB,EAEnBuB,EAAYE,IAAM,SAEhBlI,GAEImG,GAAAA,aAA2BxF,EAE7B,OAAO6B,EAAmB,CACxBnC,MAAO8F,EACPnG,IAAAA,EACAD,UAAAA,IAGE6B,IAAAA,EAAWuE,EAEb,IACF,OAAOxE,EAAYC,EAAU5B,GAC7B,MAAOK,GACAmG,OAAAA,EACLxG,EACAP,QAAAA,cAAc8G,gBACblG,EAAgBU,WAKhBiH,IACN,CACD1F,EACAE,EACAzC,EACAoG,EACAnD,EACAgD,EACA3E,EACA0E,IK/RKoC,CAOL,CAACC,UAAWxG,GAEZ7B,EAAS,aAAgBA,EAAc"}
@@ -430,6 +430,7 @@ function useTranslationsImpl(allMessages, namespace) {
430
430
  return translate;
431
431
  }
432
432
 
433
+ // import GlobalMessages from './GlobalMessages';
433
434
  /**
434
435
  * Translates messages from the given namespace by using the ICU syntax.
435
436
  * See https://formatjs.io/docs/core-concepts/icu-syntax.
@@ -447,7 +448,8 @@ function useTranslations(namespace) {
447
448
 
448
449
  return useTranslationsImpl({
449
450
  __private: messages
450
- }, namespace ? "__private." + namespace : '__private');
451
+ }, // @ts-ignore
452
+ namespace ? "__private." + namespace : '__private');
451
453
  }
452
454
 
453
455
  var MINUTE = 60;
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm.js","sources":["../src/IntlContext.tsx","../src/IntlProvider.tsx","../src/useIntlContext.tsx","../src/IntlError.tsx","../src/convertFormatsToIntlMessageFormat.tsx","../src/useTranslationsImpl.tsx","../src/useTranslations.tsx","../src/useIntl.tsx","../src/useLocale.tsx","../src/useNow.tsx","../src/useTimeZone.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport Formats from './Formats';\nimport IntlError from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\n\nexport type IntlContextShape = {\n messages?: IntlMessages;\n locale: string;\n formats?: Partial<Formats>;\n timeZone?: string;\n onError(error: IntlError): void;\n getMessageFallback(info: {\n error: IntlError;\n key: string;\n namespace?: string;\n }): string;\n now?: Date;\n defaultTranslationValues?: RichTranslationValues;\n};\n\nconst IntlContext = createContext<IntlContextShape | undefined>(undefined);\n\nexport default IntlContext;\n","import React, {ReactNode} from 'react';\nimport Formats from './Formats';\nimport IntlContext from './IntlContext';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\nimport {IntlError} from '.';\n\ntype Props = {\n /** All messages that will be available in your components. */\n messages?: IntlMessages;\n /** A valid Unicode locale tag (e.g. \"en\" or \"en-GB\"). */\n locale: string;\n /** Global formats can be provided to achieve consistent\n * formatting across components. */\n formats?: Partial<Formats>;\n /** A time zone as defined in [the tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) which will be applied when formatting dates and times. If this is absent, the user time zone will be used. You can override this by supplying an explicit time zone to `formatDateTime`. */\n timeZone?: string;\n /** This callback will be invoked when an error is encountered during\n * resolving a message or formatting it. This defaults to `console.error` to\n * keep your app running. You can customize the handling by taking\n * `error.code` into account. */\n onError?(error: IntlError): void;\n /** Will be called when a message couldn't be resolved or formatting it led to\n * an error. This defaults to `${namespace}.${key}` You can use this to\n * customize what will be rendered in this case. */\n getMessageFallback?(info: {\n namespace?: string;\n key: string;\n error: IntlError;\n }): string;\n /** All components that use the provided hooks should be within this tree. */\n children: ReactNode;\n /**\n * Providing this value will have two effects:\n * 1. It will be used as the default for the `now` argument of\n * `useIntl().formatRelativeTime` if no explicit value is provided.\n * 2. It will be returned as a static value from the `useNow` hook. Note\n * however that when `updateInterval` is configured on the `useNow` hook,\n * the global `now` value will only be used for the initial render, but\n * afterwards the current date will be returned continuously.\n */\n now?: Date;\n /** Global default values for translation values and rich text elements.\n * Can be used for consistent usage or styling of rich text elements.\n * Defaults will be overidden by locally provided values. */\n defaultTranslationValues?: RichTranslationValues;\n};\n\nfunction defaultGetMessageFallback({\n key,\n namespace\n}: {\n key: string;\n namespace?: string;\n}) {\n return [namespace, key].filter((part) => part != null).join('.');\n}\n\nfunction defaultOnError(error: IntlError) {\n console.error(error);\n}\n\nexport default function IntlProvider({\n children,\n onError = defaultOnError,\n getMessageFallback = defaultGetMessageFallback,\n ...contextValues\n}: Props) {\n return (\n <IntlContext.Provider\n value={{...contextValues, onError, getMessageFallback}}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n","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 __DEV__\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n","export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\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';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: string\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?: string\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 IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray,\n useMemo,\n useRef\n} from 'react';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport useIntlContext from './useIntlContext';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: IntlMessages | undefined,\n idPath: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n __DEV__ ? `No messages available at \\`${namespace}\\`.` : undefined\n );\n }\n\n let message = messages;\n\n idPath.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n __DEV__\n ? `Could not resolve \\`${idPath}\\` 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 = (children: ReactNode) => {\n const result = value(children);\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\nexport default function useTranslationsImpl<\n Messages extends IntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const messagesOrError = useMemo(() => {\n try {\n if (!allMessages) {\n throw new Error(\n __DEV__ ? `No messages were configured on the provider.` : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(allMessages, namespace)\n : allMessages;\n\n if (!retrievedMessages) {\n throw new Error(\n __DEV__\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 }, [allMessages, namespace, onError]);\n\n const translate = useMemo(() => {\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 const cachedFormatsByLocale = cachedFormatsByLocaleRef.current;\n\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 const cacheKey = [namespace, key]\n .filter((part) => part != null)\n .join('.');\n\n let messageFormat;\n if (cachedFormatsByLocale[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale[locale][cacheKey];\n } else {\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 if (typeof message === 'object') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INSUFFICIENT_PATH,\n __DEV__\n ? `Insufficient path specified for \\`${key}\\` in \\`${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }\\`.`\n : undefined\n );\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[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n\n try {\n const formattedMessage = messageFormat.format(\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n __DEV__\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 message = translateBaseFn(key, values, formats);\n\n if (typeof message !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n __DEV__\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 message;\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 onError,\n getMessageFallback,\n namespace,\n messagesOrError,\n locale,\n globalFormats,\n timeZone,\n defaultTranslationValues\n ]);\n\n return translate;\n}\n","import GlobalMessages from './GlobalMessages';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\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<GlobalMessages, NestedKeyOf<GlobalMessages>>\n>(namespace?: NestedKey) {\n // @ts-ignore\n const messages = useIntlContext().messages as GlobalMessages;\n if (!messages) throw new Error('TODO')\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 return useTranslationsImpl<\n // @ts-ignore\n {__private: GlobalMessages},\n NamespaceKeys<GlobalMessages, NestedKeyOf<GlobalMessages>> extends NestedKey\n ? '__private'\n : `__private.${NestedKey}`\n >(\n {__private: messages},\n namespace ? `__private.${namespace}` : '__private'\n );\n}\n","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport useIntlContext from './useIntlContext';\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\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\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 __DEV__\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 formatDateTime(\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 formatNumber(\n value: number,\n formatOrOptions?: string | Intl.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 formatRelativeTime(\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 __DEV__\n ? `The \\`now\\` parameter wasn't provided to \\`formatRelativeTime\\` 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 return {formatDateTime, formatNumber, formatRelativeTime};\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n","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","import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"names":["IntlContext","createContext","undefined","defaultGetMessageFallback","key","namespace","filter","part","join","defaultOnError","error","console","IntlProvider","children","onError","getMessageFallback","contextValues","React","Provider","value","useIntlContext","context","useContext","Error","IntlErrorCode","IntlError","code","originalMessage","message","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","date","time","resolvePath","messages","idPath","split","forEach","next","prepareTranslationValues","values","length","transformedValues","index","transformed","result","isValidElement","cloneElement","useTranslationsImpl","allMessages","defaultTranslationValues","globalFormats","locale","cachedFormatsByLocaleRef","useRef","messagesOrError","useMemo","retrievedMessages","intlError","MISSING_MESSAGE","translate","getFallbackFromErrorAndNotify","translateBaseFn","cachedFormatsByLocale","current","cacheKey","messageFormat","INSUFFICIENT_PATH","IntlMessageFormat","INVALID_MESSAGE","formattedMessage","format","Array","isArray","String","FORMATTING_ERROR","translateFn","rich","raw","useTranslations","__private","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","Math","abs","unit","round","useIntl","globalNow","now","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","MISSING_FORMAT","getFormattedValue","formatter","formatDateTime","Intl","DateTimeFormat","formatNumber","number","NumberFormat","formatRelativeTime","dateDate","Date","nowDate","getTime","RelativeTimeFormat","numeric","useLocale","getNow","useNow","updateInterval","useState","setNow","useEffect","intervalId","setInterval","clearInterval","useTimeZone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAMA,WAAW,gBAAGC,aAAa,CAA+BC,SAA/B,CAAjC;;;;AC2BA,SAASC,yBAAT,CAMC,IAAA,EAAA;AAAA,EALCC,IAAAA,GAKD,QALCA,GAKD;AAAA,MAJCC,SAID,QAJCA,SAID,CAAA;AACC,EAAO,OAAA,CAACA,SAAD,EAAYD,GAAZ,EAAiBE,MAAjB,CAAwB,UAACC,IAAD,EAAA;AAAA,IAAUA,OAAAA,IAAI,IAAI,IAAlB,CAAA;AAAA,GAAxB,CAAgDC,CAAAA,IAAhD,C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sx","../src/IntlProvider.tsx","../src/useIntlContext.tsx","../src/IntlError.tsx","../src/convertFormatsToIntlMessageFormat.tsx","../src/useTranslationsImpl.tsx","../src/useTranslations.tsx","../src/useIntl.tsx","../src/useLocale.tsx","../src/useNow.tsx","../src/useTimeZone.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport Formats from './Formats';\nimport IntlError from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\n\nexport type IntlContextShape = {\n messages?: IntlMessages;\n locale: string;\n formats?: Partial<Formats>;\n timeZone?: string;\n onError(error: IntlError): void;\n getMessageFallback(info: {\n error: IntlError;\n key: string;\n namespace?: string;\n }): string;\n now?: Date;\n defaultTranslationValues?: RichTranslationValues;\n};\n\nconst IntlContext = createContext<IntlContextShape | undefined>(undefined);\n\nexport default IntlContext;\n","import React, {ReactNode} from 'react';\nimport Formats from './Formats';\nimport IntlContext from './IntlContext';\nimport IntlMessages from './IntlMessages';\nimport {RichTranslationValues} from './TranslationValues';\nimport {IntlError} from '.';\n\ntype Props = {\n /** All messages that will be available in your components. */\n messages?: IntlMessages;\n /** A valid Unicode locale tag (e.g. \"en\" or \"en-GB\"). */\n locale: string;\n /** Global formats can be provided to achieve consistent\n * formatting across components. */\n formats?: Partial<Formats>;\n /** A time zone as defined in [the tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) which will be applied when formatting dates and times. If this is absent, the user time zone will be used. You can override this by supplying an explicit time zone to `formatDateTime`. */\n timeZone?: string;\n /** This callback will be invoked when an error is encountered during\n * resolving a message or formatting it. This defaults to `console.error` to\n * keep your app running. You can customize the handling by taking\n * `error.code` into account. */\n onError?(error: IntlError): void;\n /** Will be called when a message couldn't be resolved or formatting it led to\n * an error. This defaults to `${namespace}.${key}` You can use this to\n * customize what will be rendered in this case. */\n getMessageFallback?(info: {\n namespace?: string;\n key: string;\n error: IntlError;\n }): string;\n /** All components that use the provided hooks should be within this tree. */\n children: ReactNode;\n /**\n * Providing this value will have two effects:\n * 1. It will be used as the default for the `now` argument of\n * `useIntl().formatRelativeTime` if no explicit value is provided.\n * 2. It will be returned as a static value from the `useNow` hook. Note\n * however that when `updateInterval` is configured on the `useNow` hook,\n * the global `now` value will only be used for the initial render, but\n * afterwards the current date will be returned continuously.\n */\n now?: Date;\n /** Global default values for translation values and rich text elements.\n * Can be used for consistent usage or styling of rich text elements.\n * Defaults will be overidden by locally provided values. */\n defaultTranslationValues?: RichTranslationValues;\n};\n\nfunction defaultGetMessageFallback({\n key,\n namespace\n}: {\n key: string;\n namespace?: string;\n}) {\n return [namespace, key].filter((part) => part != null).join('.');\n}\n\nfunction defaultOnError(error: IntlError) {\n console.error(error);\n}\n\nexport default function IntlProvider({\n children,\n onError = defaultOnError,\n getMessageFallback = defaultGetMessageFallback,\n ...contextValues\n}: Props) {\n return (\n <IntlContext.Provider\n value={{...contextValues, onError, getMessageFallback}}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n","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 __DEV__\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n","export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\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';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: string\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?: string\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 IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray,\n useMemo,\n useRef\n} from 'react';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport IntlMessages from './IntlMessages';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport useIntlContext from './useIntlContext';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: IntlMessages | undefined,\n idPath: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n __DEV__ ? `No messages available at \\`${namespace}\\`.` : undefined\n );\n }\n\n let message = messages;\n\n idPath.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n __DEV__\n ? `Could not resolve \\`${idPath}\\` 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 = (children: ReactNode) => {\n const result = value(children);\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\nexport default function useTranslationsImpl<\n Messages extends IntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const messagesOrError = useMemo(() => {\n try {\n if (!allMessages) {\n throw new Error(\n __DEV__ ? `No messages were configured on the provider.` : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(allMessages, namespace)\n : allMessages;\n\n if (!retrievedMessages) {\n throw new Error(\n __DEV__\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 }, [allMessages, namespace, onError]);\n\n const translate = useMemo(() => {\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 const cachedFormatsByLocale = cachedFormatsByLocaleRef.current;\n\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 const cacheKey = [namespace, key]\n .filter((part) => part != null)\n .join('.');\n\n let messageFormat;\n if (cachedFormatsByLocale[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale[locale][cacheKey];\n } else {\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 if (typeof message === 'object') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INSUFFICIENT_PATH,\n __DEV__\n ? `Insufficient path specified for \\`${key}\\` in \\`${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }\\`.`\n : undefined\n );\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[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n\n try {\n const formattedMessage = messageFormat.format(\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n __DEV__\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 message = translateBaseFn(key, values, formats);\n\n if (typeof message !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n __DEV__\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 message;\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 onError,\n getMessageFallback,\n namespace,\n messagesOrError,\n locale,\n globalFormats,\n timeZone,\n defaultTranslationValues\n ]);\n\n return translate;\n}\n","// import GlobalMessages from './GlobalMessages';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\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<GlobalMessages, NestedKeyOf<GlobalMessages>>\n>(namespace?: NestedKey) {\n // @ts-ignore\n const messages = useIntlContext().messages as GlobalMessages;\n if (!messages) throw new Error('TODO')\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 return useTranslationsImpl<\n // @ts-ignore\n {__private: GlobalMessages},\n NamespaceKeys<GlobalMessages, NestedKeyOf<GlobalMessages>> extends NestedKey\n ? '__private'\n : `__private.${NestedKey}`\n >(\n {__private: messages},\n // @ts-ignore\n namespace ? `__private.${namespace}` : '__private'\n );\n}\n","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport useIntlContext from './useIntlContext';\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\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\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 __DEV__\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 formatDateTime(\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 formatNumber(\n value: number,\n formatOrOptions?: string | Intl.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 formatRelativeTime(\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 __DEV__\n ? `The \\`now\\` parameter wasn't provided to \\`formatRelativeTime\\` 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 return {formatDateTime, formatNumber, formatRelativeTime};\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n","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","import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"names":["IntlContext","createContext","undefined","defaultGetMessageFallback","key","namespace","filter","part","join","defaultOnError","error","console","IntlProvider","children","onError","getMessageFallback","contextValues","React","Provider","value","useIntlContext","context","useContext","Error","IntlErrorCode","IntlError","code","originalMessage","message","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","date","time","resolvePath","messages","idPath","split","forEach","next","prepareTranslationValues","values","length","transformedValues","index","transformed","result","isValidElement","cloneElement","useTranslationsImpl","allMessages","defaultTranslationValues","globalFormats","locale","cachedFormatsByLocaleRef","useRef","messagesOrError","useMemo","retrievedMessages","intlError","MISSING_MESSAGE","translate","getFallbackFromErrorAndNotify","translateBaseFn","cachedFormatsByLocale","current","cacheKey","messageFormat","INSUFFICIENT_PATH","IntlMessageFormat","INVALID_MESSAGE","formattedMessage","format","Array","isArray","String","FORMATTING_ERROR","translateFn","rich","raw","useTranslations","__private","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","Math","abs","unit","round","useIntl","globalNow","now","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","MISSING_FORMAT","getFormattedValue","formatter","formatDateTime","Intl","DateTimeFormat","formatNumber","number","NumberFormat","formatRelativeTime","dateDate","Date","nowDate","getTime","RelativeTimeFormat","numeric","useLocale","getNow","useNow","updateInterval","useState","setNow","useEffect","intervalId","setInterval","clearInterval","useTimeZone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAMA,WAAW,gBAAGC,aAAa,CAA+BC,SAA/B,CAAjC;;;;AC2BA,SAASC,yBAAT,CAMC,IAAA,EAAA;AAAA,EALCC,IAAAA,GAKD,QALCA,GAKD;AAAA,MAJCC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0B,cAAZ,CAVM,CAAT,CAAA;AAYA,EAAA,OAAOzB,GAAP,CAAA;AACD;;AC9Ca,SAAUgC,WAAV,GAAqB;AACjC,EAAOpH,OAAAA,cAAc,GAAGW,QAAxB,CAAA;AACD;;;;"}
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import GlobalMessages from './GlobalMessages';
3
2
  import NamespaceKeys from './utils/NamespaceKeys';
4
3
  import NestedKeyOf from './utils/NestedKeyOf';
5
4
  /**
@@ -13,9 +12,9 @@ import NestedKeyOf from './utils/NestedKeyOf';
13
12
  export default function useTranslations<NestedKey extends NamespaceKeys<GlobalMessages, NestedKeyOf<GlobalMessages>>>(namespace?: NestedKey): {
14
13
  <TargetKey extends import("./utils/MessageKeys").default<import("./utils/NestedValueOf").default<{
15
14
  __private: GlobalMessages;
16
- }, NamespaceKeys<GlobalMessages, "About" | "B" | "About.title" | "About.lastUpdated" | "About.nested" | "About.nested.hello" | "B.c" | "B.d" | "B.d.e"> extends NestedKey ? "__private" : `__private.${NestedKey}`>, NestedKeyOf<import("./utils/NestedValueOf").default<{
15
+ }, NamespaceKeys<GlobalMessages, "About" | "Index" | "Navigation" | "NotFound" | "PageLayout" | "Test" | "About.title" | "About.lastUpdated" | "About.nested" | "About.nested.hello" | "Index.title" | "Index.description" | "Navigation.index" | "Navigation.about" | "Navigation.switchLocale" | "NotFound.title" | "PageLayout.pageTitle" | "Test.nested" | "Test.nested.hello" | "Test.nested.another" | "Test.nested.another.level"> extends NestedKey ? "__private" : `__private.${NestedKey}`>, NestedKeyOf<import("./utils/NestedValueOf").default<{
17
16
  __private: GlobalMessages;
18
- }, NamespaceKeys<GlobalMessages, "About" | "B" | "About.title" | "About.lastUpdated" | "About.nested" | "About.nested.hello" | "B.c" | "B.d" | "B.d.e"> extends NestedKey ? "__private" : `__private.${NestedKey}`>>>>(key: TargetKey, values?: import("./TranslationValues").default | undefined, formats?: Partial<import("./Formats").default> | undefined): string;
17
+ }, NamespaceKeys<GlobalMessages, "About" | "Index" | "Navigation" | "NotFound" | "PageLayout" | "Test" | "About.title" | "About.lastUpdated" | "About.nested" | "About.nested.hello" | "Index.title" | "Index.description" | "Navigation.index" | "Navigation.about" | "Navigation.switchLocale" | "NotFound.title" | "PageLayout.pageTitle" | "Test.nested" | "Test.nested.hello" | "Test.nested.another" | "Test.nested.another.level"> extends NestedKey ? "__private" : `__private.${NestedKey}`>>>>(key: TargetKey, values?: import("./TranslationValues").default | undefined, formats?: Partial<import("./Formats").default> | undefined): string;
19
18
  rich: (key: string, values?: import("./TranslationValues").RichTranslationValues | undefined, formats?: Partial<import("./Formats").default> | undefined) => string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNodeArray;
20
19
  raw(key: string): any;
21
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "use-intl",
3
- "version": "2.4.1-alpha.1",
3
+ "version": "2.4.1-alpha.2",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.me>",
6
6
  "description": "Minimal, but complete solution for managing internationalization in React apps.",
@@ -56,5 +56,5 @@
56
56
  "engines": {
57
57
  "node": ">=10"
58
58
  },
59
- "gitHead": "28819c45eb57d2ec3d7de1752a005db5c55efc63"
59
+ "gitHead": "83d4b8601cea9390c61995a75c3ad7210530e728"
60
60
  }
@@ -1,14 +1,6 @@
1
1
  // This module is intended to be overridden
2
2
  // by the consumer for optional type safety
3
3
 
4
- // type Messages = typeof import('./en.json');
4
+ // declare interface GlobalMessages extends Record<any, any> {}
5
5
 
6
- // eslint-disable-next-line @typescript-eslint/ban-types
7
- type Unknown = {};
8
-
9
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
10
- interface GlobalMessages
11
- // Messages,
12
- extends Unknown {}
13
-
14
- export default GlobalMessages;
6
+ declare interface GlobalMessages {}
package/src/index.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  export {default as IntlProvider} from './IntlProvider';
2
2
  export {default as IntlMessages} from './IntlMessages';
3
- export {default as GlobalMessages} from './GlobalMessages';
3
+ // export {default as GlobalMessages} from './GlobalMessages';
4
4
  export {default as useTranslations} from './useTranslations';
5
5
  export {
6
6
  default as TranslationValues,
@@ -1,4 +1,4 @@
1
- import GlobalMessages from './GlobalMessages';
1
+ // import GlobalMessages from './GlobalMessages';
2
2
  import useIntlContext from './useIntlContext';
3
3
  import useTranslationsImpl from './useTranslationsImpl';
4
4
  import NamespaceKeys from './utils/NamespaceKeys';
@@ -29,6 +29,7 @@ export default function useTranslations<
29
29
  : `__private.${NestedKey}`
30
30
  >(
31
31
  {__private: messages},
32
+ // @ts-ignore
32
33
  namespace ? `__private.${namespace}` : '__private'
33
34
  );
34
35
  }