-
Notifications
You must be signed in to change notification settings - Fork 59
/
types.ts
174 lines (126 loc) · 3.93 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
export type Type<T> = new (...args: any[]) => T;
export interface DateTimeOptions {
weekday?: string;
era?: string;
year?: string;
month?: string;
day?: string;
hour?: string;
minute?: string;
second?: string;
timeZoneName?: string;
hour12?: boolean;
}
export interface DigitsOptions {
minimumIntegerDigits?: number;
minimumFractionDigits?: number;
maximumFractionDigits?: number;
minimumSignificantDigits?: number;
maximumSignificantDigits?: number;
useGrouping?: boolean;
}
export interface RelativeTimeOptions {
numeric?: string;
style?: string;
}
export type Unit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
export interface Locale {
/**
* ISO 639 two-letter or three-letter code.
*/
languageCode: string;
/**
* ISO 3166 two-letter, uppercase code.
*/
countryCode?: string;
/**
* ISO 15924 four-letter script code.
*/
scriptCode?: string;
}
export interface DefaultLocale extends Locale {
numberingSystem?: string;
calendar?: string;
}
export interface Language {
/**
* ISO 639 two-letter or three-letter code.
*/
code: string;
/**
* 'ltr' or 'rtl'.
*/
dir: string;
}
export interface Decimal {
minusSign: string;
decimalSeparator: string;
thousandSeparator: string;
}
export interface Schema extends DefaultLocale {
currency?: string;
timezone?: string;
text?: string;
}
export interface Log {
name: string;
message: string;
}
export enum StorageStrategy {
Session,
Local,
Cookie,
Disabled
}
export enum ProviderType {
Fallback,
Static,
WebAPI
}
export enum ISOCode {
Language = 'languageCode',
Country = 'countryCode',
Script = 'scriptCode'
}
export enum ExtraCode {
NumberingSystem = 'numberingSystem',
Calendar = 'calendar',
Currency = 'currency',
Timezone = 'timezone'
}
export enum LogLevel {
Error = 'error',
Warn = 'warn',
Info = 'info',
Log = 'log',
Off = 'off'
}
export enum NumberFormatStyle {
Decimal,
Percent,
Currency
}
export const NUMBER_FORMAT_REGEXP: RegExp = /^(\d+)?\.((\d+)(\-(\d+))?)?$/;
export const ISO8601_DATE_REGEX: RegExp =
/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
export const FORMAT_ALIASES: { [format: string]: DateTimeOptions } = {
'short': { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric' },
'medium': { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' },
'long': { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' },
'full': { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' },
'shortDate': { year: 'numeric', month: 'numeric', day: 'numeric' },
'mediumDate': { year: 'numeric', month: 'short', day: 'numeric' },
'longDate': { year: 'numeric', month: 'long', day: 'numeric' },
'fullDate': { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' },
'shortTime': { hour: 'numeric', minute: 'numeric' },
'mediumTime': { hour: 'numeric', minute: 'numeric', second: 'numeric' }
};
export const LOG_MESSAGES: { [message: string]: string } = {
'missingOnInit': "Missing 'ngOnInit' method: required by AoT compilation",
'missingOnDestroy': "Missing 'ngOnDestroy' method to cancel subscriptions: required by AoT compilation",
'missingLang': "Missing 'lang' parameter",
'missingDefaultLocale': "Missing 'defaultLocale' parameter",
'missingCurrency': "Missing 'currency' parameter",
'invalidNumberFormatAlias': "Invalid number format alias: the default format will be used",
'invalidDateFormatAlias': "Invalid date format alias: the default format will be used"
};