1 | import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
|
2 | export interface ExtendedNumberFormatOptions extends NumberFormatOptions {
|
3 | scale?: number;
|
4 | }
|
5 | export declare enum TYPE {
|
6 | |
7 |
|
8 |
|
9 | literal = 0,
|
10 | |
11 |
|
12 |
|
13 | argument = 1,
|
14 | |
15 |
|
16 |
|
17 | number = 2,
|
18 | |
19 |
|
20 |
|
21 | date = 3,
|
22 | |
23 |
|
24 |
|
25 | time = 4,
|
26 | |
27 |
|
28 |
|
29 | select = 5,
|
30 | |
31 |
|
32 |
|
33 | plural = 6,
|
34 | |
35 |
|
36 |
|
37 |
|
38 | pound = 7,
|
39 | |
40 |
|
41 |
|
42 | tag = 8
|
43 | }
|
44 | export declare enum SKELETON_TYPE {
|
45 | number = 0,
|
46 | dateTime = 1
|
47 | }
|
48 | export interface LocationDetails {
|
49 | offset: number;
|
50 | line: number;
|
51 | column: number;
|
52 | }
|
53 | export interface Location {
|
54 | start: LocationDetails;
|
55 | end: LocationDetails;
|
56 | }
|
57 | export interface BaseElement<T extends TYPE> {
|
58 | type: T;
|
59 | value: string;
|
60 | location?: Location;
|
61 | }
|
62 | export declare type LiteralElement = BaseElement<TYPE.literal>;
|
63 | export declare type ArgumentElement = BaseElement<TYPE.argument>;
|
64 | export interface TagElement {
|
65 | type: TYPE.tag;
|
66 | value: string;
|
67 | children: MessageFormatElement[];
|
68 | location?: Location;
|
69 | }
|
70 | export interface SimpleFormatElement<T extends TYPE, S extends Skeleton> extends BaseElement<T> {
|
71 | style?: string | S | null;
|
72 | }
|
73 | export declare type NumberElement = SimpleFormatElement<TYPE.number, NumberSkeleton>;
|
74 | export declare type DateElement = SimpleFormatElement<TYPE.date, DateTimeSkeleton>;
|
75 | export declare type TimeElement = SimpleFormatElement<TYPE.time, DateTimeSkeleton>;
|
76 | export interface SelectOption {
|
77 | id: string;
|
78 | value: MessageFormatElement[];
|
79 | location?: Location;
|
80 | }
|
81 | export declare type ValidPluralRule = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other' | string;
|
82 | export interface PluralOrSelectOption {
|
83 | value: MessageFormatElement[];
|
84 | location?: Location;
|
85 | }
|
86 | export interface SelectElement extends BaseElement<TYPE.select> {
|
87 | options: Record<string, PluralOrSelectOption>;
|
88 | }
|
89 | export interface PluralElement extends BaseElement<TYPE.plural> {
|
90 | options: Record<ValidPluralRule, PluralOrSelectOption>;
|
91 | offset: number;
|
92 | pluralType: Intl.PluralRulesOptions['type'];
|
93 | }
|
94 | export interface PoundElement {
|
95 | type: TYPE.pound;
|
96 | location?: Location;
|
97 | }
|
98 | export declare type MessageFormatElement = LiteralElement | ArgumentElement | NumberElement | DateElement | TimeElement | SelectElement | PluralElement | TagElement | PoundElement;
|
99 | export interface NumberSkeletonToken {
|
100 | stem: string;
|
101 | options: string[];
|
102 | }
|
103 | export interface NumberSkeleton {
|
104 | type: SKELETON_TYPE.number;
|
105 | tokens: NumberSkeletonToken[];
|
106 | location?: Location;
|
107 | parsedOptions: ExtendedNumberFormatOptions;
|
108 | }
|
109 | export interface DateTimeSkeleton {
|
110 | type: SKELETON_TYPE.dateTime;
|
111 | pattern: string;
|
112 | location?: Location;
|
113 | parsedOptions: Intl.DateTimeFormatOptions;
|
114 | }
|
115 | export declare type Skeleton = NumberSkeleton | DateTimeSkeleton;
|
116 |
|
117 |
|
118 |
|
119 | export declare function isLiteralElement(el: MessageFormatElement): el is LiteralElement;
|
120 | export declare function isArgumentElement(el: MessageFormatElement): el is ArgumentElement;
|
121 | export declare function isNumberElement(el: MessageFormatElement): el is NumberElement;
|
122 | export declare function isDateElement(el: MessageFormatElement): el is DateElement;
|
123 | export declare function isTimeElement(el: MessageFormatElement): el is TimeElement;
|
124 | export declare function isSelectElement(el: MessageFormatElement): el is SelectElement;
|
125 | export declare function isPluralElement(el: MessageFormatElement): el is PluralElement;
|
126 | export declare function isPoundElement(el: MessageFormatElement): el is PoundElement;
|
127 | export declare function isTagElement(el: MessageFormatElement): el is TagElement;
|
128 | export declare function isNumberSkeleton(el: NumberElement['style'] | Skeleton): el is NumberSkeleton;
|
129 | export declare function isDateTimeSkeleton(el?: DateElement['style'] | TimeElement['style'] | Skeleton): el is DateTimeSkeleton;
|
130 | export declare function createLiteralElement(value: string): LiteralElement;
|
131 | export declare function createNumberElement(value: string, style?: string | null): NumberElement;
|
132 | export interface Options {
|
133 | |
134 |
|
135 |
|
136 |
|
137 |
|
138 | normalizeHashtagInPlural?: boolean;
|
139 | |
140 |
|
141 |
|
142 |
|
143 | shouldParseSkeletons?: boolean;
|
144 | |
145 |
|
146 |
|
147 |
|
148 | captureLocation?: boolean;
|
149 | |
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 | ignoreTag?: boolean;
|
156 | }
|
157 |
|
\ | No newline at end of file |