diff --git a/fixed-data-table/fixed-data-table-tests.tsx b/fixed-data-table/fixed-data-table-tests.tsx index 9265186fb..28dae2890 100644 --- a/fixed-data-table/fixed-data-table-tests.tsx +++ b/fixed-data-table/fixed-data-table-tests.tsx @@ -1,7 +1,9 @@ /// /// +/// import * as React from "react"; +import * as ReactDOM from "react-dom"; import * as FixedDataTable from "fixed-data-table"; var rows = [ @@ -34,4 +36,4 @@ function rowGetter(rowIndex: number) { /> -React.render(table, document.body); +ReactDOM.render(table, document.body); diff --git a/jsnox/jsnox-tests.ts b/jsnox/jsnox-tests.ts index e34d71b4a..33e58720e 100644 --- a/jsnox/jsnox-tests.ts +++ b/jsnox/jsnox-tests.ts @@ -19,7 +19,7 @@ var clickHandler: React.MouseEventHandler // Tests with spec string function spec_string () { - var result: React.HTMLComponent + var result: React.ReactHTMLElement // just spec string result = $('div') diff --git a/jsnox/jsnox.d.ts b/jsnox/jsnox.d.ts index dfb59e280..22291956d 100644 --- a/jsnox/jsnox.d.ts +++ b/jsnox/jsnox.d.ts @@ -31,7 +31,7 @@ declare module 'jsnox' { * @param children A single React node (string or ReactElement) or array of nodes. * Note that unlike with React itself, multiple children must be placed into an array. */ - (specString: string, children: React.ReactNode): React.HTMLComponent +

(specString: string, children: React.ReactNode): React.DOMElement

/** * Renders an HTML element from the given spec string, with optional props @@ -42,7 +42,7 @@ declare module 'jsnox' { * @param children A single React node (string or ReactElement) or array of nodes. * Note that unlike with React itself, multiple children must be placed into an array. */ - (specString: string, props?: React.HTMLAttributes, children?: React.ReactNode): React.HTMLComponent +

(specString: string, props?: React.HTMLAttributes, children?: React.ReactNode): React.DOMElement

