import { FormatError, FormatXMLElementFn, Formats, Formatters as Formatters$1, IntlMessageFormat, Options, PrimitiveType } from "intl-messageformat"; import { MessageFormatElement } from "@formatjs/icu-messageformat-parser"; //#region packages/ecma402-abstract/types/number.d.ts type NumberFormatNotation = "standard" | "scientific" | "engineering" | "compact"; type RoundingPriorityType = "auto" | "morePrecision" | "lessPrecision"; type RoundingModeType = "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven"; type UseGroupingType = "min2" | "auto" | "always" | boolean; interface NumberFormatDigitOptions { minimumIntegerDigits?: number; minimumSignificantDigits?: number; maximumSignificantDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; roundingPriority?: RoundingPriorityType; roundingIncrement?: number; roundingMode?: RoundingModeType; trailingZeroDisplay?: TrailingZeroDisplay; } type NumberFormatOptionsLocaleMatcher = "lookup" | "best fit"; type NumberFormatOptionsStyle = "decimal" | "percent" | "currency" | "unit"; type NumberFormatOptionsCompactDisplay = "short" | "long"; type NumberFormatOptionsCurrencyDisplay = "symbol" | "code" | "name" | "narrowSymbol"; type NumberFormatOptionsCurrencySign = "standard" | "accounting"; type NumberFormatOptionsNotation = NumberFormatNotation; type NumberFormatOptionsSignDisplay = "auto" | "always" | "never" | "exceptZero" | "negative"; type NumberFormatOptionsUnitDisplay = "long" | "short" | "narrow"; type TrailingZeroDisplay = "auto" | "stripIfInteger"; type NumberFormatOptions = Omit & NumberFormatDigitOptions & { localeMatcher?: NumberFormatOptionsLocaleMatcher; style?: NumberFormatOptionsStyle; compactDisplay?: NumberFormatOptionsCompactDisplay; currencyDisplay?: NumberFormatOptionsCurrencyDisplay; currencySign?: NumberFormatOptionsCurrencySign; notation?: NumberFormatOptionsNotation; signDisplay?: NumberFormatOptionsSignDisplay; unit?: string; unitDisplay?: NumberFormatOptionsUnitDisplay; numberingSystem?: string; trailingZeroDisplay?: TrailingZeroDisplay; roundingPriority?: RoundingPriorityType; roundingIncrement?: number; roundingMode?: RoundingModeType; useGrouping?: UseGroupingType; }; //#endregion //#region packages/intl/error.d.ts declare enum IntlErrorCode { FORMAT_ERROR = "FORMAT_ERROR", UNSUPPORTED_FORMATTER = "UNSUPPORTED_FORMATTER", INVALID_CONFIG = "INVALID_CONFIG", MISSING_DATA = "MISSING_DATA", MISSING_TRANSLATION = "MISSING_TRANSLATION" } declare class IntlError extends Error { readonly code: T; constructor(code: T, message: string, exception?: Error | unknown); } declare class UnsupportedFormatterError extends IntlError { constructor(message: string, exception?: Error | unknown); } declare class InvalidConfigError extends IntlError { constructor(message: string, exception?: Error | unknown); } declare class MissingDataError extends IntlError { constructor(message: string, exception?: Error | unknown); } declare class IntlFormatError extends IntlError { readonly descriptor?: MessageDescriptor; readonly locale: string; constructor(message: string, locale: string, exception?: Error | unknown); } declare class MessageFormatError extends IntlFormatError { readonly descriptor?: MessageDescriptor; readonly locale: string; constructor(message: string, locale: string, descriptor?: MessageDescriptor, exception?: Error | unknown); } declare class MissingTranslationError extends IntlError { readonly descriptor?: MessageDescriptor; constructor(descriptor: MessageDescriptor, locale: string); } //#endregion //#region packages/intl/utils.d.ts declare function filterProps, K extends string>(props: T, allowlist: Array, defaults?: Partial): Pick; declare const DEFAULT_INTL_CONFIG: Pick, "fallbackOnEmptyString" | "formats" | "messages" | "timeZone" | "defaultLocale" | "defaultFormats" | "onError" | "onWarn">; declare function createIntlCache(): IntlCache; /** * Create intl formatters and populate cache * @param cache explicit cache to prevent leaking memory */ declare function createFormatters(cache?: IntlCache): Formatters; declare function getNamedFormat(formats: CustomFormats, type: T, name: string, onError: OnErrorFn): NumberFormatOptions | Intl.DateTimeFormatOptions | Intl.RelativeTimeFormatOptions | undefined; //#endregion //#region packages/intl/types.d.ts interface Part { type: "element" | "literal"; value: T; } declare global { namespace FormatjsIntl { interface Message {} interface IntlConfig {} interface Formats {} } } type MessageIds = FormatjsIntl.Message extends { ids: infer T; } ? T extends string ? T : string : string; type Locale = FormatjsIntl.IntlConfig extends { locale: infer T; } ? T extends string ? T : string : string; type OnErrorFn = (err: MissingTranslationError | MessageFormatError | MissingDataError | InvalidConfigError | UnsupportedFormatterError | FormatError) => void; type OnWarnFn = (warning: string) => void; /** * Config for intl object. * Generic type T is the type of potential rich text element. For example: * With React, T would be React.ReactNode */ interface ResolvedIntlConfig { locale: Locale; timeZone?: string; fallbackOnEmptyString?: boolean; formats: CustomFormats; messages: Record | Record; defaultLocale: string; defaultFormats: CustomFormats; defaultRichTextElements?: Record>; onError: OnErrorFn; onWarn?: OnWarnFn; } interface CustomFormats extends Partial { relative?: Record; dateTimeRange?: Record; } interface CustomFormatConfig { format?: Source extends keyof FormatjsIntl.Formats ? FormatjsIntl.Formats[Source] : string; } type FormatDateTimeRangeOptions = Omit & CustomFormatConfig<"dateTimeRange">; type FormatDateOptions = Omit & CustomFormatConfig<"date">; type FormatTimeOptions = Omit & CustomFormatConfig<"time">; type FormatNumberOptions = Omit & CustomFormatConfig<"number">; type FormatRelativeTimeOptions = Omit & CustomFormatConfig<"time">; type FormatPluralOptions = Omit & CustomFormatConfig; type FormatListOptions = Omit; type FormatDisplayNameOptions = Omit; /** * `TBase` is the type constraints of the rich text element in the formatted output. * For example, with React, `TBase` should be `React.ReactNode`. */ interface IntlFormatters { formatDateTimeRange(this: void, from: Parameters[0] | string, to: Parameters[1] | string, opts?: FormatDateTimeRangeOptions): string; formatDate(this: void, value: Parameters[0] | string, opts?: FormatDateOptions): string; formatTime(this: void, value: Parameters[0] | string, opts?: FormatTimeOptions): string; formatDateToParts(this: void, value: Parameters[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[]; formatTimeToParts(this: void, value: Parameters[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[]; formatRelativeTime(this: void, value: Parameters[0], unit?: Parameters[1], opts?: FormatRelativeTimeOptions): string; formatNumber(this: void, value: Parameters[0], opts?: FormatNumberOptions): string; formatNumberToParts(this: void, value: Parameters[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[]; formatPlural(this: void, value: Parameters[0], opts?: FormatPluralOptions): ReturnType; formatMessage(this: void, descriptor: MessageDescriptor, values?: Record>, opts?: Options): string; formatMessage>(this: void, descriptor: MessageDescriptor, values?: Record, opts?: Options): string | T | Array; $t(this: void, descriptor: MessageDescriptor, values?: Record>, opts?: Options): string; $t(this: void, descriptor: MessageDescriptor, values?: Record>, opts?: Options): string | T | (T | string)[]; formatList(this: void, values: Iterable, opts?: FormatListOptions): string; formatList(this: void, values: Iterable, opts?: FormatListOptions): T | string | (string | T)[]; formatListToParts(this: void, values: Iterable, opts?: FormatListOptions): Part[]; formatDisplayName(this: void, value: Parameters[0], opts: FormatDisplayNameOptions): string | undefined; } interface Formatters { getDateTimeFormat(this: void, ...args: ConstructorParameters): Intl.DateTimeFormat; getNumberFormat(this: void, locales?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat; getMessageFormat(this: void, ...args: ConstructorParameters): IntlMessageFormat; getRelativeTimeFormat(this: void, ...args: ConstructorParameters): Intl.RelativeTimeFormat; getPluralRules(this: void, ...args: ConstructorParameters): Intl.PluralRules; getListFormat(this: void, ...args: ConstructorParameters): Intl.ListFormat; getDisplayNames(this: void, ...args: ConstructorParameters): Intl.DisplayNames; } interface IntlShape extends ResolvedIntlConfig, IntlFormatters { formatters: Formatters; } interface IntlCache { dateTime: Record; number: Record; message: Record; relativeTime: Record; pluralRules: Record; list: Record; displayNames: Record; } interface MessageDescriptor { id?: MessageIds; description?: string | object; defaultMessage?: string | MessageFormatElement[]; } type IntlConfig = Omit, keyof typeof DEFAULT_INTL_CONFIG> & Partial; //#endregion //#region packages/intl/message.d.ts type FormatMessageFn = ({ locale, formats, messages, defaultLocale, defaultFormats, fallbackOnEmptyString, onError, timeZone, defaultRichTextElements }: { locale: string; timeZone?: string; formats: CustomFormats; messages: Record | Record; defaultLocale: string; defaultFormats: CustomFormats; defaultRichTextElements?: Record>; fallbackOnEmptyString?: boolean; onError: OnErrorFn; }, state: Formatters$1 & Pick, messageDescriptor: MessageDescriptor, values?: Record>, opts?: Options) => T extends string ? string : Array | string | T; declare const formatMessage: FormatMessageFn; //#endregion //#region packages/intl/dateTime.d.ts declare function formatDate(config: { locale: string; timeZone?: string; formats: CustomFormats; onError: OnErrorFn; }, getDateTimeFormat: Formatters["getDateTimeFormat"], value: Parameters[0], options?: Parameters[1]): string; declare function formatTime(config: { locale: string; timeZone?: string; formats: CustomFormats; onError: OnErrorFn; }, getDateTimeFormat: Formatters["getDateTimeFormat"], value: Parameters[0], options?: Parameters[1]): string; declare function formatDateToParts(config: { locale: string; timeZone?: string; formats: CustomFormats; onError: OnErrorFn; }, getDateTimeFormat: Formatters["getDateTimeFormat"], value: Parameters[0], options?: Parameters[1]): Intl.DateTimeFormatPart[]; declare function formatTimeToParts(config: { locale: string; timeZone?: string; formats: CustomFormats; onError: OnErrorFn; }, getDateTimeFormat: Formatters["getDateTimeFormat"], value: Parameters[0], options?: Parameters[1]): Intl.DateTimeFormatPart[]; //#endregion //#region packages/intl/displayName.d.ts declare function formatDisplayName({ locale, onError }: { locale: string; onError: OnErrorFn; }, getDisplayNames: Formatters["getDisplayNames"], value: Parameters[0], options: Parameters[1]): string | undefined; //#endregion //#region packages/intl/list.d.ts declare function formatList(opts: { locale: string; onError: OnErrorFn; }, getListFormat: Formatters["getListFormat"], values: Iterable, options: Parameters[1]): string; //#endregion //#region packages/intl/plural.d.ts declare function formatPlural({ locale, onError }: { locale: string; onError: OnErrorFn; }, getPluralRules: Formatters["getPluralRules"], value: Parameters[0], options?: Parameters[1]): Intl.LDMLPluralRule; //#endregion //#region packages/intl/relativeTime.d.ts declare function formatRelativeTime(config: { locale: string; formats: CustomFormats; onError: OnErrorFn; }, getRelativeTimeFormat: Formatters["getRelativeTimeFormat"], value: Parameters[0], unit?: Parameters[1], options?: Parameters[2]): string; //#endregion //#region packages/intl/number.d.ts declare function formatNumber(config: { locale: string; formats: CustomFormats; onError: OnErrorFn; }, getNumberFormat: Formatters["getNumberFormat"], value: Parameters[0], options?: Parameters[1]): string; declare function formatNumberToParts(config: { locale: string; formats: CustomFormats; onError: OnErrorFn; }, getNumberFormat: Formatters["getNumberFormat"], value: Parameters[0], options?: Parameters[1]): Intl.NumberFormatPart[]; //#endregion //#region packages/intl/create-intl.d.ts interface CreateIntlFn = IntlConfig, S extends IntlShape = IntlShape> { (config: C, cache?: IntlCache): S; } /** * Create intl object * @param config intl config * @param cache cache for formatter instances to prevent memory leak */ declare function createIntl(config: IntlConfig, cache?: IntlCache): IntlShape; //#endregion //#region packages/intl/index.d.ts declare function defineMessages = Record>(msgs: U): U; declare function defineMessage(msg: T): T; //#endregion export { type CreateIntlFn, CustomFormatConfig, CustomFormats, DEFAULT_INTL_CONFIG, FormatDateOptions, FormatDateTimeRangeOptions, FormatDisplayNameOptions, FormatListOptions, type FormatMessageFn, FormatNumberOptions, FormatPluralOptions, FormatRelativeTimeOptions, FormatTimeOptions, Formatters, IntlCache, IntlConfig, IntlError, IntlErrorCode, IntlFormatError, IntlFormatters, IntlShape, InvalidConfigError, MessageDescriptor, MessageFormatError, MissingDataError, MissingTranslationError, OnErrorFn, OnWarnFn, Part, ResolvedIntlConfig, UnsupportedFormatterError, createFormatters, createIntl, createIntlCache, defineMessage, defineMessages, filterProps, formatDate, formatDateToParts, formatDisplayName, formatList, formatMessage, formatNumber, formatNumberToParts, formatPlural, formatRelativeTime, formatTime, formatTimeToParts, getNamedFormat }; //# sourceMappingURL=index.d.ts.map