Fix use of generic react event handlers

This commit is contained in:
Mohamed Hegazy
2016-07-13 22:11:35 -07:00
parent 1848a0de40
commit ef98075fbf

282
react-mdl/index.d.ts vendored
View File

@@ -12,7 +12,7 @@ declare namespace __ReactMDL {
type __MDLOtherProps = React.HTMLProps<any>;
class __MDLComponent<P extends __MDLClassProps> extends React.Component<P, {}> {}
class __MDLBasicComponent extends __MDLComponent<__MDLOtherProps> {}
interface ShadowedComponent {
shadow ?: number;
}
@@ -22,8 +22,8 @@ declare namespace __ReactMDL {
interface CustomRenderedComponent {
component ?: string | JSX.Element | Function;
}
// HTMLAttributes (minus the 'data', 'icon', 'label', 'name', 'rows', 'size', 'title', 'value' attributes)
interface MDLHTMLAttributes {
// React-specific Attributes
@@ -173,7 +173,7 @@ declare namespace __ReactMDL {
[key: string]: any;
}
// DOMAttributes (minus 'onClick', 'onChange')
interface MDLDOMAttributes {
interface MDLDOMAttributes<T> {
// DOMAttributes (minus onClick)
children?: React.ReactNode;
dangerouslySetInnerHTML?: {
@@ -181,93 +181,93 @@ declare namespace __ReactMDL {
};
// Clipboard Events
onCopy?: React.ClipboardEventHandler;
onCut?: React.ClipboardEventHandler;
onPaste?: React.ClipboardEventHandler;
onCopy?: React.ClipboardEventHandler<T>;
onCut?: React.ClipboardEventHandler<T>;
onPaste?: React.ClipboardEventHandler<T>;
// Composition Events
onCompositionEnd?: React.CompositionEventHandler;
onCompositionStart?: React.CompositionEventHandler;
onCompositionUpdate?: React.CompositionEventHandler;
onCompositionEnd?: React.CompositionEventHandler<T>;
onCompositionStart?: React.CompositionEventHandler<T>;
onCompositionUpdate?: React.CompositionEventHandler<T>;
// Focus Events
onFocus?: React.FocusEventHandler;
onBlur?: React.FocusEventHandler;
onFocus?: React.FocusEventHandler<T>;
onBlur?: React.FocusEventHandler<T>;
// Form Events
onInput?: React.FormEventHandler;
onSubmit?: React.FormEventHandler;
onInput?: React.FormEventHandler<T>;
onSubmit?: React.FormEventHandler<T>;
// Image Events
onLoad?: React.ReactEventHandler;
onError?: React.ReactEventHandler; // also a Media Event
onLoad?: React.ReactEventHandler<T>;
onError?: React.ReactEventHandler<T>; // also a Media Event
// Keyboard Events
onKeyDown?: React.KeyboardEventHandler;
onKeyPress?: React.KeyboardEventHandler;
onKeyUp?: React.KeyboardEventHandler;
onKeyDown?: React.KeyboardEventHandler<T>;
onKeyPress?: React.KeyboardEventHandler<T>;
onKeyUp?: React.KeyboardEventHandler<T>;
// Media Events
onAbort?: React.ReactEventHandler;
onCanPlay?: React.ReactEventHandler;
onCanPlayThrough?: React.ReactEventHandler;
onDurationChange?: React.ReactEventHandler;
onEmptied?: React.ReactEventHandler;
onEncrypted?: React.ReactEventHandler;
onEnded?: React.ReactEventHandler;
onLoadedData?: React.ReactEventHandler;
onLoadedMetadata?: React.ReactEventHandler;
onLoadStart?: React.ReactEventHandler;
onPause?: React.ReactEventHandler;
onPlay?: React.ReactEventHandler;
onPlaying?: React.ReactEventHandler;
onProgress?: React.ReactEventHandler;
onRateChange?: React.ReactEventHandler;
onSeeked?: React.ReactEventHandler;
onSeeking?: React.ReactEventHandler;
onStalled?: React.ReactEventHandler;
onSuspend?: React.ReactEventHandler;
onTimeUpdate?: React.ReactEventHandler;
onVolumeChange?: React.ReactEventHandler;
onWaiting?: React.ReactEventHandler;
onAbort?: React.ReactEventHandler<T>;
onCanPlay?: React.ReactEventHandler<T>;
onCanPlayThrough?: React.ReactEventHandler<T>;
onDurationChange?: React.ReactEventHandler<T>;
onEmptied?: React.ReactEventHandler<T>;
onEncrypted?: React.ReactEventHandler<T>;
onEnded?: React.ReactEventHandler<T>;
onLoadedData?: React.ReactEventHandler<T>;
onLoadedMetadata?: React.ReactEventHandler<T>;
onLoadStart?: React.ReactEventHandler<T>;
onPause?: React.ReactEventHandler<T>;
onPlay?: React.ReactEventHandler<T>;
onPlaying?: React.ReactEventHandler<T>;
onProgress?: React.ReactEventHandler<T>;
onRateChange?: React.ReactEventHandler<T>;
onSeeked?: React.ReactEventHandler<T>;
onSeeking?: React.ReactEventHandler<T>;
onStalled?: React.ReactEventHandler<T>;
onSuspend?: React.ReactEventHandler<T>;
onTimeUpdate?: React.ReactEventHandler<T>;
onVolumeChange?: React.ReactEventHandler<T>;
onWaiting?: React.ReactEventHandler<T>;
// MouseEvents
onContextMenu?: React.MouseEventHandler;
onDoubleClick?: React.MouseEventHandler;
onDrag?: React.DragEventHandler;
onDragEnd?: React.DragEventHandler;
onDragEnter?: React.DragEventHandler;
onDragExit?: React.DragEventHandler;
onDragLeave?: React.DragEventHandler;
onDragOver?: React.DragEventHandler;
onDragStart?: React.DragEventHandler;
onDrop?: React.DragEventHandler;
onMouseDown?: React.MouseEventHandler;
onMouseEnter?: React.MouseEventHandler;
onMouseLeave?: React.MouseEventHandler;
onMouseMove?: React.MouseEventHandler;
onMouseOut?: React.MouseEventHandler;
onMouseOver?: React.MouseEventHandler;
onMouseUp?: React.MouseEventHandler;
onContextMenu?: React.MouseEventHandler<T>;
onDoubleClick?: React.MouseEventHandler<T>;
onDrag?: React.DragEventHandler<T>;
onDragEnd?: React.DragEventHandler<T>;
onDragEnter?: React.DragEventHandler<T>;
onDragExit?: React.DragEventHandler<T>;
onDragLeave?: React.DragEventHandler<T>;
onDragOver?: React.DragEventHandler<T>;
onDragStart?: React.DragEventHandler<T>;
onDrop?: React.DragEventHandler<T>;
onMouseDown?: React.MouseEventHandler<T>;
onMouseEnter?: React.MouseEventHandler<T>;
onMouseLeave?: React.MouseEventHandler<T>;
onMouseMove?: React.MouseEventHandler<T>;
onMouseOut?: React.MouseEventHandler<T>;
onMouseOver?: React.MouseEventHandler<T>;
onMouseUp?: React.MouseEventHandler<T>;
// Selection Events
onSelect?: React.ReactEventHandler;
onSelect?: React.ReactEventHandler<T>;
// Touch Events
onTouchCancel?: React.TouchEventHandler;
onTouchEnd?: React.TouchEventHandler;
onTouchMove?: React.TouchEventHandler;
onTouchStart?: React.TouchEventHandler;
onTouchCancel?: React.TouchEventHandler<T>;
onTouchEnd?: React.TouchEventHandler<T>;
onTouchMove?: React.TouchEventHandler<T>;
onTouchStart?: React.TouchEventHandler<T>;
// UI Events
onScroll?: React.UIEventHandler;
onScroll?: React.UIEventHandler<T>;
// Wheel Events
onWheel?: React.WheelEventHandler;
onWheel?: React.WheelEventHandler<T>;
}
interface BadgeProps extends __MDLClassProps {
text: string | number;
className ?: string;
@@ -275,8 +275,8 @@ declare namespace __ReactMDL {
overlap ?: boolean;
}
class Badge extends __MDLComponent<BadgeProps> {}
interface ButtonProps extends __MDLOtherProps, RippleComponent, CustomRenderedComponent {
accent ?: boolean;
colored ?: boolean;
@@ -295,8 +295,8 @@ declare namespace __ReactMDL {
class Button extends __MDLComponent<StandardButtonProps> {}
class FABButton extends __MDLComponent<FABButtonProps> {}
class IconButton extends __MDLComponent<IconButtonProps> {}
interface CardProps extends __MDLOtherProps, ShadowedComponent {}
interface CardActionProps extends __MDLOtherProps {
border ?: boolean;
@@ -310,19 +310,19 @@ declare namespace __ReactMDL {
class CardText extends __MDLBasicComponent {}
class CardMenu extends __MDLBasicComponent {}
class CardMedia extends __MDLBasicComponent {}
interface CheckboxProps extends __MDLOtherProps, RippleComponent {
checked ?: boolean;
disabled ?: boolean;
label ?: string;
}
class Checkbox extends __MDLComponent<CheckboxProps> {}
interface UndecoratedTableProps extends __MDLClassProps, MDLHTMLAttributes, React.DOMAttributes, ShadowedComponent {
interface UndecoratedTableProps extends __MDLClassProps, MDLHTMLAttributes, React.DOMAttributes<UndecoratedTable>, ShadowedComponent {
rows: Array<any>;
rowKeyColumn ?: string;
name ?: string;
title ?: string;
}
@@ -331,13 +331,13 @@ declare namespace __ReactMDL {
selectable ?: boolean;
onSelectionChanged ?: (row : any) => any;
}
interface TableHeaderProps extends __MDLClassProps, MDLHTMLAttributes, MDLDOMAttributes {
interface TableHeaderProps extends __MDLClassProps, MDLHTMLAttributes, MDLDOMAttributes<TableHeader> {
name : string;
title ?: string;
cellFormatter ?: (value : any, row : any, index : number) => React.ReactNode;
numeric ?: boolean;
nosort ?: boolean;
onClick ?: (e : React.MouseEvent, name : string) => any;
onClick ?: (e : React.MouseEvent<TableHeader>, name : string) => any;
sortFn ?: (a : any, b : any, isAsc : boolean) => number;
tooltip ?: React.ReactNode;
}
@@ -345,8 +345,8 @@ declare namespace __ReactMDL {
class TableHeader extends __MDLComponent<TableHeaderProps> {}
class UndecoratedTable extends __MDLComponent<UndecoratedTableProps> {}
class DataTable extends Table {}
interface DialogProps extends __MDLOtherProps {
open ?: boolean;
}
@@ -358,8 +358,8 @@ declare namespace __ReactMDL {
class DialogActions extends __MDLComponent<DialogActionsProps> {}
class DialogTitle extends __MDLComponent<DialogTitleProps> {}
class DialogContent extends __MDLBasicComponent {}
interface GridProps extends __MDLOtherProps, CustomRenderedComponent, ShadowedComponent {
noSpacing ?: boolean;
}
@@ -374,22 +374,22 @@ declare namespace __ReactMDL {
}
class Grid extends __MDLComponent<GridProps> {}
class Cell extends __MDLComponent<CellProps> {}
interface IconProps extends __MDLOtherProps {
name : string;
}
class Icon extends __MDLComponent<IconProps> {}
interface IconToggleProps extends __MDLOtherProps, RippleComponent {
name : string;
checked ?: boolean;
disabled ?: boolean;
}
class IconToggle extends __MDLComponent<IconToggleProps> {}
interface ContentProps extends __MDLOtherProps, CustomRenderedComponent {}
interface DrawerProps extends __MDLOtherProps {
title ?: string;
@@ -407,7 +407,7 @@ declare namespace __ReactMDL {
}
interface HeaderTabsProps extends __MDLOtherProps, RippleComponent {
activeTab ?: number;
onChange ?: React.FormEventHandler;
onChange ?: React.FormEventHandler<Header>;
}
interface LayoutProps extends __MDLOtherProps {
fixedDrawer ?: boolean;
@@ -423,33 +423,33 @@ declare namespace __ReactMDL {
class Layout extends __MDLComponent<LayoutProps> {}
class Navigation extends __MDLComponent<NavigationProps> {}
class Spacer extends __MDLBasicComponent {}
interface FooterProps extends MDLHTMLAttributes, React.DOMAttributes {
interface FooterProps extends MDLHTMLAttributes, React.DOMAttributes<Footer> {
size ?: string;
title ?: string;
}
interface FooterDropDownSectionProps extends MDLHTMLAttributes, React.DOMAttributes {
interface FooterDropDownSectionProps extends MDLHTMLAttributes, React.DOMAttributes<FooterDropDownSection> {
size ?: string;
title : React.ReactNode;
}
interface FooterLinkListProps extends MDLHTMLAttributes, React.DOMAttributes {
interface FooterLinkListProps extends MDLHTMLAttributes, React.DOMAttributes<FooterLinkList> {
size ?: string;
title ?: string;
}
interface FooterSectionProps extends MDLHTMLAttributes, React.DOMAttributes {
interface FooterSectionProps extends MDLHTMLAttributes, React.DOMAttributes<FooterSection> {
size ?: string;
type ?: string;
logo ?: React.ReactNode;
title ?: string;
}
class Footer extends __MDLComponent<FooterProps> {}
class FooterDropDownSection extends __MDLComponent<FooterDropDownSectionProps> {}
class FooterLinkList extends __MDLComponent<FooterLinkListProps> {}
class FooterSection extends __MDLComponent<FooterSectionProps> {}
interface ListItemProps extends __MDLOtherProps {
twoLine ?: boolean;
threeLine ?: boolean;
@@ -457,7 +457,7 @@ declare namespace __ReactMDL {
interface ListItemActionProps extends __MDLOtherProps {
info ?: string;
}
interface ListItemContentProps extends MDLHTMLAttributes, React.DOMAttributes {
interface ListItemContentProps extends MDLHTMLAttributes, React.DOMAttributes<ListItemContent> {
avatar ?: string | JSX.Element;
icon ?: string | JSX.Element;
subtitle ?: React.ReactNode;
@@ -467,8 +467,8 @@ declare namespace __ReactMDL {
class ListItem extends __MDLComponent<ListItemProps> {}
class ListItemAction extends __MDLComponent<ListItemActionProps> {}
class ListItemContent extends __MDLComponent<ListItemContentProps> {}
interface MenuProps extends __MDLOtherProps, RippleComponent {
target : string;
align ?: string;
@@ -476,99 +476,99 @@ declare namespace __ReactMDL {
}
class Menu extends __MDLComponent<MenuProps> {}
class MenuItem extends __MDLBasicComponent {}
interface ProgressBarProps extends __MDLOtherProps {
buffer ?: number;
indeterminate ?: boolean;
progress ?: number;
}
class ProgressBar extends __MDLComponent<ProgressBarProps> {}
interface RadioProps extends MDLHTMLAttributes, React.DOMAttributes, RippleComponent {
interface RadioProps extends MDLHTMLAttributes, React.DOMAttributes<Radio>, RippleComponent {
value : string | number;
checked ?: boolean;
disabled ?: boolean;
name ?: string;
onChange ?: React.FormEventHandler;
onChange ?: React.FormEventHandler<Radio>;
label ?: string;
}
interface RadioGroupProps extends MDLHTMLAttributes, React.DOMAttributes {
interface RadioGroupProps extends MDLHTMLAttributes, React.DOMAttributes<RadioGroup> {
name : string;
value : string | number;
childContainer ?: string;
container ?: string;
onChange ?: React.FormEventHandler;
onChange ?: React.FormEventHandler<RadioGroup>;
label ?: string;
}
class Radio extends __MDLComponent<RadioProps> {}
class RadioGroup extends __MDLComponent<RadioGroupProps> {}
interface SliderProps extends MDLHTMLAttributes, React.DOMAttributes {
interface SliderProps extends MDLHTMLAttributes, React.DOMAttributes<Slider> {
max : number;
min : number;
onChange ?: React.FormEventHandler;
onChange ?: React.FormEventHandler<Slider>;
value ?: number;
}
class Slider extends __MDLComponent<SliderProps> {}
interface SnackbarProps extends __MDLOtherProps {
active : boolean;
onTimeout : () => any;
action ?: string;
onActionClick ?: React.MouseEventHandler;
onActionClick ?: React.MouseEventHandler<Snackbar>;
timeout ?: number;
}
class Snackbar extends __MDLComponent<SnackbarProps> {}
interface SpinnerProps extends __MDLOtherProps {
singleColor ?: boolean;
}
class Spinner extends __MDLComponent<SpinnerProps> {}
interface SwitchProps extends __MDLOtherProps, RippleComponent {
checked ?: boolean;
disabled ?: boolean;
onChange ?: React.FormEventHandler;
onChange ?: React.FormEventHandler<Switch>;
}
class Switch extends __MDLComponent<SwitchProps> {}
interface TabProps extends __MDLOtherProps, CustomRenderedComponent {
active ?: boolean;
cssPrefix ?: string;
onTabClick ?: (tabId : number) => any;
tabId ?: number;
}
interface TabBarProps extends MDLHTMLAttributes, MDLDOMAttributes {
interface TabBarProps extends MDLHTMLAttributes, MDLDOMAttributes<TabBar> {
cssPrefix : string;
activeTab ?: number;
onChange ?: (tabId : number) => any;
name ?: string;
title ?: string;
onClick ?: React.MouseEventHandler;
title ?: string;
onClick ?: React.MouseEventHandler<TabBar>;
}
interface TabsProps extends MDLHTMLAttributes, MDLDOMAttributes {
interface TabsProps extends MDLHTMLAttributes, MDLDOMAttributes<Tabs> {
activeTab ?: number;
onChange ?: (tabId : number) => any;
tabBarProps ?: TabBarProps;
name ?: string;
title ?: string;
onClick ?: React.MouseEventHandler;
title ?: string;
onClick ?: React.MouseEventHandler<Tabs>;
}
class Tab extends __MDLComponent<TabProps> {}
class TabBar extends __MDLComponent<TabBarProps> {}
class Tabs extends __MDLComponent<TabsProps> {}
interface TextfieldProps extends MDLHTMLAttributes, React.DOMAttributes {
interface TextfieldProps extends MDLHTMLAttributes, React.DOMAttributes<Textfield> {
label : string;
disabled ?: boolean;
error ?: React.ReactNode;
@@ -578,23 +578,23 @@ declare namespace __ReactMDL {
id ?: string;
inputClassName ?: string;
maxRows ?: number;
onChange ?: React.FormEventHandler;
onChange ?: React.FormEventHandler<Textfield>;
pattern ?: string;
required ?: boolean;
rows ?: number;
value ?: string | number;
name ?: string;
title ?: string;
}
class Textfield extends __MDLComponent<TextfieldProps> {}
interface TooltipProps extends MDLHTMLAttributes, React.DOMAttributes {
interface TooltipProps extends MDLHTMLAttributes, React.DOMAttributes<Tooltip> {
label : React.ReactNode;
large ?: boolean;
position ?: string;
name ?: string;
title ?: string;
}