UNPKG

declarations

Version:

[![npm version](https://badge.fury.io/js/declarations.svg)](https://www.npmjs.com/package/declarations)

1,423 lines (1,193 loc) 209 kB
// Type definitions for react-native 0.29 // 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 // Warning: the project currently uses and older version of react-native // // 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 { module NativeMethodsMixin { type MeasureOnSuccessCallback = ( x: number, y: number, width: number, height: number, pageX: number, pageY: number ) => void type MeasureInWindowOnSuccessCallback = ( x: number, y: number, width: number, height: number ) => void type MeasureLayoutOnSuccessCallback = ( left: number, top: number, width: number, height: number ) => void } /** * @see https://github.com/facebook/react-native/blob/master/Libraries/ReactIOS/NativeMethodsMixin.js */ // export class Component<P, S> extends React.Component<P, S> { export interface NativeComponent { /** * 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: NativeMethodsMixin.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: NativeMethodsMixin.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: NativeMethodsMixin.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> }; } //TODO: BGR: Replace with ComponentClass ? // node_modules/react-tools/src/classic/class/ReactClass.js export interface ReactClass<D, P, S> { // TODO: } // 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 compoenent is a native (i.e. non composite component) */ /* export interface NativeComponent { } */ /** * //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 AppConfig = { appKey: string; component: ReactClass<any, any, any>; 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: () => React.ComponentClass<any> ): 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 } export interface LayoutAnimationStatic { configureNext: ( config: LayoutAnimationConfig, onAnimationDidEnd?: () => void, onError?: ( error?: any ) => void ) => void create: ( duration: number, type?: string, creationProp?: string ) => LayoutAnimationConfig Types: LayoutAnimationTypes Properties: LayoutAnimationProperties configChecker: ( conf: {config: LayoutAnimationConfig}, name: string, next: string ) => void Presets : { easeInEaseOut: LayoutAnimationConfig linear:LayoutAnimationConfig spring: LayoutAnimationConfig } } export type FlexAlignType = "flex-start" | "flex-end" | "center" | "stretch"; export type FlexJustifyType = "flex-start" | "flex-end" | "center" | "space-between" | "space-around"; /** * 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 flexDirection?: "row" | "column" | "row-reverse" | "column-reverse" 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 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 } } 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 should fonts scale to respect Text Size accessibility * setting on iOS. */ allowFontScaling: boolean /** * 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 } // https://facebook.github.io/react-native/docs/text.html#props export interface TextProperties extends React.Props<TextProperties> { /** * Specifies should fonts scale to respect Text Size accessibility setting on iOS. */ allowFontScaling?: boolean /** * 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 elipsis after computing the text layout, including line wrapping, such that the total number of lines does not exceed this number. */ 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 /** * @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 React.ComponentClass<TextProperties> { } /** * 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?: string /** * If true, clears the text field automatically when editing begins */ clearTextOnFocus?: boolean /** * 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 /** * 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?: () => void /** * //FIXME: requires typing * See DocumentSelectionState.js, some state that is responsible for maintaining selection information for a document */ selectionState?: any } /** * Android Specific properties for TextInput * @see https://facebook.github.io/react-native/docs/textinput.html#props */ export interface TextInputAndroidProperties { /** * 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 /** * enum('start', 'center', 'end') * Set the position of the cursor from where editing will begin. */ textAlign?: string /** * enum('top', 'center', 'bottom') * Aligns text vertically within the TextInput. */ textAlignVertical?: string /** * The color of the textInput underline. */ underlineColorAndroid?: string } /** * @see https://facebook.github.io/react-native/docs/textinput.html#props */ export interface TextInputProperties extends 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. * The default value is true. */ autoCorrect?: boolean /** * If true, focuses the input on componentDidMount. * The default value is false. */ autoFocus?: boolean /** * If true, the text field will blur when submitted. * The default value is true. */ blurOnSubmit?: boolean /** * Provides an initial value that will change when the user starts typing. * Useful for simple use-cases where you don't want to deal with listening to events * and updating the value prop to keep the controlled state in sync. */ defaultValue?: string /** * If false, text is not editable. The default value is true. */ editable?: boolean /** * enum("default", 'numeric', 'email-address', "ascii-capable", 'numbers-and-punctuation', 'url', 'number-pad', 'phone-pad', 'name-phone-pad', 'decimal-pad', 'twitter', 'web-search') * Determines which keyboard to open, e.g.numeric. * The following values work across platforms: - default - numeric - email-address */ keyboardType?: "default" | "email-address" | "numeric" | "phone-pad" | "ascii-capable" | "numbers-and-punctuation" | "url" | "number-pad" | "name-phone-pad" | "decimal-pad" | "twitter" | "web-search" /** * Limits the maximum number of characters that can be entered. * Use this instead of implementing the logic in JS to avoid flicker. */ maxLength?: number /** * If true, the text input can be multiple lines. The default value is false. */ multiline?: boolean /** * Callback that is called when the text input is blurred */ onBlur?: () => void /** * Callback that is called when the text input's text changes. */ onChange?: ( event: {nativeEvent: {text: string}} ) => void /** * Callback that is called when the text input's text changes. * Changed text is passed as an argument to the callback handler. */ onChangeText?: ( text: string ) => void /** * Callback that is called when text input ends. */ onEndEditing?: ( event: {nativeEvent: {text: string}} ) => void /** * Callback that is called when the text input is focused */ onFocus?: () => void /** * Invoked on mount and layout changes with {x, y, width, height}. */ onLayout?: ( event: {nativeEvent: {x: number, y: number, width: number, height: number}} ) => void onSelectionChange?: () => void /** * Callback that is called when the text input's submit button is pressed. */ onSubmitEditing?: ( event: {nativeEvent: {text: string}} ) => void /** * //FIXME: Not part of the doc but found in examples */ password?: boolean /** * The string that will be rendered before text input has been entered */ placeholder?: string /** * The text color of the placeholder string */ placeholderTextColor?: string /** * enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call') * Determines how the return key should look. */ returnKeyType?: "default" | "go" | "google" | "join" | "next" | "route" | "search" | "send" | "yahoo" | "done" | "emergency-call" /** * If true, the text input obscures the text entered so that sensitive text like passwords stay secure. * The default value is false. */ secureTextEntry?: boolean /** * If true, all text will automatically be selected on focus */ selectTextOnFocus?: boolean /** * The highlight (and cursor on ios) color of the text input */ selectionColor?: string /** * Styles */ style?: TextStyle /** * Used to locate this view in end-to-end tests */ testID?: string /** * The value to show for the text input. TextInput is a controlled component, * which means the native value will be forced to match this value prop if provided. * For most uses this works great, but in some cases this may cause flickering - one common cause is preventing edits by keeping value the same. * In addition to simply setting the same value, either set editable={false}, * or set/update maxLength to prevent unwanted edits without flicker. */ value?: string } /** * @see https://facebook.github.io/react-native/docs/textinput.html#methods */ export interface TextInputStatic extends NativeComponent, React.ComponentClass<TextInputProperties> { /** * Returns if the input is currently focused. */ isFocused: () => boolean /** * Removes all text from the input. */ clear: () => void // The following methods are found only in implementation blur: () => void focus: () => void } export type ToolbarAndroidAction = { /** * title: required, the title of this action */ title: string /** * icon: the icon for this action, e.g. require('./some_icon.png') */ icon?: any /** * show: when to show this action as an icon or hide it in the overflow menu: always, ifRoom or never */ show?: "always" | "ifRoom" | "never" /** * showWithText: boolean, whether to show text alongside the icon or not */ showWithText?: boolean } export interface ToolbarAndroidProperties extends ViewProperties, React.Props<ToolbarAndroidStatic> { actions?: ToolbarAndroidAction[] /** * Sets the content inset for the toolbar ending edge. * The content inset affects the valid area for Toolbar content other * than the navigation button and menu. Insets define the minimum * margin for these components and can be used to effectively align * Toolbar content along well-known gridlines. */ contentInsetEnd?: number /** * Sets the content inset for the toolbar starting edge. * The content inset affects the valid area for Toolbar content * other than the navigation button and menu. Insets define the * minimum margin for these components and can be used to effectively * align Toolbar content along well-known gridlines. */ contentInsetStart?: number /** * Sets the toolbar logo. */ logo?: any /** * Sets the navigation icon. */ navIcon?: any /** * Callback that is called when an action is selected. The only * argument that is passed to the callback is the position of the * action in the actions array. */ onActionSelected?: (position: number) => void /** * Callback called when the icon is selected. */ onIconClicked?: () => void /** * Sets the overflow icon. */ overflowIcon?: any /** * Used to set the toolbar direction to RTL. * In addition to this property you need to add * android:supportsRtl="true" * to your application AndroidManifest.xml and then call * setLayoutDirection(LayoutDirection.RTL) in your MainActivity * onCreate method. */ rtl?: boolean /** * Sets the toolbar subtitle. */ subtitle?: string /** * Sets the toolbar subtitle color. */ subtitleColor?: string /** * Used to locate this view in end-to-end tests. */ testID?: string /** * Sets the toolbar title. */ title?: string /** * Sets the toolbar title color. */ titleColor?: string ref?: Ref<ToolbarAndroidStatic> } export interface ToolbarAndroidStatic extends React.ComponentClass<ToolbarAndroidProperties> { } /** * Gesture recognition on mobile devices is much more complicated than web. * A touch can go through several phases as the app determines what the user's intention is. * For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping. * This can even change during the duration of a touch. There can also be multiple simultaneous touches. * * The touch responder system is needed to allow components to negotiate these touch interactions * without any additional knowledge about their parent or child components. * This system is implemented in ResponderEventPlugin.js, which contains further details and documentation. * * Best Practices * Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes. * Every action should have the following attributes: * Feedback/highlighting- show the user what is handling their touch, and what will happen when they release the gesture * Cancel-ability- when making an action, the user should be able to abort it mid-touch by dragging their finger away * * These features make users more comfortable while using an app, * because it allows people to experiment and interact without fear of making mistakes. * * TouchableHighlight and Touchable* * The responder system can be complicated to use. * So we have provided an abstract Touchable implementation for things that should be "tappable". * This uses the responder system and allows you to easily configure tap interactions declaratively. * Use TouchableHighlight anywhere where you would use a button or link on web. */ export interface GestureResponderHandlers { /** * A view can become the touch responder by implementing the correct negotiation methods. * There are two methods to ask the view if it wants to become responder: */ /** * Does this view want to become responder on the start of a touch? */ onStartShouldSetResponder?: ( event: GestureResponderEvent ) => boolean /** * Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness? */ onMoveShouldSetResponder?: ( event: GestureResponderEvent ) => boolean /** * If the View returns true and attempts to become the responder, one of the following will happen: */ /** * The View is now responding for touch events. * This is the time to highlight and show the user what is happening */ onResponderGrant?: ( event: GestureResponderEvent ) => void /** * Something else is the responder right now and will not release it */ onResponderReject?: ( event: GestureResponderEvent ) => void /** * If the view is responding, the following handlers can be called: */ /** * The user is moving their finger */ onResponderMove?: ( event: GestureResponderEvent ) => void /** * Fired at the end of the touch, ie "touchUp" */ onResponderRelease?: ( event: GestureResponderEvent ) => void /** * Something else wants to become responder. * Should this view release the responder? Returning true allows release */ onResponderTerminationRequest?: ( event: GestureResponderEvent ) => boolean /** * The responder has been taken from the View. * Might be taken by other views after a call to onResponderTerminationRequest, * or might be taken by the OS without asking (happens with control center/ notification center on iOS) */ onResponderTerminate?: ( event: GestureResponderEvent ) => void /** * onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, * where the deepest node is called first. * That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. * This is desirable in most cases, because it makes sure all controls and buttons are usable. * * However, sometimes a parent will want to make sure that it becomes responder. * This can be handled by using the capture phase. * Before the responder system bubbles up from the deepest component, * it will do a capture phase, firing on*ShouldSetResponderCapture. * So if a parent View wants to prevent the child from becoming responder on a touch start, * it should have a onStartShouldSetResponderCapture handler which returns true. */ onStartShouldSetResponderCapture?: ( event: GestureResponderEvent ) => boolean /** * onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, * where the deepest node is called first. * That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. * This is desirable in most cases, because it makes sure all controls and buttons are usable. * * However, sometimes a parent will want to make sure that it becomes responder. * This can be handled by using the capture phase. * Before the responder system bubbles up from the deepest component, * it will do a capture phase, firing on*ShouldSetResponderCapture. * So if a parent View wants to prevent the child from becoming responder on a touch start, * it should have a onStartShouldSetResponderCapture handler which returns true. */ onMoveShouldSetResponderCapture?: () => void; } // @see https://facebook.github.io/react-native/docs/view.html#style export interface ViewStyle extends FlexStyle, TransformsStyle { backfaceVisibility?: "visible" | "hidden" backgroundColor?: string; borderBottomColor?: string; borderBottomLeftRadius?: number; borderBottomRightRadius?: number; borderBottomWidth?: number; borderColor?: string; borderLeftColor?: string; borderRadius?: number; borderRightColor?: string; borderRightWidth?: number; borderStyle?: "solid" | "dotted" | "dashed" borderTopColor?: string; borderTopLeftRadius?: number; borderTopRightRadius?: number; borderTopWidth?: number opacity?: number; overflow?: "visible" | "hidden" shadowColor?: string; shadowOffset?: {width: number, height: number}; shadowOpacity?: number; shadowRadius?: number; elevation?: number; testID?: string; } export interface ViewPropertiesIOS { /** * Provides additional traits to screen reader. * By default no traits are provided unless specified otherwise in element * * @enum('none', 'button', 'link', 'header', 'search', 'image', 'selected', 'plays', 'key', 'text','summary', 'disabled', 'frequentUpdates', 'startsMedia', 'adjustable', 'allowsDirectInteraction', 'pageTurn') */ accessibilityTraits?: string | string[]; /** * Whether this view should be rendered as a bitmap before compositing. * * On iOS, this is useful for animations and interactions that do not modify this component's dimensions nor its children; * for example, when translating the position of a static view, rasterization allows the renderer to reuse a cached bitmap of a static view * and quickly composite it during each frame. * * Rasterization incurs an off-screen drawing pass and the bitmap consumes memory. * Test and measure when using this property. */ shouldRasterizeIOS?: boolean } export interface ViewPropertiesAndroid { /** * Indicates to accessibility services to treat UI component like a native one. * Works for Android only. * * @enum('none', 'button', 'radiobutton_checked', 'radiobutton_unchecked' ) */ accessibilityComponentType?: string /** * Indicates to accessibility services whether the user should be notified when this view changes. * Works for Android API >= 19 only. * See http://developer.android.com/reference/android/view/View.html#attr_android:accessibilityLiveRegion for references. */ accessibilityLiveRegion?: string /** * Views that are only used to layout their children or otherwise don't draw anything * may be automatically removed from the native hierarchy as an optimization. * Set this property to false to disable this optimization and ensure that this View exists in the native view hierarchy. */ collapsable?: boolean /** * Controls how view is important for accessibility which is if it fires accessibility events * and if it is reported to accessibility services that query the screen. * Works for Android only. See http://developer.android.com/reference/android/R.attr.html#importantForAccessibility for references. * * Possible values: * 'auto' - The system determines whether the view is important for accessibility - default (recommended). * 'yes' - The view is important for accessibility. * 'no' - The view is not important for accessibility. * 'no-hide-descendants' - The view is not important for accessibility, nor are any of its descendant views. */ importantForAccessibility?: string /** * Whether this view needs to rendered offscreen and composited with an alpha in order to preserve 100% correct colors and blending behavior. * The default (false) falls back to drawing the component and its children * with an alpha applied to the paint used to draw each element instead of rendering the full component offscreen and compositing it back with an alpha value. * This default may be noticeable and undesired in the case where the View you are setting an opacity on * has multiple overlapping elements (e.g. multiple overlapping Views, or text and a background). * * Rendering offscreen to preserve correct alpha behavior is extremely expensive * and hard to debug for non-native developers, which is why it is not turned on by default. * If you do need to enable this property for an animation, * consider combining it with renderToHardwareTextureAndroid if the view contents are static (i.e. it doesn't need to be redrawn each frame). * If that property is enabled, this View will be rendered off-screen once, * saved in a hardware texture, and then composited onto the screen with an alpha each frame without having to switch rendering targets on the GPU. */ needsOffscreenAlphaCompositing?: boolean /** * Whether this view should render itself (and all of its children) into a single hardware texture on the GPU. * * On Android, this is useful for animations and interactions that only modify opacity, rotation, translation, and/or scale: * in those cases, the view doesn't have to be redrawn and display lists don't need to be re-executed. The texture can just be * re-used and re-composited with different parameters. The downside is that this can use up limited video memory, so this prop should be set back to false at the end of the interaction/animation. */ renderToHardwareTextureAndroid?: boolean; } /** * @see https://facebook.github.io/react-native/docs/view.html#props */ export interface ViewProperties extends ViewPropertiesAndroid, ViewPropertiesIOS, GestureResponderHandlers, Touchable, React.Props<ViewStatic> { /** * Overrides the text that's read by the screen reader when the user interacts with the element. By default, the label is constructed by traversing all the children and accumulating all the Text nodes separated by space. */ accessibilityLabel?: string; /** * When true, indicates that the view is an accessibility element. * By default, all the touchable elements are accessible. */ accessible?: boolean; /** * This defines how far a touch event can start away from the view. * Typical interface guidelines recommend touch targets that are at least * 30 - 40 points/density-independent pixels. If a Touchable view has * a height of 20 the touchable height can be extended to 40 with * hitSlop={{top: 10, bottom: 10, left: 0, right: 0}} * NOTE The touch area never extends past the parent view bounds and * the Z-index of sibling views always takes precedence if a touch * hits two overlapping views. */ hitSlop?: {top: number, left: number, bottom: number, right: number} /** * When `accessible` is true, the system will try to invoke this function when the user performs accessibility tap gesture. */ onAcccessibilityTap?: () => void; /** * Invoked on mount and layout changes with * * {nativeEvent: { layout: {x, y, width, height}}}. */ onLayout?: ( event: LayoutChangeEvent ) => void; /** * When accessible is true, the system will invoke this function when the user performs the magic tap gesture. */ onMagicTap?: () => void; /** * * In the absence of auto property, none is much like CSS's none value. box-none is as if you had applied the CSS class: * * .box-none { * pointer-events: none; * } * .box-none * { * pointer-events: all; * } * * box-only is the equivalent of * * .box-only { * pointer-events: all; * } * .box-only * { * pointer-events: none; * } * * But since pointerEvents does not affect layout/appearance, and we are already deviating from the spec by adding additional modes, * we opt to not include pointerEvents on style. On some platforms, we would need to implement it as a className anyways. Using style or not is an implementation detail of the platform. */ pointerEvents?: "box-none" | "none" | "box-only" | "autoViewStyle" /** * * This is a special performance property exposed by RCTView and is useful for scrolling content when there are many subviews, * most of which are offscreen. For this property to be effective, it must be applied to a view that contains many subviews that extend outside its bound. * The subviews must also have overflow: hidden, as should the containing view (or one of its superviews). */ removeClippedSubviews?: boolean style?: ViewStyle; /** * Used to locate this view in end-to-end tests. */ testID?: string; } /** * The most fundamental component for building UI, View is a container that supports layout with flexbox, style, some touch handling, * and accessibility controls, and is designed to be nested inside other views and to have 0 to many children of any type. * View maps directly to the native view equivalent on whatever platform React is running on, * whether that is a UIView, <div>, android.view, etc. */ export interface ViewStatic extends NativeComponent, React.ComponentClass<ViewProperties> { } /** * @see https://facebook.github.io/react-native/docs/viewpagerandroid.html#props */ export interface ViewPagerAndroidOnPageScrollEventData { position: number; offset: number; } export interface ViewPagerAndroidOnPageSelectedEventData { position: number; } export interface ViewPagerAndroidProperties extends ViewProperties { initialPage?: number; /** * When false, the content does not scroll. * The default value is true. */ scrollEnabled?: boolean; onPageScroll?: ( event: NativeSyntheticEvent<ViewPagerAndroidOnPageScrollEventData> ) => void; onPageSelected?: ( event: NativeSyntheticEvent<ViewPagerAndroidOnPageSelectedEventData> ) => void; onPageScrollStateChanged?: (state: "Idle" | "Dragging" | "Settling") => void keyboardDismissMode?: "none" | "on-drag" pageMargin?: number } export interface ViewPagerAndroidStatic extends NativeComponent, React.ComponentClass<ViewPagerAndroidProperties> { setPage: (selectedPage: number) => void setPageWithoutAnimation: (selectedPage: number) => void } export interface KeyboardAvoidingViewStatic extends React.ComponentClass<KeyboardAvoidingViewProps> { } export interface KeyboardAvoidingViewProps extends ViewProperties, React.Props<KeyboardAvoidingViewStatic> { behavior?: 'height' | 'position' | 'padding' /** * This is the distance between the top of the user screen and the react native view, * may be non-zero in some use cases. */ keyboardVerticalOffset: number ref?: Ref<KeyboardAvoidingViewStatic & ViewStatic> } /** * //FIXME: No documentation extracted from code comment on WebView.ios.js */ export interface NavState { url?: string title?: string loading?: boolean canGoBack?: boolean canGoForward?: boolean; [key: string]: any } export interface WebViewPropertiesAndroid { /** * Used for android only, JS is enabled by default for WebView on iOS */ javaScriptEnabled?: boolean /** * Used on Android only, controls whether DOM Storage is enabled * or not android */ domStorageEnabled?: boolean } export interface WebViewIOSLoadRequestEvent { target: number canGoBack: boolean lockIdentifier: number loading: boolean title: string canGoForward: boolean navigationType: 'other' | 'click' url: string } export interface WebViewPropertiesIOS { /** * Determines whether HTML5 videos play inline or use the native * full-screen controller. default value false * NOTE : "In order * for video to play inline, not only does * this property need to be set to true, but the video element * in the HTML document must also include the webkit-playsinline * attribute." */ allowsInlineMediaPlayback?: boolean bounces?: boolean /** * A floating-point number that determines how quickly the scroll * view decelerates after the user lifts their finger. You may also * use string shortcuts "normal" and "fast" which match the * underlying iOS settings for UIScrollViewDecelerationRateNormal * and UIScrollViewDecelerationRateFast respectively. * - normal: 0.998 - fast: 0.99 (the default for iOS WebView) */ decelerationRate?: "normal" | "fast" | number /** * Allows custom handling of any webview requests by a JS handler. * Return true or false from this method to continue loading the * request. */ onShouldStartLoadWithRequest?: (event: WebViewIOSLoadRequestEvent) => boolean scrollEnabled?: boolean } export interface WebViewUriSource { /* * The URI to load in the WebView. Can be a local or remote file. */ uri?: string; /* * The HTTP Method to use. Defaults to GET if not specified. * NOTE: On Android, only GET and POST are supported. */ method?: string; /* * Additional HTTP headers to send with the request. * NOTE: On Android, this can only be used with GET requests. */ headers?: any; /* * The HTTP body to send with the request. This must be a valid * UTF-8 string, and will be sent exactly as specified, with no * additional encoding (e.g. URL-escaping or base64) applied. * NOTE: On Android, this can only be used with POST requests. */ body?: string; } export interface WebViewHtmlSource { /* * A static HTML page to display in the WebView. */ html: string; /* * The bas