/** diff --git a/material-ui/legacy/material-ui-0.11.1-tests.tsx b/material-ui/legacy/material-ui-0.11.1-tests.tsx index c686efa9e..ffc360963 100644 --- a/material-ui/legacy/material-ui-0.11.1-tests.tsx +++ b/material-ui/legacy/material-ui-0.11.1-tests.tsx @@ -1,7 +1,9 @@ /// +/// /// -import * as React from "react/addons"; +import * as React from "react"; +import * as LinkedStateMixin from "react-addons-linked-state-mixin"; import mui = require("material-ui"); import Colors = require("material-ui/lib/styles/colors"); import AppBar = require("material-ui/lib/app-bar"); diff --git a/material-ui/legacy/material-ui-0.11.1.d.ts b/material-ui/legacy/material-ui-0.11.1.d.ts index 7f464bc57..f974c33be 100644 --- a/material-ui/legacy/material-ui-0.11.1.d.ts +++ b/material-ui/legacy/material-ui-0.11.1.d.ts @@ -233,7 +233,7 @@ declare namespace __MaterialUI { } // what's not commonly overridden by Checkbox, RadioButton, or Toggle - interface CommonEnhancedSwitchProps extends React.HTMLAttributesBase { + interface CommonEnhancedSwitchProps extends React.HTMLAttributes, React.Props { // is root element id?: string; iconStyle?: React.CSSProperties; @@ -412,7 +412,7 @@ declare namespace __MaterialUI { } // non generally overridden elements of EnhancedButton - interface SharedEnhancedButtonProps extends React.HTMLAttributesBase { + interface SharedEnhancedButtonProps extends React.HTMLAttributes, React.Props { centerRipple?: boolean; containerElement?: string | React.ReactElement; disabled?: boolean; diff --git a/material-ui/material-ui-tests.tsx b/material-ui/material-ui-tests.tsx index 4c69f3410..4e1e920d7 100644 --- a/material-ui/material-ui-tests.tsx +++ b/material-ui/material-ui-tests.tsx @@ -1,7 +1,9 @@ /// +/// /// -import * as React from "react/addons"; +import * as React from "react"; +import * as LinkedStateMixin from "react-addons-linked-state-mixin"; import Checkbox = require("material-ui/lib/checkbox"); import Colors = require("material-ui/lib/styles/colors"); import AppBar = require("material-ui/lib/app-bar"); diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index ecd32ae06..c31925d6f 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -222,7 +222,7 @@ declare namespace __MaterialUI { } // what's not commonly overridden by Checkbox, RadioButton, or Toggle - interface CommonEnhancedSwitchProps extends React.HTMLAttributesBase { + interface CommonEnhancedSwitchProps extends React.HTMLAttributes, React.Props { // is root element id?: string; iconStyle?: React.CSSProperties; @@ -402,7 +402,7 @@ declare namespace __MaterialUI { } // non generally overridden elements of EnhancedButton - interface SharedEnhancedButtonProps extends React.HTMLAttributesBase { + interface SharedEnhancedButtonProps extends React.HTMLAttributes, React.Props { centerRipple?: boolean; containerElement?: string | React.ReactElement; disabled?: boolean; @@ -644,7 +644,7 @@ declare namespace __MaterialUI { export class Overlay extends React.Component { } - interface PaperProps extends React.HTMLAttributesBase { + interface PaperProps extends React.HTMLAttributes, React.Props { circle?: boolean; rounded?: boolean; transitionEnabled?: boolean; @@ -1304,7 +1304,7 @@ declare namespace __MaterialUI { export class ToolbarSeparator extends React.Component { } - interface ToolbarTitleProps extends React.HTMLAttributesBase { + interface ToolbarTitleProps extends React.HTMLAttributes, React.Props { text?: string; } export class ToolbarTitle extends React.Component { diff --git a/mobservable-react/mobservable-react-tests.ts b/mobservable-react/mobservable-react-tests.ts index 7b39dbb7f..1bf2b49c6 100644 --- a/mobservable-react/mobservable-react-tests.ts +++ b/mobservable-react/mobservable-react-tests.ts @@ -17,7 +17,7 @@ import {reactiveComponent} from 'mobservable-react'; })); let c1Factory = React.createFactory(c1); - React.render(c1Factory({ + ReactDOM.render(c1Factory({ test: "hello" }), null); } @@ -31,7 +31,7 @@ class TestComponent extends React.Component<{ test: string },{}> { { let c2Factory = React.createFactory(TestComponent); - React.render(c2Factory({ + ReactDOM.render(c2Factory({ test: "hello" }) , null); } @@ -39,7 +39,7 @@ class TestComponent extends React.Component<{ test: string },{}> { { var c3 = reactiveComponent((props: { test: string }) => React.createElement("div")); var c3Factory = React.createFactory(c3); //without JSX - React.render(c3Factory({ + ReactDOM.render(c3Factory({ test: "hello" }), null); } @@ -55,7 +55,7 @@ class TestComponent2 extends React.Component<{ test: string },{}> { // Argument of type 'typeof TestComponent2 | void' is not assignable to parameter of type 'ComponentClass<{ test: string; }>'. // Type 'void' is not assignable to type 'ComponentClass<{ test: string; }>'. let c4Factory = React.createFactory(> reactiveComponent(TestComponent2)); - React.render(c4Factory({ + ReactDOM.render(c4Factory({ test: "hello" }) , null); } \ No newline at end of file diff --git a/react-dom/react-dom.d.ts b/react-dom/react-dom.d.ts deleted file mode 100644 index 1351fa02e..000000000 --- a/react-dom/react-dom.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Type definitions for React-DOM v0.14.0-rc -// Project: https://www.npmjs.com/package/react-dom -// Definitions by: Stefan-Bieliauskas -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare namespace __ReactDom { - function render

( - element: __React.DOMElement

, - container: Element, - callback?: () => any): __React.DOMComponent

; - function render( - element: __React.ClassicElement

, - container: Element, - callback?: () => any): __React.ClassicComponent; - function render( - element: __React.ReactElement

, - container: Element, - callback?: () => any): __React.Component; - - function findDOMNode( - componentOrElement: __React.Component | Element): TElement; - function findDOMNode( - componentOrElement: __React.Component | Element): Element; - - function unmountComponentAtNode(container: Element): boolean; -} - -declare namespace __ReactDomServer { - function renderToString(element: __React.ReactElement): string; - function renderToStaticMarkup(element: __React.ReactElement): string; -} -declare module "react-dom" { - export = __ReactDom -} - -declare module "react-dom/server" { - export = __ReactDomServer -} diff --git a/react-input-calendar/react-input-calendar-tests.tsx b/react-input-calendar/react-input-calendar-tests.tsx index 127106424..9cc4963fb 100644 --- a/react-input-calendar/react-input-calendar-tests.tsx +++ b/react-input-calendar/react-input-calendar-tests.tsx @@ -1,6 +1,8 @@ /// /// +/// import * as ReactInputCalendar from 'react-input-calendar'; import * as React from 'react'; -React.render(, document.body); +import * as ReactDOM from 'react-dom'; +ReactDOM.render(, document.body); diff --git a/react-native/react-native.d.ts b/react-native/react-native.d.ts index 485fdf5c0..2b6f076d0 100644 --- a/react-native/react-native.d.ts +++ b/react-native/react-native.d.ts @@ -2274,8 +2274,8 @@ declare namespace ReactNative { export interface DOMElement

extends React.DOMElement

{} - export type HTMLElement =React.HTMLElement; - export type SVGElement = React.SVGElement; + export type HTMLElement =React.ReactHTMLElement; + export type SVGElement = React.ReactSVGElement; // // Factories @@ -2289,7 +2289,6 @@ declare namespace ReactNative { export type HTMLFactory = React.HTMLFactory; export type SVGFactory = React.SVGFactory; - export type SVGElementFactory = React.SVGElementFactory; // // React Nodes @@ -2352,9 +2351,6 @@ declare namespace ReactNative { tagName: string; } - export type HTMLComponent = React.HTMLComponent; - export type SVGComponent = React.SVGComponent - export interface ChildContextProvider extends React.ChildContextProvider {} // @@ -2422,20 +2418,14 @@ declare namespace ReactNative { export interface Props extends React.Props {} - export interface DOMAttributesBase extends React.DOMAttributesBase {} - export interface DOMAttributes extends React.DOMAttributes {} // This interface is not complete. Only properties accepting // unitless numbers are listed here (see CSSProperty.js in React) export interface CSSProperties extends React.CSSProperties {} - export interface HTMLAttributesBase extends React.HTMLAttributesBase {} - export interface HTMLAttributes extends React.HTMLAttributes {} - export interface SVGElementAttributes extends React.SVGElementAttributes {} - export interface SVGAttributes extends React.SVGAttributes {} // diff --git a/react-redux/react-redux-tests.tsx b/react-redux/react-redux-tests.tsx index abbacabef..a44c0bfaa 100644 --- a/react-redux/react-redux-tests.tsx +++ b/react-redux/react-redux-tests.tsx @@ -1,11 +1,13 @@ /// /// +/// /// /// /// import { Component, ReactElement } from 'react'; import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import * as Router from 'react-router'; import { Route, RouterState } from 'react-router'; import { Store, Dispatch, bindActionCreators } from 'redux'; @@ -65,7 +67,7 @@ class App extends Component { const targetEl = document.getElementById('root'); -React.render(( +ReactDOM.render(( {() => } @@ -100,7 +102,7 @@ declare var addTodo: () => { type: string; }; declare var todoActionCreators: { [type: string]: (...args: any[]) => any; }; declare var counterActionCreators: { [type: string]: (...args: any[]) => any; }; -React.render( +ReactDOM.render( {() => } , @@ -108,7 +110,7 @@ React.render( ); Router.run(routes, Router.HistoryLocation, (Handler, routerState) => { // note "routerState" here - React.render( + ReactDOM.render( {/* //TODO: error TS2339: Property 'routerState' does not exist on type 'RouteProp'. @@ -121,7 +123,7 @@ Router.run(routes, Router.HistoryLocation, (Handler, routerState) => { // note " //TODO: for React Router 1.0 //TODO: error TS2604: JSX element type 'Router' does not have any construct or call signatures. -//React.render( +//ReactDOM.render( // // {() => ...} // , diff --git a/react-router/react-router-tests.ts b/react-router/react-router-tests.ts index 54b0545e2..7c80d740a 100644 --- a/react-router/react-router-tests.ts +++ b/react-router/react-router-tests.ts @@ -1,8 +1,9 @@ /// +/// "use strict"; import React = require('react'); -import ReactAddons = require('react/addons'); +import ReactDOM = require('react-dom'); import Router = require('react-router'); // Mixin @@ -129,9 +130,6 @@ class DefaultRouteTest { var Handler: React.ComponentClass; React.createElement(Router.DefaultRoute, null); React.createElement(Router.DefaultRoute, {name: 'name', handler: Handler}); - - ReactAddons.createElement(Router.DefaultRoute, null); - ReactAddons.createElement(Router.DefaultRoute, {name: 'name', handler: Handler}); } } @@ -169,16 +167,6 @@ class LinkTest { query: {}, onClick: () => console.log(1) }); - - ReactAddons.createElement(Router.Link, null); - ReactAddons.createElement(Router.Link, {to: 'home'}); - ReactAddons.createElement(Router.Link, { - activeClassName: 'name', - to: 'home', - params: {}, - query: {}, - onClick: () => console.log(1) - }); } } @@ -195,10 +183,6 @@ class NotFoundRouteTest { React.createElement(Router.NotFoundRoute, null); React.createElement(Router.NotFoundRoute, {handler: Handler}); React.createElement(Router.NotFoundRoute, {handler: Handler, name: "home"}); - - ReactAddons.createElement(Router.NotFoundRoute, null); - ReactAddons.createElement(Router.NotFoundRoute, {handler: Handler}); - ReactAddons.createElement(Router.NotFoundRoute, {handler: Handler, name: "home"}); } } @@ -215,10 +199,6 @@ class RedirectTest { React.createElement(Router.Redirect, null); React.createElement(Router.Redirect, {}); React.createElement(Router.Redirect, {path: 'a', from: 'a', to: 'b'}); - - ReactAddons.createElement(Router.Redirect, null); - ReactAddons.createElement(Router.Redirect, {}); - ReactAddons.createElement(Router.Redirect, {path: 'a', from: 'a', to: 'b'}); } } @@ -237,10 +217,6 @@ class RouteTest { React.createElement(Router.Route, null); React.createElement(Router.Route, {}); React.createElement(Router.Route, {name: "home", path: "/", handler: Handler, ignoreScrollBehavior: true}); - - ReactAddons.createElement(Router.Route, null); - ReactAddons.createElement(Router.Route, {}); - ReactAddons.createElement(Router.Route, {name: "home", path: "/", handler: Handler, ignoreScrollBehavior: true}); } } @@ -250,9 +226,6 @@ class RouteHandlerTest { createElement() { React.createElement(Router.RouteHandler, null); React.createElement(Router.RouteHandler, {}); - - ReactAddons.createElement(Router.RouteHandler, null); - ReactAddons.createElement(Router.RouteHandler, {}); } } @@ -307,24 +280,24 @@ class RunTest { constructor() { // React.createElement() version var v1: Router.Router = Router.run(React.createElement(Router.Route, null), (Handler) => { - React.render(React.createElement(Handler, null), document.body); + ReactDOM.render(React.createElement(Handler, null), document.body); }); var v2: Router.Router = Router.run(React.createElement(Router.Route, null), Router.HistoryLocation, (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); + ReactDOM.render(React.createElement(Handler, null), document.body); }); var v3: Router.Router = Router.run(React.createElement(Router.Route, null), '/foo/bar', (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); + ReactDOM.render(React.createElement(Handler, null), document.body); }); // React.createFactory() version var v4: Router.Router = Router.run(React.createFactory(Router.Route)(), (Handler) => { - React.render(React.createElement(Handler, null), document.body); + ReactDOM.render(React.createElement(Handler, null), document.body); }); var v5: Router.Router = Router.run(React.createFactory(Router.Route)(), Router.HistoryLocation, (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); + ReactDOM.render(React.createElement(Handler, null), document.body); }); var v6: Router.Router = Router.run(React.createFactory(Router.Route)(), '/foo/bar', (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); + ReactDOM.render(React.createElement(Handler, null), document.body); }); } } diff --git a/react/README.md b/react/README.md index b7ff4b55e..8990e8a71 100644 --- a/react/README.md +++ b/react/README.md @@ -1,5 +1,5 @@ -# React v0.13.3 Type Definitions +# React v0.14.2 Type Definitions -This folder contains the following `.d.ts` files: -* `react.d.ts` declares the module `"react"` and `"react/addons"` -* `react-global.d.ts` declares the global namespace `React` (only include this if you are actually using the global `React`) +If you are using modules you should use `react.d.ts`, `react-dom.d.ts` and any of the `react-addon-*.d.ts` definition files. + +If you are using the global `React` variable, you should use `react-global.d.ts`. diff --git a/react/react-0.13.3.d.ts b/react/react-0.13.3.d.ts new file mode 100644 index 000000000..de8ba6732 --- /dev/null +++ b/react/react-0.13.3.d.ts @@ -0,0 +1,2038 @@ +// Type definitions for React v0.13.3 +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare namespace __React { + // + // React Elements + // ---------------------------------------------------------------------- + + type ReactType = ComponentClass | string; + + interface ReactElement

{ + type: string | ComponentClass

; + props: P; + key: string | number; + ref: string | ((component: Component) => any); + } + + interface ClassicElement

extends ReactElement

{ + type: string | ClassicComponentClass

; + ref: string | ((component: ClassicComponent) => any); + } + + interface DOMElement

extends ClassicElement

{ + type: string; + ref: string | ((component: DOMComponent

) => any); + } + + type HTMLElement = DOMElement; + type SVGElement = DOMElement; + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

extends Factory

{ + (props?: P, ...children: ReactNode[]): ClassicElement

; + } + + interface DOMFactory

extends ClassicFactory

{ + (props?: P, ...children: ReactNode[]): DOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + type SVGElementFactory = DOMFactory; + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElement | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = {} | Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass(spec: ComponentSpec): ClassicComponentClass

; + + function createFactory

(type: string): DOMFactory

; + function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; + function createFactory

(type: ComponentClass

): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): DOMElement

; + function createElement

( + type: ClassicComponentClass

| string, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function createElement

( + type: ComponentClass

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function cloneElement

( + element: DOMElement

, + props?: P, + ...children: ReactNode[]): DOMElement

; + function cloneElement

( + element: ClassicElement

, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function cloneElement

( + element: ReactElement

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: DOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElement): string; + function renderToStaticMarkup(element: ReactElement): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // Base component for plain JS classes + class Component implements ComponentLifecycle { + static propTypes: ValidationMap; + static contextTypes: ValidationMap; + static childContextTypes: ValidationMap; + static defaultProps: Props; + + constructor(props?: P, context?: any); + setState(f: (prevState: S, props: P) => S, callback?: () => any): void; + setState(state: S, callback?: () => any): void; + forceUpdate(callBack?: () => any): void; + render(): JSX.Element; + props: P; + state: S; + context: {}; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClass

{ + new(props?: P, context?: any): Component; + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + defaultProps?: P; + } + + interface ClassicComponentClass

extends ComponentClass

{ + new(props?: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap + + getDefaultProps?(): P; + getInitialState?(): S; + } + + interface ComponentSpec extends Mixin { + render(): ReactElement; + + [propertyName: string]: any; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface DragEvent extends SyntheticEvent { + dataTransfer: DataTransfer; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + interface DragEventHandler extends EventHandler {} + interface ClipboardEventHandler extends EventHandler {} + interface KeyboardEventHandler extends EventHandler {} + interface FocusEventHandler extends EventHandler {} + interface FormEventHandler extends EventHandler {} + interface MouseEventHandler extends EventHandler {} + interface TouchEventHandler extends EventHandler {} + interface UIEventHandler extends EventHandler {} + interface WheelEventHandler extends EventHandler {} + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + interface Props { + children?: ReactNode; + key?: string | number; + ref?: string | ((component: T) => any); + } + + interface DOMAttributesBase extends Props { + onCopy?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; + onChange?: FormEventHandler; + onInput?: FormEventHandler; + onSubmit?: FormEventHandler; + onClick?: MouseEventHandler; + onContextMenu?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDrag?: DragEventHandler; + onDragEnd?: DragEventHandler; + onDragEnter?: DragEventHandler; + onDragExit?: DragEventHandler; + onDragLeave?: DragEventHandler; + onDragOver?: DragEventHandler; + onDragStart?: DragEventHandler; + onDrop?: DragEventHandler; + onMouseDown?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onTouchCancel?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onScroll?: UIEventHandler; + onWheel?: WheelEventHandler; + + className?: string; + id?: string; + + dangerouslySetInnerHTML?: { + __html: string; + }; + } + + interface DOMAttributes extends DOMAttributesBase> { + } + + // This interface is not complete. Only properties accepting + // unitless numbers are listed here (see CSSProperty.js in React) + interface CSSProperties { + boxFlex?: number; + boxFlexGroup?: number; + columnCount?: number; + flex?: number | string; + flexGrow?: number; + flexShrink?: number; + fontWeight?: number | string; + lineClamp?: number; + lineHeight?: number | string; + opacity?: number; + order?: number; + orphans?: number; + widows?: number; + zIndex?: number; + zoom?: number; + + fontSize?: number | string; + + // SVG-related properties + fillOpacity?: number; + strokeOpacity?: number; + strokeWidth?: number; + + [propertyName: string]: any; + } + + interface HTMLAttributesBase extends DOMAttributesBase { + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: boolean; + autoFocus?: boolean; + autoPlay?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + checked?: boolean; + classID?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: any; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + defaultChecked?: boolean; + defaultValue?: string; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + frameBorder?: number | string; + headers?: string; + height?: number | string; + hidden?: boolean; + high?: number; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + icon?: string; + label?: string; + lang?: string; + list?: string; + loop?: boolean; + low?: number; + manifest?: string; + marginHeight?: number; + marginWidth?: number; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + multiple?: boolean; + muted?: boolean; + name?: string; + noValidate?: boolean; + open?: boolean; + optimum?: number; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + role?: string; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scoped?: boolean; + scrolling?: string; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: CSSProperties; + tabIndex?: number; + target?: string; + title?: string; + type?: string; + useMap?: string; + value?: string; + width?: number | string; + wmode?: string; + + // Non-standard Attributes + autoCapitalize?: boolean; + autoCorrect?: boolean; + property?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + unselectable?: boolean; + } + + interface HTMLAttributes extends HTMLAttributesBase { + } + + interface SVGElementAttributes extends HTMLAttributes { + viewBox?: string; + preserveAspectRatio?: string; + } + + interface SVGAttributes extends DOMAttributes { + ref?: string | ((component: SVGComponent) => void); + + cx?: number | string; + cy?: number | string; + d?: string; + dx?: number | string; + dy?: number | string; + fill?: string; + fillOpacity?: number | string; + fontFamily?: string; + fontSize?: number | string; + fx?: number | string; + fy?: number | string; + gradientTransform?: string; + gradientUnits?: string; + height?: number | string; + markerEnd?: string; + markerMid?: string; + markerStart?: string; + offset?: number | string; + opacity?: number | string; + patternContentUnits?: string; + patternUnits?: string; + points?: string; + preserveAspectRatio?: string; + r?: number | string; + rx?: number | string; + ry?: number | string; + spreadMethod?: string; + stopColor?: string; + stopOpacity?: number | string; + stroke?: string; + strokeDasharray?: string; + strokeLinecap?: string; + strokeMiterlimit?: string; + strokeOpacity?: number | string; + strokeWidth?: number | string; + textAnchor?: string; + transform?: string; + version?: string; + viewBox?: string; + width?: number | string; + x1?: number | string; + x2?: number | string; + x?: number | string; + y1?: number | string; + y2?: number | string + y?: number | string; + } + + // + // React.DOM + // ---------------------------------------------------------------------- + + interface ReactDOM { + // HTML + a: HTMLFactory; + abbr: HTMLFactory; + address: HTMLFactory; + area: HTMLFactory; + article: HTMLFactory; + aside: HTMLFactory; + audio: HTMLFactory; + b: HTMLFactory; + base: HTMLFactory; + bdi: HTMLFactory; + bdo: HTMLFactory; + big: HTMLFactory; + blockquote: HTMLFactory; + body: HTMLFactory; + br: HTMLFactory; + button: HTMLFactory; + canvas: HTMLFactory; + caption: HTMLFactory; + cite: HTMLFactory; + code: HTMLFactory; + col: HTMLFactory; + colgroup: HTMLFactory; + data: HTMLFactory; + datalist: HTMLFactory; + dd: HTMLFactory; + del: HTMLFactory; + details: HTMLFactory; + dfn: HTMLFactory; + dialog: HTMLFactory; + div: HTMLFactory; + dl: HTMLFactory; + dt: HTMLFactory; + em: HTMLFactory; + embed: HTMLFactory; + fieldset: HTMLFactory; + figcaption: HTMLFactory; + figure: HTMLFactory; + footer: HTMLFactory; + form: HTMLFactory; + h1: HTMLFactory; + h2: HTMLFactory; + h3: HTMLFactory; + h4: HTMLFactory; + h5: HTMLFactory; + h6: HTMLFactory; + head: HTMLFactory; + header: HTMLFactory; + hr: HTMLFactory; + html: HTMLFactory; + i: HTMLFactory; + iframe: HTMLFactory; + img: HTMLFactory; + input: HTMLFactory; + ins: HTMLFactory; + kbd: HTMLFactory; + keygen: HTMLFactory; + label: HTMLFactory; + legend: HTMLFactory; + li: HTMLFactory; + link: HTMLFactory; + main: HTMLFactory; + map: HTMLFactory; + mark: HTMLFactory; + menu: HTMLFactory; + menuitem: HTMLFactory; + meta: HTMLFactory; + meter: HTMLFactory; + nav: HTMLFactory; + noscript: HTMLFactory; + object: HTMLFactory; + ol: HTMLFactory; + optgroup: HTMLFactory; + option: HTMLFactory; + output: HTMLFactory; + p: HTMLFactory; + param: HTMLFactory; + picture: HTMLFactory; + pre: HTMLFactory; + progress: HTMLFactory; + q: HTMLFactory; + rp: HTMLFactory; + rt: HTMLFactory; + ruby: HTMLFactory; + s: HTMLFactory; + samp: HTMLFactory; + script: HTMLFactory; + section: HTMLFactory; + select: HTMLFactory; + small: HTMLFactory; + source: HTMLFactory; + span: HTMLFactory; + strong: HTMLFactory; + style: HTMLFactory; + sub: HTMLFactory; + summary: HTMLFactory; + sup: HTMLFactory; + table: HTMLFactory; + tbody: HTMLFactory; + td: HTMLFactory; + textarea: HTMLFactory; + tfoot: HTMLFactory; + th: HTMLFactory; + thead: HTMLFactory; + time: HTMLFactory; + title: HTMLFactory; + tr: HTMLFactory; + track: HTMLFactory; + u: HTMLFactory; + ul: HTMLFactory; + "var": HTMLFactory; + video: HTMLFactory; + wbr: HTMLFactory; + + // SVG + svg: SVGElementFactory; + circle: SVGFactory; + defs: SVGFactory; + ellipse: SVGFactory; + g: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + mask: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + text: SVGFactory; + tspan: SVGFactory; + } + + // + // React.PropTypes + // ---------------------------------------------------------------------- + + interface Validator { + (object: T, key: string, componentName: string): Error; + } + + interface Requireable extends Validator { + isRequired: Validator; + } + + interface ValidationMap { + [key: string]: Validator; + } + + interface ReactPropTypes { + any: Requireable; + array: Requireable; + bool: Requireable; + func: Requireable; + number: Requireable; + object: Requireable; + string: Requireable; + node: Requireable; + element: Requireable; + instanceOf(expectedClass: {}): Requireable; + oneOf(types: any[]): Requireable; + oneOfType(types: Validator[]): Requireable; + arrayOf(type: Validator): Requireable; + objectOf(type: Validator): Requireable; + shape(type: ValidationMap): Requireable; + } + + // + // React.Children + // ---------------------------------------------------------------------- + + interface ReactChildren { + map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T }; + forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; + count(children: ReactNode): number; + only(children: ReactNode): ReactChild; + } + + // + // Browser Interfaces + // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts + // ---------------------------------------------------------------------- + + interface AbstractView { + styleMedia: StyleMedia; + document: Document; + } + + interface Touch { + identifier: number; + target: EventTarget; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + } + + interface TouchList { + [index: number]: Touch; + length: number; + item(index: number): Touch; + identifiedTouch(identifier: number): Touch; + } +} + +declare module "react" { + export = __React; +} + +declare module "react/addons" { + // + // React Elements + // ---------------------------------------------------------------------- + + type ReactType = ComponentClass | string; + + interface ReactElement

{ + type: string | ComponentClass

; + props: P; + key: string | number; + ref: string | ((component: Component) => any); + } + + interface ClassicElement

extends ReactElement

{ + type: string | ClassicComponentClass

; + ref: string | ((component: ClassicComponent) => any); + } + + interface DOMElement

extends ClassicElement

{ + type: string; + ref: string | ((component: DOMComponent

) => any); + } + + type HTMLElement = DOMElement; + type SVGElement = DOMElement; + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

extends Factory

{ + (props?: P, ...children: ReactNode[]): ClassicElement

; + } + + interface DOMFactory

extends ClassicFactory

{ + (props?: P, ...children: ReactNode[]): DOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + type SVGElementFactory = DOMFactory; + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElement | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = {} | Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass(spec: ComponentSpec): ClassicComponentClass

; + + function createFactory

(type: string): DOMFactory

; + function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; + function createFactory

(type: ComponentClass

): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): DOMElement

; + function createElement

( + type: ClassicComponentClass

| string, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function createElement

( + type: ComponentClass

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function cloneElement

( + element: DOMElement

, + props?: P, + ...children: ReactNode[]): DOMElement

; + function cloneElement

( + element: ClassicElement

, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function cloneElement

( + element: ReactElement

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: DOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElement): string; + function renderToStaticMarkup(element: ReactElement): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // Base component for plain JS classes + class Component implements ComponentLifecycle { + static propTypes: ValidationMap; + static contextTypes: ValidationMap; + static childContextTypes: ValidationMap; + static defaultProps: Props; + + constructor(props?: P, context?: any); + setState(f: (prevState: S, props: P) => S, callback?: () => any): void; + setState(state: S, callback?: () => any): void; + forceUpdate(callBack?: () => any): void; + render(): JSX.Element; + props: P; + state: S; + context: {}; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClass

{ + new(props?: P, context?: any): Component; + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + defaultProps?: P; + } + + interface ClassicComponentClass

extends ComponentClass

{ + new(props?: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap + + getDefaultProps?(): P; + getInitialState?(): S; + } + + interface ComponentSpec extends Mixin { + render(): ReactElement; + + [propertyName: string]: any; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface DragEvent extends SyntheticEvent { + dataTransfer: DataTransfer; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + interface DragEventHandler extends EventHandler {} + interface ClipboardEventHandler extends EventHandler {} + interface KeyboardEventHandler extends EventHandler {} + interface FocusEventHandler extends EventHandler {} + interface FormEventHandler extends EventHandler {} + interface MouseEventHandler extends EventHandler {} + interface TouchEventHandler extends EventHandler {} + interface UIEventHandler extends EventHandler {} + interface WheelEventHandler extends EventHandler {} + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + interface Props { + children?: ReactNode; + key?: string | number; + ref?: string | ((component: T) => any); + } + + interface DOMAttributesBase extends Props { + onCopy?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; + onChange?: FormEventHandler; + onInput?: FormEventHandler; + onSubmit?: FormEventHandler; + onClick?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDrag?: DragEventHandler; + onDragEnd?: DragEventHandler; + onDragEnter?: DragEventHandler; + onDragExit?: DragEventHandler; + onDragLeave?: DragEventHandler; + onDragOver?: DragEventHandler; + onDragStart?: DragEventHandler; + onDrop?: DragEventHandler; + onMouseDown?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onTouchCancel?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onScroll?: UIEventHandler; + onWheel?: WheelEventHandler; + + className?: string; + id?: string; + + dangerouslySetInnerHTML?: { + __html: string; + }; + } + + interface DOMAttributes extends DOMAttributesBase> { + } + + // This interface is not complete. Only properties accepting + // unitless numbers are listed here (see CSSProperty.js in React) + interface CSSProperties { + boxFlex?: number; + boxFlexGroup?: number; + columnCount?: number; + flex?: number | string; + flexGrow?: number; + flexShrink?: number; + fontWeight?: number | string; + lineClamp?: number; + lineHeight?: number | string; + opacity?: number; + order?: number; + orphans?: number; + widows?: number; + zIndex?: number; + zoom?: number; + + fontSize?: number | string; + + // SVG-related properties + fillOpacity?: number; + strokeOpacity?: number; + strokeWidth?: number; + + [propertyName: string]: any; + } + + interface HTMLAttributesBase extends DOMAttributesBase { + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: boolean; + autoFocus?: boolean; + autoPlay?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + checked?: boolean; + classID?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: any; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + defaultChecked?: boolean; + defaultValue?: string; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + frameBorder?: number | string; + headers?: string; + height?: number | string; + hidden?: boolean; + high?: number; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + icon?: string; + label?: string; + lang?: string; + list?: string; + loop?: boolean; + low?: number; + manifest?: string; + marginHeight?: number; + marginWidth?: number; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + multiple?: boolean; + muted?: boolean; + name?: string; + noValidate?: boolean; + open?: boolean; + optimum?: number; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + role?: string; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scoped?: boolean; + scrolling?: string; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: CSSProperties; + tabIndex?: number; + target?: string; + title?: string; + type?: string; + useMap?: string; + value?: string; + width?: number | string; + wmode?: string; + + // Non-standard Attributes + autoCapitalize?: boolean; + autoCorrect?: boolean; + property?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + unselectable?: boolean; + } + + interface HTMLAttributes extends HTMLAttributesBase { + } + + interface SVGElementAttributes extends HTMLAttributes { + viewBox?: string; + preserveAspectRatio?: string; + } + + interface SVGAttributes extends DOMAttributes { + ref?: string | ((component: SVGComponent) => void); + + cx?: number | string; + cy?: number | string; + d?: string; + dx?: number | string; + dy?: number | string; + fill?: string; + fillOpacity?: number | string; + fontFamily?: string; + fontSize?: number | string; + fx?: number | string; + fy?: number | string; + gradientTransform?: string; + gradientUnits?: string; + height?: number | string; + markerEnd?: string; + markerMid?: string; + markerStart?: string; + offset?: number | string; + opacity?: number | string; + patternContentUnits?: string; + patternUnits?: string; + points?: string; + preserveAspectRatio?: string; + r?: number | string; + rx?: number | string; + ry?: number | string; + spreadMethod?: string; + stopColor?: string; + stopOpacity?: number | string; + stroke?: string; + strokeDasharray?: string; + strokeLinecap?: string; + strokeMiterlimit?: string; + strokeOpacity?: number | string; + strokeWidth?: number | string; + textAnchor?: string; + transform?: string; + version?: string; + viewBox?: string; + width?: number | string; + x1?: number | string; + x2?: number | string; + x?: number | string; + y1?: number | string; + y2?: number | string + y?: number | string; + } + + // + // React.DOM + // ---------------------------------------------------------------------- + + interface ReactDOM { + // HTML + a: HTMLFactory; + abbr: HTMLFactory; + address: HTMLFactory; + area: HTMLFactory; + article: HTMLFactory; + aside: HTMLFactory; + audio: HTMLFactory; + b: HTMLFactory; + base: HTMLFactory; + bdi: HTMLFactory; + bdo: HTMLFactory; + big: HTMLFactory; + blockquote: HTMLFactory; + body: HTMLFactory; + br: HTMLFactory; + button: HTMLFactory; + canvas: HTMLFactory; + caption: HTMLFactory; + cite: HTMLFactory; + code: HTMLFactory; + col: HTMLFactory; + colgroup: HTMLFactory; + data: HTMLFactory; + datalist: HTMLFactory; + dd: HTMLFactory; + del: HTMLFactory; + details: HTMLFactory; + dfn: HTMLFactory; + dialog: HTMLFactory; + div: HTMLFactory; + dl: HTMLFactory; + dt: HTMLFactory; + em: HTMLFactory; + embed: HTMLFactory; + fieldset: HTMLFactory; + figcaption: HTMLFactory; + figure: HTMLFactory; + footer: HTMLFactory; + form: HTMLFactory; + h1: HTMLFactory; + h2: HTMLFactory; + h3: HTMLFactory; + h4: HTMLFactory; + h5: HTMLFactory; + h6: HTMLFactory; + head: HTMLFactory; + header: HTMLFactory; + hr: HTMLFactory; + html: HTMLFactory; + i: HTMLFactory; + iframe: HTMLFactory; + img: HTMLFactory; + input: HTMLFactory; + ins: HTMLFactory; + kbd: HTMLFactory; + keygen: HTMLFactory; + label: HTMLFactory; + legend: HTMLFactory; + li: HTMLFactory; + link: HTMLFactory; + main: HTMLFactory; + map: HTMLFactory; + mark: HTMLFactory; + menu: HTMLFactory; + menuitem: HTMLFactory; + meta: HTMLFactory; + meter: HTMLFactory; + nav: HTMLFactory; + noscript: HTMLFactory; + object: HTMLFactory; + ol: HTMLFactory; + optgroup: HTMLFactory; + option: HTMLFactory; + output: HTMLFactory; + p: HTMLFactory; + param: HTMLFactory; + picture: HTMLFactory; + pre: HTMLFactory; + progress: HTMLFactory; + q: HTMLFactory; + rp: HTMLFactory; + rt: HTMLFactory; + ruby: HTMLFactory; + s: HTMLFactory; + samp: HTMLFactory; + script: HTMLFactory; + section: HTMLFactory; + select: HTMLFactory; + small: HTMLFactory; + source: HTMLFactory; + span: HTMLFactory; + strong: HTMLFactory; + style: HTMLFactory; + sub: HTMLFactory; + summary: HTMLFactory; + sup: HTMLFactory; + table: HTMLFactory; + tbody: HTMLFactory; + td: HTMLFactory; + textarea: HTMLFactory; + tfoot: HTMLFactory; + th: HTMLFactory; + thead: HTMLFactory; + time: HTMLFactory; + title: HTMLFactory; + tr: HTMLFactory; + track: HTMLFactory; + u: HTMLFactory; + ul: HTMLFactory; + "var": HTMLFactory; + video: HTMLFactory; + wbr: HTMLFactory; + + // SVG + svg: SVGElementFactory; + circle: SVGFactory; + defs: SVGFactory; + ellipse: SVGFactory; + g: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + mask: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + text: SVGFactory; + tspan: SVGFactory; + } + + // + // React.PropTypes + // ---------------------------------------------------------------------- + + interface Validator { + (object: T, key: string, componentName: string): Error; + } + + interface Requireable extends Validator { + isRequired: Validator; + } + + interface ValidationMap { + [key: string]: Validator; + } + + interface ReactPropTypes { + any: Requireable; + array: Requireable; + bool: Requireable; + func: Requireable; + number: Requireable; + object: Requireable; + string: Requireable; + node: Requireable; + element: Requireable; + instanceOf(expectedClass: {}): Requireable; + oneOf(types: any[]): Requireable; + oneOfType(types: Validator[]): Requireable; + arrayOf(type: Validator): Requireable; + objectOf(type: Validator): Requireable; + shape(type: ValidationMap): Requireable; + } + + // + // React.Children + // ---------------------------------------------------------------------- + + interface ReactChildren { + map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T }; + forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; + count(children: ReactNode): number; + only(children: ReactNode): ReactChild; + } + + // + // Browser Interfaces + // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts + // ---------------------------------------------------------------------- + + interface AbstractView { + styleMedia: StyleMedia; + document: Document; + } + + interface Touch { + identifier: number; + target: EventTarget; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + } + + interface TouchList { + [index: number]: Touch; + length: number; + item(index: number): Touch; + identifiedTouch(identifier: number): Touch; + } + + // + // React.addons + // ---------------------------------------------------------------------- + + export module addons { + export var CSSTransitionGroup: CSSTransitionGroup; + export var TransitionGroup: TransitionGroup; + + export var LinkedStateMixin: LinkedStateMixin; + export var PureRenderMixin: PureRenderMixin; + + export function batchedUpdates( + callback: (a: A, b: B) => any, a: A, b: B): void; + export function batchedUpdates(callback: (a: A) => any, a: A): void; + export function batchedUpdates(callback: () => any): void; + + // deprecated: use petehunt/react-classset or JedWatson/classnames + export function classSet(cx: { [key: string]: boolean }): string; + export function classSet(...classList: string[]): string; + + export function cloneWithProps

( + element: DOMElement

, props: P): DOMElement

; + export function cloneWithProps

( + element: ClassicElement

, props: P): ClassicElement

; + export function cloneWithProps

( + element: ReactElement

, props: P): ReactElement

; + + export function createFragment( + object: { [key: string]: ReactNode }): ReactFragment; + + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; + + // Development tools + export import Perf = ReactPerf; + export import TestUtils = ReactTestUtils; + } + + // + // React.addons (Transitions) + // ---------------------------------------------------------------------- + + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = ComponentClass; + type TransitionGroup = ComponentClass; + + // + // React.addons (Mixins) + // ---------------------------------------------------------------------- + + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + + interface PureRenderMixin extends Mixin { + } + + // + // Reat.addons.update + // ---------------------------------------------------------------------- + + interface UpdateSpecCommand { + $set?: any; + $merge?: {}; + $apply?(value: any): any; + } + + interface UpdateSpecPath { + [key: string]: UpdateSpec; + } + + type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; + + interface UpdateArraySpec extends UpdateSpecCommand { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + // + // React.addons.Perf + // ---------------------------------------------------------------------- + + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + module ReactPerf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; + } + + // + // React.addons.TestUtils + // ---------------------------------------------------------------------- + + interface MockedComponentClass { + new(): any; + } + + module ReactTestUtils { + export import Simulate = ReactSimulate; + + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; + + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; + + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isTextComponent(instance: Component): boolean; + export function isDOMComponent(instance: Component): boolean; + export function isCompositeComponent(instance: Component): boolean; + export function isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + export function findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + export function scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + export function findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + export function scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + export function findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + export function scryRenderedComponentsWithType

( + tree: Component, + type: ComponentClass

): Component[]; + export function scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + export function findRenderedComponentWithType

( + tree: Component, + type: ComponentClass

): Component; + export function findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + + export function createRenderer(): ShallowRenderer; + } + + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; + } + + module ReactSimulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; + } + + class ShallowRenderer { + getRenderOutput>(): E; + getRenderOutput(): ReactElement; + render(element: ReactElement, context?: any): void; + unmount(): void; + } +} + +declare namespace JSX { + import React = __React; + + interface Element extends React.ReactElement { } + interface ElementClass extends React.Component { + render(): JSX.Element; + } + interface ElementAttributesProperty { props: {}; } + + interface IntrinsicElements { + // HTML + a: React.HTMLAttributes; + abbr: React.HTMLAttributes; + address: React.HTMLAttributes; + area: React.HTMLAttributes; + article: React.HTMLAttributes; + aside: React.HTMLAttributes; + audio: React.HTMLAttributes; + b: React.HTMLAttributes; + base: React.HTMLAttributes; + bdi: React.HTMLAttributes; + bdo: React.HTMLAttributes; + big: React.HTMLAttributes; + blockquote: React.HTMLAttributes; + body: React.HTMLAttributes; + br: React.HTMLAttributes; + button: React.HTMLAttributes; + canvas: React.HTMLAttributes; + caption: React.HTMLAttributes; + cite: React.HTMLAttributes; + code: React.HTMLAttributes; + col: React.HTMLAttributes; + colgroup: React.HTMLAttributes; + data: React.HTMLAttributes; + datalist: React.HTMLAttributes; + dd: React.HTMLAttributes; + del: React.HTMLAttributes; + details: React.HTMLAttributes; + dfn: React.HTMLAttributes; + dialog: React.HTMLAttributes; + div: React.HTMLAttributes; + dl: React.HTMLAttributes; + dt: React.HTMLAttributes; + em: React.HTMLAttributes; + embed: React.HTMLAttributes; + fieldset: React.HTMLAttributes; + figcaption: React.HTMLAttributes; + figure: React.HTMLAttributes; + footer: React.HTMLAttributes; + form: React.HTMLAttributes; + h1: React.HTMLAttributes; + h2: React.HTMLAttributes; + h3: React.HTMLAttributes; + h4: React.HTMLAttributes; + h5: React.HTMLAttributes; + h6: React.HTMLAttributes; + head: React.HTMLAttributes; + header: React.HTMLAttributes; + hr: React.HTMLAttributes; + html: React.HTMLAttributes; + i: React.HTMLAttributes; + iframe: React.HTMLAttributes; + img: React.HTMLAttributes; + input: React.HTMLAttributes; + ins: React.HTMLAttributes; + kbd: React.HTMLAttributes; + keygen: React.HTMLAttributes; + label: React.HTMLAttributes; + legend: React.HTMLAttributes; + li: React.HTMLAttributes; + link: React.HTMLAttributes; + main: React.HTMLAttributes; + map: React.HTMLAttributes; + mark: React.HTMLAttributes; + menu: React.HTMLAttributes; + menuitem: React.HTMLAttributes; + meta: React.HTMLAttributes; + meter: React.HTMLAttributes; + nav: React.HTMLAttributes; + noscript: React.HTMLAttributes; + object: React.HTMLAttributes; + ol: React.HTMLAttributes; + optgroup: React.HTMLAttributes; + option: React.HTMLAttributes; + output: React.HTMLAttributes; + p: React.HTMLAttributes; + param: React.HTMLAttributes; + picture: React.HTMLAttributes; + pre: React.HTMLAttributes; + progress: React.HTMLAttributes; + q: React.HTMLAttributes; + rp: React.HTMLAttributes; + rt: React.HTMLAttributes; + ruby: React.HTMLAttributes; + s: React.HTMLAttributes; + samp: React.HTMLAttributes; + script: React.HTMLAttributes; + section: React.HTMLAttributes; + select: React.HTMLAttributes; + small: React.HTMLAttributes; + source: React.HTMLAttributes; + span: React.HTMLAttributes; + strong: React.HTMLAttributes; + style: React.HTMLAttributes; + sub: React.HTMLAttributes; + summary: React.HTMLAttributes; + sup: React.HTMLAttributes; + table: React.HTMLAttributes; + tbody: React.HTMLAttributes; + td: React.HTMLAttributes; + textarea: React.HTMLAttributes; + tfoot: React.HTMLAttributes; + th: React.HTMLAttributes; + thead: React.HTMLAttributes; + time: React.HTMLAttributes; + title: React.HTMLAttributes; + tr: React.HTMLAttributes; + track: React.HTMLAttributes; + u: React.HTMLAttributes; + ul: React.HTMLAttributes; + "var": React.HTMLAttributes; + video: React.HTMLAttributes; + wbr: React.HTMLAttributes; + + // SVG + svg: React.SVGElementAttributes; + + circle: React.SVGAttributes; + defs: React.SVGAttributes; + ellipse: React.SVGAttributes; + g: React.SVGAttributes; + line: React.SVGAttributes; + linearGradient: React.SVGAttributes; + mask: React.SVGAttributes; + path: React.SVGAttributes; + pattern: React.SVGAttributes; + polygon: React.SVGAttributes; + polyline: React.SVGAttributes; + radialGradient: React.SVGAttributes; + rect: React.SVGAttributes; + stop: React.SVGAttributes; + text: React.SVGAttributes; + tspan: React.SVGAttributes; + } +} diff --git a/react/react-addons-create-fragment.d.ts b/react/react-addons-create-fragment.d.ts new file mode 100644 index 000000000..b2332eae1 --- /dev/null +++ b/react/react-addons-create-fragment.d.ts @@ -0,0 +1,16 @@ +// Type definitions for React v0.14 (react-addons-create-fragment) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + export function createFragment(object: { [key: string]: ReactNode }): ReactFragment; + } +} + +declare module "react-addons-create-fragment" { + export = __React.__Addons.createFragment; +} diff --git a/react/react-addons-css-transition-group.d.ts b/react/react-addons-css-transition-group.d.ts new file mode 100644 index 000000000..c9b40476d --- /dev/null +++ b/react/react-addons-css-transition-group.d.ts @@ -0,0 +1,38 @@ +// Type definitions for React v0.14 (react-addons-css-transition-group) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare namespace __React { + + interface CSSTransitionGroupTransitionName { + enter: string; + enterActive?: string; + leave: string; + leaveActive?: string; + appear?: string; + appearActive?: string; + } + + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string | CSSTransitionGroupTransitionName; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = ComponentClass; + + namespace __Addons { + export var CSSTransitionGroup: __React.CSSTransitionGroup; + } +} + +declare module "react-addons-css-transition-group" { + var CSSTransitionGroup: __React.CSSTransitionGroup; + type CSSTransitionGroup = __React.CSSTransitionGroup; + export = CSSTransitionGroup; +} diff --git a/react/react-addons-linked-state-mixin.d.ts b/react/react-addons-linked-state-mixin.d.ts new file mode 100644 index 000000000..cbaa37958 --- /dev/null +++ b/react/react-addons-linked-state-mixin.d.ts @@ -0,0 +1,32 @@ +// Type definitions for React v0.14 (react-addons-linked-state-mixin) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + + interface HTMLAttributes { + checkedLink?: ReactLink; + valueLink?: ReactLink; + } + + namespace __Addons { + export var LinkedStateMixin: LinkedStateMixin; + } +} + +declare module "react-addons-linked-state-mixin" { + var LinkedStateMixin: __React.LinkedStateMixin; + type LinkedStateMixin = __React.LinkedStateMixin; + export = LinkedStateMixin; +} diff --git a/react/react-addons-perf.d.ts b/react/react-addons-perf.d.ts new file mode 100644 index 000000000..22a9381ef --- /dev/null +++ b/react/react-addons-perf.d.ts @@ -0,0 +1,46 @@ +// Type definitions for React v0.14 (react-addons-perf) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + namespace __Addons { + namespace Perf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; + } + } +} + +declare module "react-addons-perf" { + import Perf = __React.__Addons.Perf; + export = Perf; +} diff --git a/react/react-addons-pure-render-mixin.d.ts b/react/react-addons-pure-render-mixin.d.ts new file mode 100644 index 000000000..83b4aee3d --- /dev/null +++ b/react/react-addons-pure-render-mixin.d.ts @@ -0,0 +1,20 @@ +// Type definitions for React v0.14 (react-addons-pure-render-mixin) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + interface PureRenderMixin extends Mixin {} + + namespace __Addons { + export var PureRenderMixin: PureRenderMixin; + } +} + +declare module "react-addons-pure-render-mixin" { + var PureRenderMixin: __React.PureRenderMixin; + type PureRenderMixin = __React.PureRenderMixin; + export = PureRenderMixin; +} diff --git a/react/react-addons-shallow-compare.d.ts b/react/react-addons-shallow-compare.d.ts new file mode 100644 index 000000000..2b5a4dba2 --- /dev/null +++ b/react/react-addons-shallow-compare.d.ts @@ -0,0 +1,19 @@ +// Type definitions for React v0.14 (react-addons-css-transition-group) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + export function shallowCompare( + component: __React.Component, + nextProps: P, + nextState: S): boolean; + } +} + +declare module "react-addons-shallow-compare" { + export = __React.__Addons.shallowCompare; +} diff --git a/react/react-addons-test-utils.d.ts b/react/react-addons-test-utils.d.ts new file mode 100644 index 000000000..0b3f8c0f6 --- /dev/null +++ b/react/react-addons-test-utils.d.ts @@ -0,0 +1,155 @@ +// Type definitions for React v0.14 (react-addons-test-utils) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; + } + + interface MockedComponentClass { + new(): any; + } + + class ShallowRenderer { + getRenderOutput>(): E; + getRenderOutput(): ReactElement; + render(element: ReactElement, context?: any): void; + unmount(): void; + } + + namespace __Addons { + namespace TestUtils { + namespace Simulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; + } + + export function renderIntoDocument( + element: DOMElement): Element; + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; + + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof TestUtils; + + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isDOMComponent(instance: ReactInstance): boolean; + export function isCompositeComponent(instance: ReactInstance): boolean; + export function isCompositeComponentWithType( + instance: ReactInstance, + type: ComponentClass): boolean; + + export function findAllInRenderedTree( + root: Component, + fn: (i: ReactInstance) => boolean): ReactInstance[]; + + export function scryRenderedDOMComponentsWithClass( + root: Component, + className: string): Element[]; + export function findRenderedDOMComponentWithClass( + root: Component, + className: string): Element; + + export function scryRenderedDOMComponentsWithTag( + root: Component, + tagName: string): Element[]; + export function findRenderedDOMComponentWithTag( + root: Component, + tagName: string): Element; + + export function scryRenderedComponentsWithType

( + root: Component, + type: ComponentClass

): Component[]; + export function scryRenderedComponentsWithType>( + root: Component, + type: ComponentClass): C[]; + + export function findRenderedComponentWithType

( + root: Component, + type: ComponentClass

): Component; + export function findRenderedComponentWithType>( + root: Component, + type: ComponentClass): C; + + export function createRenderer(): ShallowRenderer; + } + } +} + +declare module "react-addons-test-utils" { + import TestUtils = __React.__Addons.TestUtils; + export = TestUtils; +} diff --git a/react/react-addons-tests.ts b/react/react-addons-tests.ts deleted file mode 100644 index 668c7d7d2..000000000 --- a/react/react-addons-tests.ts +++ /dev/null @@ -1,2506 +0,0 @@ -// Type definitions for react-native 0.14 -// Project: https://github.com/facebook/react-native -// Definitions by: Bruno Grieder -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// These definitions are meant to be used with the TSC compiler target set to ES6 -// -// This work is based on an original work made by Bernd Paradies: https://github.com/bparadie -// -// WARNING: this work is very much beta: -// -it is still missing react-native definitions -// -it re-exports the whole of react 0.14 which may not be what react-native actually does -// -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/// - -import React = __React; - -declare namespace ReactNative { - - - /** - * Represents the completion of an asynchronous operation - * @see lib.es6.d.ts - */ - export interface Promise { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then( onfulfilled?: ( value: T ) => TResult | Promise, onrejected?: ( reason: any ) => TResult | Promise ): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch( onrejected?: ( reason: any ) => T | Promise ): Promise; - - - // not in lib.es6.d.ts but called by react-native - done(): void; - } - - export interface PromiseConstructor { - /** - * A reference to the prototype. - */ - prototype: Promise; - - /** - * Creates a new Promise. - * @param init A callback used to initialize the promise. This callback is passed two arguments: - * a resolve callback used resolve the promise with a value or the result of another promise, - * and a reject callback used to reject the promise with a provided reason or error. - */ - new ( init: ( resolve: ( value?: T | Promise ) => void, reject: ( reason?: any ) => void ) => void ): Promise; - - ( init: ( resolve: ( value?: T | Promise ) => void, reject: ( reason?: any ) => void ) => void ): Promise; - - /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises - * resolve, or rejected when any Promise is rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - all( values: (T | Promise)[] ): Promise; - - /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises - * resolve, or rejected when any Promise is rejected. - * @param values An array of values. - * @returns A new Promise. - */ - all( values: Promise[] ): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race( values: (T | Promise)[] ): Promise; - - /** - * Creates a new rejected promise for the provided reason. - * @param reason The reason the promise was rejected. - * @returns A new rejected Promise. - */ - reject( reason: any ): Promise; - - /** - * Creates a new rejected promise for the provided reason. - * @param reason The reason the promise was rejected. - * @returns A new rejected Promise. - */ - reject( reason: any ): Promise; - - /** - * Creates a new resolved promise for the provided value. - * @param value A promise. - * @returns A promise whose internal state matches the provided promise. - */ - resolve( value: T | Promise ): Promise; - - /** - * Creates a new resolved promise . - * @returns A resolved promise. - */ - resolve(): Promise; - } - - // @see lib.es6.d.ts - export var Promise: PromiseConstructor; - - // node_modules/react-tools/src/classic/class/ReactClass.js - export interface ReactClass { - // TODO: - } - - // see react-jsx.d.ts - export function createElement

( type: React.ReactType, - props?: P, - ...children: React.ReactNode[] ): React.ReactElement

; - - - export type Runnable = ( appParameters: any ) => void; - - export type AppConfig = { - appKey: string; - component: ReactClass; - run?: Runnable; - } - - // https://github.com/facebook/react-native/blob/master/Libraries/AppRegistry/AppRegistry.js - export class AppRegistry { - static registerConfig( config: AppConfig[] ): void; - - static registerComponent( appKey: string, getComponentFunc: () => React.ComponentClass ): string; - - static registerRunnable( appKey: string, func: Runnable ): string; - - static runApplication( appKey: string, appParameters: any ): void; - } - - /* - export interface ReactPropTypes extends React.ReactPropTypes - { - - } - - export interface PropTypes - { - [key:string]: React.Requireable; - } - */ - - /** - * Flex Prop Types - * @see https://facebook.github.io/react-native/docs/flexbox.html#proptypes - * @see LayoutPropTypes.js - */ - export interface FlexStyle { - - alignItems?: string; //enum('flex-start', 'flex-end', 'center', 'stretch') - alignSelf?: string// enum('auto', 'flex-start', 'flex-end', 'center', 'stretch') - borderBottomWidth?: number - borderLeftWidth?: number - borderRightWidth?: number - borderTopWidth?: number - borderWidth?: number - bottom?: number - flex?: number - flexDirection?: string // enum('row', 'column') - flexWrap?: string // enum('wrap', 'nowrap') - height?: number - justifyContent?: string // enum('flex-start', 'flex-end', 'center', 'space-between', 'space-around') - left?: 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?: string // enum('absolute', 'relative') - right?: number - top?: number - width?: 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 - rotation?: number - scaleX?: number - scaleY?: number - translateX?: number - translateY?: number - - } - - - export interface StyleSheetProperties { - // TODO: - } - - export interface LayoutRectangle { - x: number; - y: number; - width: number; - height: number; - } - - // @see TextProperties.onLayout - export interface LayoutChangeEvent { - nativeEvent: { - layout: LayoutRectangle - } - } - - // @see https://facebook.github.io/react-native/docs/text.html#style - export interface TextStyle extends FlexStyle { - color?: string; - containerBackgroundColor?: string; - fontFamily?: string; - fontSize?: number; - fontStyle?: string; // 'normal' | 'italic'; - fontWeight?: string; // enum("normal", 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900') - letterSpacing?: number; - lineHeight?: number; - textAlign?: string; // enum("auto", 'left', 'right', 'center') - writingDirection?: string; //enum("auto", 'ltr', 'rtl') - } - - // https://facebook.github.io/react-native/docs/text.html#props - export interface TextProperties extends React.Props { - /** - * numberOfLines number - * - * 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; - - /** - * onLayout function - * - * Invoked on mount and layout changes with - * - * {nativeEvent: { layout: {x, y, width, height}}}. - */ - onLayout?: ( event: LayoutChangeEvent ) => void; - - /** - * onPress function - * - * 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; - } - - export interface TextStatic extends React.ComponentClass { - - } - - - /** - * IOS Specific properties for TextInput - * @see https://facebook.github.io/react-native/docs/textinput.html#props - */ - export interface TextInputIOSProperties { - - /** - * If true, the text field will blur when submitted. - * The default value is true. - */ - blurOnSubmit?: boolean - - /** - * 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 - - /** - * enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call') - * Determines how the return key should look. - */ - returnKeyType?: string - - /** - * If true, all text will automatically be selected on focus - */ - selectTextOnFocus?: boolean - - /** - * //FIXME: require 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 - - /** - * 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 { - - /** - * 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?: string - - /** - * 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 - - /** - * 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?: string - - /** - * 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 - - /** - * Callback that is called when the text input's submit button is pressed. - */ - onSubmitEditing?: (event: {nativeEvent: {text: string}}) => void - - /** - * The string that will be rendered before text input has been entered - */ - placeholder?: string - - /** - * The text color of the placeholder string - */ - placeholderTextColor?: string - - /** - * If true, the text input obscures the text entered so that sensitive text like passwords stay secure. - * The default value is false. - */ - secureTextEntry?: boolean - - /** - * 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 - } - - export interface TextInputStatic extends React.ComponentClass { - - } - - export interface AccessibilityTraits { - // TODO - } - - // @see https://facebook.github.io/react-native/docs/view.html#style - export interface ViewStyle extends FlexStyle, TransformsStyle { - backgroundColor?: string; - borderBottomColor?: string; - borderBottomLeftRadius?: number; - borderBottomRightRadius?: number; - borderColor?: string; - borderLeftColor?: string; - borderRadius?: number; - borderRightColor?: string; - borderTopColor?: string; - borderTopLeftRadius?: number; - borderTopRightRadius?: number; - opacity?: number; - overflow?: string; // enum('visible', 'hidden') - shadowColor?: string; - shadowOffset?: {width: number, height: number}; - shadowOpacity?: number; - shadowRadius?: number; - } - - /** - * @see https://facebook.github.io/react-native/docs/view.html#props - */ - export interface ViewProperties extends React.Props { - /** - * accessibilityLabel string - * - * 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; - - - /** - * accessibilityTraits AccessibilityTraits, [AccessibilityTraits] - * Provides additional traits to screen reader. By default no traits are provided unless specified otherwise in element - */ - - accessibilityTraits?: AccessibilityTraits; - - /** - * accessible bool - * - * When true, indicates that the view is an accessibility element. By default, all the touchable elements are accessible. - */ - - accessible?: boolean; - - /** - * onAcccessibilityTap function - * When accessible is true, the system will try to invoke this function when the user performs accessibility tap gesture. - * - */ - - onAcccessibilityTap?: () => void; - - /** - * onLayout function - * - * Invoked on mount and layout changes with - * - * {nativeEvent: { layout: {x, y, width, height}}}. - */ - onLayout?: ( event: LayoutChangeEvent ) => void; - - /** - * onMagicTap function - * - * When accessible is true, the system will invoke this function when the user performs the magic tap gesture. - */ - - onMagicTap?: () => void; - - /** - * onMoveShouldSetResponder function - * - * For most touch interactions, you'll simply want to wrap your component in TouchableHighlight or TouchableOpacity. Check out Touchable.js, ScrollResponder.js and ResponderEventPlugin.js for more discussion. - */ - onMoveShouldSetResponder?: () => void; - - onResponderGrant?: () => void; - - onResponderMove?: () => void; - - onResponderReject?: () => void; - - onResponderRelease?: () => void; - - onResponderTerminate?: () => void; - - onResponderTerminationRequest?: () => void; - - onStartShouldSetResponder?: () => void; - - onStartShouldSetResponderCapture?: () => void; - - /** - * pointerEvents enum('box-none', 'none', 'box-only', 'auto') - * - * 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?: string; - - /** - * removeClippedSubviews bool - * - * 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 - - /** - * renderToHardwareTextureAndroid bool - * - * 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; - - style?: ViewStyle; - - /** - * testID string - * - * Used to locate this view in end-to-end tests. - */ - - testID?: string; - } - - export interface ViewStatic extends React.ComponentClass { - - } - - /** - * @see https://facebook.github.io/react-native/docs/activityindicatorios.html#props - */ - export interface AlertIOSProperties { - /** - * animating bool - * - * Whether to show the indicator (true, the default) or hide it (false). - */ - animating?: boolean; - - /** - * color string - * - * The foreground color of the spinner (default is gray). - */ - - color?: string; - - /** - * hidesWhenStopped bool - * - * Whether the indicator should hide when not animating (true by default). - */ - - hidesWhenStopped?: boolean; - - /** - * onLayout function - * - * Invoked on mount and layout changes with - * - * {nativeEvent: { layout: {x, y, width, height}}}. - */ - onLayout?: ( event: LayoutChangeEvent ) => void; - - /** - * size enum('small', 'large') - * - * Size of the indicator. Small has a height of 20, large has a height of 36. - */ - size: string; // enum('small', 'large') - } - - /** - * @see - */ - export interface SegmentedControlIOSProperties { - /// TODO - } - - /** - * @see - */ - export interface SwitchIOSProperties { - /// TODO - } - - - export interface NavigatorIOSProperties extends React.Props { - - /** - * NavigatorIOS uses "route" objects to identify child views, their props, and navigation bar configuration. - * "push" and all the other navigation operations expect routes to be like this - */ - initialRoute?: Route - - /** - * The default wrapper style for components in the navigator. - * A common use case is to set the backgroundColor for every page - */ - itemWrapperStyle?: ViewStyle - - /** - * A Boolean value that indicates whether the navigation bar is hidden - */ - navigationBarHidden?: boolean - - /** - * A Boolean value that indicates whether to hide the 1px hairline shadow - */ - shadowHidden?: boolean - - /** - * The color used for buttons in the navigation bar - */ - tintColor?: string - - /** - * The text color of the navigation bar title - */ - titleTextColor?: string - - /** - * A Boolean value that indicates whether the navigation bar is translucent - */ - translucent?: boolean - - /** - * NOT IN THE DOC BUT IN THE EXAMPLES - */ - style?: ViewStyle - } - - /** - * A navigator is an object of navigation functions that a view can call. - * It is passed as a prop to any component rendered by NavigatorIOS. - * - * Navigator functions are also available on the NavigatorIOS component: - * - * @see https://facebook.github.io/react-native/docs/navigatorios.html#navigator - */ - export interface NavigationIOS { - /** - * Navigate forward to a new route - */ - push: ( route: Route ) => void - - /** - * Go back one page - */ - pop: () => void - - /** - * Go back N pages at once. When N=1, behavior matches pop() - */ - popN: ( n: number ) => void - - /** - * Replace the route for the current page and immediately load the view for the new route - */ - replace: ( route: Route ) => void - - /** - * Replace the route/view for the previous page - */ - replacePrevious: ( route: Route ) => void - - /** - * Replaces the previous route/view and transitions back to it - */ - replacePreviousAndPop: ( route: Route ) => void - - /** - * Replaces the top item and popToTop - */ - resetTo: ( route: Route ) => void - - /** - * Go back to the item for a particular route object - */ - popToRoute( route: Route ): void - - /** - * Go back to the top item - */ - popToTop(): void - } - - export interface NavigatorIOSStatic extends NavigationIOS, React.ComponentClass { - } - - - /** - * @see https://facebook.github.io/react-native/docs/activityindicatorios.html#props - */ - export interface ActivityIndicatorIOSProperties extends React.Props { - - /** - * Whether to show the indicator (true, the default) or hide it (false). - */ - animating?: boolean - - /** - * The foreground color of the spinner (default is gray). - */ - color?: string - - /** - * Whether the indicator should hide when not animating (true by default). - */ - hidesWhenStopped?: boolean - - /** - * Invoked on mount and layout changes with - */ - onLayout?: ( event: {nativeEvent: { layout: {x: number, y: number , width: number, height: number}}} ) => void - - /** - * Size of the indicator. - * Small has a height of 20, large has a height of 36. - * - * enum('small', 'large') - */ - size?: string - - style?: ViewStyle - } - - export interface ActivityIndicatorIOSStatic extends React.ComponentClass { - } - - - export interface DatePickerIOSProperties extends React.Props { - - /** - * The currently selected date. - */ - date?: Date - - - /** - * Maximum date. - * Restricts the range of possible date/time values. - */ - maximumDate?: Date - - /** - * Maximum date. - * Restricts the range of possible date/time values. - */ - minimumDate?: Date - - /** - * enum(1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30) - * The interval at which minutes can be selected. - */ - minuteInterval?: number - - /** - * enum('date', 'time', 'datetime') - * The date picker mode. - */ - mode?: string - - /** - * Date change handler. - * This is called when the user changes the date or time in the UI. - * The first and only argument is a Date object representing the new date and time. - */ - onDateChange?: (newDate: Date) => void - - /** - * Timezone offset in minutes. - * By default, the date picker will use the device's timezone. With this parameter, it is possible to force a certain timezone offset. - * For instance, to show times in Pacific Standard Time, pass -7 * 60. - */ - timeZoneOffsetInMinutes?: number - - } - - export interface DatePickerIOSStatic extends React.ComponentClass { - } - - /** - * @see https://facebook.github.io/react-native/docs/sliderios.html - */ - export interface SliderIOSProperties extends React.Props { - /** - maximumTrackTintColor string - The color used for the track to the right of the button. Overrides the default blue gradient image. - */ - maximumTrackTintColor?: string; - - /** - maximumValue number - - Initial maximum value of the slider. Default value is 1. - */ - maximumValue?: number; - - /** - minimumTrackTintColor string - The color used for the track to the left of the button. Overrides the default blue gradient image. - */ - minimumTrackTintColor?: string; - - /** - minimumValue number - Initial minimum value of the slider. Default value is 0. - */ - minimumValue?: number; - - /** - onSlidingComplete function - Callback called when the user finishes changing the value (e.g. when the slider is released). - */ - onSlidingComplete?: () => void; - - /** - onValueChange function - Callback continuously called while the user is dragging the slider. - */ - onValueChange?: ( value: number ) => void; - - /** - value number - Initial value of the slider. The value should be between minimumValue and maximumValue, which default to 0 and 1 respectively. Default value is 0. - - This is not a controlled component, e.g. if you don't update the value, the component won't be reset to its inital value. - */ - value?: number; - } - - export interface SliderIOSStatic extends React.ComponentClass { - - } - - /** - * @see - */ - export interface CameraRollProperties { - /// TODO - } - - /** - * Image style - * @see https://facebook.github.io/react-native/docs/image.html#style - */ - export interface ImageStyle extends FlexStyle { - color?: string; - containerBackgroundColor?: string; - fontFamily?: string; - fontSize?: number; - fontStyle?: string; // 'normal' | 'italic'; - fontWeight?: string; // enum("normal", 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900') - letterSpacing?: number; - lineHeight?: number; - textAlign?: string; // enum("auto", 'left', 'right', 'center') - writingDirection?: string; //enum("auto", 'ltr', 'rtl') - } - - /** - * @see https://facebook.github.io/react-native/docs/image.html - */ - export interface ImageProperties extends React.Props { - /** - * onLayout function - * - * Invoked on mount and layout changes with - * - * {nativeEvent: { layout: {x, y, width, height}}}. - */ - onLayout?: ( event: LayoutChangeEvent ) => void; - - - /** - * Determines how to resize the image when the frame doesn't match the raw image dimensions. - */ - resizeMode?: string; // enum('cover', 'contain', 'stretch') - - /** - * uri is a string representing the resource identifier for the image, - * which could be an http address, a local file path, - * or the name of a static image resource (which should be wrapped in the require('image!name') function). - */ - source: {uri: string} | string; - - /** - * - * Style - */ - style?: ImageStyle; - - /** - * A unique identifier for this element to be used in UI Automation testing scripts. - */ - testID?: string; - - /** - * The text that's read by the screen reader when the user interacts with the image. - */ - iosaccessibilityLabel?: string; - - /** - * When true, indicates the image is an accessibility element. - */ - iosaccessible?: boolean; - - /** - * When the image is resized, the corners of the size specified by capInsets will stay a fixed size, - * but the center content and borders of the image will be stretched. - * This is useful for creating resizable rounded buttons, shadows, and other resizable assets. - * More info on Apple documentation - */ - ioscapInsets?: {top: number, left: number, bottom: number, right: number} - - /** - * A static image to display while downloading the final image off the network. - */ - iosdefaultSource?: {uri: string} - - /** - * Invoked on load error with {nativeEvent: {error}} - */ - iosonError?: ( error: {nativeEvent: any} ) => void - - /** - * Invoked when load completes successfully - */ - iosonLoad?: () => void - - /** - * Invoked when load either succeeds or fails - */ - iosonLoadEnd?: () => void - - /** - * Invoked on load start - */ - iosonLoadStart?: () => void - - /** - * Invoked on download progress with {nativeEvent: {loaded, total}} - */ - iosonProgress?: ()=> void - } - - /** - * @see https://facebook.github.io/react-native/docs/listview.html#props - */ - export interface ListViewProperties extends ScrollViewProperties, React.Props { - - dataSource?: ListViewDataSource - - /** - * How many rows to render on initial component mount. Use this to make - * it so that the first screen worth of data apears at one time instead of - * over the course of multiple frames. - */ - initialListSize?: number - - /** - * (visibleRows, changedRows) => void - * - * Called when the set of visible rows changes. `visibleRows` maps - * { sectionID: { rowID: true }} for all the visible rows, and - * `changedRows` maps { sectionID: { rowID: true | false }} for the rows - * that have changed their visibility, with true indicating visible, and - * false indicating the view has moved out of view. - */ - onChangeVisibleRows?: ( visibleRows: Array<{[sectionId: string]: {[rowID: string]: boolean}}>, changedRows: Array<{[sectionId: string]: {[rowID: string]: boolean}}> ) => void - - /** - * Called when all rows have been rendered and the list has been scrolled - * to within onEndReachedThreshold of the bottom. The native scroll - * event is provided. - */ - onEndReached?: () => void - - /** - * Threshold in pixels for onEndReached. - */ - onEndReachedThreshold?: number - - /** - * Number of rows to render per event loop. - */ - pageSize?: number - - /** - * An experimental performance optimization for improving scroll perf of - * large lists, used in conjunction with overflow: 'hidden' on the row - * containers. Use at your own risk. - */ - removeClippedSubviews?: boolean - - /** - * () => renderable - * - * The header and footer are always rendered (if these props are provided) - * on every render pass. If they are expensive to re-render, wrap them - * in StaticContainer or other mechanism as appropriate. Footer is always - * at the bottom of the list, and header at the top, on every render pass. - */ - renderFooter?: () => React.ReactElement - - /** - * () => renderable - * - * The header and footer are always rendered (if these props are provided) - * on every render pass. If they are expensive to re-render, wrap them - * in StaticContainer or other mechanism as appropriate. Footer is always - * at the bottom of the list, and header at the top, on every render pass. - */ - renderHeader?: () => React.ReactElement - - /** - * (rowData, sectionID, rowID) => renderable - * Takes a data entry from the data source and its ids and should return - * a renderable component to be rendered as the row. By default the data - * is exactly what was put into the data source, but it's also possible to - * provide custom extractors. - */ - renderRow?: ( rowData: any, sectionID: string, rowID: string, highlightRow?: boolean ) => React.ReactElement - - - /** - * A function that returns the scrollable component in which the list rows are rendered. - * Defaults to returning a ScrollView with the given props. - */ - renderScrollComponent?: ( props: ScrollViewProperties ) => React.ReactElement - - /** - * (sectionData, sectionID) => renderable - * - * If provided, a sticky header is rendered for this section. The sticky - * behavior means that it will scroll with the content at the top of the - * section until it reaches the top of the screen, at which point it will - * stick to the top until it is pushed off the screen by the next section - * header. - */ - renderSectionHeader?: ( sectionData: any, sectionId: string ) => React.ReactElement - - - /** - * (sectionID, rowID, adjacentRowHighlighted) => renderable - * If provided, a renderable component to be rendered as the separator below each row - * but not the last row if there is a section header below. - * Take a sectionID and rowID of the row above and whether its adjacent row is highlighted. - */ - renderSeparator?: ( sectionID: string, rowID: string, adjacentRowHighlighted?: boolean ) => React.ReactElement - - /** - * How early to start rendering rows before they come on screen, in - * pixels. - */ - scrollRenderAheadDistance?: number - } - - export interface ListViewStatic extends React.ComponentClass { - DataSource: ListViewDataSource; - } - - - /** - * @see https://facebook.github.io/react-native/docs/touchablewithoutfeedback.html - */ - export interface TouchableWithoutFeedbackProperties { - /* - accessible bool - - Called when the touch is released, but not if cancelled (e.g. by a scroll that steals the responder lock). - */ - accessible?: boolean; - /* - delayLongPress number - - Delay in ms, from onPressIn, before onLongPress is called. - */ - delayLongPress?: number; - - /* - delayPressIn number - - Delay in ms, from the start of the touch, before onPressIn is called. - */ - delayPressIn?: number; - - /* - delayPressOut number - - Delay in ms, from the release of the touch, before onPressOut is called. - */ - delayPressOut?: number; - - /* - onLongPress function - */ - onLongPress?: () => void; - - /* - onPress function - */ - onPress?: () => void; - - /* - onPressIn function - */ - onPressIn?: () => void; - - /* - onPressOut function - */ - onPressOut?: () => void; - } - - - export interface TouchableWithoutFeedbackProps extends TouchableWithoutFeedbackProperties, React.Props { - - } - - export interface TouchableWithoutFeedbackStatic extends React.ComponentClass { - - } - - - /** - * @see https://facebook.github.io/react-native/docs/touchablehighlight.html#props - */ - export interface TouchableHighlightProperties extends TouchableWithoutFeedbackProperties, React.Props { - /** - * activeOpacity number - * - * Determines what the opacity of the wrapped view should be when touch is active. - */ - activeOpacity?: number - - /** - * onHideUnderlay function - * - * Called immediately after the underlay is hidden - */ - - onHideUnderlay?: () => void - - - /** - * onShowUnderlay function - * - * Called immediately after the underlay is shown - */ - onShowUnderlay?: () => void - - /** - * @see https://facebook.github.io/react-native/docs/view.html#style - */ - style?: ViewStyle - - - /** - * underlayColor string - * - * The color of the underlay that will show through when the touch is active. - */ - underlayColor?: string - - } - - export interface TouchableHighlightStatic extends React.ComponentClass { - } - - - /** - * @see https://facebook.github.io/react-native/docs/touchableopacity.html#props - */ - export interface TouchableOpacityProperties extends TouchableWithoutFeedbackProperties, React.Props { - /** - * activeOpacity number - * - * Determines what the opacity of the wrapped view should be when touch is active. - */ - activeOpacity?: number; - } - - export interface TouchableOpacityStatic extends React.ComponentClass { - } - - - export interface LeftToRightGesture { - - } - - export interface AnimationInterpolator { - - } - - // see /NavigatorSceneConfigs.js - export interface SceneConfig { - // A list of all gestures that are enabled on this scene - gestures: { - pop: LeftToRightGesture, - }, - - // Rebound spring parameters when transitioning FROM this scene - springFriction: number; - springTension: number; - - // Velocity to start at when transitioning without gesture - defaultTransitionVelocity: number; - - // Animation interpolators for horizontal transitioning: - animationInterpolators: { - into: AnimationInterpolator, - out: AnimationInterpolator - }; - - } - - // see /NavigatorSceneConfigs.js - export interface SceneConfigs { - FloatFromBottom: SceneConfig; - FloatFromRight: SceneConfig; - PushFromRight: SceneConfig; - FloatFromLeft: SceneConfig; - HorizontalSwipeJump: SceneConfig; - } - - export interface Route { - component?: ComponentClass - id?: string - title?: string - passProps?: Object; - - //anything else - [key: string]: any - - //Commonly found properties - backButtonTitle?: string - content?: string - message?: string; - index?: number - onRightButtonPress?: () => void - rightButtonTitle?: string - sceneConfig?: SceneConfig - wrapperStyle?: any - } - - - /** - * @see https://facebook.github.io/react-native/docs/navigator.html#content - */ - export interface NavigatorProperties extends React.Props { - /** - * Optional function that allows configuration about scene animations and gestures. - * Will be invoked with the route and should return a scene configuration object - * @param route - */ - configureScene?: ( route: Route ) => SceneConfig - /** - * Specify a route to start on. - * A route is an object that the navigator will use to identify each scene to render. - * initialRoute must be a route in the initialRouteStack if both props are provided. - * The initialRoute will default to the last item in the initialRouteStack. - */ - initialRoute?: Route - /** - * Provide a set of routes to initially mount. - * Required if no initialRoute is provided. - * Otherwise, it will default to an array containing only the initialRoute - */ - initialRouteStack?: Route[] - - /** - * Optionally provide a navigation bar that persists across scene transitions - */ - navigationBar?: React.ReactElement - - /** - * Optionally provide the navigator object from a parent Navigator - */ - navigator?: Navigator - - /** - * @deprecated Use navigationContext.addListener('willfocus', callback) instead. - */ - onDidFocus?: Function - - /** - * @deprecated Use navigationContext.addListener('willfocus', callback) instead. - */ - onWillFocus?: Function - - /** - * Required function which renders the scene for a given route. - * Will be invoked with the route and the navigator object - * @param route - * @param navigator - */ - renderScene?: ( route: Route, navigator: Navigator ) => React.ReactElement - - /** - * Styles to apply to the container of each scene - */ - sceneStyle?: ViewStyle - - /** - * //FIXME: not found in doc but found in examples - */ - debugOverlay?: boolean - - } - - /** - * Use Navigator to transition between different scenes in your app. - * To accomplish this, provide route objects to the navigator to identify each scene, - * and also a renderScene function that the navigator can use to render the scene for a given route. - * - * To change the animation or gesture properties of the scene, provide a configureScene prop to get the config object for a given route. - * See Navigator.SceneConfigs for default animations and more info on scene config options. - * @see https://facebook.github.io/react-native/docs/navigator.html - */ - export interface NavigatorStatic extends React.ComponentClass { - SceneConfigs: SceneConfigs; - NavigationBar: NavigatorStatic.NavigationBarStatic; - BreadcrumbNavigationBar: NavigatorStatic.BreadcrumbNavigationBarStatic - - getContext( self: any ): NavigatorStatic; - - /** - * returns the current list of routes - */ - getCurrentRoutes(): Route[]; - - /** - * Jump backward without unmounting the current scen - */ - jumpBack(): void; - - /** - * Jump forward to the next scene in the route stack - */ - jumpForward(): void; - - /** - * Transition to an existing scene without unmounting - */ - jumpTo( route: Route ): void; - - /** - * Navigate forward to a new scene, squashing any scenes that you could jumpForward to - */ - push( route: Route ): void; - - /** - * Transition back and unmount the current scene - */ - pop(): void; - - /** - * Replace the current scene with a new route - */ - replace( route: Route ): void; - - /** - * Replace a scene as specified by an index - */ - replaceAtIndex( route: Route, index: number ): void; - - /** - * Replace the previous scene - */ - replacePrevious( route: Route ): void; - - /** - * Reset every scene with an array of routes - */ - immediatelyResetRouteStack( routes: Route[] ): void; - - /** - * Pop to a particular scene, as specified by its route. All scenes after it will be unmounted - */ - popToRoute( route: Route ): void; - - /** - * Pop to the first scene in the stack, unmounting every other scene - */ - popToTop(): void; - - } - - namespace NavigatorStatic { - - - export interface NavState { - routeStack: Route[] - idStack: number[] - presentedIndex: number - } - - export interface NavigationBarStyle { - //TODO @see NavigationBarStyle.ios.js - } - - - export interface NavigationBarRouteMapper { - Title: ( route: Route, nav: Navigator, index: number, navState: NavState ) => React.ReactElement; - LeftButton: ( route: Route, nav: Navigator, index: number, navState: NavState )=> React.ReactElement; - RightButton: ( route: Route, nav: Navigator, index: number, navState: NavState )=> React.ReactElement; - } - - /** - * @see NavigatorNavigationBar.js - */ - export interface NavigationBarProperties extends React.Props { - navigator?: Navigator - routeMapper?: NavigationBarRouteMapper - navState?: NavState - style?: ViewStyle - } - - export interface NavigationBarStatic extends React.ComponentClass { - Styles: NavigationBarStyle - - } - - export type NavigationBar = NavigationBarStatic - export var NavigationBar: NavigationBarStatic - - - export interface BreadcrumbNavigationBarStyle { - //TODO &see NavigatorBreadcrumbNavigationBar.js - } - - export interface BreadcrumbNavigationBarRouteMapper { - rightContentForRoute: ( route: Route, navigator: Navigator ) => React.ReactElement - titleContentForRoute: ( route: Route, navigator: Navigator ) => React.ReactElement - iconForRoute: ( route: Route, navigator: Navigator ) => React.ReactElement - //in samples... - separatorForRoute: ( route: Route, navigator: Navigator ) => React.ReactElement - } - - /** - * @see NavigatorNavigationBar.js - */ - export interface BreadcrumbNavigationBarProperties extends React.Props { - navigator?: Navigator - routeMapper?: BreadcrumbNavigationBarRouteMapper - navState?: NavState - style?: ViewStyle - } - - export interface BreadcrumbNavigationBarStatic extends React.ComponentClass { - Styles: BreadcrumbNavigationBarStyle - } - - export type BreadcrumbNavigationBar = BreadcrumbNavigationBarStatic - var BreadcrumbNavigationBar: BreadcrumbNavigationBarStatic - - } - - - export interface StyleSheetStatic extends React.ComponentClass { - create( styles: T ): T; - } - - /** - * //FIXME: Could not find docs. Inferred from examples and jscode : ListViewDataSource.js - */ - export interface DataSourceAssetCallback { - rowHasChanged?: ( r1: any, r2: any ) => boolean - sectionHeaderHasChanged?: ( h1: any, h2: any ) => boolean - getRowData?: ( dataBlob: any, sectionID: number | string, rowID: number | string ) => T - getSectionHeaderData?: ( dataBlob: any, sectionID: number | string ) => T - } - - /** - * //FIXME: Could not find docs. Inferred from examples and js code: ListViewDataSource.js - */ - export interface ListViewDataSource { - new( onAsset: DataSourceAssetCallback ): ListViewDataSource; - /** - * Clones this `ListViewDataSource` with the specified `dataBlob` and - * `rowIdentities`. The `dataBlob` is just an aribitrary blob of data. At - * construction an extractor to get the interesting informatoin was defined - * (or the default was used). - * - * The `rowIdentities` is is a 2D array of identifiers for rows. - * ie. [['a1', 'a2'], ['b1', 'b2', 'b3'], ...]. If not provided, it's - * assumed that the keys of the section data are the row identities. - * - * Note: This function does NOT clone the data in this data source. It simply - * passes the functions defined at construction to a new data source with - * the data specified. If you wish to maintain the existing data you must - * handle merging of old and new data separately and then pass that into - * this function as the `dataBlob`. - */ - cloneWithRows( dataBlob: Array | {[key: string]: any}, rowIdentities?: Array ): ListViewDataSource - - /** - * This performs the same function as the `cloneWithRows` function but here - * you also specify what your `sectionIdentities` are. If you don't care - * about sections you should safely be able to use `cloneWithRows`. - * - * `sectionIdentities` is an array of identifiers for sections. - * ie. ['s1', 's2', ...]. If not provided, it's assumed that the - * keys of dataBlob are the section identities. - * - * Note: this returns a new object! - */ - cloneWithRowsAndSections( dataBlob: Array | {[key: string]: any}, sectionIdentities?: Array, rowIdentities?: Array> ): ListViewDataSource - - getRowCount(): number - - /** - * Gets the data required to render the row. - */ - getRowData( sectionIndex: number, rowIndex: number ): any - - /** - * Gets the rowID at index provided if the dataSource arrays were flattened, - * or null of out of range indexes. - */ - getRowIDForFlatIndex( index: number ): string - - /** - * Gets the sectionID at index provided if the dataSource arrays were flattened, - * or null for out of range indexes. - */ - getSectionIDForFlatIndex( index: number ): string - - /** - * Returns an array containing the number of rows in each section - */ - getSectionLengths(): Array - - /** - * Returns if the section header is dirtied and needs to be rerendered - */ - sectionHeaderShouldUpdate( sectionIndex: number ): boolean - - /** - * Gets the data required to render the section header - */ - getSectionHeaderData( sectionIndex: number ): any - } - - - export interface ImageStatic extends React.ComponentClass { - uri: string; - } - - /** - * @see - */ - export interface TabBarItemProperties { - - } - - export interface TabBarItem extends React.ComponentClass { - } - - /** - * @see - */ - export interface TabBarIOSProperties { - } - - export interface TabBarIOSStatic extends React.ComponentClass { - Item: TabBarItem; - } - - export interface CameraRollFetchParams { - first: number; - groupTypes: string; - after?: string; - } - - export interface CameraRollNodeInfo { - image: Image; - group_name: string; - timestamp: number; - location: any; - } - - export interface CameraRollEdgeInfo { - node: CameraRollNodeInfo; - } - - export interface CameraRollAssetInfo { - edges: CameraRollEdgeInfo[]; - page_info: { - has_next_page: boolean; - end_cursor: string; - }; - } - - export interface CameraRollStatic extends React.ComponentClass { - getPhotos( fetch: CameraRollFetchParams, - onAsset: ( assetInfo: CameraRollAssetInfo ) => void, - logError: ()=> void ): void; - } - - export interface PanHandlers { - - } - - export interface PanResponderEvent { - - } - - export interface PanResponderGestureState { - stateID: number; - moveX: number; - moveY: number; - x0: number; - y0: number; - dx: number; - dy: number; - vx: number; - vy: number; - numberActiveTouches: number; - // All `gestureState` accounts for timeStamps up until: - _accountsForMovesUpTo: number; - } - - /** - * @param {object} config Enhanced versions of all of the responder callbacks - * that provide not only the typical `ResponderSyntheticEvent`, but also the - * `PanResponder` gesture state. Simply replace the word `Responder` with - * `PanResponder` in each of the typical `onResponder*` callbacks. For - * example, the `config` object would look like: - * - * - `onMoveShouldSetPanResponder: (e, gestureState) => {...}` - * - `onMoveShouldSetPanResponderCapture: (e, gestureState) => {...}` - * - `onStartShouldSetPanResponder: (e, gestureState) => {...}` - * - `onStartShouldSetPanResponderCapture: (e, gestureState) => {...}` - * - `onPanResponderReject: (e, gestureState) => {...}` - * - `onPanResponderGrant: (e, gestureState) => {...}` - * - `onPanResponderStart: (e, gestureState) => {...}` - * - `onPanResponderEnd: (e, gestureState) => {...}` - * - `onPanResponderRelease: (e, gestureState) => {...}` - * - `onPanResponderMove: (e, gestureState) => {...}` - * - `onPanResponderTerminate: (e, gestureState) => {...}` - * - `onPanResponderTerminationRequest: (e, gestureState) => {...}` - * - * In general, for events that have capture equivalents, we update the - * gestureState once in the capture phase and can use it in the bubble phase - * as well. - * - * Be careful with onStartShould* callbacks. They only reflect updated - * `gestureState` for start/end events that bubble/capture to the Node. - * Once the node is the responder, you can rely on every start/end event - * being processed by the gesture and `gestureState` being updated - * accordingly. (numberActiveTouches) may not be totally accurate unless you - * are the responder. - */ - export interface PanResponderCallbacks { - onMoveShouldSetPanResponder?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => boolean; - onStartShouldSetPanResponder?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void; - onPanResponderGrant?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void; - onPanResponderMove?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void; - onPanResponderRelease?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void; - onPanResponderTerminate?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void; - - onMoveShouldSetPanResponderCapture?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => boolean; - onStartShouldSetPanResponderCapture?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => boolean; - onPanResponderReject?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void; - onPanResponderStart?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void; - onPanResponderEnd?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void; - onPanResponderTerminationRequest?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void; - } - - export interface PanResponderInstance { - panHandlers: PanHandlers; - } - - export interface PanResponderStatic { - create( callbacks: PanResponderCallbacks ): PanResponderInstance; - } - - export interface PixelRatioStatic { - get(): number; - } - - export interface DeviceEventSubscriptionStatic { - remove(): void; - } - - export interface DeviceEventEmitterStatic { - addListener( type: string, onReceived: ( data: T ) => void ): DeviceEventSubscription; - } - - // Used by Dimensions below - export interface ScaledSize { - width: number; - height: number; - scale: number; - } - - // @see https://facebook.github.io/react-native/docs/asyncstorage.html#content - export interface AsyncStorageStatic { - getItem( key: string, callback?: ( error?: Error, result?: string ) => void ): Promise; - setItem( key: string, value: string, callback?: ( error?: Error ) => void ): Promise; - removeItem( key: string, callback?: ( error?: Error ) => void ): Promise; - mergeItem( key: string, value: string, callback?: ( error?: Error ) => void ): Promise; - clear( callback?: ( error?: Error ) => void ): Promise; - getAllKeys( callback?: ( error?: Error, keys?: string[] ) => void ): Promise; - multiGet( keys: string[], callback?: ( errors?: Error[], result?: string[][] ) => void ): Promise; - multiSet( keyValuePairs: string[][], callback?: ( errors?: Error[] ) => void ): Promise; - multiRemove( keys: string[], callback?: ( errors?: Error[] ) => void ): Promise; - multiMerge( keyValuePairs: string[][], callback?: ( errors?: Error[] ) => void ): Promise; - } - - export interface InteractionManagerStatic { - runAfterInteractions( fn: () => void ): void; - } - - - export interface ScrollViewStyle extends FlexStyle, TransformsStyle { - - backfaceVisibility?:string //enum('visible', 'hidden') - backgroundColor?: string - borderColor?: string - borderTopColor?: string - borderRightColor?: string - borderBottomColor?: string - borderLeftColor?: string - borderRadius?: number - borderTopLeftRadius?: number - borderTopRightRadius?: number - borderBottomLeftRadius?: number - borderBottomRightRadius?: number - borderStyle?: string //enum('solid', 'dotted', 'dashed') - borderWidth?: number - borderTopWidth?: number - borderRightWidth?: number - borderBottomWidth?: number - borderLeftWidth?: number - opacity?: number - overflow?: string //enum('visible', 'hidden') - shadowColor?: string - shadowOffset?: {width: number; height: number} - shadowOpacity?: number - shadowRadius?: number - } - - export interface EdgeInsetsProperties { - top: number - left: number - bottom: number - right: number - } - - export interface PointProperties { - x: number - y: number - } - - export interface ScrollViewIOSProperties { - - /** - * When true the scroll view bounces horizontally when it reaches the end - * even if the content is smaller than the scroll view itself. The default - * value is true when `horizontal={true}` and false otherwise. - */ - alwaysBounceHorizontal?: boolean - /** - * When true the scroll view bounces vertically when it reaches the end - * even if the content is smaller than the scroll view itself. The default - * value is false when `horizontal={true}` and true otherwise. - */ - alwaysBounceVertical?: boolean - - /** - * Controls whether iOS should automatically adjust the content inset for scroll views that are placed behind a navigation bar or tab bar/ toolbar. - * The default value is true. - */ - automaticallyAdjustContentInsets?: boolean // true - - /** - * When true the scroll view bounces when it reaches the end of the - * content if the content is larger then the scroll view along the axis of - * the scroll direction. When false it disables all bouncing even if - * the `alwaysBounce*` props are true. The default value is true. - */ - bounces?: boolean - /** - * When true gestures can drive zoom past min/max and the zoom will animate - * to the min/max value at gesture end otherwise the zoom will not exceed - * the limits. - */ - bouncesZoom?: boolean - - /** - * When false once tracking starts won't try to drag if the touch moves. - * The default value is true. - */ - canCancelContentTouches?: boolean - - /** - * When true the scroll view automatically centers the content when the - * content is smaller than the scroll view bounds; when the content is - * larger than the scroll view this property has no effect. The default - * value is false. - */ - centerContent?: boolean - - - /** - * The amount by which the scroll view content is inset from the edges of the scroll view. - * Defaults to {0, 0, 0, 0}. - */ - contentInset?: EdgeInsetsProperties // zeros - - /** - * Used to manually set the starting scroll offset. - * The default value is {x: 0, y: 0} - */ - contentOffset?: PointProperties // zeros - - /** - * A floating-point number that determines how quickly the scroll view - * decelerates after the user lifts their finger. Reasonable choices include - * - Normal: 0.998 (the default) - * - Fast: 0.9 - */ - decelerationRate?: number - - /** - * When true the ScrollView will try to lock to only vertical or horizontal - * scrolling while dragging. The default value is false. - */ - directionalLockEnabled?: boolean - - /** - * The maximum allowed zoom scale. The default value is 1.0. - */ - maximumZoomScale?: number - - /** - * The minimum allowed zoom scale. The default value is 1.0. - */ - minimumZoomScale?: number - - /** - * Called when a scrolling animation ends. - */ - onScrollAnimationEnd?: () => void - - /** - * When true the scroll view stops on multiples of the scroll view's size - * when scrolling. This can be used for horizontal pagination. The default - * value is false. - */ - pagingEnabled?: boolean - - /** - * When false, the content does not scroll. The default value is true - */ - scrollEnabled?: boolean // true - - /** - * This controls how often the scroll event will be fired while scrolling (in events per seconds). - * A higher number yields better accuracy for code that is tracking the scroll position, - * but can lead to scroll performance problems due to the volume of information being send over the bridge. - * The default value is zero, which means the scroll event will be sent only once each time the view is scrolled. - */ - scrollEventThrottle?: number // null - - /** - * The amount by which the scroll view indicators are inset from the edges of the scroll view. - * This should normally be set to the same value as the contentInset. - * Defaults to {0, 0, 0, 0}. - */ - scrollIndicatorInsets?: EdgeInsetsProperties //zeroes - - /** - * When true the scroll view scrolls to top when the status bar is tapped. - * The default value is true. - */ - scrollsToTop?: boolean - - /** - * When snapToInterval is set, snapToAlignment will define the relationship of the the snapping to the scroll view. - * - start (the default) will align the snap at the left (horizontal) or top (vertical) - * - center will align the snap in the center - * - end will align the snap at the right (horizontal) or bottom (vertical) - */ - snapToAlignment?: string - - /** - * When set, causes the scroll view to stop at multiples of the value of snapToInterval. - * This can be used for paginating through children that have lengths smaller than the scroll view. - * Used in combination with snapToAlignment. - */ - snapToInterval?: number - - /** - * An array of child indices determining which children get docked to the - * top of the screen when scrolling. For example passing - * `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the - * top of the scroll view. This property is not supported in conjunction - * with `horizontal={true}`. - */ - stickyHeaderIndices?: number[] - - /** - * The current scale of the scroll view content. The default value is 1.0. - */ - zoomScale?: number - } - - export interface ScrollViewProperties extends ScrollViewIOSProperties { - - /** - * These styles will be applied to the scroll view content container which - * wraps all of the child views. Example: - * - * return ( - * - * - * ); - * ... - * var styles = StyleSheet.create({ - * contentContainer: { - * paddingVertical: 20 - * } - * }); - */ - contentContainerStyle?: ViewStyle - - /** - * When true the scroll view's children are arranged horizontally in a row - * instead of vertically in a column. The default value is false. - */ - horizontal?: boolean - - /** - * Determines whether the keyboard gets dismissed in response to a drag. - * - 'none' (the default) drags do not dismiss the keyboard. - * - 'onDrag' the keyboard is dismissed when a drag begins. - * - 'interactive' the keyboard is dismissed interactively with the drag - * and moves in synchrony with the touch; dragging upwards cancels the - * dismissal. - */ - keyboardDismissMode?: string - - /** - * When false tapping outside of the focused text input when the keyboard - * is up dismisses the keyboard. When true the scroll view will not catch - * taps and the keyboard will not dismiss automatically. The default value - * is false. - */ - keyboardShouldPersistTaps?: boolean - - /** - * Fires at most once per frame during scrolling. - * The frequency of the events can be contolled using the scrollEventThrottle prop. - */ - onScroll?: () => void - - /** - * Experimental: When true offscreen child views (whose `overflow` value is - * `hidden`) are removed from their native backing superview when offscreen. - * This canimprove scrolling performance on long lists. The default value is - * false. - */ - removeClippedSubviews?: boolean - - /** - * When true, shows a horizontal scroll indicator. - */ - showsHorizontalScrollIndicator?: boolean - - /** - * When true, shows a vertical scroll indicator. - */ - showsVerticalScrollIndicator?: boolean - - /** - * Style - */ - style?: ScrollViewStyle - } - - export interface ScrollViewProps extends ScrollViewProperties, React.Props { - - } - - interface ScrollViewStatic extends React.ComponentClass { - - } - - - export interface NativeScrollRectangle { - left: number; - top: number; - bottom: number; - right: number; - } - - export interface NativeScrollPoint { - x: number; - y: number; - } - - export interface NativeScrollSize { - height: number; - width: number; - } - - export interface NativeScrollEvent { - contentInset: NativeScrollRectangle; - contentOffset: NativeScrollPoint; - contentSize: NativeScrollSize; - layoutMeasurement: NativeScrollSize; - zoomScale: number; - } - - export interface AppStateIOSStatic { - currentState: string; - addEventListener( type: string, listener: ( state: string ) => void ): void; - removeEventListener( type: string, listener: ( state: string ) => void ): void; - } - - // exported singletons: - // export var AppRegistry: AppRegistryStatic; - - - export var ActivityIndicatorIOS: ActivityIndicatorIOSStatic; - export type ActivityIndicatorIOS = ActivityIndicatorIOSStatic; - - export var AsyncStorage: AsyncStorageStatic; - export type AsyncStorage = AsyncStorageStatic; - - export var CameraRoll: CameraRollStatic; - export type CameraRoll = CameraRollStatic; - - export var DatePickerIOS: DatePickerIOSStatic - export type DatePickerIOS = DatePickerIOSStatic - - export var Image: ImageStatic; - export type Image = ImageStatic; - - export var ListView: ListViewStatic; - export type ListView = ListViewStatic; - - export var Navigator: NavigatorStatic; - export type Navigator = NavigatorStatic; - - export var NavigatorIOS: NavigatorIOSStatic; - export type NavigatorIOS = NavigatorIOSStatic; - - export var SliderIOS: SliderIOSStatic; - export type SliderIOS = SliderIOSStatic; - - export var ScrollView: ScrollViewStatic - export type ScrollView = ScrollViewStatic - - export var StyleSheet: StyleSheetStatic; - export type StyleSheet = StyleSheetStatic; - - export var TabBarIOS: TabBarIOSStatic; - export type TabBarIOS = TabBarIOSStatic; - - export var Text: TextStatic; - export type Text = TextStatic; - - export var TextInput: TextInputStatic - export type TextInput = TextInputStatic - - export var TouchableHighlight: TouchableHighlightStatic; - export type TouchableHighlight = TouchableHighlightStatic; - - export var TouchableOpacity: TouchableOpacityStatic; - export type TouchableOpacity = TouchableOpacityStatic; - - export var TouchableWithoutFeedback: TouchableWithoutFeedbackStatic; - export type TouchableWithoutFeedback= TouchableWithoutFeedbackStatic; - - export var View: ViewStatic; - export type View = ViewStatic; - - export var AlertIOS: React.ComponentClass; - export var SegmentedControlIOS: React.ComponentClass; - export var SwitchIOS: React.ComponentClass; - - export var PixelRatio: PixelRatioStatic; - export var DeviceEventEmitter: DeviceEventEmitterStatic; - export var DeviceEventSubscription: DeviceEventSubscriptionStatic; - export type DeviceEventSubscription = DeviceEventSubscriptionStatic; - export var InteractionManager: InteractionManagerStatic; - export var PanResponder: PanResponderStatic; - export var AppStateIOS: AppStateIOSStatic; - - - //react re-exported - export type ReactType = React.ReactType; - - export interface ReactElement

extends React.ReactElement

{} - - export interface ClassicElement

extends React.ClassicElement

{} - - export interface DOMElement

extends React.DOMElement

{} - - export type HTMLElement =React.HTMLElement; - export type SVGElement = React.SVGElement; - - // - // Factories - // ---------------------------------------------------------------------- - - export interface Factory

extends React.Factory

{} - - export interface ClassicFactory

extends React.ClassicFactory

{} - - export interface DOMFactory

extends React.DOMFactory

{} - - export type HTMLFactory = React.HTMLFactory; - export type SVGFactory = React.SVGFactory; - export type SVGElementFactory = React.SVGElementFactory; - - // - // React Nodes - // http://facebook.github.io/react/docs/glossary.html - // ---------------------------------------------------------------------- - - export type ReactText = React.ReactText; - export type ReactChild = React.ReactChild; - - // Should be Array but type aliases cannot be recursive - export type ReactFragment = React.ReactFragment; - export type ReactNode = React.ReactNode; - - // - // Top Level API - // ---------------------------------------------------------------------- - - export function createClass( spec: React.ComponentSpec ): React.ClassicComponentClass

; - - export function createFactory

( type: string ): React.DOMFactory

; - export function createFactory

( type: React.ClassicComponentClass

| string ): React.ClassicFactory

; - export function createFactory

( type: React.ComponentClass

): React.Factory

; - - export function createElement

( type: string, - props?: P, - ...children: React.ReactNode[] ): React.DOMElement

; - export function createElement

( type: React.ClassicComponentClass

| string, - props?: P, - ...children: React.ReactNode[] ): React.ClassicElement

; - export function createElement

( type: React.ComponentClass

, - props?: P, - ...children: React.ReactNode[] ): React.ReactElement

; - - export function cloneElement

( element: React.DOMElement

, - props?: P, - ...children: React.ReactNode[] ): React.DOMElement

; - export function cloneElement

( element: React.ClassicElement

, - props?: P, - ...children: React.ReactNode[] ): React.ClassicElement

; - export function cloneElement

( element: React.ReactElement

, - props?: P, - ...children: React.ReactNode[] ): React.ReactElement

; - - export function isValidElement( object: {} ): boolean; - - export var DOM: React.ReactDOM; - export var PropTypes: React.ReactPropTypes; - export var Children: React.ReactChildren; - - // - // Component API - // ---------------------------------------------------------------------- - - // Base component for plain JS classes - export class Component extends React.Component {} - - export interface ClassicComponent extends React.ClassicComponent {} - - export interface DOMComponent

extends ClassicComponent { - tagName: string; - } - - export type HTMLComponent = React.HTMLComponent; - export type SVGComponent = React.SVGComponent - - export interface ChildContextProvider extends React.ChildContextProvider {} - - // - // Class Interfaces - // ---------------------------------------------------------------------- - - export interface ComponentClass

extends React.ComponentClass

{} - - export interface ClassicComponentClass

extends React.ClassicComponentClass

{} - - // - // Component Specs and Lifecycle - // ---------------------------------------------------------------------- - - export interface ComponentLifecycle extends React.ComponentLifecycle {} - - export interface Mixin extends React.Mixin {} - - export interface ComponentSpec extends React.ComponentSpec {} - - // - // Event System - // ---------------------------------------------------------------------- - - export interface SyntheticEvent extends React.SyntheticEvent {} - - export interface DragEvent extends React.DragEvent {} - - export interface ClipboardEvent extends React.ClipboardEvent {} - - export interface KeyboardEvent extends React.KeyboardEvent {} - - - export interface FocusEvent extends React.FocusEvent {} - - export interface FormEvent extends React.FormEvent {} - - export interface MouseEvent extends React.MouseEvent {} - - export interface TouchEvent extends React.TouchEvent {} - - export interface UIEvent extends React.UIEvent {} - - export interface WheelEvent extends React.WheelEvent {} - - // - // Event Handler Types - // ---------------------------------------------------------------------- - - export interface EventHandler extends React.EventHandler {} - - export interface DragEventHandler extends React.DragEventHandler {} - export interface ClipboardEventHandler extends React.ClipboardEventHandler {} - export interface KeyboardEventHandler extends React.KeyboardEventHandler {} - export interface FocusEventHandler extends React.FocusEventHandler {} - export interface FormEventHandler extends React.FormEventHandler {} - export interface MouseEventHandler extends React.MouseEventHandler {} - export interface TouchEventHandler extends React.TouchEventHandler {} - export interface UIEventHandler extends React.UIEventHandler {} - export interface WheelEventHandler extends React.WheelEventHandler {} - - // - // Props / DOM Attributes - // ---------------------------------------------------------------------- - - export interface Props extends React.Props {} - - export interface DOMAttributesBase extends React.DOMAttributesBase {} - - export interface DOMAttributes extends React.DOMAttributes {} - - // This interface is not complete. Only properties accepting - // unitless numbers are listed here (see CSSProperty.js in React) - export interface CSSProperties extends React.CSSProperties {} - - export interface HTMLAttributesBase extends React.HTMLAttributesBase {} - - export interface HTMLAttributes extends React.HTMLAttributes {} - - export interface SVGElementAttributes extends React.SVGElementAttributes {} - - export interface SVGAttributes extends React.SVGAttributes {} - - // - // React.DOM - // ---------------------------------------------------------------------- - - export interface ReactDOM extends React.ReactDOM {} - - // - // React.PropTypes - // ---------------------------------------------------------------------- - - export interface Validator extends React.Validator {} - - export interface Requireable extends React.Requireable {} - - export interface ValidationMap extends React.ValidationMap {} - - export interface ReactPropTypes extends React.ReactPropTypes {} - - // - // React.Children - // ---------------------------------------------------------------------- - - export interface ReactChildren extends React.ReactChildren {} - - // - // Browser Interfaces - // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts - // ---------------------------------------------------------------------- - - export interface AbstractView extends React.AbstractView {} - - export interface Touch extends React.Touch {} - - export interface TouchList extends React.TouchList {} - - // - // Additional ( and controversial) - // - - export function __spread( target: any, ...sources: any[] ): any; - - - export interface GlobalStatic { - - /** - * Accepts a function as its only argument and calls that function before the next repaint. - * It is an essential building block for animations that underlies all of the JavaScript-based animation APIs. - * In general, you shouldn't need to call this yourself - the animation API's will manage frame updates for you. - * @see https://facebook.github.io/react-native/docs/animations.html#requestanimationframe - */ - requestAnimationFrame( fn: () => void ) : void; - - } - - // - // Add-Ons - // - namespace addons { - - //FIXME: Documentation ? - export interface TestModuleStatic { - - verifySnapshot: (done: (indicator?: any) => void) => void - markTestPassed: (indicator: any) => void - markTestCompleted: () => void - } - - export var TestModule: TestModuleStatic - export type TestModule = TestModuleStatic - } - - -} - -declare module "react-native" { - - export default ReactNative -} - - -declare module "Dimensions" { - import React from 'react-native'; - - interface Dimensions { - get( what: string ): React.ScaledSize; - } - - var ExportDimensions: Dimensions; - export = ExportDimensions; -} - -declare var global: ReactNative.GlobalStatic - -declare function require( name: string ): any diff --git a/react/react-addons-transition-group.d.ts b/react/react-addons-transition-group.d.ts new file mode 100644 index 000000000..728c52aa8 --- /dev/null +++ b/react/react-addons-transition-group.d.ts @@ -0,0 +1,26 @@ +// Type definitions for React v0.14 (react-addons-transition-group) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + type TransitionGroup = ComponentClass; + + namespace __Addons { + export var TransitionGroup: __React.TransitionGroup; + } +} + +declare module "react-addons-transition-group" { + var TransitionGroup: __React.TransitionGroup; + type TransitionGroup = __React.TransitionGroup; + export = TransitionGroup; +} \ No newline at end of file diff --git a/react/react-addons-update.d.ts b/react/react-addons-update.d.ts new file mode 100644 index 000000000..2140e2908 --- /dev/null +++ b/react/react-addons-update.d.ts @@ -0,0 +1,35 @@ +// Type definitions for React v0.14 (react-addons-update) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + interface UpdateSpecCommand { + $set?: any; + $merge?: {}; + $apply?(value: any): any; + } + + interface UpdateSpecPath { + [key: string]: UpdateSpec; + } + + type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; + + interface UpdateArraySpec extends UpdateSpecCommand { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + namespace __Addons { + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; + } +} + +declare module "react-addons-update" { + export = __React.__Addons.update; +} diff --git a/react/react-dom.d.ts b/react/react-dom.d.ts new file mode 100644 index 000000000..f8fd1d5c6 --- /dev/null +++ b/react/react-dom.d.ts @@ -0,0 +1,67 @@ +// Type definitions for React v0.14 (react-dom) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + + namespace __DOM { + function findDOMNode(instance: ReactInstance): E; + function findDOMNode(instance: ReactInstance): Element; + + function render

( + element: DOMElement

, + container: Element, + callback?: (element: Element) => any): Element; + function render( + element: ClassicElement

, + container: Element, + callback?: (component: ClassicComponent) => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: (component: Component) => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + + var version: string; + + function unstable_batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; + function unstable_batchedUpdates(callback: (a: A) => any, a: A): void; + function unstable_batchedUpdates(callback: () => any): void; + + function unstable_renderSubtreeIntoContainer

( + parentComponent: Component, + nextElement: DOMElement

, + container: Element, + callback?: (element: Element) => any): Element; + function unstable_renderSubtreeIntoContainer( + parentComponent: Component, + nextElement: ClassicElement

, + container: Element, + callback?: (component: ClassicComponent) => any): ClassicComponent; + function unstable_renderSubtreeIntoContainer( + parentComponent: Component, + nextElement: ReactElement

, + container: Element, + callback?: (component: Component) => any): Component; + } + + namespace __DOMServer { + function renderToString(element: ReactElement): string; + function renderToStaticMarkup(element: ReactElement): string; + var version: string; + } +} + +declare module "react-dom" { + import DOM = __React.__DOM; + export = DOM; +} + +declare module "react-dom/server" { + import DOMServer = __React.__DOMServer; + export = DOMServer; +} diff --git a/react/react-global-0.13.3.d.ts b/react/react-global-0.13.3.d.ts new file mode 100644 index 000000000..13d114892 --- /dev/null +++ b/react/react-global-0.13.3.d.ts @@ -0,0 +1,285 @@ +// Type definitions for React v0.13.3 (namespace) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +import React = __React; + +declare namespace __React { + // + // React.addons + // ---------------------------------------------------------------------- + + export module addons { + export var CSSTransitionGroup: CSSTransitionGroup; + export var TransitionGroup: TransitionGroup; + + export var LinkedStateMixin: LinkedStateMixin; + export var PureRenderMixin: PureRenderMixin; + + export function batchedUpdates( + callback: (a: A, b: B) => any, a: A, b: B): void; + export function batchedUpdates(callback: (a: A) => any, a: A): void; + export function batchedUpdates(callback: () => any): void; + + // deprecated: use petehunt/react-classset or JedWatson/classnames + export function classSet(cx: { [key: string]: boolean }): string; + export function classSet(...classList: string[]): string; + + export function cloneWithProps

