/
index.d.ts
2033 lines (1706 loc) · 39 KB
/
index.d.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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import * as React from 'react';
import {
ViewStyle,
TextStyle,
ImageStyle,
ImageSourcePropType,
ImageURISource,
TouchableWithoutFeedbackProps,
TouchableOpacityProps,
TouchableNativeFeedbackProps,
ViewProperties,
TextInputProperties,
TextInput,
TextProperties,
StatusBarProperties,
StyleProp,
Animated,
ActivityIndicatorProperties,
SwitchProperties,
StatusBarStyle,
ModalProps,
TextInputProps,
ImageProps as RNImageProps,
TouchableHighlightProps,
} from 'react-native';
import { RatingProps, AirbnbRatingProps } from 'react-native-ratings';
import { IconButtonProps } from 'react-native-vector-icons/Icon';
/**
* Supports auto complete for most used types as well as any other string type.
*/
export type IconType =
| 'material'
| 'material-community'
| 'simple-line-icon'
| 'zocial'
| 'font-awesome'
| 'octicon'
| 'ionicon'
| 'foundation'
| 'evilicon'
| 'entypo'
| 'antdesign'
| string;
export interface IconObject {
name?: string;
color?: string;
size?: number;
type?: IconType;
style?: StyleProp<TextStyle>;
}
export interface AvatarIcon extends IconObject {
iconStyle?: StyleProp<TextStyle>;
}
export interface TextProps extends TextProperties {
/**
* font size 40
*/
h1?: boolean;
/**
* font size 34
*/
h2?: boolean;
/**
* font size 28
*/
h3?: boolean;
/**
* font size 22
*/
h4?: boolean;
/**
* Styling for when `h1` is set
*/
h1Style?: StyleProp<TextStyle>;
/**
* Styling for when `h2` is set
*/
h2Style?: StyleProp<TextStyle>;
/**
* Styling for when `h3` is set
*/
h3Style?: StyleProp<TextStyle>;
/**
* Styling for when `h4` is set
*/
h4Style?: StyleProp<TextStyle>;
/**
* Additional styling for Text
*/
style?: StyleProp<TextStyle>;
}
/**
* HTML Style Headings
*
*/
export class Text extends React.Component<TextProps, any> {}
export interface AvatarProps {
/**
* Component for enclosing element (eg: TouchableHighlight, View, etc)
*
* @default TouchableOpacity
*/
Component?: React.ComponentClass;
/**
* Callback function when pressing Edit button
*/
onEditPress?(): void;
/**
* Callback function when pressing component
*/
onPress?(): void;
/**
* Callback function when long pressing component
*/
onLongPress?(): void;
/**
* Styling for outer container
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Image source
*/
source?: ImageSourcePropType;
/**
* Style for avatar image
*/
avatarStyle?: ImageStyle;
/**
* Determines the shape of avatar
*
* @default false
*/
rounded?: boolean;
/**
* Renders title in the avatar
*/
title?: string;
/**
* Style for the title
*/
titleStyle?: StyleProp<TextStyle>;
/**
* Style for the view outside image or icon
*/
overlayContainerStyle?: StyleProp<ViewStyle>;
/**
* Opacity when pressed
*
* @default 0.2
*/
activeOpacity?: number;
/**
* If to show the edit button or not
*
* @default false
*/
showEditButton?: boolean;
/**
* Edit button for the avatar
*
* @default "{size: null, iconName: 'mode-edit', iconType: 'material', iconColor: '#fff', underlayColor: '#000', style: null}"
*/
editButton?: Partial<IconProps>;
/**
* Style for the placeholder
*/
placeholderStyle?: StyleProp<ViewStyle>;
/**
* Render a content inside placeholder
*/
renderPlaceholderContent?: React.ReactElement<{}>;
/**
* Icon for the avatar
*/
icon?: AvatarIcon;
/**
* extra styling for icon component
*/
iconStyle?: StyleProp<TextStyle>;
/**
* Optional properties to pass to the image if provided e.g "resizeMode"
*/
imageProps?: Partial<RNImageProps>;
/**
* Size of Avatar
* @default "small"
*/
size?: 'small' | 'medium' | 'large' | 'xlarge' | number;
/**
* Image Component of Avatar
* @default React Native default Image component
*/
ImageComponent?: React.ComponentClass;
}
/**
* Avatar Component
*
*/
export class Avatar extends React.Component<AvatarProps, any> {}
export interface ButtonProps
extends TouchableOpacityProps,
TouchableNativeFeedbackProps {
/**
* Specify other touchable such as TouchableOpacity/TouchableNativeFeedback
*
* Default is TouchableOpacity on IOS and TouchableNativeFeedback on Android
*/
TouchableComponent?: React.ComponentClass;
/**
* Specify a different component as the background for the button.
* Useful for if you want to make a button with a gradient background.
*
* @default View
*/
ViewComponent?: React.ComponentClass<any>;
/**
* Additional styling for button (background) view component
*
* @default null
*/
buttonStyle?: StyleProp<ViewStyle>;
/**
* Button title
*/
title?: string;
/**
* If to show the icon on the right
*
* @default false
*/
iconRight?: boolean;
/**
* Icon to show in the button
*/
icon?: IconNode;
/**
* Style for the container around the icon
*/
iconContainerStyle?: StyleProp<ViewStyle>;
/**
* Title styling
*/
titleStyle?: StyleProp<TextStyle>;
/**
* Optional props for the title inside the button
*/
titleProps?: TextProperties;
/**
* Styling for Component container
*
* @default null
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Display a loading spinner
*
* @default false
*/
loading?: boolean;
/**
* Additional style to applied to the ActivityIndicator
*/
loadingStyle?: StyleProp<ViewStyle>;
/**
* Additional props to applied to the ActivityIndicator
*/
loadingProps?: ActivityIndicatorProperties;
/**
* Object of props to be applied to the linearGradient view(ViewComponent)
*/
linearGradientProps?: Object;
/**
* Type of button
*
* @default solid
*/
type?: 'solid' | 'clear' | 'outline';
/**
* If the user is allowed to interact with the button
*
* @default false
*/
disabled?: boolean;
/**
* Style of the title when the button is disabled
*/
disabledTitleStyle?: StyleProp<TextStyle>;
/**
* Style of the button when disabled
*/
disabledStyle?: StyleProp<ViewStyle>;
/**
* If the button has raised styling
*
* @default false
*/
raised?: boolean;
}
/**
* Button component
*
*/
export class Button extends React.Component<ButtonProps, any> {}
export interface BadgeProps {
/**
* Text value to be displayed by badge
*
* @default null
*/
value?: React.ReactNode;
/**
* Additional styling for badge (background) view component
*/
badgeStyle?: StyleProp<ViewStyle>;
/**
* Style for the container
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Style for the text in the badge
*/
textStyle?: StyleProp<TextStyle>;
/**
* Custom component to replace the badge component
*
* @default View (if onPress then TouchableOpacity)
*/
Component?: React.ComponentClass;
/**
* Determines color of the indicator
*
* @default primary
*/
status?: 'primary' | 'success' | 'warning' | 'error';
/**
* Function called when pressed on the badge
*/
onPress?(): void;
}
/**
* Badge component
*
*/
export class Badge extends React.Component<BadgeProps> {}
/**
* withBadge Higher-Order Component
*
* @param value
* @param options
*/
export function withBadge(
/**
* Text value to be displayed by badge
*/
value?: React.ReactNode | (() => React.ReactNode),
/**
* Options to configure the badge
*/
options?: {
bottom?: number;
left?: number;
right?: number;
top?: number;
hidden?: boolean;
containerStyle?: StyleProp<ViewStyle>;
} & BadgeProps
): <P = {}>(WrappedComponent: React.ComponentType<P>) => React.ComponentType<P>;
export interface CardProps {
/**
* Outer container style
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Inner container style
*/
wrapperStyle?: StyleProp<ViewStyle>;
/**
* Card title
*/
title?: string | React.ReactElement<{}>;
/**
* Additional title styling (if title provided)
*/
titleStyle?: StyleProp<TextStyle>;
/**
* Title rendered over the image
* (only works if image prop is present)
*/
featuredTitle?: string;
/**
* Styling for featured title
*/
featuredTitleStyle?: StyleProp<TextStyle>;
/**
* Subtitle rendered over the image
* (only works if image prop is present)
*/
featuredSubtitle?: string;
/**
* Styling for featured subtitle
*/
featuredSubtitleStyle?: StyleProp<TextStyle>;
/**
* Additional divider styling
* (if title provided)
*/
dividerStyle?: StyleProp<ViewStyle>;
/**
* Specify image styling if image is provided
*/
imageStyle?: ImageStyle;
/**
* Specify styling for view surrounding image
*/
imageWrapperStyle?: StyleProp<ViewStyle>;
/**
* Add an image as the heading with the image prop
*/
image?: ImageSourcePropType;
/**
* Optional properties to pass to the image if provided e.g "resizeMode"
*/
imageProps?: Partial<RNImageProps>;
}
/**
* Card component
*
*/
export class Card extends React.Component<CardProps> {}
/**
* Set the buttons within a Group.
*/
export interface ElementObject {
element: React.ReactElement<{}> | React.ReactType;
}
/**
* Set the border styles for a component.
*/
export interface InnerBorderStyleProperty {
color?: string;
width?: number;
}
export interface ButtonGroupProps {
/**
* Allows the user to select multiple items
*
* @default false
*/
selectMultiple?: boolean;
/**
* Current selected index of array of buttons
*/
selectedIndex: number;
/**
* The indexes that are selected. Used with 'selectMultiple'
*
* @default []
*/
selectedIndexes?: number[];
/**
* Array of buttons for component, if returning a component, must be an object with { element: componentName }
*/
buttons: string[] | ElementObject[];
/**
* Choose other button component such as TouchableOpacity
*
* @default TouchableHighlight
*/
Component?: React.ComponentType<any>;
/**
* Specify styling for main button container
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* inherited styling specify styling for button
*/
buttonStyle?: StyleProp<ViewStyle>;
/**
* Specify styling selected button
*
* @default 'white'
*/
selectedButtonStyle?: StyleProp<ViewStyle>;
/**
* Specify specific styling for text
*/
textStyle?: StyleProp<TextStyle>;
/**
* Specify specific styling for text in the selected state
*/
selectedTextStyle?: StyleProp<TextStyle>;
/**
* inherited styling object { width, color } update the styling of the interior border of the list of buttons
*/
innerBorderStyle?: InnerBorderStyleProperty;
/**
* Specify underlayColor for TouchableHighlight
*
* @default 'white'
*/
underlayColor?: string;
/**
* Determines what the opacity of the wrapped view should be when touch is active.
*/
activeOpacity?: number;
/**
* Border radius for the container
*/
containerBorderRadius?: number;
/**
* Styling for the final border edge
*/
lastBorderStyle?: StyleProp<TextStyle | ViewStyle>;
/**
* Controls if buttons are disabled
*
* Setting `true` makes all of them disabled, while using an array only makes those indices disabled
*
* @default false
*/
disabled?: boolean | number[];
/**
* Styling for each button when disabled
*/
disabledStyle?: StyleProp<ViewStyle>;
/**
* Styling for each selected button when disabled
*/
disabledSelectedStyle?: StyleProp<ViewStyle>;
/**
* Styling for the text of each button when disabled
*/
disabledTextStyle?: StyleProp<TextStyle>;
/**
* Styling for the text of each selected button when disabled
*/
disabledSelectedTextStyle?: StyleProp<TextStyle>;
/**
* Method to update Button Group Index
*/
onPress(selectedIndex: number): void;
/**
*
* Called immediately after the underlay is hidden
*/
onHideUnderlay?(): void;
/**
* Called immediately after the underlay is shown
*/
onShowUnderlay?(): void;
/**
* Animate the touchable to a new opacity.
*/
setOpacityTo?(value: number): void;
}
export class ButtonGroup extends React.Component<ButtonGroupProps> {}
export interface CheckBoxProps {
/**
* Icon family, can be one of the following
* (required only if specifying an icon that is not from font-awesome)
*/
iconType?: IconType;
/**
* Specify React Native component for main button
*/
Component?: React.ComponentClass;
/**
* Flag for checking the icon
*
* @default false
*/
checked: boolean;
/**
* Moves icon to right of text.
*
* @default false
*/
iconRight?: boolean;
/**
* Aligns checkbox to right
*
* @default false
*/
right?: boolean;
/**
* Aligns checkbox to center
*
* @default false
*/
center?: boolean;
/**
* Title of checkbox
*/
title?: string | React.ReactElement<{}>;
/**
* Additional props for the title
*/
titleProps?: Partial<TextProperties>;
/**
* Style of main container
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Style of container that wraps the check box and text
*/
wrapperStyle?: StyleProp<ViewStyle>;
/**
* style of text
*/
textStyle?: StyleProp<TextStyle>;
/**
* Size of the checkbox
*
* @default 24
*/
size?: number;
/**
* onLongPress function for checkbox
*/
onLongPress?(): void;
/**
* onLongPress function for checkbox
*/
onLongIconPress?(): void;
/**
* onPress function for container
*/
onPress?(): void;
/**
* onPress function for checkbox
*/
onIconPress?(): void;
/**
* Default checked icon (Font Awesome Icon)
*
* @default 'check-square-o'
*/
checkedIcon?: string | React.ReactElement<{}>;
/**
* Default checked icon (Font Awesome Icon)
*
* @default 'square-o'
*/
uncheckedIcon?: string | React.ReactElement<{}>;
/**
* Default checked color
*
* @default 'green'
*/
checkedColor?: string;
/**
* Default unchecked color
* @default '#bfbfbf'
*/
uncheckedColor?: string;
/**
* Specify a custom checked message
*/
checkedTitle?: string;
/**
* Specify different font family
* @default 'System font bold (iOS)'
* @default 'Sans Serif Bold (android)'
*/
fontFamily?: string;
}
export class CheckBox extends React.Component<CheckBoxProps, any> {}
export interface DividerProps extends ViewProperties {}
export class Divider extends React.Component<DividerProps> {}
export interface InputProps extends TextInputProperties {
/**
* Styling for Input Component Container (optional)
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Styling for Input Component Container (optional)
*/
inputContainerStyle?: StyleProp<ViewStyle>;
/**
* Displays an icon to the left (optional)
*/
leftIcon?: IconNode;
/**
* Styling for left Icon Component container
*/
leftIconContainerStyle?: StyleProp<ViewStyle>;
/**
* Displays an icon to the right (optional)
*/
rightIcon?: IconNode;
/**
* Styling for the right icon container
*/
rightIconContainerStyle?: StyleProp<ViewStyle>;
/**
* Renders component in place of the React Native `TextInput` (optional)
*/
inputComponent?: React.ComponentType<any>;
/**
* Adds styling to input component (optional)
*/
inputStyle?: StyleProp<TextStyle>;
/**
* Add styling to error message (optional)
*/
errorStyle?: StyleProp<TextStyle>;
/**
* Adds error message (optional)
*/
errorMessage?: string;
/**
* props to be passed to the React Native Text component used to display the error message (optional)
*/
errorProps?: TextProps;
/**
* Add styling to label (optional)
*/
labelStyle?: StyleProp<TextStyle>;
/**
* Adds label (optional)
*/
label?: string;
/**
* props to be passed to the React Native Text component used to display the label (optional)
*/
labelProps?: TextProps;
}
export class Input extends React.Component<InputProps> {
/**
* Shakes the Input
*
* eg `this.inputRef.shake()`
*/
shake(): void;
/**
* Calls focus on the Input
*
* eg `this.inputRef.focus()`
*/
focus(): void;
/**
* Calls isFocused() on the Input
*
* eg `let focused = this.inputRef.isFocused()`
*/
isFocused(): boolean;
/**
* Calls blur on the Input
*
* eg `this.inputRef.blur()`
*/
blur(): void;
/**
* Calls clear on the Input
*
* eg `this.inputRef.clear()`
*/
clear(): void;
/**
* Calls setNativeProps on the Input
*
* eg `this.inputRef.setNativeProps({ text: 'any text' })`
*/
setNativeProps(nativeProps: Partial<TextInputProps>): void;
}
export interface HeaderIcon extends IconObject {
icon?: string;
text?: string;
color?: string;
style?: StyleProp<TextStyle>;
}
/**
* Defines the types that can be used in a header sub component
*/
export type HeaderSubComponent =
| React.ReactElement<{}>
| TextProps
| HeaderIcon;
export interface HeaderProps extends ViewProperties {
/**
* Accepts all props for StatusBar
*/
statusBarProps?: StatusBarProperties;
/**
* Sets the color of the status bar text.
*
* @default 'default'
*/
barStyle?: StatusBarStyle;
/**
* Configuration object for default component (icon: string, ...props for React Native Elements Icon) or a valid React Element define your left component here
*/
leftComponent?: HeaderSubComponent;
/**
* Configuration object for default component (text: string, ...props for React Native Text component) valid React Element define your center component here
*/
centerComponent?: HeaderSubComponent;
/**
* Configuration object for default component (icon: string, ...props for React Native Elements Icon component) or a valid React Element define your right component here
*/
rightComponent?: HeaderSubComponent;
/**
* Sets backgroundColor of the parent component
*/
backgroundColor?: string;
/**
* Background image source
*/
backgroundImage?: ImageSourcePropType;
/**
* Styles for the background image in the container
*/
backgroundImageStyle?: ImageStyle;
/**
* Determines the alignment of the title
*
* @default 'center'
*/
placement?: 'left' | 'center' | 'right';
/**
* Styling for main container
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Styles for the container surrounding the title
*/
centerContainerStyle?: StyleProp<ViewStyle>;
/**
* Styling for container around the leftComponent
*/
leftContainerStyle?: StyleProp<ViewStyle>;
/**
* Styling for container around the rightComponent
*/