-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.d.ts
6695 lines (5803 loc) · 216 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
// Type definitions for react-native 0.61
// Project: https://github.com/facebook/react-native
// Definitions by: Eloy Durán <https://github.com/alloy>
// HuHuanming <https://github.com/huhuanming>
// Kyle Roach <https://github.com/iRoachie>
// Simon Knott <https://github.com/skn0tt>
// Tim Wang <https://github.com/timwangdev>
// Kamal Mahyuddin <https://github.com/kamal>
// Alex Dunne <https://github.com/alexdunne>
// Manuel Alabor <https://github.com/swissmanu>
// Michele Bombardi <https://github.com/bm-software>
// Alexander T. <https://github.com/a-tarasyuk>
// Martin van Dam <https://github.com/mvdam>
// Kacper Wiszczuk <https://github.com/esemesek>
// Ryan Nickel <https://github.com/mrnickel>
// Souvik Ghosh <https://github.com/souvik-ghosh>
// Cheng Gibson <https://github.com/nossbigg>
// Saransh Kataria <https://github.com/saranshkataria>
// Francesco Moro <https://github.com/franzmoro>
// Wojciech Tyczynski <https://github.com/tykus160>
// Jake Bloom <https://github.com/jakebloom>
// Ceyhun Ozugur <https://github.com/ceyhun>
// Mike Martin <https://github.com/mcmar>
// Theo Henry de Villeneuve <https://github.com/theohdv>
// Eli White <https://github.com/TheSavior>
// Romain Faust <https://github.com/romain-faust>
// Be Birchall <https://github.com/bebebebebe>
// Jesse Katsumata <https://github.com/Naturalclar>
// Xianming Zhong <https://github.com/chinesedfan>
// Valentyn Tolochko <https://github.com/vtolochk>
// Sergey Sychev <https://github.com/SychevSP>
// Kelvin Chu <https://github.com/RageBill>
// Daiki Ihara <https://github.com/sasurau4>
// Abe Dolinger <https://github.com/256hz>
// Dominique Richard <https://github.com/doumart>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// USING: these definitions are meant to be used with the TSC compiler target set to at least ES2015.
//
// 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
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
import * as React from 'react';
type Constructor<T> = new (...args: any[]) => T;
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 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.
*/
declare class EventSubscriptionVendor {
constructor();
/**
* Adds a subscription keyed by an event type.
*
*/
addSubscription(eventType: string, subscription: EventSubscription): EventSubscription;
/**
* Removes a bulk set of the subscriptions.
*
* @param 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.
*
*/
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.
*
*/
getSubscriptionsForType(eventType: string): EventSubscription[];
}
/**
* EmitterSubscription represents a subscription with listener and context data.
*/
interface EmitterSubscription extends EventSubscription {
emitter: EventEmitter;
listener: () => any;
context: any;
/**
* @param emitter - The event emitter that registered this
* subscription
* @param subscriber - The subscriber that controls
* this subscription
* @param 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 EventEmitterListener {
/**
* 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 eventType - Name of the event to listen to
* @param 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;
}
interface EventEmitter extends EventEmitterListener {
/**
*
* @param subscriber - Optional subscriber instance
* to use. If omitted, a new subscriber will be created for the emitter.
*/
new (subscriber?: EventSubscriptionVendor): EventEmitter;
/**
* Similar to addListener, except that the listener is removed after it is
* invoked once.
*
* @param eventType - Name of the event to listen to
* @param 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 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
* const 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 eventType - Name of the event to query
*/
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 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, ...params: any[]): void;
/**
* Removes the given listener for event of specific type.
*
* @param eventType - Name of the event to emit
* @param 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]: React.Component<any, any>;
};
}
interface CreateElementProps {
[key: string]: mixed;
}
// see react-jsx.d.ts
export function unstable_createElement(
type: React.ReactType,
props?: CreateElementProps,
...children: React.ReactNode[]
): React.ReactElement<CreateElementProps>;
export type Runnable = (appParameters: any) => void;
type Task = (taskData: any) => Promise<void>;
type TaskProvider = () => Task;
type NodeHandle = number;
// Similar to React.SyntheticEvent except for nativeEvent
export interface NativeSyntheticEvent<T> extends React.BaseSyntheticEvent<T, NodeHandle, NodeHandle> {}
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> {}
// See https://facebook.github.io/react-native/docs/scrollview.html#contentoffset
export interface PointPropType {
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 {
autoFocus?: boolean;
onTouchStart?: (event: GestureResponderEvent) => void;
onTouchMove?: (event: GestureResponderEvent) => void;
onTouchEnd?: (event: GestureResponderEvent) => void;
onTouchCancel?: (event: GestureResponderEvent) => void;
onTouchEndCapture?: (event: GestureResponderEvent) => void;
// mouse
onContextMenu?: (event: GestureResponderEvent) => void;
}
export type ComponentProvider = () => React.ComponentType<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 namespace AppRegistry {
function registerConfig(config: AppConfig[]): void;
function registerComponent(appKey: string, getComponentFunc: ComponentProvider): string;
function registerRunnable(appKey: string, func: Runnable): string;
function getAppKeys(): string[];
function unmountApplicationComponentAtRootTag(rootTag: number): void;
function runApplication(appKey: string, appParameters: any): void;
function registerHeadlessTask(appKey: string, task: TaskProvider): void;
function getRunnable(appKey: string): Runnable | undefined;
function getApplication(
appKey: string,
appParams: any
): { element: React.ReactElement; getStyleElement: (any) => React.ReactElement };
}
export interface LayoutAnimationTypes {
spring: string;
linear: string;
easeInEaseOut: string;
easeIn: string;
easeOut: string;
keyboard: 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: (onAnimationDidEnd?: () => void) => void;
linear: (onAnimationDidEnd?: () => void) => void;
spring: (onAnimationDidEnd?: () => void) => void;
}
type FlexAlignType = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
/**
* Flex Prop Types
* @see https://facebook.github.io/react-native/docs/flexbox.html#proptypes
* @see https://facebook.github.io/react-native/docs/layout-props.html
* @see https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/LayoutPropTypes.js
*/
export interface FlexStyle {
alignContent?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'space-between' | 'space-around';
alignItems?: FlexAlignType;
alignSelf?: 'auto' | FlexAlignType;
animationKeyframes?: Array<{ [key: string]: mixed }>;
animationDuration?: string;
animationIterationCount?: number;
aspectRatio?: number;
borderBottomWidth?: number;
borderEndWidth?: number | string;
borderLeftWidth?: number;
borderRightWidth?: number;
borderStartWidth?: number | string;
borderTopWidth?: number;
borderWidth?: number;
bottom?: number | string;
display?: 'none' | 'flex' | 'inline-flex' | 'block' | 'inline-block';
end?: number | string;
flex?: number;
flexBasis?: number | string;
flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
flexGrow?: number;
flexShrink?: number;
flexWrap?: 'wrap' | 'nowrap' | 'wrap-reverse';
height?: number | string;
justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
left?: number | string;
margin?: number | string;
marginBottom?: number | string;
marginEnd?: number | string;
marginHorizontal?: number | string;
marginLeft?: number | string;
marginRight?: number | string;
marginStart?: number | string;
marginTop?: number | string;
marginVertical?: number | string;
maxHeight?: number | string;
maxWidth?: number | string;
minHeight?: number | string;
minWidth?: number | string;
overflow?: 'visible' | 'hidden' | 'scroll';
outlineStyle?: string;
padding?: number | string;
paddingBottom?: number | string;
paddingEnd?: number | string;
paddingHorizontal?: number | string;
paddingLeft?: number | string;
paddingRight?: number | string;
paddingStart?: number | string;
paddingTop?: number | string;
paddingVertical?: number | string;
position?: 'absolute' | 'relative' | 'static' | 'fixed' | 'sticky';
right?: number | string;
start?: number | string;
top?: number | string;
transform?: Array<{}>;
transformOrigin?: string;
transitionDelay?: string;
transitionDuration?: string;
transitionProperty?: string;
transitionTimingFunction?: string;
width?: number | string;
zIndex?: number;
/**
* @platform ios
*/
direction?: 'inherit' | 'ltr' | 'rtl';
}
interface PerpectiveTransform {
perspective: number;
}
interface RotateTransform {
rotate: string;
}
interface RotateXTransform {
rotateX: string;
}
interface RotateYTransform {
rotateY: string;
}
interface RotateZTransform {
rotateZ: string;
}
interface ScaleTransform {
scale: number;
}
interface ScaleXTransform {
scaleX: number;
}
interface ScaleYTransform {
scaleY: number;
}
interface TranslateXTransform {
translateX: number;
}
interface TranslateYTransform {
translateY: number;
}
interface SkewXTransform {
skewX: string;
}
interface SkewYTransform {
skewY: string;
}
export interface TransformsStyle {
transform?: (
| PerpectiveTransform
| RotateTransform
| RotateXTransform
| RotateYTransform
| RotateZTransform
| ScaleTransform
| ScaleXTransform
| ScaleYTransform
| TranslateXTransform
| TranslateYTransform
| SkewXTransform
| SkewYTransform
)[];
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 TextProps.onLayout
export interface LayoutChangeEvent {
nativeEvent: {
layout: LayoutRectangle;
};
}
export type FontVariant = 'small-caps' | 'oldstyle-nums' | 'lining-nums' | 'tabular-nums' | 'proportional-nums';
// @see https://facebook.github.io/react-native/docs/text.html#style
export interface TextStyle extends ViewStyle {
color?: string;
fontFamily?: string;
fontSize?: number | string;
fontStyle?: 'normal' | 'italic';
fontVariant?: FontVariant[];
/**
* 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;
letterSpacing?: number;
lineHeight?: number;
testID?: string;
textAlign?: 'center' | 'end' | 'inherit' | 'justify' | 'justify-all' | 'left' | 'right' | 'start';
textDecorationColor?: string;
textDecorationColor?: string;
textDecorationLine?: 'none' | 'underline' | 'line-through' | 'underline line-through';
textDecorationStyle?: 'solid' | 'double' | 'dotted' | 'dashed';
textDecorationStyle?: 'solid' | 'double' | 'dotted' | 'dashed';
textShadowColor?: string;
textShadowOffset?: { width: number; height: number };
textShadowRadius?: number;
textTransform?: 'none' | 'capitalize' | 'uppercase' | 'lowercase';
writingDirection?: 'auto' | 'ltr' | 'rtl';
writingDirection?: 'auto' | 'ltr' | 'rtl';
}
// https://facebook.github.io/react-native/docs/text.html#props
export interface TextProps extends AccessibilityProps {
/**
* Specifies whether fonts should scale to respect Text Size accessibility settings.
* The default is `true`.
*/
allowFontScaling?: 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';
href?: string;
/**
* 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?: (event: GestureResponderEvent) => void;
/**
* This function is called on long press.
* e.g., `onLongPress={this.increaseSize}>``
*/
onLongPress?: (event: GestureResponderEvent) => void;
/**
* @see https://facebook.github.io/react-native/docs/text.html#style
*/
style?: StyleProp<TextStyle>;
target?: string;
/**
* Used to locate this view in end-to-end tests.
*/
testID?: string;
/**
* Used to reference react managed views from native code.
*/
nativeID?: string;
/**
* Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values:
* - null/undefined (default): inherit from the parent node or the global default (0)
* - 0: no max, ignore parent/global default
* - >= 1: sets the maxFontSizeMultiplier of this node to this value
*/
maxFontSizeMultiplier?: number | null;
}
/**
* A React component for displaying text which supports nesting, styling, and touch handling.
*/
declare class TextComponent extends React.Component<TextProps> {}
declare const TextBase: Constructor<NativeMethodsMixin> & typeof TextComponent;
export class Text extends TextBase {}
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.
*
*/
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.
*
*/
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;
}
export type KeyboardType = 'default' | 'email-address' | 'numeric' | 'phone-pad' | 'number-pad' | 'decimal-pad';
export type KeyboardTypeOptions = KeyboardType;
export type ReturnKeyType = 'done' | 'go' | 'next' | 'search' | 'send';
export type ReturnKeyTypeOptions = ReturnKeyType;
export interface TargetedEvent {
target: number;
}
/**
* @see TextInputProps.onFocus
*/
export interface TextInputFocusEventData extends TargetedEvent {
text: string;
eventCount: number;
}
/**
* @see TextInputProps.onScroll
*/
export interface TextInputScrollEventData {
contentOffset: { x: number; y: number };
}
/**
* @see TextInputProps.onSelectionChange
*/
export interface TextInputSelectionChangeEventData extends TargetedEvent {
selection: {
start: number;
end: number;
};
}
/**
* @see TextInputProps.onKeyPress
*/
export interface TextInputKeyPressEventData {
key: string;
}
/**
* @see TextInputProps.onChange
*/
export interface TextInputChangeEventData extends TargetedEvent {
eventCount: number;
text: string;
}
/**
* @see TextInputProps.onContentSizeChange
*/
export interface TextInputContentSizeChangeEventData {
contentSize: { width: number; height: number };
}
/**
* @see TextInputProps.onEndEditing
*/
export interface TextInputEndEditingEventData {
text: string;
}
/**
* @see TextInputProps.onSubmitEditing
*/
export interface TextInputSubmitEditingEventData {
text: string;
}
/**
* @see https://facebook.github.io/react-native/docs/textinput.html#props
*/
export interface TextInputProps extends ViewProps, TextInputIOSProps, AccessibilityProps {
/**
* Specifies whether fonts should scale to respect Text Size accessibility settings.
* The default is `true`.
*/
allowFontScaling?: boolean;
/**
* 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.
* The default value is true.
*/
autoCorrect?: boolean;
/**
* If true, focuses the input on componentDidMount.
* The default value is false.
*/