( + element: DOMElement

, props: P): DOMElement

; + export function cloneWithProps

( + element: ClassicElement

, props: P): ClassicElement

; + export function cloneWithProps

( + element: ReactElement

, props: P): ReactElement

; + + export function createFragment( + object: { [key: string]: ReactNode }): ReactFragment; + + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; + + // Development tools + export import Perf = ReactPerf; + export import TestUtils = ReactTestUtils; + } + + // + // React.addons (Transitions) + // ---------------------------------------------------------------------- + + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = ComponentClass; + type TransitionGroup = ComponentClass; + + // + // React.addons (Mixins) + // ---------------------------------------------------------------------- + + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + + interface PureRenderMixin extends Mixin { + } + + // + // Reat.addons.update + // ---------------------------------------------------------------------- + + interface UpdateSpecCommand { + $set?: any; + $merge?: {}; + $apply?(value: any): any; + } + + interface UpdateSpecPath { + [key: string]: UpdateSpec; + } + + type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; + + interface UpdateArraySpec extends UpdateSpecCommand { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + // + // React.addons.Perf + // ---------------------------------------------------------------------- + + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + module ReactPerf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; + } + + // + // React.addons.TestUtils + // ---------------------------------------------------------------------- + + interface MockedComponentClass { + new(): any; + } + + module ReactTestUtils { + export import Simulate = ReactSimulate; + + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; + + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; + + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isTextComponent(instance: Component): boolean; + export function isDOMComponent(instance: Component): boolean; + export function isCompositeComponent(instance: Component): boolean; + export function isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + export function findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + export function scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + export function findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + export function scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + export function findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + export function scryRenderedComponentsWithType

