;
63 | type ReactNode = ReactChild | ReactFragment | boolean;
64 |
65 | //
66 | // Top Level API
67 | // ----------------------------------------------------------------------
68 |
69 | function createClass(spec: ComponentSpec
): ClassicComponentClass
;
70 |
71 | function createFactory
(type: string): DOMFactory
;
72 | function createFactory
(type: ClassicComponentClass
| string): ClassicFactory
;
73 | function createFactory
(type: ComponentClass
): Factory
;
74 |
75 | function createElement
(
76 | type: string,
77 | props?: P,
78 | ...children: ReactNode[]): DOMElement
;
79 | function createElement
(
80 | type: ClassicComponentClass
| string,
81 | props?: P,
82 | ...children: ReactNode[]): ClassicElement
;
83 | function createElement
(
84 | type: ComponentClass
,
85 | props?: P,
86 | ...children: ReactNode[]): ReactElement
;
87 |
88 | function cloneElement
(
89 | element: DOMElement
,
90 | props?: P,
91 | ...children: ReactNode[]): DOMElement
;
92 | function cloneElement
(
93 | element: ClassicElement
,
94 | props?: P,
95 | ...children: ReactNode[]): ClassicElement
;
96 | function cloneElement
(
97 | element: ReactElement
,
98 | props?: P,
99 | ...children: ReactNode[]): ReactElement
;
100 |
101 | function render
(
102 | element: DOMElement
,
103 | container: Element,
104 | callback?: () => any): DOMComponent
;
105 | function render
(
106 | element: ClassicElement
,
107 | container: Element,
108 | callback?: () => any): ClassicComponent
;
109 | function render
(
110 | element: ReactElement
,
111 | container: Element,
112 | callback?: () => any): Component
;
113 |
114 | function unmountComponentAtNode(container: Element): boolean;
115 | function renderToString(element: ReactElement): string;
116 | function renderToStaticMarkup(element: ReactElement): string;
117 | function isValidElement(object: {}): boolean;
118 | function initializeTouchEvents(shouldUseTouch: boolean): void;
119 |
120 | function findDOMNode(
121 | componentOrElement: Component | Element): TElement;
122 | function findDOMNode(
123 | componentOrElement: Component | Element): Element;
124 |
125 | var DOM: ReactDOM;
126 | var PropTypes: ReactPropTypes;
127 | var Children: ReactChildren;
128 |
129 | //
130 | // Component API
131 | // ----------------------------------------------------------------------
132 |
133 | // Base component for plain JS classes
134 | class Component implements ComponentLifecycle
{
135 | constructor(props?: P, context?: any);
136 | setState(f: (prevState: S, props: P) => S, callback?: () => any): void;
137 | setState(state: S, callback?: () => any): void;
138 | forceUpdate(): void;
139 | render(): JSX.Element;
140 | props: P;
141 | state: S;
142 | context: {};
143 | refs: {
144 | [key: string]: Component
145 | };
146 | }
147 |
148 | interface ClassicComponent extends Component
{
149 | replaceState(nextState: S, callback?: () => any): void;
150 | getDOMNode(): TElement;
151 | getDOMNode(): Element;
152 | isMounted(): boolean;
153 | getInitialState?(): S;
154 | setProps(nextProps: P, callback?: () => any): void;
155 | replaceProps(nextProps: P, callback?: () => any): void;
156 | }
157 |
158 | interface DOMComponent extends ClassicComponent
{
159 | tagName: string;
160 | }
161 |
162 | type HTMLComponent = DOMComponent;
163 | type SVGComponent = DOMComponent;
164 |
165 | interface ChildContextProvider {
166 | getChildContext(): CC;
167 | }
168 |
169 | //
170 | // Class Interfaces
171 | // ----------------------------------------------------------------------
172 |
173 | interface ComponentClass {
174 | new(props?: P, context?: any): Component
;
175 | propTypes?: ValidationMap
;
176 | contextTypes?: ValidationMap;
177 | childContextTypes?: ValidationMap;
178 | defaultProps?: P;
179 | }
180 |
181 | interface ClassicComponentClass extends ComponentClass
{
182 | new(props?: P, context?: any): ClassicComponent
;
183 | getDefaultProps?(): P;
184 | displayName?: string;
185 | }
186 |
187 | //
188 | // Component Specs and Lifecycle
189 | // ----------------------------------------------------------------------
190 |
191 | interface ComponentLifecycle
{
192 | componentWillMount?(): void;
193 | componentDidMount?(): void;
194 | componentWillReceiveProps?(nextProps: P, nextContext: any): void;
195 | shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean;
196 | componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void;
197 | componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void;
198 | componentWillUnmount?(): void;
199 | }
200 |
201 | interface Mixin
extends ComponentLifecycle
{
202 | mixins?: Mixin
;
203 | statics?: {
204 | [key: string]: any;
205 | };
206 |
207 | displayName?: string;
208 | propTypes?: ValidationMap;
209 | contextTypes?: ValidationMap;
210 | childContextTypes?: ValidationMap
211 |
212 | getDefaultProps?(): P;
213 | getInitialState?(): S;
214 | }
215 |
216 | interface ComponentSpec extends Mixin
{
217 | render(): ReactElement;
218 |
219 | [propertyName: string]: any;
220 | }
221 |
222 | //
223 | // Event System
224 | // ----------------------------------------------------------------------
225 |
226 | interface SyntheticEvent {
227 | bubbles: boolean;
228 | cancelable: boolean;
229 | currentTarget: EventTarget;
230 | defaultPrevented: boolean;
231 | eventPhase: number;
232 | isTrusted: boolean;
233 | nativeEvent: Event;
234 | preventDefault(): void;
235 | stopPropagation(): void;
236 | target: EventTarget;
237 | timeStamp: Date;
238 | type: string;
239 | }
240 |
241 | interface DragEvent extends SyntheticEvent {
242 | dataTransfer: DataTransfer;
243 | }
244 |
245 | interface ClipboardEvent extends SyntheticEvent {
246 | clipboardData: DataTransfer;
247 | }
248 |
249 | interface KeyboardEvent extends SyntheticEvent {
250 | altKey: boolean;
251 | charCode: number;
252 | ctrlKey: boolean;
253 | getModifierState(key: string): boolean;
254 | key: string;
255 | keyCode: number;
256 | locale: string;
257 | location: number;
258 | metaKey: boolean;
259 | repeat: boolean;
260 | shiftKey: boolean;
261 | which: number;
262 | }
263 |
264 | interface FocusEvent extends SyntheticEvent {
265 | relatedTarget: EventTarget;
266 | }
267 |
268 | interface FormEvent extends SyntheticEvent {
269 | }
270 |
271 | interface MouseEvent extends SyntheticEvent {
272 | altKey: boolean;
273 | button: number;
274 | buttons: number;
275 | clientX: number;
276 | clientY: number;
277 | ctrlKey: boolean;
278 | getModifierState(key: string): boolean;
279 | metaKey: boolean;
280 | pageX: number;
281 | pageY: number;
282 | relatedTarget: EventTarget;
283 | screenX: number;
284 | screenY: number;
285 | shiftKey: boolean;
286 | }
287 |
288 | interface TouchEvent extends SyntheticEvent {
289 | altKey: boolean;
290 | changedTouches: TouchList;
291 | ctrlKey: boolean;
292 | getModifierState(key: string): boolean;
293 | metaKey: boolean;
294 | shiftKey: boolean;
295 | targetTouches: TouchList;
296 | touches: TouchList;
297 | }
298 |
299 | interface UIEvent extends SyntheticEvent {
300 | detail: number;
301 | view: AbstractView;
302 | }
303 |
304 | interface WheelEvent extends SyntheticEvent {
305 | deltaMode: number;
306 | deltaX: number;
307 | deltaY: number;
308 | deltaZ: number;
309 | }
310 |
311 | //
312 | // Event Handler Types
313 | // ----------------------------------------------------------------------
314 |
315 | interface EventHandler {
316 | (event: E): void;
317 | }
318 |
319 | interface DragEventHandler extends EventHandler {}
320 | interface ClipboardEventHandler extends EventHandler {}
321 | interface KeyboardEventHandler extends EventHandler {}
322 | interface FocusEventHandler extends EventHandler {}
323 | interface FormEventHandler extends EventHandler {}
324 | interface MouseEventHandler extends EventHandler {}
325 | interface TouchEventHandler extends EventHandler {}
326 | interface UIEventHandler extends EventHandler {}
327 | interface WheelEventHandler extends EventHandler {}
328 |
329 | //
330 | // Props / DOM Attributes
331 | // ----------------------------------------------------------------------
332 |
333 | interface Props {
334 | children?: ReactNode;
335 | key?: string | number;
336 | ref?: string | ((component: T) => any);
337 | }
338 |
339 | interface DOMAttributes extends Props> {
340 | onCopy?: ClipboardEventHandler;
341 | onCut?: ClipboardEventHandler;
342 | onPaste?: ClipboardEventHandler;
343 | onKeyDown?: KeyboardEventHandler;
344 | onKeyPress?: KeyboardEventHandler;
345 | onKeyUp?: KeyboardEventHandler;
346 | onFocus?: FocusEventHandler;
347 | onBlur?: FocusEventHandler;
348 | onChange?: FormEventHandler;
349 | onInput?: FormEventHandler;
350 | onSubmit?: FormEventHandler;
351 | onClick?: MouseEventHandler;
352 | onDoubleClick?: MouseEventHandler;
353 | onDrag?: DragEventHandler;
354 | onDragEnd?: DragEventHandler;
355 | onDragEnter?: DragEventHandler;
356 | onDragExit?: DragEventHandler;
357 | onDragLeave?: DragEventHandler;
358 | onDragOver?: DragEventHandler;
359 | onDragStart?: DragEventHandler;
360 | onDrop?: DragEventHandler;
361 | onMouseDown?: MouseEventHandler;
362 | onMouseEnter?: MouseEventHandler;
363 | onMouseLeave?: MouseEventHandler;
364 | onMouseMove?: MouseEventHandler;
365 | onMouseOut?: MouseEventHandler;
366 | onMouseOver?: MouseEventHandler;
367 | onMouseUp?: MouseEventHandler;
368 | onTouchCancel?: TouchEventHandler;
369 | onTouchEnd?: TouchEventHandler;
370 | onTouchMove?: TouchEventHandler;
371 | onTouchStart?: TouchEventHandler;
372 | onScroll?: UIEventHandler;
373 | onWheel?: WheelEventHandler;
374 |
375 | dangerouslySetInnerHTML?: {
376 | __html: string;
377 | };
378 | }
379 |
380 | // This interface is not complete. Only properties accepting
381 | // unitless numbers are listed here (see CSSProperty.js in React)
382 | interface CSSProperties {
383 | boxFlex?: number;
384 | boxFlexGroup?: number;
385 | columnCount?: number;
386 | flex?: number | string;
387 | flexGrow?: number;
388 | flexShrink?: number;
389 | fontWeight?: number | string;
390 | lineClamp?: number;
391 | lineHeight?: number | string;
392 | opacity?: number;
393 | order?: number;
394 | orphans?: number;
395 | widows?: number;
396 | zIndex?: number;
397 | zoom?: number;
398 |
399 | fontSize?: number | string;
400 |
401 | // SVG-related properties
402 | fillOpacity?: number;
403 | strokeOpacity?: number;
404 | strokeWidth?: number;
405 |
406 | [propertyName: string]: any;
407 | }
408 |
409 | interface HTMLAttributes extends DOMAttributes {
410 | ref?: string | ((component: HTMLComponent) => void);
411 |
412 | accept?: string;
413 | acceptCharset?: string;
414 | accessKey?: string;
415 | action?: string;
416 | allowFullScreen?: boolean;
417 | allowTransparency?: boolean;
418 | alt?: string;
419 | async?: boolean;
420 | autoComplete?: boolean;
421 | autoFocus?: boolean;
422 | autoPlay?: boolean;
423 | cellPadding?: number | string;
424 | cellSpacing?: number | string;
425 | charSet?: string;
426 | checked?: boolean;
427 | classID?: string;
428 | className?: string;
429 | cols?: number;
430 | colSpan?: number;
431 | content?: string;
432 | contentEditable?: boolean;
433 | contextMenu?: string;
434 | controls?: any;
435 | coords?: string;
436 | crossOrigin?: string;
437 | data?: string;
438 | dateTime?: string;
439 | defaultChecked?: boolean;
440 | defaultValue?: string;
441 | defer?: boolean;
442 | dir?: string;
443 | disabled?: boolean;
444 | download?: any;
445 | draggable?: boolean;
446 | encType?: string;
447 | form?: string;
448 | formAction?: string;
449 | formEncType?: string;
450 | formMethod?: string;
451 | formNoValidate?: boolean;
452 | formTarget?: string;
453 | frameBorder?: number | string;
454 | headers?: string;
455 | height?: number | string;
456 | hidden?: boolean;
457 | high?: number;
458 | href?: string;
459 | hrefLang?: string;
460 | htmlFor?: string;
461 | httpEquiv?: string;
462 | icon?: string;
463 | id?: string;
464 | label?: string;
465 | lang?: string;
466 | list?: string;
467 | loop?: boolean;
468 | low?: number;
469 | manifest?: string;
470 | marginHeight?: number;
471 | marginWidth?: number;
472 | max?: number | string;
473 | maxLength?: number;
474 | media?: string;
475 | mediaGroup?: string;
476 | method?: string;
477 | min?: number | string;
478 | multiple?: boolean;
479 | muted?: boolean;
480 | name?: string;
481 | noValidate?: boolean;
482 | open?: boolean;
483 | optimum?: number;
484 | pattern?: string;
485 | placeholder?: string;
486 | poster?: string;
487 | preload?: string;
488 | radioGroup?: string;
489 | readOnly?: boolean;
490 | rel?: string;
491 | required?: boolean;
492 | role?: string;
493 | rows?: number;
494 | rowSpan?: number;
495 | sandbox?: string;
496 | scope?: string;
497 | scoped?: boolean;
498 | scrolling?: string;
499 | seamless?: boolean;
500 | selected?: boolean;
501 | shape?: string;
502 | size?: number;
503 | sizes?: string;
504 | span?: number;
505 | spellCheck?: boolean;
506 | src?: string;
507 | srcDoc?: string;
508 | srcSet?: string;
509 | start?: number;
510 | step?: number | string;
511 | style?: CSSProperties;
512 | tabIndex?: number;
513 | target?: string;
514 | title?: string;
515 | type?: string;
516 | useMap?: string;
517 | value?: string;
518 | width?: number | string;
519 | wmode?: string;
520 |
521 | // Non-standard Attributes
522 | autoCapitalize?: boolean;
523 | autoCorrect?: boolean;
524 | property?: string;
525 | itemProp?: string;
526 | itemScope?: boolean;
527 | itemType?: string;
528 | unselectable?: boolean;
529 | }
530 |
531 | interface SVGElementAttributes extends HTMLAttributes {
532 | viewBox?: string;
533 | preserveAspectRatio?: string;
534 | }
535 |
536 | interface SVGAttributes extends DOMAttributes {
537 | ref?: string | ((component: SVGComponent) => void);
538 |
539 | cx?: number | string;
540 | cy?: number | string;
541 | d?: string;
542 | dx?: number | string;
543 | dy?: number | string;
544 | fill?: string;
545 | fillOpacity?: number | string;
546 | fontFamily?: string;
547 | fontSize?: number | string;
548 | fx?: number | string;
549 | fy?: number | string;
550 | gradientTransform?: string;
551 | gradientUnits?: string;
552 | height?: number | string;
553 | markerEnd?: string;
554 | markerMid?: string;
555 | markerStart?: string;
556 | offset?: number | string;
557 | opacity?: number | string;
558 | patternContentUnits?: string;
559 | patternUnits?: string;
560 | points?: string;
561 | preserveAspectRatio?: string;
562 | r?: number | string;
563 | rx?: number | string;
564 | ry?: number | string;
565 | spreadMethod?: string;
566 | stopColor?: string;
567 | stopOpacity?: number | string;
568 | stroke?: string;
569 | strokeDasharray?: string;
570 | strokeLinecap?: string;
571 | strokeOpacity?: number | string;
572 | strokeWidth?: number | string;
573 | textAnchor?: string;
574 | transform?: string;
575 | version?: string;
576 | viewBox?: string;
577 | width?: number | string;
578 | x1?: number | string;
579 | x2?: number | string;
580 | x?: number | string;
581 | y1?: number | string;
582 | y2?: number | string
583 | y?: number | string;
584 | }
585 |
586 | //
587 | // React.DOM
588 | // ----------------------------------------------------------------------
589 |
590 | interface ReactDOM {
591 | // HTML
592 | a: HTMLFactory;
593 | abbr: HTMLFactory;
594 | address: HTMLFactory;
595 | area: HTMLFactory;
596 | article: HTMLFactory;
597 | aside: HTMLFactory;
598 | audio: HTMLFactory;
599 | b: HTMLFactory;
600 | base: HTMLFactory;
601 | bdi: HTMLFactory;
602 | bdo: HTMLFactory;
603 | big: HTMLFactory;
604 | blockquote: HTMLFactory;
605 | body: HTMLFactory;
606 | br: HTMLFactory;
607 | button: HTMLFactory;
608 | canvas: HTMLFactory;
609 | caption: HTMLFactory;
610 | cite: HTMLFactory;
611 | code: HTMLFactory;
612 | col: HTMLFactory;
613 | colgroup: HTMLFactory;
614 | data: HTMLFactory;
615 | datalist: HTMLFactory;
616 | dd: HTMLFactory;
617 | del: HTMLFactory;
618 | details: HTMLFactory;
619 | dfn: HTMLFactory;
620 | dialog: HTMLFactory;
621 | div: HTMLFactory;
622 | dl: HTMLFactory;
623 | dt: HTMLFactory;
624 | em: HTMLFactory;
625 | embed: HTMLFactory;
626 | fieldset: HTMLFactory;
627 | figcaption: HTMLFactory;
628 | figure: HTMLFactory;
629 | footer: HTMLFactory;
630 | form: HTMLFactory;
631 | h1: HTMLFactory;
632 | h2: HTMLFactory;
633 | h3: HTMLFactory;
634 | h4: HTMLFactory;
635 | h5: HTMLFactory;
636 | h6: HTMLFactory;
637 | head: HTMLFactory;
638 | header: HTMLFactory;
639 | hr: HTMLFactory;
640 | html: HTMLFactory;
641 | i: HTMLFactory;
642 | iframe: HTMLFactory;
643 | img: HTMLFactory;
644 | input: HTMLFactory;
645 | ins: HTMLFactory;
646 | kbd: HTMLFactory;
647 | keygen: HTMLFactory;
648 | label: HTMLFactory;
649 | legend: HTMLFactory;
650 | li: HTMLFactory;
651 | link: HTMLFactory;
652 | main: HTMLFactory;
653 | map: HTMLFactory;
654 | mark: HTMLFactory;
655 | menu: HTMLFactory;
656 | menuitem: HTMLFactory;
657 | meta: HTMLFactory;
658 | meter: HTMLFactory;
659 | nav: HTMLFactory;
660 | noscript: HTMLFactory;
661 | object: HTMLFactory;
662 | ol: HTMLFactory;
663 | optgroup: HTMLFactory;
664 | option: HTMLFactory;
665 | output: HTMLFactory;
666 | p: HTMLFactory;
667 | param: HTMLFactory;
668 | picture: HTMLFactory;
669 | pre: HTMLFactory;
670 | progress: HTMLFactory;
671 | q: HTMLFactory;
672 | rp: HTMLFactory;
673 | rt: HTMLFactory;
674 | ruby: HTMLFactory;
675 | s: HTMLFactory;
676 | samp: HTMLFactory;
677 | script: HTMLFactory;
678 | section: HTMLFactory;
679 | select: HTMLFactory;
680 | small: HTMLFactory;
681 | source: HTMLFactory;
682 | span: HTMLFactory;
683 | strong: HTMLFactory;
684 | style: HTMLFactory;
685 | sub: HTMLFactory;
686 | summary: HTMLFactory;
687 | sup: HTMLFactory;
688 | table: HTMLFactory;
689 | tbody: HTMLFactory;
690 | td: HTMLFactory;
691 | textarea: HTMLFactory;
692 | tfoot: HTMLFactory;
693 | th: HTMLFactory;
694 | thead: HTMLFactory;
695 | time: HTMLFactory;
696 | title: HTMLFactory;
697 | tr: HTMLFactory;
698 | track: HTMLFactory;
699 | u: HTMLFactory;
700 | ul: HTMLFactory;
701 | "var": HTMLFactory;
702 | video: HTMLFactory;
703 | wbr: HTMLFactory;
704 |
705 | // SVG
706 | svg: SVGElementFactory;
707 | circle: SVGFactory;
708 | defs: SVGFactory;
709 | ellipse: SVGFactory;
710 | g: SVGFactory;
711 | line: SVGFactory;
712 | linearGradient: SVGFactory;
713 | mask: SVGFactory;
714 | path: SVGFactory;
715 | pattern: SVGFactory;
716 | polygon: SVGFactory;
717 | polyline: SVGFactory;
718 | radialGradient: SVGFactory;
719 | rect: SVGFactory;
720 | stop: SVGFactory;
721 | text: SVGFactory;
722 | tspan: SVGFactory;
723 | }
724 |
725 | //
726 | // React.PropTypes
727 | // ----------------------------------------------------------------------
728 |
729 | interface Validator {
730 | (object: T, key: string, componentName: string): Error;
731 | }
732 |
733 | interface Requireable extends Validator {
734 | isRequired: Validator;
735 | }
736 |
737 | interface ValidationMap {
738 | [key: string]: Validator;
739 | }
740 |
741 | interface ReactPropTypes {
742 | any: Requireable;
743 | array: Requireable;
744 | bool: Requireable;
745 | func: Requireable;
746 | number: Requireable;
747 | object: Requireable;
748 | string: Requireable;
749 | node: Requireable;
750 | element: Requireable;
751 | instanceOf(expectedClass: {}): Requireable;
752 | oneOf(types: any[]): Requireable;
753 | oneOfType(types: Validator[]): Requireable;
754 | arrayOf(type: Validator): Requireable;
755 | objectOf(type: Validator): Requireable;
756 | shape(type: ValidationMap): Requireable;
757 | }
758 |
759 | //
760 | // React.Children
761 | // ----------------------------------------------------------------------
762 |
763 | interface ReactChildren {
764 | map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T };
765 | forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void;
766 | count(children: ReactNode): number;
767 | only(children: ReactNode): ReactChild;
768 | }
769 |
770 | //
771 | // Browser Interfaces
772 | // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts
773 | // ----------------------------------------------------------------------
774 |
775 | interface AbstractView {
776 | styleMedia: StyleMedia;
777 | document: Document;
778 | }
779 |
780 | interface Touch {
781 | identifier: number;
782 | target: EventTarget;
783 | screenX: number;
784 | screenY: number;
785 | clientX: number;
786 | clientY: number;
787 | pageX: number;
788 | pageY: number;
789 | }
790 |
791 | interface TouchList {
792 | [index: number]: Touch;
793 | length: number;
794 | item(index: number): Touch;
795 | identifiedTouch(identifier: number): Touch;
796 | }
797 | }
798 |
799 | declare module "react" {
800 | export = __React;
801 | }
802 |
803 | declare module "react/addons" {
804 | //
805 | // React Elements
806 | // ----------------------------------------------------------------------
807 |
808 | type ReactType = ComponentClass | string;
809 |
810 | interface ReactElement {
811 | type: string | ComponentClass
;
812 | props: P;
813 | key: string | number;
814 | ref: string | ((component: Component
) => any);
815 | }
816 |
817 | interface ClassicElement
extends ReactElement
{
818 | type: string | ClassicComponentClass
;
819 | ref: string | ((component: ClassicComponent
) => any);
820 | }
821 |
822 | interface DOMElement
extends ClassicElement
{
823 | type: string;
824 | ref: string | ((component: DOMComponent
) => any);
825 | }
826 |
827 | type HTMLElement = DOMElement;
828 | type SVGElement = DOMElement;
829 |
830 | //
831 | // Factories
832 | // ----------------------------------------------------------------------
833 |
834 | interface Factory {
835 | (props?: P, ...children: ReactNode[]): ReactElement
;
836 | }
837 |
838 | interface ClassicFactory
extends Factory
{
839 | (props?: P, ...children: ReactNode[]): ClassicElement
;
840 | }
841 |
842 | interface DOMFactory
extends ClassicFactory
{
843 | (props?: P, ...children: ReactNode[]): DOMElement
;
844 | }
845 |
846 | type HTMLFactory = DOMFactory;
847 | type SVGFactory = DOMFactory;
848 | type SVGElementFactory = DOMFactory;
849 |
850 | //
851 | // React Nodes
852 | // http://facebook.github.io/react/docs/glossary.html
853 | // ----------------------------------------------------------------------
854 |
855 | type ReactText = string | number;
856 | type ReactChild = ReactElement | ReactText;
857 |
858 | // Should be Array but type aliases cannot be recursive
859 | type ReactFragment = {} | Array;
860 | type ReactNode = ReactChild | ReactFragment | boolean;
861 |
862 | //
863 | // Top Level API
864 | // ----------------------------------------------------------------------
865 |
866 | function createClass(spec: ComponentSpec
): ClassicComponentClass
;
867 |
868 | function createFactory
(type: string): DOMFactory
;
869 | function createFactory
(type: ClassicComponentClass
| string): ClassicFactory
;
870 | function createFactory
(type: ComponentClass
): Factory
;
871 |
872 | function createElement
(
873 | type: string,
874 | props?: P,
875 | ...children: ReactNode[]): DOMElement
;
876 | function createElement
(
877 | type: ClassicComponentClass
| string,
878 | props?: P,
879 | ...children: ReactNode[]): ClassicElement
;
880 | function createElement
(
881 | type: ComponentClass
,
882 | props?: P,
883 | ...children: ReactNode[]): ReactElement
;
884 |
885 | function cloneElement
(
886 | element: DOMElement
,
887 | props?: P,
888 | ...children: ReactNode[]): DOMElement
;
889 | function cloneElement
(
890 | element: ClassicElement
,
891 | props?: P,
892 | ...children: ReactNode[]): ClassicElement
;
893 | function cloneElement
(
894 | element: ReactElement
,
895 | props?: P,
896 | ...children: ReactNode[]): ReactElement
;
897 |
898 | function render
(
899 | element: DOMElement
,
900 | container: Element,
901 | callback?: () => any): DOMComponent
;
902 | function render
(
903 | element: ClassicElement
,
904 | container: Element,
905 | callback?: () => any): ClassicComponent
;
906 | function render
(
907 | element: ReactElement
,
908 | container: Element,
909 | callback?: () => any): Component
;
910 |
911 | function unmountComponentAtNode(container: Element): boolean;
912 | function renderToString(element: ReactElement): string;
913 | function renderToStaticMarkup(element: ReactElement): string;
914 | function isValidElement(object: {}): boolean;
915 | function initializeTouchEvents(shouldUseTouch: boolean): void;
916 |
917 | function findDOMNode(
918 | componentOrElement: Component | Element): TElement;
919 | function findDOMNode(
920 | componentOrElement: Component | Element): Element;
921 |
922 | var DOM: ReactDOM;
923 | var PropTypes: ReactPropTypes;
924 | var Children: ReactChildren;
925 |
926 | //
927 | // Component API
928 | // ----------------------------------------------------------------------
929 |
930 | // Base component for plain JS classes
931 | class Component implements ComponentLifecycle
{
932 | constructor(props?: P, context?: any);
933 | setState(f: (prevState: S, props: P) => S, callback?: () => any): void;
934 | setState(state: S, callback?: () => any): void;
935 | forceUpdate(): void;
936 | render(): JSX.Element;
937 | props: P;
938 | state: S;
939 | context: {};
940 | refs: {
941 | [key: string]: Component
942 | };
943 | }
944 |
945 | interface ClassicComponent extends Component
{
946 | replaceState(nextState: S, callback?: () => any): void;
947 | getDOMNode(): TElement;
948 | getDOMNode(): Element;
949 | isMounted(): boolean;
950 | getInitialState?(): S;
951 | setProps(nextProps: P, callback?: () => any): void;
952 | replaceProps(nextProps: P, callback?: () => any): void;
953 | }
954 |
955 | interface DOMComponent extends ClassicComponent
{
956 | tagName: string;
957 | }
958 |
959 | type HTMLComponent = DOMComponent;
960 | type SVGComponent = DOMComponent;
961 |
962 | interface ChildContextProvider {
963 | getChildContext(): CC;
964 | }
965 |
966 | //
967 | // Class Interfaces
968 | // ----------------------------------------------------------------------
969 |
970 | interface ComponentClass {
971 | new(props?: P, context?: any): Component
;
972 | propTypes?: ValidationMap
;
973 | contextTypes?: ValidationMap;
974 | childContextTypes?: ValidationMap;
975 | defaultProps?: P;
976 | }
977 |
978 | interface ClassicComponentClass extends ComponentClass
{
979 | new(props?: P, context?: any): ClassicComponent
;
980 | getDefaultProps?(): P;
981 | displayName?: string;
982 | }
983 |
984 | //
985 | // Component Specs and Lifecycle
986 | // ----------------------------------------------------------------------
987 |
988 | interface ComponentLifecycle
{
989 | componentWillMount?(): void;
990 | componentDidMount?(): void;
991 | componentWillReceiveProps?(nextProps: P, nextContext: any): void;
992 | shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean;
993 | componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void;
994 | componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void;
995 | componentWillUnmount?(): void;
996 | }
997 |
998 | interface Mixin
extends ComponentLifecycle
{
999 | mixins?: Mixin
;
1000 | statics?: {
1001 | [key: string]: any;
1002 | };
1003 |
1004 | displayName?: string;
1005 | propTypes?: ValidationMap;
1006 | contextTypes?: ValidationMap;
1007 | childContextTypes?: ValidationMap
1008 |
1009 | getDefaultProps?(): P;
1010 | getInitialState?(): S;
1011 | }
1012 |
1013 | interface ComponentSpec extends Mixin
{
1014 | render(): ReactElement;
1015 |
1016 | [propertyName: string]: any;
1017 | }
1018 |
1019 | //
1020 | // Event System
1021 | // ----------------------------------------------------------------------
1022 |
1023 | interface SyntheticEvent {
1024 | bubbles: boolean;
1025 | cancelable: boolean;
1026 | currentTarget: EventTarget;
1027 | defaultPrevented: boolean;
1028 | eventPhase: number;
1029 | isTrusted: boolean;
1030 | nativeEvent: Event;
1031 | preventDefault(): void;
1032 | stopPropagation(): void;
1033 | target: EventTarget;
1034 | timeStamp: Date;
1035 | type: string;
1036 | }
1037 |
1038 | interface DragEvent extends SyntheticEvent {
1039 | dataTransfer: DataTransfer;
1040 | }
1041 |
1042 | interface ClipboardEvent extends SyntheticEvent {
1043 | clipboardData: DataTransfer;
1044 | }
1045 |
1046 | interface KeyboardEvent extends SyntheticEvent {
1047 | altKey: boolean;
1048 | charCode: number;
1049 | ctrlKey: boolean;
1050 | getModifierState(key: string): boolean;
1051 | key: string;
1052 | keyCode: number;
1053 | locale: string;
1054 | location: number;
1055 | metaKey: boolean;
1056 | repeat: boolean;
1057 | shiftKey: boolean;
1058 | which: number;
1059 | }
1060 |
1061 | interface FocusEvent extends SyntheticEvent {
1062 | relatedTarget: EventTarget;
1063 | }
1064 |
1065 | interface FormEvent extends SyntheticEvent {
1066 | }
1067 |
1068 | interface MouseEvent extends SyntheticEvent {
1069 | altKey: boolean;
1070 | button: number;
1071 | buttons: number;
1072 | clientX: number;
1073 | clientY: number;
1074 | ctrlKey: boolean;
1075 | getModifierState(key: string): boolean;
1076 | metaKey: boolean;
1077 | pageX: number;
1078 | pageY: number;
1079 | relatedTarget: EventTarget;
1080 | screenX: number;
1081 | screenY: number;
1082 | shiftKey: boolean;
1083 | }
1084 |
1085 | interface TouchEvent extends SyntheticEvent {
1086 | altKey: boolean;
1087 | changedTouches: TouchList;
1088 | ctrlKey: boolean;
1089 | getModifierState(key: string): boolean;
1090 | metaKey: boolean;
1091 | shiftKey: boolean;
1092 | targetTouches: TouchList;
1093 | touches: TouchList;
1094 | }
1095 |
1096 | interface UIEvent extends SyntheticEvent {
1097 | detail: number;
1098 | view: AbstractView;
1099 | }
1100 |
1101 | interface WheelEvent extends SyntheticEvent {
1102 | deltaMode: number;
1103 | deltaX: number;
1104 | deltaY: number;
1105 | deltaZ: number;
1106 | }
1107 |
1108 | //
1109 | // Event Handler Types
1110 | // ----------------------------------------------------------------------
1111 |
1112 | interface EventHandler {
1113 | (event: E): void;
1114 | }
1115 |
1116 | interface DragEventHandler extends EventHandler {}
1117 | interface ClipboardEventHandler extends EventHandler {}
1118 | interface KeyboardEventHandler extends EventHandler {}
1119 | interface FocusEventHandler extends EventHandler {}
1120 | interface FormEventHandler extends EventHandler {}
1121 | interface MouseEventHandler extends EventHandler {}
1122 | interface TouchEventHandler extends EventHandler {}
1123 | interface UIEventHandler extends EventHandler {}
1124 | interface WheelEventHandler extends EventHandler {}
1125 |
1126 | //
1127 | // Props / DOM Attributes
1128 | // ----------------------------------------------------------------------
1129 |
1130 | interface Props {
1131 | children?: ReactNode;
1132 | key?: string | number;
1133 | ref?: string | ((component: T) => any);
1134 | }
1135 |
1136 | interface DOMAttributes extends Props> {
1137 | onCopy?: ClipboardEventHandler;
1138 | onCut?: ClipboardEventHandler;
1139 | onPaste?: ClipboardEventHandler;
1140 | onKeyDown?: KeyboardEventHandler;
1141 | onKeyPress?: KeyboardEventHandler;
1142 | onKeyUp?: KeyboardEventHandler;
1143 | onFocus?: FocusEventHandler;
1144 | onBlur?: FocusEventHandler;
1145 | onChange?: FormEventHandler;
1146 | onInput?: FormEventHandler;
1147 | onSubmit?: FormEventHandler;
1148 | onClick?: MouseEventHandler;
1149 | onDoubleClick?: MouseEventHandler;
1150 | onDrag?: DragEventHandler;
1151 | onDragEnd?: DragEventHandler;
1152 | onDragEnter?: DragEventHandler;
1153 | onDragExit?: DragEventHandler;
1154 | onDragLeave?: DragEventHandler;
1155 | onDragOver?: DragEventHandler;
1156 | onDragStart?: DragEventHandler;
1157 | onDrop?: DragEventHandler;
1158 | onMouseDown?: MouseEventHandler;
1159 | onMouseEnter?: MouseEventHandler;
1160 | onMouseLeave?: MouseEventHandler;
1161 | onMouseMove?: MouseEventHandler;
1162 | onMouseOut?: MouseEventHandler;
1163 | onMouseOver?: MouseEventHandler;
1164 | onMouseUp?: MouseEventHandler;
1165 | onTouchCancel?: TouchEventHandler;
1166 | onTouchEnd?: TouchEventHandler;
1167 | onTouchMove?: TouchEventHandler;
1168 | onTouchStart?: TouchEventHandler;
1169 | onScroll?: UIEventHandler;
1170 | onWheel?: WheelEventHandler;
1171 |
1172 | dangerouslySetInnerHTML?: {
1173 | __html: string;
1174 | };
1175 | }
1176 |
1177 | // This interface is not complete. Only properties accepting
1178 | // unitless numbers are listed here (see CSSProperty.js in React)
1179 | interface CSSProperties {
1180 | boxFlex?: number;
1181 | boxFlexGroup?: number;
1182 | columnCount?: number;
1183 | flex?: number | string;
1184 | flexGrow?: number;
1185 | flexShrink?: number;
1186 | fontWeight?: number | string;
1187 | lineClamp?: number;
1188 | lineHeight?: number | string;
1189 | opacity?: number;
1190 | order?: number;
1191 | orphans?: number;
1192 | widows?: number;
1193 | zIndex?: number;
1194 | zoom?: number;
1195 |
1196 | fontSize?: number | string;
1197 |
1198 | // SVG-related properties
1199 | fillOpacity?: number;
1200 | strokeOpacity?: number;
1201 | strokeWidth?: number;
1202 |
1203 | [propertyName: string]: any;
1204 | }
1205 |
1206 | interface HTMLAttributes extends DOMAttributes {
1207 | ref?: string | ((component: HTMLComponent) => void);
1208 |
1209 | accept?: string;
1210 | acceptCharset?: string;
1211 | accessKey?: string;
1212 | action?: string;
1213 | allowFullScreen?: boolean;
1214 | allowTransparency?: boolean;
1215 | alt?: string;
1216 | async?: boolean;
1217 | autoComplete?: boolean;
1218 | autoFocus?: boolean;
1219 | autoPlay?: boolean;
1220 | cellPadding?: number | string;
1221 | cellSpacing?: number | string;
1222 | charSet?: string;
1223 | checked?: boolean;
1224 | classID?: string;
1225 | className?: string;
1226 | cols?: number;
1227 | colSpan?: number;
1228 | content?: string;
1229 | contentEditable?: boolean;
1230 | contextMenu?: string;
1231 | controls?: any;
1232 | coords?: string;
1233 | crossOrigin?: string;
1234 | data?: string;
1235 | dateTime?: string;
1236 | defaultChecked?: boolean;
1237 | defaultValue?: string;
1238 | defer?: boolean;
1239 | dir?: string;
1240 | disabled?: boolean;
1241 | download?: any;
1242 | draggable?: boolean;
1243 | encType?: string;
1244 | form?: string;
1245 | formAction?: string;
1246 | formEncType?: string;
1247 | formMethod?: string;
1248 | formNoValidate?: boolean;
1249 | formTarget?: string;
1250 | frameBorder?: number | string;
1251 | headers?: string;
1252 | height?: number | string;
1253 | hidden?: boolean;
1254 | high?: number;
1255 | href?: string;
1256 | hrefLang?: string;
1257 | htmlFor?: string;
1258 | httpEquiv?: string;
1259 | icon?: string;
1260 | id?: string;
1261 | label?: string;
1262 | lang?: string;
1263 | list?: string;
1264 | loop?: boolean;
1265 | low?: number;
1266 | manifest?: string;
1267 | marginHeight?: number;
1268 | marginWidth?: number;
1269 | max?: number | string;
1270 | maxLength?: number;
1271 | media?: string;
1272 | mediaGroup?: string;
1273 | method?: string;
1274 | min?: number | string;
1275 | multiple?: boolean;
1276 | muted?: boolean;
1277 | name?: string;
1278 | noValidate?: boolean;
1279 | open?: boolean;
1280 | optimum?: number;
1281 | pattern?: string;
1282 | placeholder?: string;
1283 | poster?: string;
1284 | preload?: string;
1285 | radioGroup?: string;
1286 | readOnly?: boolean;
1287 | rel?: string;
1288 | required?: boolean;
1289 | role?: string;
1290 | rows?: number;
1291 | rowSpan?: number;
1292 | sandbox?: string;
1293 | scope?: string;
1294 | scoped?: boolean;
1295 | scrolling?: string;
1296 | seamless?: boolean;
1297 | selected?: boolean;
1298 | shape?: string;
1299 | size?: number;
1300 | sizes?: string;
1301 | span?: number;
1302 | spellCheck?: boolean;
1303 | src?: string;
1304 | srcDoc?: string;
1305 | srcSet?: string;
1306 | start?: number;
1307 | step?: number | string;
1308 | style?: CSSProperties;
1309 | tabIndex?: number;
1310 | target?: string;
1311 | title?: string;
1312 | type?: string;
1313 | useMap?: string;
1314 | value?: string;
1315 | width?: number | string;
1316 | wmode?: string;
1317 |
1318 | // Non-standard Attributes
1319 | autoCapitalize?: boolean;
1320 | autoCorrect?: boolean;
1321 | property?: string;
1322 | itemProp?: string;
1323 | itemScope?: boolean;
1324 | itemType?: string;
1325 | unselectable?: boolean;
1326 | }
1327 |
1328 | interface SVGElementAttributes extends HTMLAttributes {
1329 | viewBox?: string;
1330 | preserveAspectRatio?: string;
1331 | }
1332 |
1333 | interface SVGAttributes extends DOMAttributes {
1334 | ref?: string | ((component: SVGComponent) => void);
1335 |
1336 | cx?: number | string;
1337 | cy?: number | string;
1338 | d?: string;
1339 | dx?: number | string;
1340 | dy?: number | string;
1341 | fill?: string;
1342 | fillOpacity?: number | string;
1343 | fontFamily?: string;
1344 | fontSize?: number | string;
1345 | fx?: number | string;
1346 | fy?: number | string;
1347 | gradientTransform?: string;
1348 | gradientUnits?: string;
1349 | height?: number | string;
1350 | markerEnd?: string;
1351 | markerMid?: string;
1352 | markerStart?: string;
1353 | offset?: number | string;
1354 | opacity?: number | string;
1355 | patternContentUnits?: string;
1356 | patternUnits?: string;
1357 | points?: string;
1358 | preserveAspectRatio?: string;
1359 | r?: number | string;
1360 | rx?: number | string;
1361 | ry?: number | string;
1362 | spreadMethod?: string;
1363 | stopColor?: string;
1364 | stopOpacity?: number | string;
1365 | stroke?: string;
1366 | strokeDasharray?: string;
1367 | strokeLinecap?: string;
1368 | strokeOpacity?: number | string;
1369 | strokeWidth?: number | string;
1370 | textAnchor?: string;
1371 | transform?: string;
1372 | version?: string;
1373 | viewBox?: string;
1374 | width?: number | string;
1375 | x1?: number | string;
1376 | x2?: number | string;
1377 | x?: number | string;
1378 | y1?: number | string;
1379 | y2?: number | string
1380 | y?: number | string;
1381 | }
1382 |
1383 | //
1384 | // React.DOM
1385 | // ----------------------------------------------------------------------
1386 |
1387 | interface ReactDOM {
1388 | // HTML
1389 | a: HTMLFactory;
1390 | abbr: HTMLFactory;
1391 | address: HTMLFactory;
1392 | area: HTMLFactory;
1393 | article: HTMLFactory;
1394 | aside: HTMLFactory;
1395 | audio: HTMLFactory;
1396 | b: HTMLFactory;
1397 | base: HTMLFactory;
1398 | bdi: HTMLFactory;
1399 | bdo: HTMLFactory;
1400 | big: HTMLFactory;
1401 | blockquote: HTMLFactory;
1402 | body: HTMLFactory;
1403 | br: HTMLFactory;
1404 | button: HTMLFactory;
1405 | canvas: HTMLFactory;
1406 | caption: HTMLFactory;
1407 | cite: HTMLFactory;
1408 | code: HTMLFactory;
1409 | col: HTMLFactory;
1410 | colgroup: HTMLFactory;
1411 | data: HTMLFactory;
1412 | datalist: HTMLFactory;
1413 | dd: HTMLFactory;
1414 | del: HTMLFactory;
1415 | details: HTMLFactory;
1416 | dfn: HTMLFactory;
1417 | dialog: HTMLFactory;
1418 | div: HTMLFactory;
1419 | dl: HTMLFactory;
1420 | dt: HTMLFactory;
1421 | em: HTMLFactory;
1422 | embed: HTMLFactory;
1423 | fieldset: HTMLFactory;
1424 | figcaption: HTMLFactory;
1425 | figure: HTMLFactory;
1426 | footer: HTMLFactory;
1427 | form: HTMLFactory;
1428 | h1: HTMLFactory;
1429 | h2: HTMLFactory;
1430 | h3: HTMLFactory;
1431 | h4: HTMLFactory;
1432 | h5: HTMLFactory;
1433 | h6: HTMLFactory;
1434 | head: HTMLFactory;
1435 | header: HTMLFactory;
1436 | hr: HTMLFactory;
1437 | html: HTMLFactory;
1438 | i: HTMLFactory;
1439 | iframe: HTMLFactory;
1440 | img: HTMLFactory;
1441 | input: HTMLFactory;
1442 | ins: HTMLFactory;
1443 | kbd: HTMLFactory;
1444 | keygen: HTMLFactory;
1445 | label: HTMLFactory;
1446 | legend: HTMLFactory;
1447 | li: HTMLFactory;
1448 | link: HTMLFactory;
1449 | main: HTMLFactory;
1450 | map: HTMLFactory;
1451 | mark: HTMLFactory;
1452 | menu: HTMLFactory;
1453 | menuitem: HTMLFactory;
1454 | meta: HTMLFactory;
1455 | meter: HTMLFactory;
1456 | nav: HTMLFactory;
1457 | noscript: HTMLFactory;
1458 | object: HTMLFactory;
1459 | ol: HTMLFactory;
1460 | optgroup: HTMLFactory;
1461 | option: HTMLFactory;
1462 | output: HTMLFactory;
1463 | p: HTMLFactory;
1464 | param: HTMLFactory;
1465 | picture: HTMLFactory;
1466 | pre: HTMLFactory;
1467 | progress: HTMLFactory;
1468 | q: HTMLFactory;
1469 | rp: HTMLFactory;
1470 | rt: HTMLFactory;
1471 | ruby: HTMLFactory;
1472 | s: HTMLFactory;
1473 | samp: HTMLFactory;
1474 | script: HTMLFactory;
1475 | section: HTMLFactory;
1476 | select: HTMLFactory;
1477 | small: HTMLFactory;
1478 | source: HTMLFactory;
1479 | span: HTMLFactory;
1480 | strong: HTMLFactory;
1481 | style: HTMLFactory;
1482 | sub: HTMLFactory;
1483 | summary: HTMLFactory;
1484 | sup: HTMLFactory;
1485 | table: HTMLFactory;
1486 | tbody: HTMLFactory;
1487 | td: HTMLFactory;
1488 | textarea: HTMLFactory;
1489 | tfoot: HTMLFactory;
1490 | th: HTMLFactory;
1491 | thead: HTMLFactory;
1492 | time: HTMLFactory;
1493 | title: HTMLFactory;
1494 | tr: HTMLFactory;
1495 | track: HTMLFactory;
1496 | u: HTMLFactory;
1497 | ul: HTMLFactory;
1498 | "var": HTMLFactory;
1499 | video: HTMLFactory;
1500 | wbr: HTMLFactory;
1501 |
1502 | // SVG
1503 | svg: SVGElementFactory;
1504 | circle: SVGFactory;
1505 | defs: SVGFactory;
1506 | ellipse: SVGFactory;
1507 | g: SVGFactory;
1508 | line: SVGFactory;
1509 | linearGradient: SVGFactory;
1510 | mask: SVGFactory;
1511 | path: SVGFactory;
1512 | pattern: SVGFactory;
1513 | polygon: SVGFactory;
1514 | polyline: SVGFactory;
1515 | radialGradient: SVGFactory;
1516 | rect: SVGFactory;
1517 | stop: SVGFactory;
1518 | text: SVGFactory;
1519 | tspan: SVGFactory;
1520 | }
1521 |
1522 | //
1523 | // React.PropTypes
1524 | // ----------------------------------------------------------------------
1525 |
1526 | interface Validator {
1527 | (object: T, key: string, componentName: string): Error;
1528 | }
1529 |
1530 | interface Requireable extends Validator {
1531 | isRequired: Validator;
1532 | }
1533 |
1534 | interface ValidationMap {
1535 | [key: string]: Validator;
1536 | }
1537 |
1538 | interface ReactPropTypes {
1539 | any: Requireable;
1540 | array: Requireable;
1541 | bool: Requireable;
1542 | func: Requireable;
1543 | number: Requireable;
1544 | object: Requireable;
1545 | string: Requireable;
1546 | node: Requireable;
1547 | element: Requireable;
1548 | instanceOf(expectedClass: {}): Requireable;
1549 | oneOf(types: any[]): Requireable;
1550 | oneOfType(types: Validator[]): Requireable;
1551 | arrayOf(type: Validator): Requireable;
1552 | objectOf(type: Validator): Requireable;
1553 | shape(type: ValidationMap): Requireable;
1554 | }
1555 |
1556 | //
1557 | // React.Children
1558 | // ----------------------------------------------------------------------
1559 |
1560 | interface ReactChildren {
1561 | map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T };
1562 | forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void;
1563 | count(children: ReactNode): number;
1564 | only(children: ReactNode): ReactChild;
1565 | }
1566 |
1567 | //
1568 | // Browser Interfaces
1569 | // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts
1570 | // ----------------------------------------------------------------------
1571 |
1572 | interface AbstractView {
1573 | styleMedia: StyleMedia;
1574 | document: Document;
1575 | }
1576 |
1577 | interface Touch {
1578 | identifier: number;
1579 | target: EventTarget;
1580 | screenX: number;
1581 | screenY: number;
1582 | clientX: number;
1583 | clientY: number;
1584 | pageX: number;
1585 | pageY: number;
1586 | }
1587 |
1588 | interface TouchList {
1589 | [index: number]: Touch;
1590 | length: number;
1591 | item(index: number): Touch;
1592 | identifiedTouch(identifier: number): Touch;
1593 | }
1594 |
1595 | //
1596 | // React.addons
1597 | // ----------------------------------------------------------------------
1598 |
1599 | export module addons {
1600 | export var CSSTransitionGroup: CSSTransitionGroup;
1601 | export var TransitionGroup: TransitionGroup;
1602 |
1603 | export var LinkedStateMixin: LinkedStateMixin;
1604 | export var PureRenderMixin: PureRenderMixin;
1605 |
1606 | export function batchedUpdates(
1607 | callback: (a: A, b: B) => any, a: A, b: B): void;
1608 | export function batchedUpdates(callback: (a: A) => any, a: A): void;
1609 | export function batchedUpdates(callback: () => any): void;
1610 |
1611 | // deprecated: use petehunt/react-classset or JedWatson/classnames
1612 | export function classSet(cx: { [key: string]: boolean }): string;
1613 | export function classSet(...classList: string[]): string;
1614 |
1615 | export function cloneWithProps(
1616 | element: DOMElement
, props: P): DOMElement
;
1617 | export function cloneWithProps
(
1618 | element: ClassicElement
, props: P): ClassicElement
;
1619 | export function cloneWithProps
(
1620 | element: ReactElement
, props: P): ReactElement
;
1621 |
1622 | export function createFragment(
1623 | object: { [key: string]: ReactNode }): ReactFragment;
1624 |
1625 | export function update(value: any[], spec: UpdateArraySpec): any[];
1626 | export function update(value: {}, spec: UpdateSpec): any;
1627 |
1628 | // Development tools
1629 | export import Perf = ReactPerf;
1630 | export import TestUtils = ReactTestUtils;
1631 | }
1632 |
1633 | //
1634 | // React.addons (Transitions)
1635 | // ----------------------------------------------------------------------
1636 |
1637 | interface TransitionGroupProps {
1638 | component?: ReactType;
1639 | childFactory?: (child: ReactElement) => ReactElement;
1640 | }
1641 |
1642 | interface CSSTransitionGroupProps extends TransitionGroupProps {
1643 | transitionName: string;
1644 | transitionAppear?: boolean;
1645 | transitionEnter?: boolean;
1646 | transitionLeave?: boolean;
1647 | }
1648 |
1649 | type CSSTransitionGroup = ComponentClass;
1650 | type TransitionGroup = ComponentClass;
1651 |
1652 | //
1653 | // React.addons (Mixins)
1654 | // ----------------------------------------------------------------------
1655 |
1656 | interface ReactLink {
1657 | value: T;
1658 | requestChange(newValue: T): void;
1659 | }
1660 |
1661 | interface LinkedStateMixin extends Mixin {
1662 | linkState(key: string): ReactLink;
1663 | }
1664 |
1665 | interface PureRenderMixin extends Mixin {
1666 | }
1667 |
1668 | //
1669 | // Reat.addons.update
1670 | // ----------------------------------------------------------------------
1671 |
1672 | interface UpdateSpec {
1673 | $set?: any;
1674 | $merge?: {};
1675 | $apply?(value: any): any;
1676 | // [key: string]: UpdateSpec;
1677 | }
1678 |
1679 | interface UpdateArraySpec extends UpdateSpec {
1680 | $push?: any[];
1681 | $unshift?: any[];
1682 | $splice?: any[][];
1683 | }
1684 |
1685 | //
1686 | // React.addons.Perf
1687 | // ----------------------------------------------------------------------
1688 |
1689 | interface ComponentPerfContext {
1690 | current: string;
1691 | owner: string;
1692 | }
1693 |
1694 | interface NumericPerfContext {
1695 | [key: string]: number;
1696 | }
1697 |
1698 | interface Measurements {
1699 | exclusive: NumericPerfContext;
1700 | inclusive: NumericPerfContext;
1701 | render: NumericPerfContext;
1702 | counts: NumericPerfContext;
1703 | writes: NumericPerfContext;
1704 | displayNames: {
1705 | [key: string]: ComponentPerfContext;
1706 | };
1707 | totalTime: number;
1708 | }
1709 |
1710 | module ReactPerf {
1711 | export function start(): void;
1712 | export function stop(): void;
1713 | export function printInclusive(measurements: Measurements[]): void;
1714 | export function printExclusive(measurements: Measurements[]): void;
1715 | export function printWasted(measurements: Measurements[]): void;
1716 | export function printDOM(measurements: Measurements[]): void;
1717 | export function getLastMeasurements(): Measurements[];
1718 | }
1719 |
1720 | //
1721 | // React.addons.TestUtils
1722 | // ----------------------------------------------------------------------
1723 |
1724 | interface MockedComponentClass {
1725 | new(): any;
1726 | }
1727 |
1728 | module ReactTestUtils {
1729 | export import Simulate = ReactSimulate;
1730 |
1731 | export function renderIntoDocument(
1732 | element: ReactElement
): Component
;
1733 | export function renderIntoDocument>(
1734 | element: ReactElement): C;
1735 |
1736 | export function mockComponent(
1737 | mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils;
1738 |
1739 | export function isElementOfType(
1740 | element: ReactElement, type: ReactType): boolean;
1741 | export function isTextComponent(instance: Component): boolean;
1742 | export function isDOMComponent(instance: Component): boolean;
1743 | export function isCompositeComponent(instance: Component): boolean;
1744 | export function isCompositeComponentWithType(
1745 | instance: Component,
1746 | type: ComponentClass): boolean;
1747 |
1748 | export function findAllInRenderedTree(
1749 | tree: Component,
1750 | fn: (i: Component) => boolean): Component;
1751 |
1752 | export function scryRenderedDOMComponentsWithClass(
1753 | tree: Component,
1754 | className: string): DOMComponent[];
1755 | export function findRenderedDOMComponentWithClass(
1756 | tree: Component,
1757 | className: string): DOMComponent;
1758 |
1759 | export function scryRenderedDOMComponentsWithTag(
1760 | tree: Component,
1761 | tagName: string): DOMComponent[];
1762 | export function findRenderedDOMComponentWithTag(
1763 | tree: Component,
1764 | tagName: string): DOMComponent;
1765 |
1766 | export function scryRenderedComponentsWithType(
1767 | tree: Component,
1768 | type: ComponentClass): Component
[];
1769 | export function scryRenderedComponentsWithType>(
1770 | tree: Component,
1771 | type: ComponentClass): C[];
1772 |
1773 | export function findRenderedComponentWithType(
1774 | tree: Component,
1775 | type: ComponentClass): Component
;
1776 | export function findRenderedComponentWithType>(
1777 | tree: Component,
1778 | type: ComponentClass): C;
1779 |
1780 | export function createRenderer(): ShallowRenderer;
1781 | }
1782 |
1783 | interface SyntheticEventData {
1784 | altKey?: boolean;
1785 | button?: number;
1786 | buttons?: number;
1787 | clientX?: number;
1788 | clientY?: number;
1789 | changedTouches?: TouchList;
1790 | charCode?: boolean;
1791 | clipboardData?: DataTransfer;
1792 | ctrlKey?: boolean;
1793 | deltaMode?: number;
1794 | deltaX?: number;
1795 | deltaY?: number;
1796 | deltaZ?: number;
1797 | detail?: number;
1798 | getModifierState?(key: string): boolean;
1799 | key?: string;
1800 | keyCode?: number;
1801 | locale?: string;
1802 | location?: number;
1803 | metaKey?: boolean;
1804 | pageX?: number;
1805 | pageY?: number;
1806 | relatedTarget?: EventTarget;
1807 | repeat?: boolean;
1808 | screenX?: number;
1809 | screenY?: number;
1810 | shiftKey?: boolean;
1811 | targetTouches?: TouchList;
1812 | touches?: TouchList;
1813 | view?: AbstractView;
1814 | which?: number;
1815 | }
1816 |
1817 | interface EventSimulator {
1818 | (element: Element, eventData?: SyntheticEventData): void;
1819 | (component: Component, eventData?: SyntheticEventData): void;
1820 | }
1821 |
1822 | module ReactSimulate {
1823 | export var blur: EventSimulator;
1824 | export var change: EventSimulator;
1825 | export var click: EventSimulator;
1826 | export var cut: EventSimulator;
1827 | export var doubleClick: EventSimulator;
1828 | export var drag: EventSimulator;
1829 | export var dragEnd: EventSimulator;
1830 | export var dragEnter: EventSimulator;
1831 | export var dragExit: EventSimulator;
1832 | export var dragLeave: EventSimulator;
1833 | export var dragOver: EventSimulator;
1834 | export var dragStart: EventSimulator;
1835 | export var drop: EventSimulator;
1836 | export var focus: EventSimulator;
1837 | export var input: EventSimulator;
1838 | export var keyDown: EventSimulator;
1839 | export var keyPress: EventSimulator;
1840 | export var keyUp: EventSimulator;
1841 | export var mouseDown: EventSimulator;
1842 | export var mouseEnter: EventSimulator;
1843 | export var mouseLeave: EventSimulator;
1844 | export var mouseMove: EventSimulator;
1845 | export var mouseOut: EventSimulator;
1846 | export var mouseOver: EventSimulator;
1847 | export var mouseUp: EventSimulator;
1848 | export var paste: EventSimulator;
1849 | export var scroll: EventSimulator;
1850 | export var submit: EventSimulator;
1851 | export var touchCancel: EventSimulator;
1852 | export var touchEnd: EventSimulator;
1853 | export var touchMove: EventSimulator;
1854 | export var touchStart: EventSimulator;
1855 | export var wheel: EventSimulator;
1856 | }
1857 |
1858 | class ShallowRenderer {
1859 | getRenderOutput>(): E;
1860 | getRenderOutput(): ReactElement;
1861 | render(element: ReactElement, context?: any): void;
1862 | unmount(): void;
1863 | }
1864 | }
1865 |
1866 | declare namespace JSX {
1867 | import React = __React;
1868 |
1869 | interface Element extends React.ReactElement { }
1870 | interface ElementClass extends React.Component {
1871 | render(): JSX.Element;
1872 | }
1873 | interface ElementAttributesProperty { props: {}; }
1874 |
1875 | interface IntrinsicElements {
1876 | // HTML
1877 | a: React.HTMLAttributes;
1878 | abbr: React.HTMLAttributes;
1879 | address: React.HTMLAttributes;
1880 | area: React.HTMLAttributes;
1881 | article: React.HTMLAttributes;
1882 | aside: React.HTMLAttributes;
1883 | audio: React.HTMLAttributes;
1884 | b: React.HTMLAttributes;
1885 | base: React.HTMLAttributes;
1886 | bdi: React.HTMLAttributes;
1887 | bdo: React.HTMLAttributes;
1888 | big: React.HTMLAttributes;
1889 | blockquote: React.HTMLAttributes;
1890 | body: React.HTMLAttributes;
1891 | br: React.HTMLAttributes;
1892 | button: React.HTMLAttributes;
1893 | canvas: React.HTMLAttributes;
1894 | caption: React.HTMLAttributes;
1895 | cite: React.HTMLAttributes;
1896 | code: React.HTMLAttributes;
1897 | col: React.HTMLAttributes;
1898 | colgroup: React.HTMLAttributes;
1899 | data: React.HTMLAttributes;
1900 | datalist: React.HTMLAttributes;
1901 | dd: React.HTMLAttributes;
1902 | del: React.HTMLAttributes;
1903 | details: React.HTMLAttributes;
1904 | dfn: React.HTMLAttributes;
1905 | dialog: React.HTMLAttributes;
1906 | div: React.HTMLAttributes;
1907 | dl: React.HTMLAttributes;
1908 | dt: React.HTMLAttributes;
1909 | em: React.HTMLAttributes;
1910 | embed: React.HTMLAttributes;
1911 | fieldset: React.HTMLAttributes;
1912 | figcaption: React.HTMLAttributes;
1913 | figure: React.HTMLAttributes;
1914 | footer: React.HTMLAttributes;
1915 | form: React.HTMLAttributes;
1916 | h1: React.HTMLAttributes;
1917 | h2: React.HTMLAttributes;
1918 | h3: React.HTMLAttributes;
1919 | h4: React.HTMLAttributes;
1920 | h5: React.HTMLAttributes;
1921 | h6: React.HTMLAttributes;
1922 | head: React.HTMLAttributes;
1923 | header: React.HTMLAttributes;
1924 | hr: React.HTMLAttributes;
1925 | html: React.HTMLAttributes;
1926 | i: React.HTMLAttributes;
1927 | iframe: React.HTMLAttributes;
1928 | img: React.HTMLAttributes;
1929 | input: React.HTMLAttributes;
1930 | ins: React.HTMLAttributes;
1931 | kbd: React.HTMLAttributes;
1932 | keygen: React.HTMLAttributes;
1933 | label: React.HTMLAttributes;
1934 | legend: React.HTMLAttributes;
1935 | li: React.HTMLAttributes;
1936 | link: React.HTMLAttributes;
1937 | main: React.HTMLAttributes;
1938 | map: React.HTMLAttributes;
1939 | mark: React.HTMLAttributes;
1940 | menu: React.HTMLAttributes;
1941 | menuitem: React.HTMLAttributes;
1942 | meta: React.HTMLAttributes;
1943 | meter: React.HTMLAttributes;
1944 | nav: React.HTMLAttributes;
1945 | noscript: React.HTMLAttributes;
1946 | object: React.HTMLAttributes;
1947 | ol: React.HTMLAttributes;
1948 | optgroup: React.HTMLAttributes;
1949 | option: React.HTMLAttributes;
1950 | output: React.HTMLAttributes;
1951 | p: React.HTMLAttributes;
1952 | param: React.HTMLAttributes;
1953 | picture: React.HTMLAttributes;
1954 | pre: React.HTMLAttributes;
1955 | progress: React.HTMLAttributes;
1956 | q: React.HTMLAttributes;
1957 | rp: React.HTMLAttributes;
1958 | rt: React.HTMLAttributes;
1959 | ruby: React.HTMLAttributes;
1960 | s: React.HTMLAttributes;
1961 | samp: React.HTMLAttributes;
1962 | script: React.HTMLAttributes;
1963 | section: React.HTMLAttributes;
1964 | select: React.HTMLAttributes;
1965 | small: React.HTMLAttributes;
1966 | source: React.HTMLAttributes;
1967 | span: React.HTMLAttributes;
1968 | strong: React.HTMLAttributes;
1969 | style: React.HTMLAttributes;
1970 | sub: React.HTMLAttributes;
1971 | summary: React.HTMLAttributes;
1972 | sup: React.HTMLAttributes;
1973 | table: React.HTMLAttributes;
1974 | tbody: React.HTMLAttributes;
1975 | td: React.HTMLAttributes;
1976 | textarea: React.HTMLAttributes;
1977 | tfoot: React.HTMLAttributes;
1978 | th: React.HTMLAttributes;
1979 | thead: React.HTMLAttributes;
1980 | time: React.HTMLAttributes;
1981 | title: React.HTMLAttributes;
1982 | tr: React.HTMLAttributes;
1983 | track: React.HTMLAttributes;
1984 | u: React.HTMLAttributes;
1985 | ul: React.HTMLAttributes;
1986 | "var": React.HTMLAttributes;
1987 | video: React.HTMLAttributes;
1988 | wbr: React.HTMLAttributes;
1989 |
1990 | // SVG
1991 | svg: React.SVGElementAttributes;
1992 |
1993 | circle: React.SVGAttributes;
1994 | defs: React.SVGAttributes;
1995 | ellipse: React.SVGAttributes;
1996 | g: React.SVGAttributes;
1997 | line: React.SVGAttributes;
1998 | linearGradient: React.SVGAttributes;
1999 | mask: React.SVGAttributes;
2000 | path: React.SVGAttributes;
2001 | pattern: React.SVGAttributes;
2002 | polygon: React.SVGAttributes;
2003 | polyline: React.SVGAttributes;
2004 | radialGradient: React.SVGAttributes;
2005 | rect: React.SVGAttributes;
2006 | stop: React.SVGAttributes;
2007 | text: React.SVGAttributes;
2008 | tspan: React.SVGAttributes;
2009 | }
2010 | }
2011 |
--------------------------------------------------------------------------------
/typings/tsd.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------