/
index.ts
382 lines (332 loc) · 12.3 KB
/
index.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
/**
* General @nativescript/core types used throughout the library.
*/
// imported for definition purposes only
import * as animationModule from '../ui/animation';
import { makeValidator, makeParser } from '../ui/core/properties';
export namespace CoreTypes {
/**
* Denotes a length number that is in device independent pixel units.
*/
export type dip = number;
/**
* Denotes a length number that is in physical device pixels.
*/
export type px = number;
/**
* Denotes a normalized percent number.
* 0% is represented as 0
* 50% is represented as 0.5
* 100% is represented as 1
*/
export type percent = number;
export type LengthDipUnit = { readonly unit: 'dip'; readonly value: dip };
export type LengthPxUnit = { readonly unit: 'px'; readonly value: px };
export type LengthPercentUnit = { readonly unit: '%'; readonly value: percent };
export type LengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit;
export type PercentLengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit | LengthPercentUnit;
export const zeroLength: LengthType = {
value: 0,
unit: 'px',
};
export type KeyboardInputType = 'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer';
export namespace KeyboardType {
export const datetime = 'datetime';
export const phone = 'phone';
export const number = 'number';
export const url = 'url';
export const email = 'email';
export const integer = 'integer';
}
export type AutofillType = 'username' | 'password' | 'none' | string;
export namespace AutofillType {
export const username = 'username';
export const password = 'password';
export const newUsername = 'newUsername';
export const newPassword = 'newPassword';
export const oneTimeCode = 'oneTimeCode';
export const none = 'none';
}
export type ReturnKeyButtonType = 'done' | 'next' | 'go' | 'search' | 'send';
export namespace ReturnKeyType {
export const done = 'done';
export const next = 'next';
export const go = 'go';
export const search = 'search';
export const send = 'send';
}
export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right' | 'justify';
export namespace TextAlignment {
export const left = 'left';
export const center = 'center';
export const right = 'right';
export const justify = 'justify';
}
export type TextDecorationType = 'none' | 'underline' | 'line-through' | 'underline line-through';
export namespace TextDecoration {
export const none = 'none';
export const underline = 'underline';
export const lineThrough = 'line-through';
}
export type TextTransformType = 'initial' | 'none' | 'capitalize' | 'uppercase' | 'lowercase';
export namespace TextTransform {
export const none = 'none';
export const capitalize = 'capitalize';
export const uppercase = 'uppercase';
export const lowercase = 'lowercase';
}
export type WhiteSpaceType = 'initial' | 'normal' | 'nowrap';
export namespace WhiteSpace {
export const normal = 'normal';
export const nowrap = 'nowrap';
}
export type TextOverflowType = 'clip' | 'ellipsis' | 'initial' | 'unset';
export namespace TextOverflow {
export const clip = 'clip';
export const ellipsis = 'ellipsis';
export const initial = 'initial';
export const unset = 'unset';
}
export type MaxLinesType = number;
export type OrientationType = 'horizontal' | 'vertical';
export namespace Orientation {
export const horizontal = 'horizontal';
export const vertical = 'vertical';
}
export type DeviceOrientationType = 'portrait' | 'landscape' | 'unknown';
export namespace DeviceOrientation {
export const portrait = 'portrait';
export const landscape = 'landscape';
export const unknown = 'unknown';
}
export type HorizontalAlignmentType = 'left' | 'center' | 'right' | 'stretch';
export namespace HorizontalAlignment {
export const left = 'left';
export const center = 'center';
export const right = 'right';
export const stretch = 'stretch';
export const isValid = makeValidator<HorizontalAlignmentType>(left, center, right, stretch);
export const parse = makeParser<HorizontalAlignmentType>(isValid);
}
export type VerticalAlignmentType = 'top' | 'middle' | 'bottom' | 'stretch';
export namespace VerticalAlignment {
export const top = 'top';
export const middle = 'middle';
export const bottom = 'bottom';
export const stretch = 'stretch';
}
export type VerticalAlignmentTextType = VerticalAlignmentType | 'text-top' | 'text-bottom' | 'sup' | 'sub' | 'baseline';
export namespace VerticalAlignmentText {
export const top = 'top';
export const middle = 'middle';
export const bottom = 'bottom';
export const stretch = 'stretch';
export const texttop = 'text-top';
export const textbottom = 'text-bottom';
export const sup = 'sup';
export const sub = 'sub';
export const baseline = 'baseline';
export const isValid = makeValidator<VerticalAlignmentTextType>(top, middle, bottom, stretch, texttop, textbottom, sup, sub, baseline);
export const parse = (value: string) => (value.toLowerCase() === 'center' ? middle : parseStrict(value));
const parseStrict = makeParser<CoreTypes.VerticalAlignmentTextType>(isValid);
}
export type ImageStretchType = 'none' | 'aspectFill' | 'aspectFit' | 'fill';
export namespace ImageStretch {
export const none: ImageStretchType = 'none';
export const aspectFill: ImageStretchType = 'aspectFill';
export const aspectFit: ImageStretchType = 'aspectFit';
export const fill: ImageStretchType = 'fill';
}
export type VisibilityType = 'visible' | 'hidden' | 'collapse' | 'collapsed';
export namespace Visibility {
export const visible: VisibilityType = 'visible';
export const collapse: VisibilityType = 'collapse';
export const collapsed: VisibilityType = 'collapsed';
export const hidden: VisibilityType = 'hidden';
export const isValid = makeValidator<CoreTypes.VisibilityType>(visible, hidden, collapse);
export const parse = (value: string) => (value.toLowerCase() === 'collapsed' ? collapse : parseStrict(value));
const parseStrict = makeParser<CoreTypes.VisibilityType>(isValid);
}
export namespace FontAttributes {
export const Normal = 0;
export const Bold = 1;
export const Italic = 1 << 1;
}
export namespace DeviceType {
export const Phone: string = 'Phone';
export const Tablet: string = 'Tablet';
}
export type UpdateTextTriggerType = 'focusLost' | 'textChanged';
export namespace UpdateTextTrigger {
export const focusLost: UpdateTextTriggerType = 'focusLost';
export const textChanged: UpdateTextTriggerType = 'textChanged';
}
export namespace Accuracy {
export const any: number = 300;
export const high: number = 3;
}
export type DockType = 'left' | 'top' | 'right' | 'bottom';
export namespace Dock {
export const left: DockType = 'left';
export const top: DockType = 'top';
export const right: DockType = 'right';
export const bottom: DockType = 'bottom';
}
export type AutocapitalizationInputType = 'none' | 'words' | 'sentences' | 'allcharacters';
export namespace AutocapitalizationType {
export const none: AutocapitalizationInputType = 'none';
export const words: AutocapitalizationInputType = 'words';
export const sentences: AutocapitalizationInputType = 'sentences';
export const allCharacters: AutocapitalizationInputType = 'allcharacters';
}
export namespace NavigationBarVisibility {
export const auto: string = 'auto';
export const never: string = 'never';
export const always: string = 'always';
}
export namespace AndroidActionBarIconVisibility {
export const auto: string = 'auto';
export const never: string = 'never';
export const always: string = 'always';
}
export namespace AndroidActionItemPosition {
export const actionBar: string = 'actionBar';
export const actionBarIfRoom: string = 'actionBarIfRoom';
export const popup: string = 'popup';
}
export namespace IOSActionItemPosition {
export const left: string = 'left';
export const right: string = 'right';
}
export namespace ImageFormat {
export const png: string = 'png';
export const jpeg: string = 'jpeg';
export const jpg: string = 'jpg';
}
export namespace FontStyle {
export const normal: string = 'normal';
export const italic: string = 'italic';
}
export namespace FontWeight {
export const thin: string = '100';
export const extraLight: string = '200';
export const light: string = '300';
export const normal: string = 'normal'; // 400
export const medium: string = '500';
export const semiBold: string = '600';
export const bold: string = 'bold'; // 700
export const extraBold: string = '800';
export const black: string = '900';
}
export type BackgroundRepeatType = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
export namespace BackgroundRepeat {
export const repeat: BackgroundRepeatType = 'repeat';
export const repeatX: BackgroundRepeatType = 'repeat-x';
export const repeatY: BackgroundRepeatType = 'repeat-y';
export const noRepeat: BackgroundRepeatType = 'no-repeat';
export const isValid = makeValidator<BackgroundRepeatType>(repeat, repeatX, repeatY, noRepeat);
export const parse = makeParser<BackgroundRepeatType>(isValid);
}
let animation: typeof animationModule;
export namespace AnimationCurve {
export const ease = 'ease';
export const easeIn = 'easeIn';
export const easeOut = 'easeOut';
export const easeInOut = 'easeInOut';
export const linear = 'linear';
export const spring = 'spring';
export function cubicBezier(x1: number, y1: number, x2: number, y2: number) {
animation = animation || require('../ui/animation');
return new animation.CubicBezierAnimationCurve(x1, y1, x2, y2);
}
}
export namespace StatusBarStyle {
export const light = 'light';
export const dark = 'dark';
}
export namespace SystemAppearance {
export const light = 'light';
export const dark = 'dark';
}
}
/**
* NOTE: Auto migrate deprecations via eslint-plugin in future
*/
/**
* @deprecated Use `CoreTypes.dip` instead.
*/
export type dip = number;
/**
* @deprecated Use `CoreTypes.px` instead.
*/
export type px = number;
/**
* @deprecated Use `CoreTypes.percent` instead.
*/
export type percent = number;
/**
* @deprecated Use `CoreTypes.LengthDipUnit` instead.
*/
export type LengthDipUnit = CoreTypes.LengthDipUnit;
/**
* @deprecated Use `CoreTypes.LengthPxUnit` instead.
*/
export type LengthPxUnit = CoreTypes.LengthPxUnit;
/**
* @deprecated Use `CoreTypes.LengthPercentUnit` instead.
*/
export type LengthPercentUnit = CoreTypes.LengthPercentUnit;
/**
* @deprecated Use `CoreTypes.LengthType` instead.
*/
export type LengthType = CoreTypes.LengthType;
/**
* @deprecated Use `CoreTypes.PercentLengthType` instead.
*/
export type PercentLengthType = CoreTypes.PercentLengthType;
/**
* @deprecated Use `CoreTypes.AnimationCurve` instead.
*/
export const AnimationCurve = CoreTypes.AnimationCurve;
/**
* @deprecated Use `CoreTypes.HorizontalAlignmentType` instead.
*/
export type HorizontalAlignment = CoreTypes.HorizontalAlignmentType;
/**
* @deprecated Use `CoreTypes.VerticalAlignmentType` instead.
*/
export type VerticalAlignment = CoreTypes.VerticalAlignmentType;
/**
* @deprecated Use `CoreTypes` instead. Enums will be removed in 9.0
*/
export const Enums = {
Accuracy: CoreTypes.Accuracy,
AndroidActionBarIconVisibility: CoreTypes.AndroidActionBarIconVisibility,
AndroidActionItemPosition: CoreTypes.AndroidActionItemPosition,
AnimationCurve: CoreTypes.AnimationCurve,
AutocapitalizationType: CoreTypes.AutocapitalizationType,
BackgroundRepeat: CoreTypes.BackgroundRepeat,
DeviceOrientation: CoreTypes.DeviceOrientation,
DeviceType: CoreTypes.DeviceType,
Dock: CoreTypes.Dock,
FontAttributes: CoreTypes.FontAttributes,
FontStyle: CoreTypes.FontStyle,
FontWeight: CoreTypes.FontWeight,
HorizontalAlignment: CoreTypes.HorizontalAlignment,
IOSActionItemPosition: CoreTypes.IOSActionItemPosition,
ImageFormat: CoreTypes.ImageFormat,
KeyboardType: CoreTypes.KeyboardType,
NavigationBarVisibility: CoreTypes.NavigationBarVisibility,
Orientation: CoreTypes.Orientation,
ReturnKeyType: CoreTypes.ReturnKeyType,
StatusBarStyle: CoreTypes.StatusBarStyle,
Stretch: CoreTypes.ImageStretch,
SystemAppearance: CoreTypes.SystemAppearance,
TextAlignment: CoreTypes.TextAlignment,
TextDecoration: CoreTypes.TextDecoration,
TextTransform: CoreTypes.TextTransform,
UpdateTextTrigger: CoreTypes.UpdateTextTrigger,
VerticalAlignment: CoreTypes.VerticalAlignment,
Visibility: CoreTypes.Visibility,
WhiteSpace: CoreTypes.WhiteSpace,
};