( + tree: Component, + type: ComponentClass

): Component[]; + export function scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + export function findRenderedComponentWithType

( + tree: Component, + type: ComponentClass

): Component; + export function findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + + export function createRenderer(): ShallowRenderer; + } + + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; + } + + module ReactSimulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; + } + + class ShallowRenderer { + getRenderOutput>(): E; + getRenderOutput(): ReactElement; + render(element: ReactElement, context?: any): void; + unmount(): void; + } +} diff --git a/react/react-global-tests.ts b/react/react-global-tests.ts index 0b20e4650..7caf82fdf 100644 --- a/react/react-global-tests.ts +++ b/react/react-global-tests.ts @@ -103,12 +103,12 @@ class ModernComponent extends React.Component }); } - private _input: React.HTMLComponent; + private _input: HTMLInputElement; render() { return React.DOM.div(null, React.DOM.input({ - ref: input => this._input = input, + ref: input => this._input = input, value: this.state.inputValue })); } @@ -135,7 +135,7 @@ var element: React.ReactElement = React.createElement(ModernComponent, props); var classicElement: React.ClassicElement = React.createElement(ClassicComponent, props); -var domElement: React.HTMLElement = +var domElement: React.ReactHTMLElement = React.createElement("div"); // React.cloneElement @@ -143,26 +143,27 @@ var clonedElement: React.ReactElement = React.cloneElement(element, props); var clonedClassicElement: React.ClassicElement = React.cloneElement(classicElement, props); -var clonedDOMElement: React.HTMLElement = +var clonedDOMElement: React.ReactHTMLElement = React.cloneElement(domElement); // React.render var component: React.Component = - React.render(element, container); + ReactDOM.render(element, container); var classicComponent: React.ClassicComponent = - React.render(classicElement, container); -var domComponent: React.DOMComponent = - React.render(domElement, container); + ReactDOM.render(classicElement, container); +var domComponent: Element = + ReactDOM.render(domElement, container); // Other Top-Level API -var unmounted: boolean = React.unmountComponentAtNode(container); -var str: string = React.renderToString(element); -var markup: string = React.renderToStaticMarkup(element); +var unmounted: boolean = ReactDOM.unmountComponentAtNode(container); + +// ReactDOMServer is not supported in global version +// var str: string = ReactDOMServer.renderToString(element); +// var markup: string = ReactDOMServer.renderToStaticMarkup(element); var notValid: boolean = React.isValidElement(props); // false var isValid = React.isValidElement(element); // true -React.initializeTouchEvents(true); -var domNode: Element = React.findDOMNode(component); -domNode = React.findDOMNode(domNode); +var domNode: Element = ReactDOM.findDOMNode(component); +domNode = ReactDOM.findDOMNode(domNode); // // React Elements @@ -190,11 +191,7 @@ component.setState({ inputValue: "!!!" }); component.forceUpdate(); // classic -var htmlElement: Element = classicComponent.getDOMNode(); -var divElement: HTMLDivElement = classicComponent.getDOMNode(); var isMounted: boolean = classicComponent.isMounted(); -classicComponent.setProps(elementProps); -classicComponent.replaceProps(props); classicComponent.replaceState({ inputValue: "???", seconds: 60 }); var myComponent = component; @@ -209,7 +206,7 @@ var divStyle: React.CSSProperties = { // CSSProperties flex: "1 1 main-size", backgroundImage: "url('hello.png')" }; -var htmlAttr: React.HTMLAttributes = { +var htmlAttr: React.HTMLProps = { key: 36, ref: "htmlComponent", children: children, @@ -328,11 +325,12 @@ var ContextTypesSpecification: React.ComponentSpec = { // React.Children // -------------------------------------------------------------------------- -var childMap: { [key: string]: number } = +var mappedChildrenArray: number[] = React.Children.map(children, (child) => { return 42; }); React.Children.forEach(children, (child) => {}); var nChildren: number = React.Children.count(children); var onlyChild = React.Children.only([null, [[["Hallo"], true]], false]); +var childrenToArray: React.ReactChild[] = React.Children.toArray(children); // // Example from http://facebook.github.io/react/ @@ -365,5 +363,93 @@ class Timer extends React.Component<{}, TimerState> { ); } } -React.render(React.createElement(Timer), container); +ReactDOM.render(React.createElement(Timer), container); +// +// createFragment addon +// -------------------------------------------------------------------------- +React.addons.createFragment({ + a: React.DOM.div(), + b: ["a", false, React.createElement("span")] +}); + +// +// CSSTransitionGroup addon +// -------------------------------------------------------------------------- +React.createFactory(React.addons.CSSTransitionGroup)({ + component: React.createClass({ + render: (): React.ReactElement => null + }), + childFactory: (c) => c, + transitionName: "transition", + transitionAppear: false, + transitionEnter: true, + transitionLeave: true +}); + +// +// LinkedStateMixin addon +// -------------------------------------------------------------------------- +React.createClass({ + mixins: [React.addons.LinkedStateMixin], + render: function() { return React.DOM.div(null) } +}); + +// +// Perf addon +// -------------------------------------------------------------------------- +React.addons.Perf.start(); +React.addons.Perf.stop(); +var measurements = React.addons.Perf.getLastMeasurements(); +React.addons.Perf.printInclusive(measurements); +React.addons.Perf.printExclusive(measurements); +React.addons.Perf.printWasted(measurements); +React.addons.Perf.printDOM(measurements); + +// +// PureRenderMixin addon +// -------------------------------------------------------------------------- +React.createClass({ + mixins: [React.addons.PureRenderMixin], + render: function() { return React.DOM.div(null) } +}); + +// +// TestUtils addon +// -------------------------------------------------------------------------- +var node: Element; +React.addons.TestUtils.Simulate.click(node); +React.addons.TestUtils.Simulate.change(node); +React.addons.TestUtils.Simulate.keyDown(node, { key: "Enter" }); + +var renderer: React.ShallowRenderer = + React.addons.TestUtils.createRenderer(); +renderer.render(React.createElement(Timer)); +var output: React.ReactElement> = + renderer.getRenderOutput(); + +// +// TransitionGroup addon +// -------------------------------------------------------------------------- +React.createFactory(React.addons.TransitionGroup)({ component: "div" }); + +// +// update addon +// -------------------------------------------------------------------------- +{ +// These are copied from https://facebook.github.io/react/docs/update.html +let initialArray = [1, 2, 3]; +let newArray = React.addons.update(initialArray, {$push: [4]}); // => [1, 2, 3, 4] + +let collection = [1, 2, {a: [12, 17, 15]}]; +let newCollection = React.addons.update(collection, {2: {a: {$splice: [[1, 1, 13, 14]]}}}); +// => [1, 2, {a: [12, 13, 14, 15]}] + +let obj = {a: 5, b: 3}; +let newObj = React.addons.update(obj, {b: {$apply: function(x) {return x * 2;}}}); +// => {a: 5, b: 6} +let newObj2 = React.addons.update(obj, {b: {$set: obj.b * 2}}); + +let objShallow = {a: 5, b: 3}; +let newObjShallow = React.addons.update(obj, {$merge: {b: 6, c: 7}}); // => {a: 5, b: 6, c: 7} +} diff --git a/react/react-global.d.ts b/react/react-global.d.ts index 1728ba2fc..1c50ce7e4 100644 --- a/react/react-global.d.ts +++ b/react/react-global.d.ts @@ -1,285 +1,22 @@ -// Type definitions for React v0.13.3 (namespace) +// Type definitions for React v0.14 (namespace) // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// +/// +/// +/// +/// +/// +/// +/// +/// import React = __React; +import ReactDOM = __React.__DOM; declare namespace __React { - // - // React.addons - // ---------------------------------------------------------------------- - - export module addons { - export var CSSTransitionGroup: CSSTransitionGroup; - export var TransitionGroup: TransitionGroup; - - export var LinkedStateMixin: LinkedStateMixin; - export var PureRenderMixin: PureRenderMixin; - - export function batchedUpdates( - callback: (a: A, b: B) => any, a: A, b: B): void; - export function batchedUpdates(callback: (a: A) => any, a: A): void; - export function batchedUpdates(callback: () => any): void; - - // deprecated: use petehunt/react-classset or JedWatson/classnames - export function classSet(cx: { [key: string]: boolean }): string; - export function classSet(...classList: string[]): string; - - export function cloneWithProps

