1 | import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
|
2 | import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
|
3 | declare global {
|
4 | namespace FormatjsIntl {
|
5 | interface Message {
|
6 | }
|
7 | interface IntlConfig {
|
8 | }
|
9 | interface Formats {
|
10 | }
|
11 | }
|
12 | }
|
13 | type Format<Source = string> = Source extends keyof FormatjsIntl.Formats ? FormatjsIntl.Formats[Source] : string;
|
14 | export interface Formats {
|
15 | number: Record<Format<'number'>, NumberFormatOptions>;
|
16 | date: Record<Format<'date'>, Intl.DateTimeFormatOptions>;
|
17 | time: Record<Format<'time'>, Intl.DateTimeFormatOptions>;
|
18 | }
|
19 | export interface FormatterCache {
|
20 | number: Record<string, NumberFormatOptions>;
|
21 | dateTime: Record<string, Intl.DateTimeFormat>;
|
22 | pluralRules: Record<string, Intl.PluralRules>;
|
23 | }
|
24 | export interface Formatters {
|
25 | getNumberFormat(locals?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
|
26 | getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): Intl.DateTimeFormat;
|
27 | getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
|
28 | }
|
29 | export declare enum PART_TYPE {
|
30 | literal = 0,
|
31 | object = 1
|
32 | }
|
33 | export interface LiteralPart {
|
34 | type: PART_TYPE.literal;
|
35 | value: string;
|
36 | }
|
37 | export interface ObjectPart<T = any> {
|
38 | type: PART_TYPE.object;
|
39 | value: T;
|
40 | }
|
41 | export type MessageFormatPart<T> = LiteralPart | ObjectPart<T>;
|
42 | export type PrimitiveType = string | number | boolean | null | undefined | Date;
|
43 | export declare function isFormatXMLElementFn<T>(el: PrimitiveType | T | FormatXMLElementFn<T>): el is FormatXMLElementFn<T>;
|
44 | export declare function formatToParts<T>(els: MessageFormatElement[], locales: string | string[], formatters: Formatters, formats: Formats, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, currentPluralValue?: number, originalMessage?: string): MessageFormatPart<T>[];
|
45 | export type FormatXMLElementFn<T, R = string | T | (string | T)[]> = (parts: Array<string | T>) => R;
|
46 | export {};
|