mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge remote-tracking branch 'refs/remotes/DefinitelyTyped/master'
This commit is contained in:
Vendored
+1
@@ -110,6 +110,7 @@ declare module "express" {
|
||||
use(path: string[], handler: ErrorRequestHandler): T;
|
||||
use(path: RegExp, ...handler: RequestHandler[]): T;
|
||||
use(path: RegExp, handler: ErrorRequestHandler): T;
|
||||
use(path:string, router:Router): T;
|
||||
}
|
||||
|
||||
export function Router(options?: any): Router;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
///<reference path="./fixed-data-table.d.ts"" />
|
||||
/// <reference path="../react/react.d.ts"/>
|
||||
/// <reference path="../react/react-dom.d.ts"/>
|
||||
|
||||
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) {
|
||||
/>
|
||||
</FixedDataTable.Table>
|
||||
|
||||
React.render(table, document.body);
|
||||
ReactDOM.render(table, document.body);
|
||||
|
||||
@@ -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')
|
||||
|
||||
Vendored
+2
-2
@@ -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
|
||||
<P>(specString: string, children: React.ReactNode): React.DOMElement<P>
|
||||
|
||||
/**
|
||||
* 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
|
||||
<P>(specString: string, props?: React.HTMLAttributes, children?: React.ReactNode): React.DOMElement<P>
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+1
@@ -142,6 +142,7 @@ interface KnockoutAllBindingsAccessor {
|
||||
}
|
||||
|
||||
interface KnockoutBindingHandler {
|
||||
after?: Array<string>;
|
||||
init?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void | { controlsDescendantBindings: boolean; };
|
||||
update?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void;
|
||||
options?: any;
|
||||
|
||||
Vendored
+5
@@ -4176,6 +4176,11 @@ declare namespace L {
|
||||
* When this option is set, the TileLayer only loads tiles that are in the given geographical bounds.
|
||||
*/
|
||||
bounds?: LatLngBounds;
|
||||
|
||||
/**
|
||||
* Custom keys may be specified in TileLayerOptions so they can be used in a provided URL template.
|
||||
*/
|
||||
[additionalKeys: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
///<reference path='../../react/react.d.ts' />
|
||||
///<reference path='../../react/react-addons-linked-state-mixin.d.ts' />
|
||||
///<reference path='material-ui-0.11.1.d.ts' />
|
||||
|
||||
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");
|
||||
|
||||
+2
-2
@@ -233,7 +233,7 @@ declare namespace __MaterialUI {
|
||||
}
|
||||
|
||||
// what's not commonly overridden by Checkbox, RadioButton, or Toggle
|
||||
interface CommonEnhancedSwitchProps<T> extends React.HTMLAttributesBase<T> {
|
||||
interface CommonEnhancedSwitchProps<T> extends React.HTMLAttributes, React.Props<T> {
|
||||
// <input/> is root element
|
||||
id?: string;
|
||||
iconStyle?: React.CSSProperties;
|
||||
@@ -412,7 +412,7 @@ declare namespace __MaterialUI {
|
||||
}
|
||||
|
||||
// non generally overridden elements of EnhancedButton
|
||||
interface SharedEnhancedButtonProps<T> extends React.HTMLAttributesBase<T> {
|
||||
interface SharedEnhancedButtonProps<T> extends React.HTMLAttributes, React.Props<T> {
|
||||
centerRipple?: boolean;
|
||||
containerElement?: string | React.ReactElement<any>;
|
||||
disabled?: boolean;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
///<reference path='../react/react.d.ts' />
|
||||
///<reference path='../react/react-addons-linked-state-mixin.d.ts' />
|
||||
///<reference path='material-ui.d.ts' />
|
||||
|
||||
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");
|
||||
|
||||
Vendored
+4
-4
@@ -222,7 +222,7 @@ declare namespace __MaterialUI {
|
||||
}
|
||||
|
||||
// what's not commonly overridden by Checkbox, RadioButton, or Toggle
|
||||
interface CommonEnhancedSwitchProps<T> extends React.HTMLAttributesBase<T> {
|
||||
interface CommonEnhancedSwitchProps<T> extends React.HTMLAttributes, React.Props<T> {
|
||||
// <input/> is root element
|
||||
id?: string;
|
||||
iconStyle?: React.CSSProperties;
|
||||
@@ -402,7 +402,7 @@ declare namespace __MaterialUI {
|
||||
}
|
||||
|
||||
// non generally overridden elements of EnhancedButton
|
||||
interface SharedEnhancedButtonProps<T> extends React.HTMLAttributesBase<T> {
|
||||
interface SharedEnhancedButtonProps<T> extends React.HTMLAttributes, React.Props<T> {
|
||||
centerRipple?: boolean;
|
||||
containerElement?: string | React.ReactElement<any>;
|
||||
disabled?: boolean;
|
||||
@@ -644,7 +644,7 @@ declare namespace __MaterialUI {
|
||||
export class Overlay extends React.Component<OverlayProps, {}> {
|
||||
}
|
||||
|
||||
interface PaperProps extends React.HTMLAttributesBase<Paper> {
|
||||
interface PaperProps extends React.HTMLAttributes, React.Props<Paper> {
|
||||
circle?: boolean;
|
||||
rounded?: boolean;
|
||||
transitionEnabled?: boolean;
|
||||
@@ -1304,7 +1304,7 @@ declare namespace __MaterialUI {
|
||||
export class ToolbarSeparator extends React.Component<ToolbarSeparatorProps, {}> {
|
||||
}
|
||||
|
||||
interface ToolbarTitleProps extends React.HTMLAttributesBase<ToolbarTitle> {
|
||||
interface ToolbarTitleProps extends React.HTMLAttributes, React.Props<ToolbarTitle> {
|
||||
text?: string;
|
||||
}
|
||||
export class ToolbarTitle extends React.Component<ToolbarTitleProps, {}> {
|
||||
|
||||
@@ -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(<React.ClassicComponentClass<{test:string}>><any> reactiveComponent(TestComponent2));
|
||||
React.render(c4Factory({
|
||||
ReactDOM.render(c4Factory({
|
||||
test: "hello"
|
||||
}) , null);
|
||||
}
|
||||
Vendored
-40
@@ -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 <http://www.conts.de>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="./../react/react.d.ts" />
|
||||
|
||||
declare namespace __ReactDom {
|
||||
function render<P>(
|
||||
element: __React.DOMElement<P>,
|
||||
container: Element,
|
||||
callback?: () => any): __React.DOMComponent<P>;
|
||||
function render<P, S>(
|
||||
element: __React.ClassicElement<P>,
|
||||
container: Element,
|
||||
callback?: () => any): __React.ClassicComponent<P, S>;
|
||||
function render<P, S>(
|
||||
element: __React.ReactElement<P>,
|
||||
container: Element,
|
||||
callback?: () => any): __React.Component<P, S>;
|
||||
|
||||
function findDOMNode<TElement extends Element>(
|
||||
componentOrElement: __React.Component<any, any> | Element): TElement;
|
||||
function findDOMNode(
|
||||
componentOrElement: __React.Component<any, any> | Element): Element;
|
||||
|
||||
function unmountComponentAtNode(container: Element): boolean;
|
||||
}
|
||||
|
||||
declare namespace __ReactDomServer {
|
||||
function renderToString(element: __React.ReactElement<any>): string;
|
||||
function renderToStaticMarkup(element: __React.ReactElement<any>): string;
|
||||
}
|
||||
declare module "react-dom" {
|
||||
export = __ReactDom
|
||||
}
|
||||
|
||||
declare module "react-dom/server" {
|
||||
export = __ReactDomServer
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
/// <reference path="./react-input-calendar.d.ts"/>
|
||||
/// <reference path="../react/react.d.ts"/>
|
||||
/// <reference path="../react/react-dom.d.ts"/>
|
||||
|
||||
import * as ReactInputCalendar from 'react-input-calendar';
|
||||
import * as React from 'react';
|
||||
React.render(<ReactInputCalendar />, document.body);
|
||||
import * as ReactDOM from 'react-dom';
|
||||
ReactDOM.render(<ReactInputCalendar />, document.body);
|
||||
|
||||
Vendored
+2
-12
@@ -2274,8 +2274,8 @@ declare namespace ReactNative {
|
||||
|
||||
export interface DOMElement<P> extends React.DOMElement<P> {}
|
||||
|
||||
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<CC> extends React.ChildContextProvider<CC> {}
|
||||
|
||||
//
|
||||
@@ -2422,20 +2418,14 @@ declare namespace ReactNative {
|
||||
|
||||
export interface Props<T> extends React.Props<T> {}
|
||||
|
||||
export interface DOMAttributesBase<T> extends React.DOMAttributesBase<T> {}
|
||||
|
||||
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<T> extends React.HTMLAttributesBase<T> {}
|
||||
|
||||
export interface HTMLAttributes extends React.HTMLAttributes {}
|
||||
|
||||
export interface SVGElementAttributes extends React.SVGElementAttributes {}
|
||||
|
||||
export interface SVGAttributes extends React.SVGAttributes {}
|
||||
|
||||
//
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
/// <reference path="react-redux.d.ts" />
|
||||
/// <reference path="../react/react.d.ts"/>
|
||||
/// <reference path="../react/react-dom.d.ts"/>
|
||||
/// <reference path="../redux/redux.d.ts" />
|
||||
/// <reference path="../react-router/react-router.d.ts" />
|
||||
/// <reference path="../object-assign/object-assign.d.ts" />
|
||||
|
||||
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<any, any> {
|
||||
|
||||
const targetEl = document.getElementById('root');
|
||||
|
||||
React.render((
|
||||
ReactDOM.render((
|
||||
<Provider store={store}>
|
||||
{() => <App />}
|
||||
</Provider>
|
||||
@@ -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(
|
||||
<Provider store={store}>
|
||||
{() => <MyRootComponent />}
|
||||
</Provider>,
|
||||
@@ -108,7 +110,7 @@ React.render(
|
||||
);
|
||||
|
||||
Router.run(routes, Router.HistoryLocation, (Handler, routerState) => { // note "routerState" here
|
||||
React.render(
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
{/*
|
||||
//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(
|
||||
// <Provider store={store}>
|
||||
// {() => <Router history={history}>...</Router>}
|
||||
// </Provider>,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
///<reference path="react-router.d.ts" />
|
||||
///<reference path='../react/react-dom.d.ts' />
|
||||
"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<any>;
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -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`.
|
||||
|
||||
Vendored
+2038
File diff suppressed because it is too large
Load Diff
+16
@@ -0,0 +1,16 @@
|
||||
// Type definitions for React v0.14 (react-addons-create-fragment)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
namespace __Addons {
|
||||
export function createFragment(object: { [key: string]: ReactNode }): ReactFragment;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-create-fragment" {
|
||||
export = __React.__Addons.createFragment;
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// Type definitions for React v0.14 (react-addons-css-transition-group)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
/// <reference path="react-addons-transition-group.d.ts" />
|
||||
|
||||
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<CSSTransitionGroupProps>;
|
||||
|
||||
namespace __Addons {
|
||||
export var CSSTransitionGroup: __React.CSSTransitionGroup;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-css-transition-group" {
|
||||
var CSSTransitionGroup: __React.CSSTransitionGroup;
|
||||
type CSSTransitionGroup = __React.CSSTransitionGroup;
|
||||
export = CSSTransitionGroup;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// Type definitions for React v0.14 (react-addons-linked-state-mixin)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
interface ReactLink<T> {
|
||||
value: T;
|
||||
requestChange(newValue: T): void;
|
||||
}
|
||||
|
||||
interface LinkedStateMixin extends Mixin<any, any> {
|
||||
linkState<T>(key: string): ReactLink<T>;
|
||||
}
|
||||
|
||||
interface HTMLAttributes {
|
||||
checkedLink?: ReactLink<boolean>;
|
||||
valueLink?: ReactLink<boolean | string | number>;
|
||||
}
|
||||
|
||||
namespace __Addons {
|
||||
export var LinkedStateMixin: LinkedStateMixin;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-linked-state-mixin" {
|
||||
var LinkedStateMixin: __React.LinkedStateMixin;
|
||||
type LinkedStateMixin = __React.LinkedStateMixin;
|
||||
export = LinkedStateMixin;
|
||||
}
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
// Type definitions for React v0.14 (react-addons-perf)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
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;
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// Type definitions for React v0.14 (react-addons-pure-render-mixin)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
interface PureRenderMixin extends Mixin<any, any> {}
|
||||
|
||||
namespace __Addons {
|
||||
export var PureRenderMixin: PureRenderMixin;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-pure-render-mixin" {
|
||||
var PureRenderMixin: __React.PureRenderMixin;
|
||||
type PureRenderMixin = __React.PureRenderMixin;
|
||||
export = PureRenderMixin;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for React v0.14 (react-addons-css-transition-group)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
namespace __Addons {
|
||||
export function shallowCompare<P, S>(
|
||||
component: __React.Component<P, S>,
|
||||
nextProps: P,
|
||||
nextState: S): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-shallow-compare" {
|
||||
export = __React.__Addons.shallowCompare;
|
||||
}
|
||||
Vendored
+155
@@ -0,0 +1,155 @@
|
||||
// Type definitions for React v0.14 (react-addons-test-utils)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
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<any, any>, eventData?: SyntheticEventData): void;
|
||||
}
|
||||
|
||||
interface MockedComponentClass {
|
||||
new(): any;
|
||||
}
|
||||
|
||||
class ShallowRenderer {
|
||||
getRenderOutput<E extends ReactElement<any>>(): E;
|
||||
getRenderOutput(): ReactElement<any>;
|
||||
render(element: ReactElement<any>, 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<any>): Element;
|
||||
export function renderIntoDocument<P>(
|
||||
element: ReactElement<P>): Component<P, any>;
|
||||
export function renderIntoDocument<C extends Component<any, any>>(
|
||||
element: ReactElement<any>): C;
|
||||
|
||||
export function mockComponent(
|
||||
mocked: MockedComponentClass, mockTagName?: string): typeof TestUtils;
|
||||
|
||||
export function isElementOfType(
|
||||
element: ReactElement<any>, type: ReactType): boolean;
|
||||
export function isDOMComponent(instance: ReactInstance): boolean;
|
||||
export function isCompositeComponent(instance: ReactInstance): boolean;
|
||||
export function isCompositeComponentWithType(
|
||||
instance: ReactInstance,
|
||||
type: ComponentClass<any>): boolean;
|
||||
|
||||
export function findAllInRenderedTree(
|
||||
root: Component<any, any>,
|
||||
fn: (i: ReactInstance) => boolean): ReactInstance[];
|
||||
|
||||
export function scryRenderedDOMComponentsWithClass(
|
||||
root: Component<any, any>,
|
||||
className: string): Element[];
|
||||
export function findRenderedDOMComponentWithClass(
|
||||
root: Component<any, any>,
|
||||
className: string): Element;
|
||||
|
||||
export function scryRenderedDOMComponentsWithTag(
|
||||
root: Component<any, any>,
|
||||
tagName: string): Element[];
|
||||
export function findRenderedDOMComponentWithTag(
|
||||
root: Component<any, any>,
|
||||
tagName: string): Element;
|
||||
|
||||
export function scryRenderedComponentsWithType<P>(
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<P>): Component<P, {}>[];
|
||||
export function scryRenderedComponentsWithType<C extends Component<any, any>>(
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<any>): C[];
|
||||
|
||||
export function findRenderedComponentWithType<P>(
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<P>): Component<P, {}>;
|
||||
export function findRenderedComponentWithType<C extends Component<any, any>>(
|
||||
root: Component<any, any>,
|
||||
type: ComponentClass<any>): C;
|
||||
|
||||
export function createRenderer(): ShallowRenderer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-test-utils" {
|
||||
import TestUtils = __React.__Addons.TestUtils;
|
||||
export = TestUtils;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for React v0.14 (react-addons-transition-group)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
|
||||
interface TransitionGroupProps {
|
||||
component?: ReactType;
|
||||
childFactory?: (child: ReactElement<any>) => ReactElement<any>;
|
||||
}
|
||||
|
||||
type TransitionGroup = ComponentClass<TransitionGroupProps>;
|
||||
|
||||
namespace __Addons {
|
||||
export var TransitionGroup: __React.TransitionGroup;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-transition-group" {
|
||||
var TransitionGroup: __React.TransitionGroup;
|
||||
type TransitionGroup = __React.TransitionGroup;
|
||||
export = TransitionGroup;
|
||||
}
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for React v0.14 (react-addons-update)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
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;
|
||||
}
|
||||
Vendored
+67
@@ -0,0 +1,67 @@
|
||||
// Type definitions for React v0.14 (react-dom)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
|
||||
namespace __DOM {
|
||||
function findDOMNode<E extends Element>(instance: ReactInstance): E;
|
||||
function findDOMNode(instance: ReactInstance): Element;
|
||||
|
||||
function render<P>(
|
||||
element: DOMElement<P>,
|
||||
container: Element,
|
||||
callback?: (element: Element) => any): Element;
|
||||
function render<P, S>(
|
||||
element: ClassicElement<P>,
|
||||
container: Element,
|
||||
callback?: (component: ClassicComponent<P, S>) => any): ClassicComponent<P, S>;
|
||||
function render<P, S>(
|
||||
element: ReactElement<P>,
|
||||
container: Element,
|
||||
callback?: (component: Component<P, S>) => any): Component<P, S>;
|
||||
|
||||
function unmountComponentAtNode(container: Element): boolean;
|
||||
|
||||
var version: string;
|
||||
|
||||
function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
|
||||
function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
|
||||
function unstable_batchedUpdates(callback: () => any): void;
|
||||
|
||||
function unstable_renderSubtreeIntoContainer<P>(
|
||||
parentComponent: Component<any, any>,
|
||||
nextElement: DOMElement<P>,
|
||||
container: Element,
|
||||
callback?: (element: Element) => any): Element;
|
||||
function unstable_renderSubtreeIntoContainer<P, S>(
|
||||
parentComponent: Component<any, any>,
|
||||
nextElement: ClassicElement<P>,
|
||||
container: Element,
|
||||
callback?: (component: ClassicComponent<P, S>) => any): ClassicComponent<P, S>;
|
||||
function unstable_renderSubtreeIntoContainer<P, S>(
|
||||
parentComponent: Component<any, any>,
|
||||
nextElement: ReactElement<P>,
|
||||
container: Element,
|
||||
callback?: (component: Component<P, S>) => any): Component<P, S>;
|
||||
}
|
||||
|
||||
namespace __DOMServer {
|
||||
function renderToString(element: ReactElement<any>): string;
|
||||
function renderToStaticMarkup(element: ReactElement<any>): 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;
|
||||
}
|
||||
Vendored
+285
@@ -0,0 +1,285 @@
|
||||
// Type definitions for React v0.13.3 (namespace)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react-0.13.3.d.ts" />
|
||||
|
||||
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<A, B>(
|
||||
callback: (a: A, b: B) => any, a: A, b: B): void;
|
||||
export function batchedUpdates<A>(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<P>(
|
||||
element: DOMElement<P>, props: P): DOMElement<P>;
|
||||
export function cloneWithProps<P>(
|
||||
element: ClassicElement<P>, props: P): ClassicElement<P>;
|
||||
export function cloneWithProps<P>(
|
||||
element: ReactElement<P>, props: P): ReactElement<P>;
|
||||
|
||||
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<any>) => ReactElement<any>;
|
||||
}
|
||||
|
||||
interface CSSTransitionGroupProps extends TransitionGroupProps {
|
||||
transitionName: string;
|
||||
transitionAppear?: boolean;
|
||||
transitionEnter?: boolean;
|
||||
transitionLeave?: boolean;
|
||||
}
|
||||
|
||||
type CSSTransitionGroup = ComponentClass<CSSTransitionGroupProps>;
|
||||
type TransitionGroup = ComponentClass<TransitionGroupProps>;
|
||||
|
||||
//
|
||||
// React.addons (Mixins)
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
interface ReactLink<T> {
|
||||
value: T;
|
||||
requestChange(newValue: T): void;
|
||||
}
|
||||
|
||||
interface LinkedStateMixin extends Mixin<any, any> {
|
||||
linkState<T>(key: string): ReactLink<T>;
|
||||
}
|
||||
|
||||
interface PureRenderMixin extends Mixin<any, any> {
|
||||
}
|
||||
|
||||
//
|
||||
// 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<P>(
|
||||
element: ReactElement<P>): Component<P, any>;
|
||||
export function renderIntoDocument<C extends Component<any, any>>(
|
||||
element: ReactElement<any>): C;
|
||||
|
||||
export function mockComponent(
|
||||
mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils;
|
||||
|
||||
export function isElementOfType(
|
||||
element: ReactElement<any>, type: ReactType): boolean;
|
||||
export function isTextComponent(instance: Component<any, any>): boolean;
|
||||
export function isDOMComponent(instance: Component<any, any>): boolean;
|
||||
export function isCompositeComponent(instance: Component<any, any>): boolean;
|
||||
export function isCompositeComponentWithType(
|
||||
instance: Component<any, any>,
|
||||
type: ComponentClass<any>): boolean;
|
||||
|
||||
export function findAllInRenderedTree(
|
||||
tree: Component<any, any>,
|
||||
fn: (i: Component<any, any>) => boolean): Component<any, any>;
|
||||
|
||||
export function scryRenderedDOMComponentsWithClass(
|
||||
tree: Component<any, any>,
|
||||
className: string): DOMComponent<any>[];
|
||||
export function findRenderedDOMComponentWithClass(
|
||||
tree: Component<any, any>,
|
||||
className: string): DOMComponent<any>;
|
||||
|
||||
export function scryRenderedDOMComponentsWithTag(
|
||||
tree: Component<any, any>,
|
||||
tagName: string): DOMComponent<any>[];
|
||||
export function findRenderedDOMComponentWithTag(
|
||||
tree: Component<any, any>,
|
||||
tagName: string): DOMComponent<any>;
|
||||
|
||||
export function scryRenderedComponentsWithType<P>(
|
||||
tree: Component<any, any>,
|
||||
type: ComponentClass<P>): Component<P, {}>[];
|
||||
export function scryRenderedComponentsWithType<C extends Component<any, any>>(
|
||||
tree: Component<any, any>,
|
||||
type: ComponentClass<any>): C[];
|
||||
|
||||
export function findRenderedComponentWithType<P>(
|
||||
tree: Component<any, any>,
|
||||
type: ComponentClass<P>): Component<P, {}>;
|
||||
export function findRenderedComponentWithType<C extends Component<any, any>>(
|
||||
tree: Component<any, any>,
|
||||
type: ComponentClass<any>): 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<any, any>, 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 extends ReactElement<any>>(): E;
|
||||
getRenderOutput(): ReactElement<any>;
|
||||
render(element: ReactElement<any>, context?: any): void;
|
||||
unmount(): void;
|
||||
}
|
||||
}
|
||||
+107
-21
@@ -103,12 +103,12 @@ class ModernComponent extends React.Component<Props, State>
|
||||
});
|
||||
}
|
||||
|
||||
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 = <HTMLInputElement>input,
|
||||
value: this.state.inputValue
|
||||
}));
|
||||
}
|
||||
@@ -135,7 +135,7 @@ var element: React.ReactElement<Props> =
|
||||
React.createElement(ModernComponent, props);
|
||||
var classicElement: React.ClassicElement<Props> =
|
||||
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<Props> =
|
||||
React.cloneElement(element, props);
|
||||
var clonedClassicElement: React.ClassicElement<Props> =
|
||||
React.cloneElement(classicElement, props);
|
||||
var clonedDOMElement: React.HTMLElement =
|
||||
var clonedDOMElement: React.ReactHTMLElement =
|
||||
React.cloneElement(domElement);
|
||||
|
||||
// React.render
|
||||
var component: React.Component<Props, any> =
|
||||
React.render(element, container);
|
||||
ReactDOM.render(element, container);
|
||||
var classicComponent: React.ClassicComponent<Props, any> =
|
||||
React.render(classicElement, container);
|
||||
var domComponent: React.DOMComponent<any> =
|
||||
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<HTMLDivElement>();
|
||||
var isMounted: boolean = classicComponent.isMounted();
|
||||
classicComponent.setProps(elementProps);
|
||||
classicComponent.replaceProps(props);
|
||||
classicComponent.replaceState({ inputValue: "???", seconds: 60 });
|
||||
|
||||
var myComponent = <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<any, any> = {
|
||||
// React.Children
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var childMap: { [key: string]: number } =
|
||||
var mappedChildrenArray: number[] =
|
||||
React.Children.map<number>(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<any> => 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<React.Props<Timer>> =
|
||||
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}
|
||||
}
|
||||
|
||||
Vendored
+12
-275
@@ -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 <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
/// <reference path="react-dom.d.ts" />
|
||||
/// <reference path="react-addons-create-fragment.d.ts" />
|
||||
/// <reference path="react-addons-css-transition-group.d.ts" />
|
||||
/// <reference path="react-addons-linked-state-mixin.d.ts" />
|
||||
/// <reference path="react-addons-perf.d.ts" />
|
||||
/// <reference path="react-addons-pure-render-mixin.d.ts" />
|
||||
/// <reference path="react-addons-test-utils.d.ts" />
|
||||
/// <reference path="react-addons-transition-group.d.ts" />
|
||||
/// <reference path="react-addons-update.d.ts" />
|
||||
|
||||
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<A, B>(
|
||||
callback: (a: A, b: B) => any, a: A, b: B): void;
|
||||
export function batchedUpdates<A>(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<P>(
|
||||
element: DOMElement<P>, props: P): DOMElement<P>;
|
||||
export function cloneWithProps<P>(
|
||||
element: ClassicElement<P>, props: P): ClassicElement<P>;
|
||||
export function cloneWithProps<P>(
|
||||
element: ReactElement<P>, props: P): ReactElement<P>;
|
||||
|
||||
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<any>) => ReactElement<any>;
|
||||
}
|
||||
|
||||
interface CSSTransitionGroupProps extends TransitionGroupProps {
|
||||
transitionName: string;
|
||||
transitionAppear?: boolean;
|
||||
transitionEnter?: boolean;
|
||||
transitionLeave?: boolean;
|
||||
}
|
||||
|
||||
type CSSTransitionGroup = ComponentClass<CSSTransitionGroupProps>;
|
||||
type TransitionGroup = ComponentClass<TransitionGroupProps>;
|
||||
|
||||
//
|
||||
// React.addons (Mixins)
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
interface ReactLink<T> {
|
||||
value: T;
|
||||
requestChange(newValue: T): void;
|
||||
}
|
||||
|
||||
interface LinkedStateMixin extends Mixin<any, any> {
|
||||
linkState<T>(key: string): ReactLink<T>;
|
||||
}
|
||||
|
||||
interface PureRenderMixin extends Mixin<any, any> {
|
||||
}
|
||||
|
||||
//
|
||||
// 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<P>(
|
||||
element: ReactElement<P>): Component<P, any>;
|
||||
export function renderIntoDocument<C extends Component<any, any>>(
|
||||
element: ReactElement<any>): C;
|
||||
|
||||
export function mockComponent(
|
||||
mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils;
|
||||
|
||||
export function isElementOfType(
|
||||
element: ReactElement<any>, type: ReactType): boolean;
|
||||
export function isTextComponent(instance: Component<any, any>): boolean;
|
||||
export function isDOMComponent(instance: Component<any, any>): boolean;
|
||||
export function isCompositeComponent(instance: Component<any, any>): boolean;
|
||||
export function isCompositeComponentWithType(
|
||||
instance: Component<any, any>,
|
||||
type: ComponentClass<any>): boolean;
|
||||
|
||||
export function findAllInRenderedTree(
|
||||
tree: Component<any, any>,
|
||||
fn: (i: Component<any, any>) => boolean): Component<any, any>;
|
||||
|
||||
export function scryRenderedDOMComponentsWithClass(
|
||||
tree: Component<any, any>,
|
||||
className: string): DOMComponent<any>[];
|
||||
export function findRenderedDOMComponentWithClass(
|
||||
tree: Component<any, any>,
|
||||
className: string): DOMComponent<any>;
|
||||
|
||||
export function scryRenderedDOMComponentsWithTag(
|
||||
tree: Component<any, any>,
|
||||
tagName: string): DOMComponent<any>[];
|
||||
export function findRenderedDOMComponentWithTag(
|
||||
tree: Component<any, any>,
|
||||
tagName: string): DOMComponent<any>;
|
||||
|
||||
export function scryRenderedComponentsWithType<P>(
|
||||
tree: Component<any, any>,
|
||||
type: ComponentClass<P>): Component<P, {}>[];
|
||||
export function scryRenderedComponentsWithType<C extends Component<any, any>>(
|
||||
tree: Component<any, any>,
|
||||
type: ComponentClass<any>): C[];
|
||||
|
||||
export function findRenderedComponentWithType<P>(
|
||||
tree: Component<any, any>,
|
||||
type: ComponentClass<P>): Component<P, {}>;
|
||||
export function findRenderedComponentWithType<C extends Component<any, any>>(
|
||||
tree: Component<any, any>,
|
||||
type: ComponentClass<any>): 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<any, any>, 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 extends ReactElement<any>>(): E;
|
||||
getRenderOutput(): ReactElement<any>;
|
||||
render(element: ReactElement<any>, context?: any): void;
|
||||
unmount(): void;
|
||||
}
|
||||
export import addons = __React.__Addons;
|
||||
}
|
||||
|
||||
+226
-38
@@ -1,11 +1,31 @@
|
||||
/// <reference path="react.d.ts" />
|
||||
/// <reference path="react-dom.d.ts" />
|
||||
/// <reference path="react-addons-create-fragment.d.ts" />
|
||||
/// <reference path="react-addons-css-transition-group.d.ts" />
|
||||
/// <reference path="react-addons-linked-state-mixin.d.ts" />
|
||||
/// <reference path="react-addons-perf.d.ts" />
|
||||
/// <reference path="react-addons-pure-render-mixin.d.ts" />
|
||||
/// <reference path="react-addons-shallow-compare.d.ts" />
|
||||
/// <reference path="react-addons-test-utils.d.ts" />
|
||||
/// <reference path="react-addons-transition-group.d.ts" />
|
||||
/// <reference path="react-addons-update.d.ts" />
|
||||
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<MyComponent> {
|
||||
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<Props> =
|
||||
React.createClass<Props, State>({
|
||||
getDefaultProps() {
|
||||
return <Props>{
|
||||
return {
|
||||
hello: undefined,
|
||||
world: "peace",
|
||||
foo: undefined,
|
||||
bar: undefined,
|
||||
foo: undefined
|
||||
};
|
||||
},
|
||||
getInitialState() {
|
||||
@@ -68,59 +86,83 @@ var ClassicComponent: React.ClassicComponentClass<Props> =
|
||||
});
|
||||
|
||||
class ModernComponent extends React.Component<Props, State>
|
||||
implements React.ChildContextProvider<ChildContext> {
|
||||
|
||||
implements MyComponent, React.ChildContextProvider<ChildContext> {
|
||||
|
||||
static propTypes: React.ValidationMap<Props> = {
|
||||
foo: React.PropTypes.number
|
||||
}
|
||||
|
||||
|
||||
static contextTypes: React.ValidationMap<Context> = {
|
||||
someValue: React.PropTypes.string
|
||||
}
|
||||
|
||||
|
||||
static childContextTypes: React.ValidationMap<ChildContext> = {
|
||||
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 = <HTMLInputElement>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<SCProps> =
|
||||
(props: SCProps) => React.DOM.div(null, props.foo);
|
||||
StatelessComponent2.defaultProps = {
|
||||
foo: 42
|
||||
};
|
||||
|
||||
// React.createFactory
|
||||
var factory: React.Factory<Props> =
|
||||
React.createFactory(ModernComponent);
|
||||
var factoryElement: React.ReactElement<Props> =
|
||||
factory(props);
|
||||
|
||||
var statelessFactory: React.Factory<SCProps> =
|
||||
React.createFactory(StatelessComponent);
|
||||
var statelessElement: React.ReactElement<SCProps> =
|
||||
statelessFactory(props);
|
||||
|
||||
var classicFactory: React.ClassicFactory<Props> =
|
||||
React.createFactory(ClassicComponent);
|
||||
var classicFactoryElement: React.ClassicElement<Props> =
|
||||
@@ -134,36 +176,39 @@ var domFactoryElement: React.DOMElement<any> =
|
||||
// React.createElement
|
||||
var element: React.ReactElement<Props> =
|
||||
React.createElement(ModernComponent, props);
|
||||
var statelessElement: React.ReactElement<SCProps> =
|
||||
React.createElement(StatelessComponent, props);
|
||||
var classicElement: React.ClassicElement<Props> =
|
||||
React.createElement(ClassicComponent, props);
|
||||
var domElement: React.HTMLElement =
|
||||
var domElement: React.ReactHTMLElement =
|
||||
React.createElement("div");
|
||||
|
||||
// React.cloneElement
|
||||
var clonedElement: React.ReactElement<Props> =
|
||||
React.cloneElement(element, props);
|
||||
var clonedStatelessElement: React.ReactElement<SCProps> =
|
||||
React.cloneElement(statelessElement, props);
|
||||
var clonedClassicElement: React.ClassicElement<Props> =
|
||||
React.cloneElement(classicElement, props);
|
||||
var clonedDOMElement: React.HTMLElement =
|
||||
var clonedDOMElement: React.ReactHTMLElement =
|
||||
React.cloneElement(domElement);
|
||||
|
||||
// React.render
|
||||
var component: React.Component<Props, any> =
|
||||
React.render(element, container);
|
||||
ReactDOM.render(element, container);
|
||||
var classicComponent: React.ClassicComponent<Props, any> =
|
||||
React.render(classicElement, container);
|
||||
var domComponent: React.DOMComponent<any> =
|
||||
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<HTMLDivElement>();
|
||||
var isMounted: boolean = classicComponent.isMounted();
|
||||
classicComponent.setProps(elementProps);
|
||||
classicComponent.replaceProps(props);
|
||||
classicComponent.replaceState({ inputValue: "???", seconds: 60 });
|
||||
|
||||
var myComponent = <MyComponent>component;
|
||||
myComponent.reset();
|
||||
|
||||
//
|
||||
// Refs
|
||||
// NB: to infer the correct type for callback refs, your component's Props
|
||||
// interface must extend React.Props<T> where T is your component type (or
|
||||
// an interface that it implements).
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
interface RCProps extends React.Props<RefComponent> {
|
||||
}
|
||||
|
||||
class RefComponent extends React.Component<RCProps, {}> {
|
||||
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 = <HTMLInputElement>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<any, any> = {
|
||||
// React.Children
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var childMap: { [key: string]: number } =
|
||||
var mappedChildrenArray: number[] =
|
||||
React.Children.map<number>(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<any> => 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<React.Props<Timer>> =
|
||||
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}
|
||||
}
|
||||
|
||||
Vendored
+308
-1325
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user