( - element: DOMElement

, props: P): DOMElement

; - export function cloneWithProps

( - element: ClassicElement

, props: P): ClassicElement

; - export function cloneWithProps

( - element: ReactElement

, props: P): ReactElement

; - - export function createFragment( - object: { [key: string]: ReactNode }): ReactFragment; - - export function update(value: any[], spec: UpdateArraySpec): any[]; - export function update(value: {}, spec: UpdateSpec): any; - - // Development tools - export import Perf = ReactPerf; - export import TestUtils = ReactTestUtils; - } - - // - // React.addons (Transitions) - // ---------------------------------------------------------------------- - - interface TransitionGroupProps { - component?: ReactType; - childFactory?: (child: ReactElement) => ReactElement; - } - - interface CSSTransitionGroupProps extends TransitionGroupProps { - transitionName: string; - transitionAppear?: boolean; - transitionEnter?: boolean; - transitionLeave?: boolean; - } - - type CSSTransitionGroup = ComponentClass; - type TransitionGroup = ComponentClass; - - // - // React.addons (Mixins) - // ---------------------------------------------------------------------- - - interface ReactLink { - value: T; - requestChange(newValue: T): void; - } - - interface LinkedStateMixin extends Mixin { - linkState(key: string): ReactLink; - } - - interface PureRenderMixin extends Mixin { - } - - // - // Reat.addons.update - // ---------------------------------------------------------------------- - - interface UpdateSpecCommand { - $set?: any; - $merge?: {}; - $apply?(value: any): any; - } - - interface UpdateSpecPath { - [key: string]: UpdateSpec; - } - - type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; - - interface UpdateArraySpec extends UpdateSpecCommand { - $push?: any[]; - $unshift?: any[]; - $splice?: any[][]; - } - - // - // React.addons.Perf - // ---------------------------------------------------------------------- - - interface ComponentPerfContext { - current: string; - owner: string; - } - - interface NumericPerfContext { - [key: string]: number; - } - - interface Measurements { - exclusive: NumericPerfContext; - inclusive: NumericPerfContext; - render: NumericPerfContext; - counts: NumericPerfContext; - writes: NumericPerfContext; - displayNames: { - [key: string]: ComponentPerfContext; - }; - totalTime: number; - } - - module ReactPerf { - export function start(): void; - export function stop(): void; - export function printInclusive(measurements: Measurements[]): void; - export function printExclusive(measurements: Measurements[]): void; - export function printWasted(measurements: Measurements[]): void; - export function printDOM(measurements: Measurements[]): void; - export function getLastMeasurements(): Measurements[]; - } - - // - // React.addons.TestUtils - // ---------------------------------------------------------------------- - - interface MockedComponentClass { - new(): any; - } - - module ReactTestUtils { - export import Simulate = ReactSimulate; - - export function renderIntoDocument

