forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreact-native.d.ts
8187 lines (6938 loc) · 292 KB
/
react-native.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
// Type definitions for react-native 0.34
// Project: https://github.com/facebook/react-native
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// USING: these definitions are meant to be used with the TSC compiler target set to ES6
//
// USAGE EXAMPLES: check the RNTSExplorer project at https://github.com/bgrieder/RNTSExplorer
//
// CONTRIBUTING: please open pull requests
//
// CREDITS: This work is based on an original work made by Bernd Paradies: https://github.com/bparadie
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <reference path="../react/react.d.ts" />
//so we know what is "original" React
import React = __React;
//react-native "extends" react
declare namespace __React {
export type MeasureOnSuccessCallback = (
x: number,
y: number,
width: number,
height: number,
pageX: number,
pageY: number
) => void
export type MeasureInWindowOnSuccessCallback = (
x: number,
y: number,
width: number,
height: number
) => void
export type MeasureLayoutOnSuccessCallback = (
left: number,
top: number,
width: number,
height: number
) => void
/**
* EventSubscription represents a subscription to a particular event. It can
* remove its own subscription.
*/
interface EventSubscription {
eventType: string;
key: number;
subscriber: EventSubscriptionVendor;
/**
* @param {EventSubscriptionVendor} subscriber the subscriber that controls
* this subscription.
*/
new(subscriber: EventSubscriptionVendor): EventSubscription
/**
* Removes this subscription from the subscriber that controls it.
*/
remove(): void
}
/**
* EventSubscriptionVendor stores a set of EventSubscriptions that are
* subscribed to a particular event type.
*/
interface EventSubscriptionVendor {
constructor(): EventSubscriptionVendor
/**
* Adds a subscription keyed by an event type.
*
* @param {string} eventType
* @param {EventSubscription} subscription
*/
addSubscription(eventType: string, subscription: EventSubscription): EventSubscription
/**
* Removes a bulk set of the subscriptions.
*
* @param {?string} eventType - Optional name of the event type whose
* registered supscriptions to remove, if null remove all subscriptions.
*/
removeAllSubscriptions(eventType?: string): void
/**
* Removes a specific subscription. Instead of calling this function, call
* `subscription.remove()` directly.
*
* @param {object} subscription
*/
removeSubscription(subscription: any): void
/**
* Returns the array of subscriptions that are currently registered for the
* given event type.
*
* Note: This array can be potentially sparse as subscriptions are deleted
* from it when they are removed.
*
* @param {string} eventType
* @returns {?array}
*/
getSubscriptionsForType(eventType: string): EventSubscription[]
}
/**
* EmitterSubscription represents a subscription with listener and context data.
*/
interface EmitterSubscription extends EventSubscription {
emitter: EventEmitter
listener: () => any
context: any
/**
* @param {EventEmitter} emitter - The event emitter that registered this
* subscription
* @param {EventSubscriptionVendor} subscriber - The subscriber that controls
* this subscription
* @param {function} listener - Function to invoke when the specified event is
* emitted
* @param {*} context - Optional context object to use when invoking the
* listener
*/
new(emitter: EventEmitter, subscriber: EventSubscriptionVendor, listener: () => any, context: any): EmitterSubscription
/**
* Removes this subscription from the emitter that registered it.
* Note: we're overriding the `remove()` method of EventSubscription here
* but deliberately not calling `super.remove()` as the responsibility
* for removing the subscription lies with the EventEmitter.
*/
remove(): void
}
interface EventEmitter {
/**
* @constructor
*
* @param {EventSubscriptionVendor} subscriber - Optional subscriber instance
* to use. If omitted, a new subscriber will be created for the emitter.
*/
new(subscriber?: EventSubscriptionVendor): EventEmitter
/**
* Adds a listener to be invoked when events of the specified type are
* emitted. An optional calling context may be provided. The data arguments
* emitted will be passed to the listener function.
*
* @param {string} eventType - Name of the event to listen to
* @param {function} listener - Function to invoke when the specified event is
* emitted
* @param {*} context - Optional context object to use when invoking the
* listener
*/
addListener(eventType: string, listener: (...args: any[]) => any, context: any): EmitterSubscription
/**
* Similar to addListener, except that the listener is removed after it is
* invoked once.
*
* @param {string} eventType - Name of the event to listen to
* @param {function} listener - Function to invoke only once when the
* specified event is emitted
* @param {*} context - Optional context object to use when invoking the
* listener
*/
once(eventType: string, listener: (...args: any[]) => any, context: any): EmitterSubscription
/**
* Removes all of the registered listeners, including those registered as
* listener maps.
*
* @param {?string} eventType - Optional name of the event whose registered
* listeners to remove
*/
removeAllListeners(eventType?: string): void
/**
* Provides an API that can be called during an eventing cycle to remove the
* last listener that was invoked. This allows a developer to provide an event
* object that can remove the listener (or listener map) during the
* invocation.
*
* If it is called when not inside of an emitting cycle it will throw.
*
* @throws {Error} When called not during an eventing cycle
*
* @example
* var subscription = emitter.addListenerMap({
* someEvent: function(data, event) {
* console.log(data);
* emitter.removeCurrentListener();
* }
* });
*
* emitter.emit('someEvent', 'abc'); // logs 'abc'
* emitter.emit('someEvent', 'def'); // does not log anything
*/
removeCurrentListener(): void
/**
* Removes a specific subscription. Called by the `remove()` method of the
* subscription itself to ensure any necessary cleanup is performed.
*/
removeSubscription(subscription: EmitterSubscription): void
/**
* Returns an array of listeners that are currently registered for the given
* event.
*
* @param {string} eventType - Name of the event to query
* @returns {array}
*/
listeners(eventType: string): EmitterSubscription[]
/**
* Emits an event of the given type with the given data. All handlers of that
* particular type will be notified.
*
* @param {string} eventType - Name of the event to emit
* @param {...*} Arbitrary arguments to be passed to each registered listener
*
* @example
* emitter.addListener('someEvent', function(message) {
* console.log(message);
* });
*
* emitter.emit('someEvent', 'abc'); // logs 'abc'
*/
emit(eventType: string): void
/**
* Removes the given listener for event of specific type.
*
* @param {string} eventType - Name of the event to emit
* @param {function} listener - Function to invoke when the specified event is
* emitted
*
* @example
* emitter.removeListener('someEvent', function(message) {
* console.log(message);
* }); // removes the listener if already registered
*
*/
removeListener(eventType: string, listener: (...args: any[]) => any): void
}
/** NativeMethodsMixin provides methods to access the underlying native component directly.
* This can be useful in cases when you want to focus a view or measure its on-screen dimensions,
* for example.
* The methods described here are available on most of the default components provided by React Native.
* Note, however, that they are not available on composite components that aren't directly backed by a
* native view. This will generally include most components that you define in your own app.
* For more information, see [Direct Manipulation](http://facebook.github.io/react-native/docs/direct-manipulation.html).
* @see https://github.com/facebook/react-native/blob/master/Libraries/ReactIOS/NativeMethodsMixin.js
*/
export interface NativeMethodsMixinStatic {
/**
* Determines the location on screen, width, and height of the given view and
* returns the values via an async callback. If successful, the callback will
* be called with the following arguments:
*
* - x
* - y
* - width
* - height
* - pageX
* - pageY
*
* Note that these measurements are not available until after the rendering
* has been completed in native. If you need the measurements as soon as
* possible, consider using the [`onLayout`
* prop](docs/view.html#onlayout) instead.
*/
measure(callback: MeasureOnSuccessCallback): void;
/**
* Determines the location of the given view in the window and returns the
* values via an async callback. If the React root view is embedded in
* another native view, this will give you the absolute coordinates. If
* successful, the callback will be called with the following
* arguments:
*
* - x
* - y
* - width
* - height
*
* Note that these measurements are not available until after the rendering
* has been completed in native.
*/
measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;
/**
* Like [`measure()`](#measure), but measures the view relative an ancestor,
* specified as `relativeToNativeNode`. This means that the returned x, y
* are relative to the origin x, y of the ancestor view.
*
* As always, to obtain a native node handle for a component, you can use
* `React.findNodeHandle(component)`.
*/
measureLayout(
relativeToNativeNode: number,
onSuccess: MeasureLayoutOnSuccessCallback,
onFail: () => void /* currently unused */
): void;
/**
* This function sends props straight to native. They will not participate in
* future diff process - this means that if you do not include them in the
* next render, they will remain active (see [Direct
* Manipulation](docs/direct-manipulation.html)).
*/
setNativeProps(nativeProps: Object): void;
/**
* Requests focus for the given input or view. The exact behavior triggered
* will depend on the platform and type of view.
*/
focus(): void;
/**
* Removes focus from an input or view. This is the opposite of `focus()`.
*/
blur(): void;
refs: {
[key: string]: Component<any, any>
};
}
// see react-jsx.d.ts
export function createElement<P>( type: React.ReactType,
props?: P,
...children: React.ReactNode[] ): React.ReactElement<P>;
export type Runnable = ( appParameters: any ) => void;
// Similar to React.SyntheticEvent except for nativeEvent
interface NativeSyntheticEvent<T> {
bubbles: boolean
cancelable: boolean
currentTarget: EventTarget
defaultPrevented: boolean
eventPhase: number
isTrusted: boolean
nativeEvent: T
preventDefault(): void
stopPropagation(): void
target: EventTarget
timeStamp: Date
type: string
}
export interface NativeTouchEvent {
/**
* Array of all touch events that have changed since the last event
*/
changedTouches: NativeTouchEvent[]
/**
* The ID of the touch
*/
identifier: string
/**
* The X position of the touch, relative to the element
*/
locationX: number
/**
* The Y position of the touch, relative to the element
*/
locationY: number
/**
* The X position of the touch, relative to the screen
*/
pageX: number
/**
* The Y position of the touch, relative to the screen
*/
pageY: number
/**
* The node id of the element receiving the touch event
*/
target: string
/**
* A time identifier for the touch, useful for velocity calculation
*/
timestamp: number
/**
* Array of all current touches on the screen
*/
touches : NativeTouchEvent[]
}
export interface GestureResponderEvent extends NativeSyntheticEvent<NativeTouchEvent> {
}
export interface PointProperties {
x: number
y: number
}
export interface Insets {
top?: number
left?: number
bottom?: number
right?: number
}
/**
* //FIXME: need to find documentation on which component is a TTouchable and can implement that interface
* @see React.DOMAtributes
*/
export interface Touchable {
onTouchStart?: ( event: GestureResponderEvent ) => void
onTouchMove?: ( event: GestureResponderEvent ) => void
onTouchEnd?: ( event: GestureResponderEvent ) => void
onTouchCancel?: ( event: GestureResponderEvent ) => void
onTouchEndCapture?: ( event: GestureResponderEvent ) => void
}
export type ComponentProvider = () => React.ComponentClass<any>
export type AppConfig = {
appKey: string;
component?: ComponentProvider
run?: Runnable;
}
// https://github.com/facebook/react-native/blob/master/Libraries/AppRegistry/AppRegistry.js
/**
* `AppRegistry` is the JS entry point to running all React Native apps. App
* root components should register themselves with
* `AppRegistry.registerComponent`, then the native system can load the bundle
* for the app and then actually run the app when it's ready by invoking
* `AppRegistry.runApplication`.
*
* To "stop" an application when a view should be destroyed, call
* `AppRegistry.unmountApplicationComponentAtRootTag` with the tag that was
* pass into `runApplication`. These should always be used as a pair.
*
* `AppRegistry` should be `require`d early in the `require` sequence to make
* sure the JS execution environment is setup before other modules are
* `require`d.
*/
export class AppRegistry {
static registerConfig( config: AppConfig[] ): void;
static registerComponent( appKey: string, getComponentFunc: ComponentProvider ): string;
static registerRunnable( appKey: string, func: Runnable ): string;
static getAppKeys(): string[];
static unmountApplicationComponentAtRootTag(rootTag: number): void;
static runApplication( appKey: string, appParameters: any ): void;
}
export interface LayoutAnimationTypes {
spring: string
linear: string
easeInEaseOut: string
easeIn: string
easeOut: string
}
export interface LayoutAnimationProperties {
opacity: string
scaleXY: string
}
export interface LayoutAnimationAnim {
duration?: number
delay?: number
springDamping?: number
initialVelocity?: number
type?: string //LayoutAnimationTypes
property?: string //LayoutAnimationProperties
}
export interface LayoutAnimationConfig {
duration: number
create?: LayoutAnimationAnim
update?: LayoutAnimationAnim
delete?: LayoutAnimationAnim
}
/** Automatically animates views to their new positions when the next layout happens.
* A common way to use this API is to call LayoutAnimation.configureNext before
* calling setState. */
export interface LayoutAnimationStatic {
/** Schedules an animation to happen on the next layout.
* @param config Specifies animation properties:
* `duration` in milliseconds
* `create`, config for animating in new views (see Anim type)
* `update`, config for animating views that have been updated (see Anim type)
* @param onAnimationDidEnd Called when the animation finished. Only supported on iOS.
*/
configureNext: ( config: LayoutAnimationConfig, onAnimationDidEnd?: () => void ) => void
/** Helper for creating a config for configureNext. */
create: ( duration: number, type?: string, creationProp?: string ) => LayoutAnimationConfig
Types: LayoutAnimationTypes
Properties: LayoutAnimationProperties
configChecker: (shapeTypes: {[key: string]: any}) => any
Presets : {
easeInEaseOut: LayoutAnimationConfig
linear:LayoutAnimationConfig
spring: LayoutAnimationConfig
}
easeInEaseOut: (config: LayoutAnimationConfig, onAnimationDidEnd?: () => void) => void
linear: (config: LayoutAnimationConfig, onAnimationDidEnd?: () => void) => void
spring: (config: LayoutAnimationConfig, onAnimationDidEnd?: () => void) => void
}
export type FlexAlignType = "flex-start" | "flex-end" | "center" | "stretch";
export type FlexJustifyType = "flex-start" | "flex-end" | "center" | "space-between" | "space-around";
export type FlexDirection = "row" | "column" | "row-reverse" | "column-reverse";
/**
* Flex Prop Types
* @see https://facebook.github.io/react-native/docs/flexbox.html#proptypes
* @see LayoutPropTypes.js
*/
export interface FlexStyle {
alignItems?: FlexAlignType;
alignSelf?: "auto" | FlexAlignType;
borderBottomWidth?: number
borderLeftWidth?: number
borderRightWidth?: number
borderTopWidth?: number
borderWidth?: number
bottom?: number
flex?: number
flexGrow?: number
flexShrink?: number
flexBasis?: number
flexDirection?: FlexDirection
flexWrap?: "wrap" | "nowrap"
height?: number
justifyContent?: FlexJustifyType
left?: number
minWidth?: number
maxWidth?: number
minHeight?: number
maxHeight?: number
margin?: number
marginBottom?: number
marginHorizontal?: number
marginLeft?: number
marginRight?: number
marginTop?: number
marginVertical?: number
overflow?: "visible" | "hidden" | "scroll"
padding?: number
paddingBottom?: number
paddingHorizontal?: number
paddingLeft?: number
paddingRight?: number
paddingTop?: number
paddingVertical?: number
position?: "absolute" | "relative"
right?: number
top?: number
width?: number
/**
* @platform ios
*/
zIndex?: number
}
/**
* @see ShadowPropTypesIOS.js
*/
export interface ShadowPropTypesIOSStatic {
/**
* Sets the drop shadow color
* @platform ios
*/
shadowColor: string
/**
* Sets the drop shadow offset
* @platform ios
*/
shadowOffset: {width: number, height: number}
/**
* Sets the drop shadow opacity (multiplied by the color's alpha component)
* @platform ios
*/
shadowOpacity: number
/**
* Sets the drop shadow blur radius
* @platform ios
*/
shadowRadius: number
}
type GetCurrentPositionOptions = {
timeout: number
maximumAge: number
enableHighAccuracy: boolean
distanceFilter: number
}
type WatchPositionOptions = {
timeout: number
maximumAge: number
enableHighAccuracy: boolean
distanceFilter: number
}
type GeolocationReturnType = {
coords: {
latitude: number
longitude: number
altitude?: number
accuracy?: number
altitudeAccuracy?: number
heading?: number
speed?: number
}
timestamp: number
}
export interface TransformsStyle {
transform?: [{perspective: number}, {rotate: string}, {rotateX: string}, {rotateY: string}, {rotateZ: string}, {scale: number}, {scaleX: number}, {scaleY: number}, {translateX: number}, {translateY: number}, {skewX: string}, {skewY: string}]
transformMatrix?: Array<number>
rotation?: number
scaleX?: number
scaleY?: number
translateX?: number
translateY?: number
}
export interface StyleSheetProperties {
hairlineWidth: number
flatten<T extends string>(style: T): T
}
export interface LayoutRectangle {
x: number;
y: number;
width: number;
height: number;
}
// @see TextProperties.onLayout
export interface LayoutChangeEvent {
nativeEvent: {
layout: LayoutRectangle
}
}
export interface TextStyleIOS extends ViewStyle {
letterSpacing?: number
textDecorationColor?: string
textDecorationStyle?: "solid" | "double" | "dotted" | "dashed"
writingDirection?: "auto" | "ltr" | "rtl"
}
export interface TextStyleAndroid extends ViewStyle {
textAlignVertical?: "auto" | "top" | "bottom" | "center"
}
// @see https://facebook.github.io/react-native/docs/text.html#style
export interface TextStyle extends TextStyleIOS, TextStyleAndroid, ViewStyle {
color?: string
fontFamily?: string
fontSize?: number
fontStyle?: "normal" | "italic"
/**
* Specifies font weight. The values 'normal' and 'bold' are supported
* for most fonts. Not all fonts have a variant for each of the numeric
* values, in that case the closest one is chosen.
*/
fontWeight?: "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900"
letterSpacing?: number
lineHeight?: number
/**
* Specifies text alignment.
* The value 'justify' is only supported on iOS.
*/
textAlign?: "auto" | "left" | "right" | "center"
textDecorationLine?: "none" | "underline" | "line-through" | "underline line-through"
textDecorationStyle?: "solid" | "double" | "dotted" | "dashed"
textDecorationColor?: string
textShadowColor?: string
textShadowOffset?: {width: number, height: number}
textShadowRadius?: number
testID?: string
}
export interface TextPropertiesIOS {
/**
* Specifies whether fonts should scale to respect Text Size accessibility setting on iOS. The
* default is `true`.
*/
allowFontScaling?: boolean
/**
* Specifies whether font should be scaled down automatically to fit given style constraints.
*/
adjustsFontSizeToFit?: boolean
/**
* Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).
*/
minimumFontScale?: number
/**
* When `true`, no visual change is made when text is pressed down. By
* default, a gray oval highlights the text on press down.
*/
suppressHighlighting?: boolean
}
export interface TextPropertiesAndroid {
/**
* Lets the user select text, to use the native copy and paste functionality.
*/
selectable?: boolean
}
// https://facebook.github.io/react-native/docs/text.html#props
export interface TextProperties extends TextPropertiesIOS, TextPropertiesAndroid, React.Props<TextStatic> {
/**
* When set to `true`, indicates that the view is an accessibility element. The default value
* for a `Text` element is `true`.
*
* See the
* [Accessibility guide](/react-native/docs/accessibility.html#accessible-ios-android)
* for more information.
*/
accessible?: boolean
/**
* This can be one of the following values:
*
* - `head` - The line is displayed so that the end fits in the container and the missing text
* at the beginning of the line is indicated by an ellipsis glyph. e.g., "...wxyz"
* - `middle` - The line is displayed so that the beginning and end fit in the container and the
* missing text in the middle is indicated by an ellipsis glyph. "ab...yz"
* - `tail` - The line is displayed so that the beginning fits in the container and the
* missing text at the end of the line is indicated by an ellipsis glyph. e.g., "abcd..."
* - `clip` - Lines are not drawn past the edge of the text container.
*
* The default is `tail`.
*
* `numberOfLines` must be set in conjunction with this prop.
*
* > `clip` is working only for iOS
*/
ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip'
/**
* Line Break mode. Works only with numberOfLines.
* clip is working only for iOS
*/
lineBreakMode?: 'head' | 'middle' | 'tail' | 'clip'
/**
* Used to truncate the text with an ellipsis after computing the text
* layout, including line wrapping, such that the total number of lines
* does not exceed this number.
*
* This prop is commonly used with `ellipsizeMode`.
*/
numberOfLines?: number
/**
* Invoked on mount and layout changes with
*
* {nativeEvent: { layout: {x, y, width, height}}}.
*/
onLayout?: ( event: LayoutChangeEvent ) => void
/**
* This function is called on press.
* Text intrinsically supports press handling with a default highlight state (which can be disabled with suppressHighlighting).
*/
onPress?: () => void
/**
* This function is called on long press.
* e.g., `onLongPress={this.increaseSize}>``
*/
onLongPress?: () => void
/**
* @see https://facebook.github.io/react-native/docs/text.html#style
*/
style?: TextStyle
/**
* Used to locate this view in end-to-end tests.
*/
testID?: string
}
/**
* A React component for displaying text which supports nesting, styling, and touch handling.
*/
export interface TextStatic extends NativeMethodsMixin, React.ClassicComponentClass<TextProperties> {
}
type DataDetectorTypes = 'phoneNumber' | 'link' | 'address' | 'calendarEvent' | 'none' | 'all';
/**
* DocumentSelectionState is responsible for maintaining selection information
* for a document.
*
* It is intended for use by AbstractTextEditor-based components for
* identifying the appropriate start/end positions to modify the
* DocumentContent, and for programatically setting browser selection when
* components re-render.
*/
export interface DocumentSelectionState extends EventEmitter {
new(anchor: number, focus: number): DocumentSelectionState
/**
* Apply an update to the state. If either offset value has changed,
* set the values and emit the `change` event. Otherwise no-op.
*
* @param {number} anchor
* @param {number} focus
*/
update(anchor: number, focus: number): void
/**
* Given a max text length, constrain our selection offsets to ensure
* that the selection remains strictly within the text range.
*
* @param {number} maxLength
*/
constrainLength(maxLength: number): void
focus(): void
blur(): void
hasFocus(): boolean
isCollapsed(): boolean
isBackward(): boolean
getAnchorOffset(): number
getFocusOffset(): number
getStartOffset(): number
getEndOffset(): number
overlaps(start: number, end: number): boolean
}
/**
* IOS Specific properties for TextInput
* @see https://facebook.github.io/react-native/docs/textinput.html#props
*/
export interface TextInputIOSProperties {
/**
* enum('never', 'while-editing', 'unless-editing', 'always')
* When the clear button should appear on the right side of the text view
*/
clearButtonMode?: 'never' | 'while-editing' | 'unless-editing' | 'always'
/**
* If true, clears the text field automatically when editing begins
*/
clearTextOnFocus?: boolean
/**
* Determines the types of data converted to clickable URLs in the text input.
* Only valid if `multiline={true}` and `editable={false}`.
* By default no data types are detected.
*
* You can provide one type or an array of many types.
*
* Possible values for `dataDetectorTypes` are:
*
* - `'phoneNumber'`
* - `'link'`
* - `'address'`
* - `'calendarEvent'`
* - `'none'`
* - `'all'`
*/
dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[]
/**
* If true, the keyboard disables the return key when there is no text and automatically enables it when there is text.
* The default value is false.
*/
enablesReturnKeyAutomatically?: boolean
/**
* Determines the color of the keyboard.
*/
keyboardAppearance?: 'default' | 'light' | 'dark'
/**
* Callback that is called when a key is pressed.
* Pressed key value is passed as an argument to the callback handler.
* Fires before onChange callbacks.
*/
onKeyPress?: (key: string) => void
/**
* See DocumentSelectionState.js, some state that is responsible for maintaining selection information for a document
*/
selectionState?: DocumentSelectionState
}
/**
* Android Specific properties for TextInput
* @see https://facebook.github.io/react-native/docs/textinput.html#props
*/
export interface TextInputAndroidProperties {
/**
* If defined, the provided image resource will be rendered on the left.
*/
inlineImageLeft?: string
/**
* Padding between the inline image, if any, and the text input itself.
*/
inlineImagePadding?: number
/**
* Sets the number of lines for a TextInput.
* Use it with multiline set to true to be able to fill the lines.
*/
numberOfLines?: number
/**
* Sets the return key to the label. Use it instead of `returnKeyType`.
* @platform android
*/
returnKeyLabel?: string
/**
* The color of the textInput underline.
*/
underlineColorAndroid?: string
}
export type KeyboardType = "default" | "email-address" | "numeric" | "phone-pad"
export type KeyboardTypeIOS = "ascii-capable" | "numbers-and-punctuation" | "url" | "number-pad" | "name-phone-pad" | "decimal-pad" | "twitter" | "web-search"
export type ReturnKeyType = "done" | "go" | "next" | "search" | "send"
export type ReturnKeyTypeAndroid = "none" | "previous"
export type ReturnKeyTypeIOS = "default" | "google" | "join" | "route" | "yahoo" | "emergency-call"
/**
* @see https://facebook.github.io/react-native/docs/textinput.html#props
*/
export interface TextInputProperties extends ViewProperties, TextInputIOSProperties, TextInputAndroidProperties, React.Props<TextInputStatic> {
/**
* Can tell TextInput to automatically capitalize certain characters.
* characters: all characters,
* words: first letter of each word
* sentences: first letter of each sentence (default)
* none: don't auto capitalize anything
*
* https://facebook.github.io/react-native/docs/textinput.html#autocapitalize
*/
autoCapitalize?: "none" | "sentences" | "words" | "characters"
/**
* If false, disables auto-correct.