( - element: ReactElement

): Component; - export function renderIntoDocument>( - element: ReactElement): C; - - export function mockComponent( - mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; - - export function isElementOfType( - element: ReactElement, type: ReactType): boolean; - export function isTextComponent(instance: Component): boolean; - export function isDOMComponent(instance: Component): boolean; - export function isCompositeComponent(instance: Component): boolean; - export function isCompositeComponentWithType( - instance: Component, - type: ComponentClass): boolean; - - export function findAllInRenderedTree( - tree: Component, - fn: (i: Component) => boolean): Component; - - export function scryRenderedDOMComponentsWithClass( - tree: Component, - className: string): DOMComponent[]; - export function findRenderedDOMComponentWithClass( - tree: Component, - className: string): DOMComponent; - - export function scryRenderedDOMComponentsWithTag( - tree: Component, - tagName: string): DOMComponent[]; - export function findRenderedDOMComponentWithTag( - tree: Component, - tagName: string): DOMComponent; - - export function scryRenderedComponentsWithType

( - tree: Component, - type: ComponentClass

): Component[]; - export function scryRenderedComponentsWithType>( - tree: Component, - type: ComponentClass): C[]; - - export function findRenderedComponentWithType

( - tree: Component, - type: ComponentClass

): Component; - export function findRenderedComponentWithType>( - tree: Component, - type: ComponentClass): C; - - export function createRenderer(): ShallowRenderer; - } - - interface SyntheticEventData { - altKey?: boolean; - button?: number; - buttons?: number; - clientX?: number; - clientY?: number; - changedTouches?: TouchList; - charCode?: boolean; - clipboardData?: DataTransfer; - ctrlKey?: boolean; - deltaMode?: number; - deltaX?: number; - deltaY?: number; - deltaZ?: number; - detail?: number; - getModifierState?(key: string): boolean; - key?: string; - keyCode?: number; - locale?: string; - location?: number; - metaKey?: boolean; - pageX?: number; - pageY?: number; - relatedTarget?: EventTarget; - repeat?: boolean; - screenX?: number; - screenY?: number; - shiftKey?: boolean; - targetTouches?: TouchList; - touches?: TouchList; - view?: AbstractView; - which?: number; - } - - interface EventSimulator { - (element: Element, eventData?: SyntheticEventData): void; - (component: Component, eventData?: SyntheticEventData): void; - } - - module ReactSimulate { - export var blur: EventSimulator; - export var change: EventSimulator; - export var click: EventSimulator; - export var cut: EventSimulator; - export var doubleClick: EventSimulator; - export var drag: EventSimulator; - export var dragEnd: EventSimulator; - export var dragEnter: EventSimulator; - export var dragExit: EventSimulator; - export var dragLeave: EventSimulator; - export var dragOver: EventSimulator; - export var dragStart: EventSimulator; - export var drop: EventSimulator; - export var focus: EventSimulator; - export var input: EventSimulator; - export var keyDown: EventSimulator; - export var keyPress: EventSimulator; - export var keyUp: EventSimulator; - export var mouseDown: EventSimulator; - export var mouseEnter: EventSimulator; - export var mouseLeave: EventSimulator; - export var mouseMove: EventSimulator; - export var mouseOut: EventSimulator; - export var mouseOver: EventSimulator; - export var mouseUp: EventSimulator; - export var paste: EventSimulator; - export var scroll: EventSimulator; - export var submit: EventSimulator; - export var touchCancel: EventSimulator; - export var touchEnd: EventSimulator; - export var touchMove: EventSimulator; - export var touchStart: EventSimulator; - export var wheel: EventSimulator; - } - - class ShallowRenderer { - getRenderOutput>(): E; - getRenderOutput(): ReactElement; - render(element: ReactElement, context?: any): void; - unmount(): void; - } + export import addons = __React.__Addons; } diff --git a/react/react-tests.ts b/react/react-tests.ts index 053a17eb9..ef505f85e 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -1,11 +1,31 @@ /// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// import React = require("react"); +import ReactDOM = require("react-dom"); +import ReactDOMServer = require("react-dom/server"); +import createFragment = require("react-addons-create-fragment"); +import CSSTransitionGroup = require("react-addons-css-transition-group"); +import LinkedStateMixin = require("react-addons-linked-state-mixin"); +import Perf = require("react-addons-perf"); +import PureRenderMixin = require("react-addons-pure-render-mixin"); +import shallowCompare = require("react-addons-shallow-compare"); +import TestUtils = require("react-addons-test-utils"); +import TransitionGroup = require("react-addons-transition-group"); +import update = require("react-addons-update"); interface Props extends React.Props { hello: string; world?: string; foo: number; - bar: boolean; } interface State { @@ -29,8 +49,7 @@ var props: Props = { key: 42, ref: "myComponent42", hello: "world", - foo: 42, - bar: true + foo: 42 }; var container: Element; @@ -42,11 +61,10 @@ var container: Element; var ClassicComponent: React.ClassicComponentClass = React.createClass({ getDefaultProps() { - return { + return { hello: undefined, world: "peace", - foo: undefined, - bar: undefined, + foo: undefined }; }, getInitialState() { @@ -68,59 +86,83 @@ var ClassicComponent: React.ClassicComponentClass = }); class ModernComponent extends React.Component - implements React.ChildContextProvider { - + implements MyComponent, React.ChildContextProvider { + static propTypes: React.ValidationMap = { foo: React.PropTypes.number } - + static contextTypes: React.ValidationMap = { someValue: React.PropTypes.string } - + static childContextTypes: React.ValidationMap = { someOtherValue: React.PropTypes.string } - - static defaultProps: Props; - + context: Context; - + getChildContext() { return { someOtherValue: 'foo' } } - + state = { inputValue: this.context.someValue, seconds: this.props.foo } - + reset() { + this._myComponent.reset(); this.setState({ inputValue: this.context.someValue, seconds: this.props.foo }); } - private _input: React.HTMLComponent; - + private _myComponent: MyComponent; + private _input: HTMLInputElement; + render() { return React.DOM.div(null, React.DOM.input({ - ref: input => this._input = input, + ref: input => this._input = input, value: this.state.inputValue })); } + + shouldComponentUpdate(nextProps: Props, nextState: State, nextContext: any): boolean { + return shallowCompare(this, nextProps, nextState); + } } +interface SCProps extends React.Props<{}> { + foo?: number; +} + +var StatelessComponent = (props: SCProps) => { + return React.DOM.div(null, props.foo); +}; + +// Must explicitly type-annotate to add defaultProps/contextTypes +var StatelessComponent2: React.StatelessComponent = + (props: SCProps) => React.DOM.div(null, props.foo); +StatelessComponent2.defaultProps = { + foo: 42 +}; + // React.createFactory var factory: React.Factory = React.createFactory(ModernComponent); var factoryElement: React.ReactElement = factory(props); +var statelessFactory: React.Factory = + React.createFactory(StatelessComponent); +var statelessElement: React.ReactElement = + statelessFactory(props); + var classicFactory: React.ClassicFactory = React.createFactory(ClassicComponent); var classicFactoryElement: React.ClassicElement = @@ -134,36 +176,39 @@ var domFactoryElement: React.DOMElement = // React.createElement var element: React.ReactElement = React.createElement(ModernComponent, props); +var statelessElement: React.ReactElement = + React.createElement(StatelessComponent, props); var classicElement: React.ClassicElement = React.createElement(ClassicComponent, props); -var domElement: React.HTMLElement = +var domElement: React.ReactHTMLElement = React.createElement("div"); // React.cloneElement var clonedElement: React.ReactElement = React.cloneElement(element, props); +var clonedStatelessElement: React.ReactElement = + React.cloneElement(statelessElement, props); var clonedClassicElement: React.ClassicElement = React.cloneElement(classicElement, props); -var clonedDOMElement: React.HTMLElement = +var clonedDOMElement: React.ReactHTMLElement = React.cloneElement(domElement); // React.render var component: React.Component = - React.render(element, container); + ReactDOM.render(element, container); var classicComponent: React.ClassicComponent = - React.render(classicElement, container); -var domComponent: React.DOMComponent = - React.render(domElement, container); + ReactDOM.render(classicElement, container); +var domComponent: Element = + ReactDOM.render(domElement, container); // Other Top-Level API -var unmounted: boolean = React.unmountComponentAtNode(container); -var str: string = React.renderToString(element); -var markup: string = React.renderToStaticMarkup(element); +var unmounted: boolean = ReactDOM.unmountComponentAtNode(container); +var str: string = ReactDOMServer.renderToString(element); +var markup: string = ReactDOMServer.renderToStaticMarkup(element); var notValid: boolean = React.isValidElement(props); // false var isValid = React.isValidElement(element); // true -React.initializeTouchEvents(true); -var domNode: Element = React.findDOMNode(component); -domNode = React.findDOMNode(domNode); +var domNode: Element = ReactDOM.findDOMNode(component); +domNode = ReactDOM.findDOMNode(domNode); // // React Elements @@ -191,16 +236,42 @@ component.setState({ inputValue: "!!!" }); component.forceUpdate(); // classic -var htmlElement: Element = classicComponent.getDOMNode(); -var divElement: HTMLDivElement = classicComponent.getDOMNode(); var isMounted: boolean = classicComponent.isMounted(); -classicComponent.setProps(elementProps); -classicComponent.replaceProps(props); classicComponent.replaceState({ inputValue: "???", seconds: 60 }); var myComponent = component; myComponent.reset(); +// +// Refs +// NB: to infer the correct type for callback refs, your component's Props +// interface must extend React.Props where T is your component type (or +// an interface that it implements). +// -------------------------------------------------------------------------- + +interface RCProps extends React.Props { +} + +class RefComponent extends React.Component { + static create = React.createFactory(RefComponent); + refMethod() { + } +} + +var componentRef: RefComponent; +RefComponent.create({ ref: "componentRef" }); +// type of c should be inferred +RefComponent.create({ ref: c => componentRef = c }); +componentRef.refMethod(); + +var domNodeRef: Element; +React.DOM.div({ ref: "domRef" }); +// type of node should be inferred +React.DOM.div({ ref: node => domNodeRef = node }); + +var inputNodeRef: HTMLInputElement; +React.DOM.input({ ref: node => inputNodeRef = node }); + // // Attributes // -------------------------------------------------------------------------- @@ -210,7 +281,7 @@ var divStyle: React.CSSProperties = { // CSSProperties flex: "1 1 main-size", backgroundImage: "url('hello.png')" }; -var htmlAttr: React.HTMLAttributes = { +var htmlAttr: React.HTMLProps = { key: 36, ref: "htmlComponent", children: children, @@ -329,11 +400,12 @@ var ContextTypesSpecification: React.ComponentSpec = { // React.Children // -------------------------------------------------------------------------- -var childMap: { [key: string]: number } = +var mappedChildrenArray: number[] = React.Children.map(children, (child) => { return 42; }); React.Children.forEach(children, (child) => {}); var nChildren: number = React.Children.count(children); var onlyChild = React.Children.only([null, [[["Hallo"], true]], false]); +var childrenToArray: React.ReactChild[] = React.Children.toArray(children); // // Example from http://facebook.github.io/react/ @@ -366,5 +438,121 @@ class Timer extends React.Component<{}, TimerState> { ); } } -React.render(React.createElement(Timer), container); +ReactDOM.render(React.createElement(Timer), container); +// +// createFragment addon +// -------------------------------------------------------------------------- +createFragment({ + a: React.DOM.div(), + b: ["a", false, React.createElement("span")] +}); + +// +// CSSTransitionGroup addon +// -------------------------------------------------------------------------- +React.createFactory(CSSTransitionGroup)({ + component: React.createClass({ + render: (): React.ReactElement => null + }), + childFactory: (c) => c, + transitionName: "transition", + transitionAppear: false, + transitionEnter: true, + transitionLeave: true +}); + +React.createFactory(CSSTransitionGroup)({ + transitionName: { + enter: "enter", + enterActive: "enterActive", + leave: "leave", + leaveActive: "leaveActive", + appear: "appear", + appearActive: "appearActive" + } +}); + +// +// LinkedStateMixin addon +// -------------------------------------------------------------------------- +React.createClass({ + mixins: [LinkedStateMixin], + getInitialState: function() { + return { + isChecked: false, + message: "hello!" + }; + }, + render: function() { + return React.DOM.div(null, + React.DOM.input({ + type: "checkbox", + checkedLink: this.linkState("isChecked") + }), + React.DOM.input({ + type: "text", + valueLink: this.linkState("message") + }) + ); + } +}); + +// +// Perf addon +// -------------------------------------------------------------------------- +Perf.start(); +Perf.stop(); +var measurements = Perf.getLastMeasurements(); +Perf.printInclusive(measurements); +Perf.printExclusive(measurements); +Perf.printWasted(measurements); +Perf.printDOM(measurements); + +// +// PureRenderMixin addon +// -------------------------------------------------------------------------- +React.createClass({ + mixins: [PureRenderMixin], + render: function() { return React.DOM.div(null) } +}); + +// +// TestUtils addon +// -------------------------------------------------------------------------- +var node: Element; +TestUtils.Simulate.click(node); +TestUtils.Simulate.change(node); +TestUtils.Simulate.keyDown(node, { key: "Enter" }); + +var renderer: React.ShallowRenderer = + TestUtils.createRenderer(); +renderer.render(React.createElement(Timer)); +var output: React.ReactElement> = + renderer.getRenderOutput(); + +// +// TransitionGroup addon +// -------------------------------------------------------------------------- +React.createFactory(TransitionGroup)({ component: "div" }); + +// +// update addon +// -------------------------------------------------------------------------- +{ +// These are copied from https://facebook.github.io/react/docs/update.html +let initialArray = [1, 2, 3]; +let newArray = update(initialArray, {$push: [4]}); // => [1, 2, 3, 4] + +let collection = [1, 2, {a: [12, 17, 15]}]; +let newCollection = update(collection, {2: {a: {$splice: [[1, 1, 13, 14]]}}}); +// => [1, 2, {a: [12, 13, 14, 15]}] + +let obj = {a: 5, b: 3}; +let newObj = update(obj, {b: {$apply: function(x) {return x * 2;}}}); +// => {a: 5, b: 6} +let newObj2 = update(obj, {b: {$set: obj.b * 2}}); + +let objShallow = {a: 5, b: 3}; +let newObjShallow = update(obj, {$merge: {b: 6, c: 7}}); // => {a: 5, b: 6, c: 7} +} diff --git a/react/react.d.ts b/react/react.d.ts index 25a3a30b9..e3d0f43f7 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -1,4 +1,4 @@ -// Type definitions for React v0.13.3 +// Type definitions for React v0.14 // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -8,27 +8,32 @@ declare namespace __React { // React Elements // ---------------------------------------------------------------------- - type ReactType = ComponentClass | string; + type ReactType = string | ComponentClass | StatelessComponent; - interface ReactElement

{ - type: string | ComponentClass

; + interface ReactElement

> { + type: string | ComponentClass

| StatelessComponent

; props: P; key: string | number; - ref: string | ((component: Component) => any); + ref: string | ((component: Component | Element) => any); } interface ClassicElement

extends ReactElement

{ - type: string | ClassicComponentClass

; + type: ClassicComponentClass

; ref: string | ((component: ClassicComponent) => any); } - interface DOMElement

extends ClassicElement

{ + interface DOMElement

> extends ReactElement

{ type: string; - ref: string | ((component: DOMComponent

) => any); + ref: string | ((element: Element) => any); } - type HTMLElement = DOMElement; - type SVGElement = DOMElement; + interface ReactHTMLElement extends DOMElement { + ref: string | ((element: HTMLElement) => any); + } + + interface ReactSVGElement extends DOMElement { + ref: string | ((element: SVGElement) => any); + } // // Factories @@ -42,13 +47,12 @@ declare namespace __React { (props?: P, ...children: ReactNode[]): ClassicElement

; } - interface DOMFactory

extends ClassicFactory

{ + interface DOMFactory

> extends Factory

{ (props?: P, ...children: ReactNode[]): DOMElement

; } - type HTMLFactory = DOMFactory; - type SVGFactory = DOMFactory; - type SVGElementFactory = DOMFactory; + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; // // React Nodes @@ -69,19 +73,19 @@ declare namespace __React { function createClass(spec: ComponentSpec): ClassicComponentClass

; function createFactory

(type: string): DOMFactory

; - function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; - function createFactory

(type: ComponentClass

): Factory

; + function createFactory

(type: ClassicComponentClass

): ClassicFactory

; + function createFactory

(type: ComponentClass

| StatelessComponent

): Factory

; function createElement

( type: string, props?: P, ...children: ReactNode[]): DOMElement

; function createElement

( - type: ClassicComponentClass

| string, + type: ClassicComponentClass

, props?: P, ...children: ReactNode[]): ClassicElement

; function createElement

( - type: ComponentClass

, + type: ComponentClass

| StatelessComponent

, props?: P, ...children: ReactNode[]): ReactElement

; @@ -98,29 +102,7 @@ declare namespace __React { props?: P, ...children: ReactNode[]): ReactElement

; - function render

( - element: DOMElement

, - container: Element, - callback?: () => any): DOMComponent

; - function render( - element: ClassicElement

, - container: Element, - callback?: () => any): ClassicComponent; - function render( - element: ReactElement

, - container: Element, - callback?: () => any): Component; - - function unmountComponentAtNode(container: Element): boolean; - function renderToString(element: ReactElement): string; - function renderToStaticMarkup(element: ReactElement): string; function isValidElement(object: {}): boolean; - function initializeTouchEvents(shouldUseTouch: boolean): void; - - function findDOMNode( - componentOrElement: Component | Element): TElement; - function findDOMNode( - componentOrElement: Component | Element): Element; var DOM: ReactDOM; var PropTypes: ReactPropTypes; @@ -130,13 +112,10 @@ declare namespace __React { // Component API // ---------------------------------------------------------------------- + type ReactInstance = Component | Element; + // Base component for plain JS classes class Component implements ComponentLifecycle { - static propTypes: ValidationMap; - static contextTypes: ValidationMap; - static childContextTypes: ValidationMap; - static defaultProps: Props; - constructor(props?: P, context?: any); setState(f: (prevState: S, props: P) => S, callback?: () => any): void; setState(state: S, callback?: () => any): void; @@ -146,27 +125,16 @@ declare namespace __React { state: S; context: {}; refs: { - [key: string]: Component + [key: string]: ReactInstance }; } interface ClassicComponent extends Component { replaceState(nextState: S, callback?: () => any): void; - getDOMNode(): TElement; - getDOMNode(): Element; isMounted(): boolean; getInitialState?(): S; - setProps(nextProps: P, callback?: () => any): void; - replaceProps(nextProps: P, callback?: () => any): void; } - interface DOMComponent

extends ClassicComponent { - tagName: string; - } - - type HTMLComponent = DOMComponent; - type SVGComponent = DOMComponent; - interface ChildContextProvider { getChildContext(): CC; } @@ -175,6 +143,13 @@ declare namespace __React { // Class Interfaces // ---------------------------------------------------------------------- + interface StatelessComponent

{ + (props?: P, context?: any): ReactElement; + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + defaultProps?: P; + } + interface ComponentClass

{ new(props?: P, context?: any): Component; propTypes?: ValidationMap

; @@ -243,12 +218,23 @@ declare namespace __React { type: string; } + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface CompositionEvent extends SyntheticEvent { + data: string; + } + interface DragEvent extends SyntheticEvent { dataTransfer: DataTransfer; } - interface ClipboardEvent extends SyntheticEvent { - clipboardData: DataTransfer; + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { } interface KeyboardEvent extends SyntheticEvent { @@ -266,13 +252,6 @@ declare namespace __React { which: number; } - interface FocusEvent extends SyntheticEvent { - relatedTarget: EventTarget; - } - - interface FormEvent extends SyntheticEvent { - } - interface MouseEvent extends SyntheticEvent { altKey: boolean; button: number; @@ -313,8 +292,6 @@ declare namespace __React { deltaZ: number; } - interface LoadEvent extends SyntheticEvent {} - // // Event Handler Types // ---------------------------------------------------------------------- @@ -323,16 +300,18 @@ declare namespace __React { (event: E): void; } - interface DragEventHandler extends EventHandler {} - interface ClipboardEventHandler extends EventHandler {} - interface KeyboardEventHandler extends EventHandler {} - interface FocusEventHandler extends EventHandler {} - interface FormEventHandler extends EventHandler {} - interface MouseEventHandler extends EventHandler {} - interface TouchEventHandler extends EventHandler {} - interface UIEventHandler extends EventHandler {} - interface WheelEventHandler extends EventHandler {} - interface LoadEventHandler extends EventHandler {} + type ReactEventHandler = EventHandler; + + type ClipboardEventHandler = EventHandler; + type CompositionEventHandler = EventHandler; + type DragEventHandler = EventHandler; + type FocusEventHandler = EventHandler; + type FormEventHandler = EventHandler; + type KeyboardEventHandler = EventHandler; + type MouseEventHandler = EventHandler; + type TouchEventHandler = EventHandler; + type UIEventHandler = EventHandler; + type WheelEventHandler = EventHandler; // // Props / DOM Attributes @@ -344,18 +323,70 @@ declare namespace __React { ref?: string | ((component: T) => any); } - interface DOMAttributesBase extends Props { + interface HTMLProps extends HTMLAttributes, Props { + } + + interface SVGProps extends SVGAttributes, Props { + } + + interface DOMAttributes { + dangerouslySetInnerHTML?: { + __html: string; + }; + + // Clipboard Events onCopy?: ClipboardEventHandler; onCut?: ClipboardEventHandler; onPaste?: ClipboardEventHandler; - onKeyDown?: KeyboardEventHandler; - onKeyPress?: KeyboardEventHandler; - onKeyUp?: KeyboardEventHandler; + + // Composition Events + onCompositionEnd?: CompositionEventHandler; + onCompositionStart?: CompositionEventHandler; + onCompositionUpdate?: CompositionEventHandler; + + // Focus Events onFocus?: FocusEventHandler; onBlur?: FocusEventHandler; + + // Form Events onChange?: FormEventHandler; onInput?: FormEventHandler; onSubmit?: FormEventHandler; + + // Image Events + onLoad?: ReactEventHandler; + onError?: ReactEventHandler; // also a Media Event + + // Keyboard Events + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + + // Media Events + onAbort?: ReactEventHandler; + onCanPlay?: ReactEventHandler; + onCanPlayThrough?: ReactEventHandler; + onDurationChange?: ReactEventHandler; + onEmptied?: ReactEventHandler; + onEncrypted?: ReactEventHandler; + onEnded?: ReactEventHandler; + onLoadedData?: ReactEventHandler; + onLoadedMetadata?: ReactEventHandler; + onLoadStart?: ReactEventHandler; + onPause?: ReactEventHandler; + onPlay?: ReactEventHandler; + onPlaying?: ReactEventHandler; + onProgress?: ReactEventHandler; + onRateChange?: ReactEventHandler; + onSeeked?: ReactEventHandler; + onSeeking?: ReactEventHandler; + onStalled?: ReactEventHandler; + onSuspend?: ReactEventHandler; + onTimeUpdate?: ReactEventHandler; + onVolumeChange?: ReactEventHandler; + onWaiting?: ReactEventHandler; + + // MouseEvents onClick?: MouseEventHandler; onContextMenu?: MouseEventHandler; onDoubleClick?: MouseEventHandler; @@ -374,23 +405,21 @@ declare namespace __React { onMouseOut?: MouseEventHandler; onMouseOver?: MouseEventHandler; onMouseUp?: MouseEventHandler; + + // Selection Events + onSelect?: ReactEventHandler; + + // Touch Events onTouchCancel?: TouchEventHandler; onTouchEnd?: TouchEventHandler; onTouchMove?: TouchEventHandler; onTouchStart?: TouchEventHandler; + + // UI Events onScroll?: UIEventHandler; + + // Wheel Events onWheel?: WheelEventHandler; - onLoad?: LoadEventHandler; - - className?: string; - id?: string; - - dangerouslySetInnerHTML?: { - __html: string; - }; - } - - interface DOMAttributes extends DOMAttributesBase> { } // This interface is not complete. Only properties accepting @@ -422,7 +451,12 @@ declare namespace __React { [propertyName: string]: any; } - interface HTMLAttributesBase extends DOMAttributesBase { + interface HTMLAttributes extends DOMAttributes { + // React-specific Attributes + defaultChecked?: boolean; + defaultValue?: string | string[]; + + // Standard HTML Attributes accept?: string; acceptCharset?: string; accessKey?: string; @@ -434,23 +468,25 @@ declare namespace __React { autoComplete?: string; autoFocus?: boolean; autoPlay?: boolean; + capture?: boolean; cellPadding?: number | string; cellSpacing?: number | string; charSet?: string; + challenge?: string; checked?: boolean; classID?: string; + className?: string; cols?: number; colSpan?: number; content?: string; contentEditable?: boolean; contextMenu?: string; - controls?: any; + controls?: boolean; coords?: string; crossOrigin?: string; data?: string; dateTime?: string; - defaultChecked?: boolean; - defaultValue?: string; + default?: boolean; defer?: boolean; dir?: string; disabled?: boolean; @@ -473,6 +509,13 @@ declare namespace __React { htmlFor?: string; httpEquiv?: string; icon?: string; + id?: string; + inputMode?: string; + integrity?: string; + is?: string; + keyParams?: string; + keyType?: string; + kind?: string; label?: string; lang?: string; list?: string; @@ -487,6 +530,7 @@ declare namespace __React { mediaGroup?: string; method?: string; min?: number | string; + minLength?: number; multiple?: boolean; muted?: boolean; name?: string; @@ -517,40 +561,49 @@ declare namespace __React { spellCheck?: boolean; src?: string; srcDoc?: string; + srcLang?: string; srcSet?: string; start?: number; step?: number | string; style?: CSSProperties; + summary?: string; tabIndex?: number; target?: string; title?: string; type?: string; useMap?: string; - value?: string; + value?: string | string[]; width?: number | string; wmode?: string; + wrap?: string; + + // RDFa Attributes + about?: string; + datatype?: string; + inlist?: any; + prefix?: string; + property?: string; + resource?: string; + typeof?: string; + vocab?: string; // Non-standard Attributes autoCapitalize?: boolean; - autoCorrect?: boolean; - property?: string; + autoCorrect?: string; + autoSave?: string; + color?: string; itemProp?: string; itemScope?: boolean; itemType?: string; + itemID?: string; + itemRef?: string; + results?: number; + security?: string; unselectable?: boolean; } - interface HTMLAttributes extends HTMLAttributesBase { - } - - interface SVGElementAttributes extends HTMLAttributes { - viewBox?: string; - preserveAspectRatio?: string; - } - - interface SVGAttributes extends DOMAttributes { - ref?: string | ((component: SVGComponent) => void); - + interface SVGAttributes extends HTMLAttributes { + clipPath?: string; cx?: number | string; cy?: number | string; d?: string; @@ -564,7 +617,6 @@ declare namespace __React { fy?: number | string; gradientTransform?: string; gradientUnits?: string; - height?: number | string; markerEnd?: string; markerMid?: string; markerStart?: string; @@ -583,17 +635,25 @@ declare namespace __React { stroke?: string; strokeDasharray?: string; strokeLinecap?: string; - strokeMiterlimit?: string; strokeOpacity?: number | string; strokeWidth?: number | string; textAnchor?: string; transform?: string; version?: string; viewBox?: string; - width?: number | string; x1?: number | string; x2?: number | string; x?: number | string; + xlinkActuate?: string; + xlinkArcrole?: string; + xlinkHref?: string; + xlinkRole?: string; + xlinkShow?: string; + xlinkTitle?: string; + xlinkType?: string; + xmlBase?: string; + xmlLang?: string; + xmlSpace?: string; y1?: number | string; y2?: number | string y?: number | string; @@ -719,11 +779,12 @@ declare namespace __React { wbr: HTMLFactory; // SVG - svg: SVGElementFactory; + svg: SVGFactory; circle: SVGFactory; defs: SVGFactory; ellipse: SVGFactory; g: SVGFactory; + image: SVGFactory; line: SVGFactory; linearGradient: SVGFactory; mask: SVGFactory; @@ -777,10 +838,11 @@ declare namespace __React { // ---------------------------------------------------------------------- interface ReactChildren { - map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T }; + map(children: ReactNode, fn: (child: ReactChild, index: number) => T): T[]; forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; count(children: ReactNode): number; only(children: ReactNode): ReactChild; + toArray(children: ReactNode): ReactChild[]; } // @@ -816,1085 +878,6 @@ declare module "react" { export = __React; } -declare module "react/addons" { - // - // React Elements - // ---------------------------------------------------------------------- - - type ReactType = ComponentClass | string; - - interface ReactElement

{ - type: string | ComponentClass

; - props: P; - key: string | number; - ref: string | ((component: Component) => any); - } - - interface ClassicElement

extends ReactElement

{ - type: string | ClassicComponentClass

; - ref: string | ((component: ClassicComponent) => any); - } - - interface DOMElement

extends ClassicElement

{ - type: string; - ref: string | ((component: DOMComponent

) => any); - } - - type HTMLElement = DOMElement; - type SVGElement = DOMElement; - - // - // Factories - // ---------------------------------------------------------------------- - - interface Factory

{ - (props?: P, ...children: ReactNode[]): ReactElement

; - } - - interface ClassicFactory

extends Factory

{ - (props?: P, ...children: ReactNode[]): ClassicElement

; - } - - interface DOMFactory

extends ClassicFactory

{ - (props?: P, ...children: ReactNode[]): DOMElement

; - } - - type HTMLFactory = DOMFactory; - type SVGFactory = DOMFactory; - type SVGElementFactory = DOMFactory; - - // - // React Nodes - // http://facebook.github.io/react/docs/glossary.html - // ---------------------------------------------------------------------- - - type ReactText = string | number; - type ReactChild = ReactElement | ReactText; - - // Should be Array but type aliases cannot be recursive - type ReactFragment = {} | Array; - type ReactNode = ReactChild | ReactFragment | boolean; - - // - // Top Level API - // ---------------------------------------------------------------------- - - function createClass(spec: ComponentSpec): ClassicComponentClass

; - - function createFactory

(type: string): DOMFactory

; - function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; - function createFactory

(type: ComponentClass

): Factory

; - - function createElement

( - type: string, - props?: P, - ...children: ReactNode[]): DOMElement

; - function createElement

( - type: ClassicComponentClass

| string, - props?: P, - ...children: ReactNode[]): ClassicElement

; - function createElement

( - type: ComponentClass

, - props?: P, - ...children: ReactNode[]): ReactElement

; - - function cloneElement

( - element: DOMElement

, - props?: P, - ...children: ReactNode[]): DOMElement

; - function cloneElement

( - element: ClassicElement

, - props?: P, - ...children: ReactNode[]): ClassicElement

; - function cloneElement

( - element: ReactElement

, - props?: P, - ...children: ReactNode[]): ReactElement

; - - function render

( - element: DOMElement

, - container: Element, - callback?: () => any): DOMComponent

; - function render( - element: ClassicElement

, - container: Element, - callback?: () => any): ClassicComponent; - function render( - element: ReactElement

, - container: Element, - callback?: () => any): Component; - - function unmountComponentAtNode(container: Element): boolean; - function renderToString(element: ReactElement): string; - function renderToStaticMarkup(element: ReactElement): string; - function isValidElement(object: {}): boolean; - function initializeTouchEvents(shouldUseTouch: boolean): void; - - function findDOMNode( - componentOrElement: Component | Element): TElement; - function findDOMNode( - componentOrElement: Component | Element): Element; - - var DOM: ReactDOM; - var PropTypes: ReactPropTypes; - var Children: ReactChildren; - - // - // Component API - // ---------------------------------------------------------------------- - - // Base component for plain JS classes - class Component implements ComponentLifecycle { - static propTypes: ValidationMap; - static contextTypes: ValidationMap; - static childContextTypes: ValidationMap; - static defaultProps: Props; - - constructor(props?: P, context?: any); - setState(f: (prevState: S, props: P) => S, callback?: () => any): void; - setState(state: S, callback?: () => any): void; - forceUpdate(callBack?: () => any): void; - render(): JSX.Element; - props: P; - state: S; - context: {}; - refs: { - [key: string]: Component - }; - } - - interface ClassicComponent extends Component { - replaceState(nextState: S, callback?: () => any): void; - getDOMNode(): TElement; - getDOMNode(): Element; - isMounted(): boolean; - getInitialState?(): S; - setProps(nextProps: P, callback?: () => any): void; - replaceProps(nextProps: P, callback?: () => any): void; - } - - interface DOMComponent

extends ClassicComponent { - tagName: string; - } - - type HTMLComponent = DOMComponent; - type SVGComponent = DOMComponent; - - interface ChildContextProvider { - getChildContext(): CC; - } - - // - // Class Interfaces - // ---------------------------------------------------------------------- - - interface ComponentClass

{ - new(props?: P, context?: any): Component; - propTypes?: ValidationMap

; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap; - defaultProps?: P; - } - - interface ClassicComponentClass

extends ComponentClass

{ - new(props?: P, context?: any): ClassicComponent; - getDefaultProps?(): P; - displayName?: string; - } - - // - // Component Specs and Lifecycle - // ---------------------------------------------------------------------- - - interface ComponentLifecycle { - componentWillMount?(): void; - componentDidMount?(): void; - componentWillReceiveProps?(nextProps: P, nextContext: any): void; - shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; - componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; - componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; - componentWillUnmount?(): void; - } - - interface Mixin extends ComponentLifecycle { - mixins?: Mixin; - statics?: { - [key: string]: any; - }; - - displayName?: string; - propTypes?: ValidationMap; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap - - getDefaultProps?(): P; - getInitialState?(): S; - } - - interface ComponentSpec extends Mixin { - render(): ReactElement; - - [propertyName: string]: any; - } - - // - // Event System - // ---------------------------------------------------------------------- - - interface SyntheticEvent { - bubbles: boolean; - cancelable: boolean; - currentTarget: EventTarget; - defaultPrevented: boolean; - eventPhase: number; - isTrusted: boolean; - nativeEvent: Event; - preventDefault(): void; - stopPropagation(): void; - target: EventTarget; - timeStamp: Date; - type: string; - } - - interface DragEvent extends SyntheticEvent { - dataTransfer: DataTransfer; - } - - interface ClipboardEvent extends SyntheticEvent { - clipboardData: DataTransfer; - } - - interface KeyboardEvent extends SyntheticEvent { - altKey: boolean; - charCode: number; - ctrlKey: boolean; - getModifierState(key: string): boolean; - key: string; - keyCode: number; - locale: string; - location: number; - metaKey: boolean; - repeat: boolean; - shiftKey: boolean; - which: number; - } - - interface FocusEvent extends SyntheticEvent { - relatedTarget: EventTarget; - } - - interface FormEvent extends SyntheticEvent { - } - - interface MouseEvent extends SyntheticEvent { - altKey: boolean; - button: number; - buttons: number; - clientX: number; - clientY: number; - ctrlKey: boolean; - getModifierState(key: string): boolean; - metaKey: boolean; - pageX: number; - pageY: number; - relatedTarget: EventTarget; - screenX: number; - screenY: number; - shiftKey: boolean; - } - - interface TouchEvent extends SyntheticEvent { - altKey: boolean; - changedTouches: TouchList; - ctrlKey: boolean; - getModifierState(key: string): boolean; - metaKey: boolean; - shiftKey: boolean; - targetTouches: TouchList; - touches: TouchList; - } - - interface UIEvent extends SyntheticEvent { - detail: number; - view: AbstractView; - } - - interface WheelEvent extends SyntheticEvent { - deltaMode: number; - deltaX: number; - deltaY: number; - deltaZ: number; - } - - // - // Event Handler Types - // ---------------------------------------------------------------------- - - interface EventHandler { - (event: E): void; - } - - interface DragEventHandler extends EventHandler {} - interface ClipboardEventHandler extends EventHandler {} - interface KeyboardEventHandler extends EventHandler {} - interface FocusEventHandler extends EventHandler {} - interface FormEventHandler extends EventHandler {} - interface MouseEventHandler extends EventHandler {} - interface TouchEventHandler extends EventHandler {} - interface UIEventHandler extends EventHandler {} - interface WheelEventHandler extends EventHandler {} - - // - // Props / DOM Attributes - // ---------------------------------------------------------------------- - - interface Props { - children?: ReactNode; - key?: string | number; - ref?: string | ((component: T) => any); - } - - interface DOMAttributesBase extends Props { - onCopy?: ClipboardEventHandler; - onCut?: ClipboardEventHandler; - onPaste?: ClipboardEventHandler; - onKeyDown?: KeyboardEventHandler; - onKeyPress?: KeyboardEventHandler; - onKeyUp?: KeyboardEventHandler; - onFocus?: FocusEventHandler; - onBlur?: FocusEventHandler; - onChange?: FormEventHandler; - onInput?: FormEventHandler; - onSubmit?: FormEventHandler; - onClick?: MouseEventHandler; - onDoubleClick?: MouseEventHandler; - onDrag?: DragEventHandler; - onDragEnd?: DragEventHandler; - onDragEnter?: DragEventHandler; - onDragExit?: DragEventHandler; - onDragLeave?: DragEventHandler; - onDragOver?: DragEventHandler; - onDragStart?: DragEventHandler; - onDrop?: DragEventHandler; - onMouseDown?: MouseEventHandler; - onMouseEnter?: MouseEventHandler; - onMouseLeave?: MouseEventHandler; - onMouseMove?: MouseEventHandler; - onMouseOut?: MouseEventHandler; - onMouseOver?: MouseEventHandler; - onMouseUp?: MouseEventHandler; - onTouchCancel?: TouchEventHandler; - onTouchEnd?: TouchEventHandler; - onTouchMove?: TouchEventHandler; - onTouchStart?: TouchEventHandler; - onScroll?: UIEventHandler; - onWheel?: WheelEventHandler; - - className?: string; - id?: string; - - dangerouslySetInnerHTML?: { - __html: string; - }; - } - - interface DOMAttributes extends DOMAttributesBase> { - } - - // This interface is not complete. Only properties accepting - // unitless numbers are listed here (see CSSProperty.js in React) - interface CSSProperties { - boxFlex?: number; - boxFlexGroup?: number; - columnCount?: number; - flex?: number | string; - flexGrow?: number; - flexShrink?: number; - fontWeight?: number | string; - lineClamp?: number; - lineHeight?: number | string; - opacity?: number; - order?: number; - orphans?: number; - widows?: number; - zIndex?: number; - zoom?: number; - - fontSize?: number | string; - - // SVG-related properties - fillOpacity?: number; - strokeOpacity?: number; - strokeWidth?: number; - - [propertyName: string]: any; - } - - interface HTMLAttributesBase extends DOMAttributesBase { - accept?: string; - acceptCharset?: string; - accessKey?: string; - action?: string; - allowFullScreen?: boolean; - allowTransparency?: boolean; - alt?: string; - async?: boolean; - autoComplete?: boolean; - autoFocus?: boolean; - autoPlay?: boolean; - cellPadding?: number | string; - cellSpacing?: number | string; - charSet?: string; - checked?: boolean; - classID?: string; - cols?: number; - colSpan?: number; - content?: string; - contentEditable?: boolean; - contextMenu?: string; - controls?: any; - coords?: string; - crossOrigin?: string; - data?: string; - dateTime?: string; - defaultChecked?: boolean; - defaultValue?: string; - defer?: boolean; - dir?: string; - disabled?: boolean; - download?: any; - draggable?: boolean; - encType?: string; - form?: string; - formAction?: string; - formEncType?: string; - formMethod?: string; - formNoValidate?: boolean; - formTarget?: string; - frameBorder?: number | string; - headers?: string; - height?: number | string; - hidden?: boolean; - high?: number; - href?: string; - hrefLang?: string; - htmlFor?: string; - httpEquiv?: string; - icon?: string; - label?: string; - lang?: string; - list?: string; - loop?: boolean; - low?: number; - manifest?: string; - marginHeight?: number; - marginWidth?: number; - max?: number | string; - maxLength?: number; - media?: string; - mediaGroup?: string; - method?: string; - min?: number | string; - multiple?: boolean; - muted?: boolean; - name?: string; - noValidate?: boolean; - open?: boolean; - optimum?: number; - pattern?: string; - placeholder?: string; - poster?: string; - preload?: string; - radioGroup?: string; - readOnly?: boolean; - rel?: string; - required?: boolean; - role?: string; - rows?: number; - rowSpan?: number; - sandbox?: string; - scope?: string; - scoped?: boolean; - scrolling?: string; - seamless?: boolean; - selected?: boolean; - shape?: string; - size?: number; - sizes?: string; - span?: number; - spellCheck?: boolean; - src?: string; - srcDoc?: string; - srcSet?: string; - start?: number; - step?: number | string; - style?: CSSProperties; - tabIndex?: number; - target?: string; - title?: string; - type?: string; - useMap?: string; - value?: string; - width?: number | string; - wmode?: string; - - // Non-standard Attributes - autoCapitalize?: boolean; - autoCorrect?: boolean; - property?: string; - itemProp?: string; - itemScope?: boolean; - itemType?: string; - unselectable?: boolean; - } - - interface HTMLAttributes extends HTMLAttributesBase { - } - - interface SVGElementAttributes extends HTMLAttributes { - viewBox?: string; - preserveAspectRatio?: string; - } - - interface SVGAttributes extends DOMAttributes { - ref?: string | ((component: SVGComponent) => void); - - cx?: number | string; - cy?: number | string; - d?: string; - dx?: number | string; - dy?: number | string; - fill?: string; - fillOpacity?: number | string; - fontFamily?: string; - fontSize?: number | string; - fx?: number | string; - fy?: number | string; - gradientTransform?: string; - gradientUnits?: string; - height?: number | string; - markerEnd?: string; - markerMid?: string; - markerStart?: string; - offset?: number | string; - opacity?: number | string; - patternContentUnits?: string; - patternUnits?: string; - points?: string; - preserveAspectRatio?: string; - r?: number | string; - rx?: number | string; - ry?: number | string; - spreadMethod?: string; - stopColor?: string; - stopOpacity?: number | string; - stroke?: string; - strokeDasharray?: string; - strokeLinecap?: string; - strokeMiterlimit?: string; - strokeOpacity?: number | string; - strokeWidth?: number | string; - textAnchor?: string; - transform?: string; - version?: string; - viewBox?: string; - width?: number | string; - x1?: number | string; - x2?: number | string; - x?: number | string; - y1?: number | string; - y2?: number | string - y?: number | string; - } - - // - // React.DOM - // ---------------------------------------------------------------------- - - interface ReactDOM { - // HTML - a: HTMLFactory; - abbr: HTMLFactory; - address: HTMLFactory; - area: HTMLFactory; - article: HTMLFactory; - aside: HTMLFactory; - audio: HTMLFactory; - b: HTMLFactory; - base: HTMLFactory; - bdi: HTMLFactory; - bdo: HTMLFactory; - big: HTMLFactory; - blockquote: HTMLFactory; - body: HTMLFactory; - br: HTMLFactory; - button: HTMLFactory; - canvas: HTMLFactory; - caption: HTMLFactory; - cite: HTMLFactory; - code: HTMLFactory; - col: HTMLFactory; - colgroup: HTMLFactory; - data: HTMLFactory; - datalist: HTMLFactory; - dd: HTMLFactory; - del: HTMLFactory; - details: HTMLFactory; - dfn: HTMLFactory; - dialog: HTMLFactory; - div: HTMLFactory; - dl: HTMLFactory; - dt: HTMLFactory; - em: HTMLFactory; - embed: HTMLFactory; - fieldset: HTMLFactory; - figcaption: HTMLFactory; - figure: HTMLFactory; - footer: HTMLFactory; - form: HTMLFactory; - h1: HTMLFactory; - h2: HTMLFactory; - h3: HTMLFactory; - h4: HTMLFactory; - h5: HTMLFactory; - h6: HTMLFactory; - head: HTMLFactory; - header: HTMLFactory; - hr: HTMLFactory; - html: HTMLFactory; - i: HTMLFactory; - iframe: HTMLFactory; - img: HTMLFactory; - input: HTMLFactory; - ins: HTMLFactory; - kbd: HTMLFactory; - keygen: HTMLFactory; - label: HTMLFactory; - legend: HTMLFactory; - li: HTMLFactory; - link: HTMLFactory; - main: HTMLFactory; - map: HTMLFactory; - mark: HTMLFactory; - menu: HTMLFactory; - menuitem: HTMLFactory; - meta: HTMLFactory; - meter: HTMLFactory; - nav: HTMLFactory; - noscript: HTMLFactory; - object: HTMLFactory; - ol: HTMLFactory; - optgroup: HTMLFactory; - option: HTMLFactory; - output: HTMLFactory; - p: HTMLFactory; - param: HTMLFactory; - picture: HTMLFactory; - pre: HTMLFactory; - progress: HTMLFactory; - q: HTMLFactory; - rp: HTMLFactory; - rt: HTMLFactory; - ruby: HTMLFactory; - s: HTMLFactory; - samp: HTMLFactory; - script: HTMLFactory; - section: HTMLFactory; - select: HTMLFactory; - small: HTMLFactory; - source: HTMLFactory; - span: HTMLFactory; - strong: HTMLFactory; - style: HTMLFactory; - sub: HTMLFactory; - summary: HTMLFactory; - sup: HTMLFactory; - table: HTMLFactory; - tbody: HTMLFactory; - td: HTMLFactory; - textarea: HTMLFactory; - tfoot: HTMLFactory; - th: HTMLFactory; - thead: HTMLFactory; - time: HTMLFactory; - title: HTMLFactory; - tr: HTMLFactory; - track: HTMLFactory; - u: HTMLFactory; - ul: HTMLFactory; - "var": HTMLFactory; - video: HTMLFactory; - wbr: HTMLFactory; - - // SVG - svg: SVGElementFactory; - circle: SVGFactory; - defs: SVGFactory; - ellipse: SVGFactory; - g: SVGFactory; - line: SVGFactory; - linearGradient: SVGFactory; - mask: SVGFactory; - path: SVGFactory; - pattern: SVGFactory; - polygon: SVGFactory; - polyline: SVGFactory; - radialGradient: SVGFactory; - rect: SVGFactory; - stop: SVGFactory; - text: SVGFactory; - tspan: SVGFactory; - } - - // - // React.PropTypes - // ---------------------------------------------------------------------- - - interface Validator { - (object: T, key: string, componentName: string): Error; - } - - interface Requireable extends Validator { - isRequired: Validator; - } - - interface ValidationMap { - [key: string]: Validator; - } - - interface ReactPropTypes { - any: Requireable; - array: Requireable; - bool: Requireable; - func: Requireable; - number: Requireable; - object: Requireable; - string: Requireable; - node: Requireable; - element: Requireable; - instanceOf(expectedClass: {}): Requireable; - oneOf(types: any[]): Requireable; - oneOfType(types: Validator[]): Requireable; - arrayOf(type: Validator): Requireable; - objectOf(type: Validator): Requireable; - shape(type: ValidationMap): Requireable; - } - - // - // React.Children - // ---------------------------------------------------------------------- - - interface ReactChildren { - map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T }; - forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; - count(children: ReactNode): number; - only(children: ReactNode): ReactChild; - } - - // - // Browser Interfaces - // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts - // ---------------------------------------------------------------------- - - interface AbstractView { - styleMedia: StyleMedia; - document: Document; - } - - interface Touch { - identifier: number; - target: EventTarget; - screenX: number; - screenY: number; - clientX: number; - clientY: number; - pageX: number; - pageY: number; - } - - interface TouchList { - [index: number]: Touch; - length: number; - item(index: number): Touch; - identifiedTouch(identifier: number): Touch; - } - - // - // React.addons - // ---------------------------------------------------------------------- - - export module addons { - export var CSSTransitionGroup: CSSTransitionGroup; - export var TransitionGroup: TransitionGroup; - - export var LinkedStateMixin: LinkedStateMixin; - export var PureRenderMixin: PureRenderMixin; - - export function batchedUpdates( - callback: (a: A, b: B) => any, a: A, b: B): void; - export function batchedUpdates(callback: (a: A) => any, a: A): void; - export function batchedUpdates(callback: () => any): void; - - // deprecated: use petehunt/react-classset or JedWatson/classnames - export function classSet(cx: { [key: string]: boolean }): string; - export function classSet(...classList: string[]): string; - - export function cloneWithProps

( - element: DOMElement

, props: P): DOMElement

; - export function cloneWithProps

( - element: ClassicElement

, props: P): ClassicElement

; - export function cloneWithProps

( - element: ReactElement

, props: P): ReactElement

; - - export function createFragment( - object: { [key: string]: ReactNode }): ReactFragment; - - export function update(value: any[], spec: UpdateArraySpec): any[]; - export function update(value: {}, spec: UpdateSpec): any; - - // Development tools - export import Perf = ReactPerf; - export import TestUtils = ReactTestUtils; - } - - // - // React.addons (Transitions) - // ---------------------------------------------------------------------- - - interface TransitionGroupProps { - component?: ReactType; - childFactory?: (child: ReactElement) => ReactElement; - } - - interface CSSTransitionGroupProps extends TransitionGroupProps { - transitionName: string; - transitionAppear?: boolean; - transitionEnter?: boolean; - transitionLeave?: boolean; - } - - type CSSTransitionGroup = ComponentClass; - type TransitionGroup = ComponentClass; - - // - // React.addons (Mixins) - // ---------------------------------------------------------------------- - - interface ReactLink { - value: T; - requestChange(newValue: T): void; - } - - interface LinkedStateMixin extends Mixin { - linkState(key: string): ReactLink; - } - - interface PureRenderMixin extends Mixin { - } - - // - // Reat.addons.update - // ---------------------------------------------------------------------- - - interface UpdateSpecCommand { - $set?: any; - $merge?: {}; - $apply?(value: any): any; - } - - interface UpdateSpecPath { - [key: string]: UpdateSpec; - } - - type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; - - interface UpdateArraySpec extends UpdateSpecCommand { - $push?: any[]; - $unshift?: any[]; - $splice?: any[][]; - } - - // - // React.addons.Perf - // ---------------------------------------------------------------------- - - interface ComponentPerfContext { - current: string; - owner: string; - } - - interface NumericPerfContext { - [key: string]: number; - } - - interface Measurements { - exclusive: NumericPerfContext; - inclusive: NumericPerfContext; - render: NumericPerfContext; - counts: NumericPerfContext; - writes: NumericPerfContext; - displayNames: { - [key: string]: ComponentPerfContext; - }; - totalTime: number; - } - - module ReactPerf { - export function start(): void; - export function stop(): void; - export function printInclusive(measurements: Measurements[]): void; - export function printExclusive(measurements: Measurements[]): void; - export function printWasted(measurements: Measurements[]): void; - export function printDOM(measurements: Measurements[]): void; - export function getLastMeasurements(): Measurements[]; - } - - // - // React.addons.TestUtils - // ---------------------------------------------------------------------- - - interface MockedComponentClass { - new(): any; - } - - module ReactTestUtils { - export import Simulate = ReactSimulate; - - export function renderIntoDocument

( - element: ReactElement

): Component; - export function renderIntoDocument>( - element: ReactElement): C; - - export function mockComponent( - mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; - - export function isElementOfType( - element: ReactElement, type: ReactType): boolean; - export function isTextComponent(instance: Component): boolean; - export function isDOMComponent(instance: Component): boolean; - export function isCompositeComponent(instance: Component): boolean; - export function isCompositeComponentWithType( - instance: Component, - type: ComponentClass): boolean; - - export function findAllInRenderedTree( - tree: Component, - fn: (i: Component) => boolean): Component; - - export function scryRenderedDOMComponentsWithClass( - tree: Component, - className: string): DOMComponent[]; - export function findRenderedDOMComponentWithClass( - tree: Component, - className: string): DOMComponent; - - export function scryRenderedDOMComponentsWithTag( - tree: Component, - tagName: string): DOMComponent[]; - export function findRenderedDOMComponentWithTag( - tree: Component, - tagName: string): DOMComponent; - - export function scryRenderedComponentsWithType

( - tree: Component, - type: ComponentClass

): Component[]; - export function scryRenderedComponentsWithType>( - tree: Component, - type: ComponentClass): C[]; - - export function findRenderedComponentWithType

( - tree: Component, - type: ComponentClass

): Component; - export function findRenderedComponentWithType>( - tree: Component, - type: ComponentClass): C; - - export function createRenderer(): ShallowRenderer; - } - - interface SyntheticEventData { - altKey?: boolean; - button?: number; - buttons?: number; - clientX?: number; - clientY?: number; - changedTouches?: TouchList; - charCode?: boolean; - clipboardData?: DataTransfer; - ctrlKey?: boolean; - deltaMode?: number; - deltaX?: number; - deltaY?: number; - deltaZ?: number; - detail?: number; - getModifierState?(key: string): boolean; - key?: string; - keyCode?: number; - locale?: string; - location?: number; - metaKey?: boolean; - pageX?: number; - pageY?: number; - relatedTarget?: EventTarget; - repeat?: boolean; - screenX?: number; - screenY?: number; - shiftKey?: boolean; - targetTouches?: TouchList; - touches?: TouchList; - view?: AbstractView; - which?: number; - } - - interface EventSimulator { - (element: Element, eventData?: SyntheticEventData): void; - (component: Component, eventData?: SyntheticEventData): void; - } - - module ReactSimulate { - export var blur: EventSimulator; - export var change: EventSimulator; - export var click: EventSimulator; - export var cut: EventSimulator; - export var doubleClick: EventSimulator; - export var drag: EventSimulator; - export var dragEnd: EventSimulator; - export var dragEnter: EventSimulator; - export var dragExit: EventSimulator; - export var dragLeave: EventSimulator; - export var dragOver: EventSimulator; - export var dragStart: EventSimulator; - export var drop: EventSimulator; - export var focus: EventSimulator; - export var input: EventSimulator; - export var keyDown: EventSimulator; - export var keyPress: EventSimulator; - export var keyUp: EventSimulator; - export var mouseDown: EventSimulator; - export var mouseEnter: EventSimulator; - export var mouseLeave: EventSimulator; - export var mouseMove: EventSimulator; - export var mouseOut: EventSimulator; - export var mouseOver: EventSimulator; - export var mouseUp: EventSimulator; - export var paste: EventSimulator; - export var scroll: EventSimulator; - export var submit: EventSimulator; - export var touchCancel: EventSimulator; - export var touchEnd: EventSimulator; - export var touchMove: EventSimulator; - export var touchStart: EventSimulator; - export var wheel: EventSimulator; - } - - class ShallowRenderer { - getRenderOutput>(): E; - getRenderOutput(): ReactElement; - render(element: ReactElement, context?: any): void; - unmount(): void; - } -} - declare namespace JSX { import React = __React; @@ -1906,137 +889,137 @@ declare namespace JSX { interface IntrinsicElements { // HTML - a: React.HTMLAttributes; - abbr: React.HTMLAttributes; - address: React.HTMLAttributes; - area: React.HTMLAttributes; - article: React.HTMLAttributes; - aside: React.HTMLAttributes; - audio: React.HTMLAttributes; - b: React.HTMLAttributes; - base: React.HTMLAttributes; - bdi: React.HTMLAttributes; - bdo: React.HTMLAttributes; - big: React.HTMLAttributes; - blockquote: React.HTMLAttributes; - body: React.HTMLAttributes; - br: React.HTMLAttributes; - button: React.HTMLAttributes; - canvas: React.HTMLAttributes; - caption: React.HTMLAttributes; - cite: React.HTMLAttributes; - code: React.HTMLAttributes; - col: React.HTMLAttributes; - colgroup: React.HTMLAttributes; - data: React.HTMLAttributes; - datalist: React.HTMLAttributes; - dd: React.HTMLAttributes; - del: React.HTMLAttributes; - details: React.HTMLAttributes; - dfn: React.HTMLAttributes; - dialog: React.HTMLAttributes; - div: React.HTMLAttributes; - dl: React.HTMLAttributes; - dt: React.HTMLAttributes; - em: React.HTMLAttributes; - embed: React.HTMLAttributes; - fieldset: React.HTMLAttributes; - figcaption: React.HTMLAttributes; - figure: React.HTMLAttributes; - footer: React.HTMLAttributes; - form: React.HTMLAttributes; - h1: React.HTMLAttributes; - h2: React.HTMLAttributes; - h3: React.HTMLAttributes; - h4: React.HTMLAttributes; - h5: React.HTMLAttributes; - h6: React.HTMLAttributes; - head: React.HTMLAttributes; - header: React.HTMLAttributes; - hr: React.HTMLAttributes; - html: React.HTMLAttributes; - i: React.HTMLAttributes; - iframe: React.HTMLAttributes; - img: React.HTMLAttributes; - input: React.HTMLAttributes; - ins: React.HTMLAttributes; - kbd: React.HTMLAttributes; - keygen: React.HTMLAttributes; - label: React.HTMLAttributes; - legend: React.HTMLAttributes; - li: React.HTMLAttributes; - link: React.HTMLAttributes; - main: React.HTMLAttributes; - map: React.HTMLAttributes; - mark: React.HTMLAttributes; - menu: React.HTMLAttributes; - menuitem: React.HTMLAttributes; - meta: React.HTMLAttributes; - meter: React.HTMLAttributes; - nav: React.HTMLAttributes; - noscript: React.HTMLAttributes; - object: React.HTMLAttributes; - ol: React.HTMLAttributes; - optgroup: React.HTMLAttributes; - option: React.HTMLAttributes; - output: React.HTMLAttributes; - p: React.HTMLAttributes; - param: React.HTMLAttributes; - picture: React.HTMLAttributes; - pre: React.HTMLAttributes; - progress: React.HTMLAttributes; - q: React.HTMLAttributes; - rp: React.HTMLAttributes; - rt: React.HTMLAttributes; - ruby: React.HTMLAttributes; - s: React.HTMLAttributes; - samp: React.HTMLAttributes; - script: React.HTMLAttributes; - section: React.HTMLAttributes; - select: React.HTMLAttributes; - small: React.HTMLAttributes; - source: React.HTMLAttributes; - span: React.HTMLAttributes; - strong: React.HTMLAttributes; - style: React.HTMLAttributes; - sub: React.HTMLAttributes; - summary: React.HTMLAttributes; - sup: React.HTMLAttributes; - table: React.HTMLAttributes; - tbody: React.HTMLAttributes; - td: React.HTMLAttributes; - textarea: React.HTMLAttributes; - tfoot: React.HTMLAttributes; - th: React.HTMLAttributes; - thead: React.HTMLAttributes; - time: React.HTMLAttributes; - title: React.HTMLAttributes; - tr: React.HTMLAttributes; - track: React.HTMLAttributes; - u: React.HTMLAttributes; - ul: React.HTMLAttributes; - "var": React.HTMLAttributes; - video: React.HTMLAttributes; - wbr: React.HTMLAttributes; + a: React.HTMLProps; + abbr: React.HTMLProps; + address: React.HTMLProps; + area: React.HTMLProps; + article: React.HTMLProps; + aside: React.HTMLProps; + audio: React.HTMLProps; + b: React.HTMLProps; + base: React.HTMLProps; + bdi: React.HTMLProps; + bdo: React.HTMLProps; + big: React.HTMLProps; + blockquote: React.HTMLProps; + body: React.HTMLProps; + br: React.HTMLProps; + button: React.HTMLProps; + canvas: React.HTMLProps; + caption: React.HTMLProps; + cite: React.HTMLProps; + code: React.HTMLProps; + col: React.HTMLProps; + colgroup: React.HTMLProps; + data: React.HTMLProps; + datalist: React.HTMLProps; + dd: React.HTMLProps; + del: React.HTMLProps; + details: React.HTMLProps; + dfn: React.HTMLProps; + dialog: React.HTMLProps; + div: React.HTMLProps; + dl: React.HTMLProps; + dt: React.HTMLProps; + em: React.HTMLProps; + embed: React.HTMLProps; + fieldset: React.HTMLProps; + figcaption: React.HTMLProps; + figure: React.HTMLProps; + footer: React.HTMLProps; + form: React.HTMLProps; + h1: React.HTMLProps; + h2: React.HTMLProps; + h3: React.HTMLProps; + h4: React.HTMLProps; + h5: React.HTMLProps; + h6: React.HTMLProps; + head: React.HTMLProps; + header: React.HTMLProps; + hr: React.HTMLProps; + html: React.HTMLProps; + i: React.HTMLProps; + iframe: React.HTMLProps; + img: React.HTMLProps; + input: React.HTMLProps; + ins: React.HTMLProps; + kbd: React.HTMLProps; + keygen: React.HTMLProps; + label: React.HTMLProps; + legend: React.HTMLProps; + li: React.HTMLProps; + link: React.HTMLProps; + main: React.HTMLProps; + map: React.HTMLProps; + mark: React.HTMLProps; + menu: React.HTMLProps; + menuitem: React.HTMLProps; + meta: React.HTMLProps; + meter: React.HTMLProps; + nav: React.HTMLProps; + noscript: React.HTMLProps; + object: React.HTMLProps; + ol: React.HTMLProps; + optgroup: React.HTMLProps; + option: React.HTMLProps; + output: React.HTMLProps; + p: React.HTMLProps; + param: React.HTMLProps; + picture: React.HTMLProps; + pre: React.HTMLProps; + progress: React.HTMLProps; + q: React.HTMLProps; + rp: React.HTMLProps; + rt: React.HTMLProps; + ruby: React.HTMLProps; + s: React.HTMLProps; + samp: React.HTMLProps; + script: React.HTMLProps; + section: React.HTMLProps; + select: React.HTMLProps; + small: React.HTMLProps; + source: React.HTMLProps; + span: React.HTMLProps; + strong: React.HTMLProps; + style: React.HTMLProps; + sub: React.HTMLProps; + summary: React.HTMLProps; + sup: React.HTMLProps; + table: React.HTMLProps; + tbody: React.HTMLProps; + td: React.HTMLProps; + textarea: React.HTMLProps; + tfoot: React.HTMLProps; + th: React.HTMLProps; + thead: React.HTMLProps; + time: React.HTMLProps; + title: React.HTMLProps; + tr: React.HTMLProps; + track: React.HTMLProps; + u: React.HTMLProps; + ul: React.HTMLProps; + "var": React.HTMLProps; + video: React.HTMLProps; + wbr: React.HTMLProps; // SVG - svg: React.SVGElementAttributes; - - circle: React.SVGAttributes; - defs: React.SVGAttributes; - ellipse: React.SVGAttributes; - g: React.SVGAttributes; - line: React.SVGAttributes; - linearGradient: React.SVGAttributes; - mask: React.SVGAttributes; - path: React.SVGAttributes; - pattern: React.SVGAttributes; - polygon: React.SVGAttributes; - polyline: React.SVGAttributes; - radialGradient: React.SVGAttributes; - rect: React.SVGAttributes; - stop: React.SVGAttributes; - text: React.SVGAttributes; - tspan: React.SVGAttributes; + circle: React.SVGProps; + defs: React.SVGProps; + ellipse: React.SVGProps; + g: React.SVGProps; + image: React.SVGProps; + line: React.SVGProps; + linearGradient: React.SVGProps; + mask: React.SVGProps; + path: React.SVGProps; + pattern: React.SVGProps; + polygon: React.SVGProps; + polyline: React.SVGProps; + radialGradient: React.SVGProps; + rect: React.SVGProps; + stop: React.SVGProps; + svg: React.SVGProps; + text: React.SVGProps; + tspan: React.SVGProps; } }