Implement suggestion from @openscript

This commit is contained in:
Maarten Mulders 2017-12-29 20:04:24 +01:00
parent 82acd03b68
commit 8ebd2dfd05
2 changed files with 60 additions and 81 deletions

View File

@ -147,10 +147,6 @@ declare module "material-ui" {
export import ToolbarSeparatorProps = __MaterialUI.Toolbar.ToolbarSeparatorProps;
export import ToolbarTitle = __MaterialUI.Toolbar.ToolbarTitle;
export import ToolbarTitleProps = __MaterialUI.Toolbar.ToolbarTitleProps;
// export type definitions
export type TouchTapEvent = __MaterialUI.TouchTapEvent;
export type TouchTapEventHandler = __MaterialUI.TouchTapEventHandler;
}
declare namespace __MaterialUI {
@ -160,19 +156,6 @@ declare namespace __MaterialUI {
requestChange(newValue: T): void;
}
// What's common between React.TouchEvent and React.MouseEvent
interface TouchTapEvent extends React.SyntheticEvent<{}> {
altKey: boolean;
ctrlKey: boolean;
getModifierState(key: string): boolean;
metaKey: boolean;
shiftKey: boolean;
}
// What's common between React.TouchEventHandler and React.MouseEventHandler
interface TouchTapEventHandler extends React.EventHandler<TouchTapEvent> {
}
export interface ThemeWrapperProps {
theme: Styles.MuiTheme;
}
@ -578,9 +561,9 @@ declare namespace __MaterialUI {
iconElementRight?: React.ReactElement<any>;
iconStyleRight?: React.CSSProperties;
iconStyleLeft?: React.CSSProperties;
onLeftIconButtonClick?: TouchTapEventHandler;
onRightIconButtonClick?: TouchTapEventHandler;
onTitleTouchTap?: TouchTapEventHandler;
onLeftIconButtonClick?: React.MouseEventHandler<{}>;
onRightIconButtonClick?: React.MouseEventHandler<{}>;
onTitleClick?: React.MouseEventHandler<{}>;
showMenuIconButton?: boolean;
style?: React.CSSProperties;
title?: React.ReactNode;
@ -715,7 +698,6 @@ declare namespace __MaterialUI {
onKeyboardFocus?(e: React.FocusEvent<{}>, isKeyboardFocused: boolean): void;
onKeyDown?: React.KeyboardEventHandler<{}>;
onKeyUp?: React.KeyboardEventHandler<{}>;
onTouchTap?: TouchTapEventHandler;
onClick?: React.MouseEventHandler<{}>;
style?: React.CSSProperties;
tabIndex?: number;
@ -1048,7 +1030,6 @@ declare namespace __MaterialUI {
export interface DialogAction {
id?: string;
onClick?: React.MouseEventHandler<{}>;
onTouchTap?: TouchTapEventHandler;
ref?: string;
text: string;
}
@ -1129,7 +1110,7 @@ declare namespace __MaterialUI {
titleBackground?: string;
titlePosition?: "top" | "bottom";
titleStyle?: React.CSSProperties;
onTouchTap?: TouchTapEventHandler;
onClick?: React.MouseEventHandler<{}>;
}
export class GridTile extends React.Component<GridTileProps> {
}
@ -1186,7 +1167,7 @@ declare namespace __MaterialUI {
onMouseLeave?: React.MouseEventHandler<{}>;
onNestedListToggle?(item: ListItem): void;
onTouchStart?: React.TouchEventHandler<{}>;
onTouchTap?: TouchTapEventHandler;
onClick?: React.MouseEventHandler<{}>;
open?: boolean;
primaryText?: React.ReactNode;
primaryTogglesNestedList?: boolean;
@ -1203,7 +1184,7 @@ declare namespace __MaterialUI {
}
export interface SelectableProps {
onChange?(e: TouchTapEvent, value: any): void;
onChange?(e: React.SyntheticEvent<{}>, value: any): void;
selectedItemStyle?: React.CSSProperties;
value?: any;
}
@ -1222,9 +1203,9 @@ declare namespace __MaterialUI {
listStyle?: React.CSSProperties;
maxHeight?: number;
multiple?: boolean;
onChange?(e: TouchTapEvent, itemValue: any | any[]): void;
onChange?(e: React.SyntheticEvent<{}>, itemValue: any | any[]): void;
onEscKeyDown?: React.KeyboardEventHandler<{}>;
onItemTouchTap?(e: TouchTapEvent, item: MenuItem): void;
onItemTouchTap?(e: React.SyntheticEvent<{}>, item: MenuItem): void;
onKeyDown?: React.KeyboardEventHandler<{}>;
selectedMenuItemStyle?: React.CSSProperties;
style?: React.CSSProperties;
@ -1247,7 +1228,7 @@ declare namespace __MaterialUI {
label?: string | React.ReactNode;
leftIcon?: React.ReactElement<any>;
menuItems?: React.ReactNode;
onTouchTap?: TouchTapEventHandler;
onClick?: React.MouseEventHandler<{}>;
primaryText?: React.ReactNode;
rightIcon?: React.ReactElement<any>;
secondaryText?: React.ReactNode;
@ -1265,14 +1246,14 @@ declare namespace __MaterialUI {
iconButtonElement: React.ReactElement<IconButtonProps>;
iconStyle?: React.CSSProperties;
menuStyle?: React.CSSProperties;
onItemTouchTap?(e: TouchTapEvent, item: MenuItem): void;
onItemTouchTap?(e: React.SyntheticEvent<{}>, item: MenuItem): void;
onKeyboardFocus?(e: React.FocusEvent<{}>, isKeyboardFocused: boolean): void;
onMouseDown?: React.MouseEventHandler<{}>;
onMouseEnter?: React.MouseEventHandler<{}>;
onMouseLeave?: React.MouseEventHandler<{}>;
onMouseUp?: React.MouseEventHandler<{}>;
onRequestChange?(opening: boolean, reason: string): void;
onTouchTap?: TouchTapEventHandler;
onClick?: React.MouseEventHandler<{}>;
open?: boolean;
style?: React.CSSProperties;
targetOrigin?: propTypes.origin;
@ -1285,7 +1266,7 @@ declare namespace __MaterialUI {
listStyle?: React.CSSProperties;
maxHeight?: number;
multiple?: boolean;
onChange?(e: TouchTapEvent, itemValue: any | any[]): void;
onChange?(e: React.SyntheticEvent<{}>, itemValue: any | any[]): void;
onKeyDown?: React.KeyboardEventHandler<{}>;
selectedMenuItemStyle?: React.CSSProperties;
value?: any | any[];
@ -1311,8 +1292,8 @@ declare namespace __MaterialUI {
menuItemStyle?: React.CSSProperties;
menuStyle?: React.CSSProperties;
multiple?: boolean;
onChange?(e: TouchTapEvent, index: number, menuItemValue: any): void;
onClose?(e: TouchTapEvent): void;
onChange?(e: React.SyntheticEvent<{}>, index: number, menuItemValue: any): void;
onClose?(e: React.SyntheticEvent<{}>): void;
openImmediately?: boolean;
selectedMenuItemStyle?: React.CSSProperties;
selectionRenderer?(value: any, menuItem: any): void;
@ -1330,7 +1311,6 @@ declare namespace __MaterialUI {
show?: boolean;
transitionEnabled?: boolean;
onClick?: React.MouseEventHandler<{}>;
onTouchTap?: TouchTapEventHandler;
}
export class Overlay extends React.Component<OverlayProps> {
}
@ -1444,7 +1424,7 @@ declare namespace __MaterialUI {
labelStyle?: React.CSSProperties;
multiple?: boolean;
onBlur?: React.FocusEventHandler<{}>;
onChange?(e: TouchTapEvent, index: number, menuItemValue: any): void;
onChange?(e: React.SyntheticEvent<{}>, index: number, menuItemValue: any): void;
onFocus?: React.FocusEventHandler<{}>;
selectFieldRoot?: React.CSSProperties;
selectionRenderer?(value: any): React.ReactNode;
@ -1957,7 +1937,7 @@ declare namespace __MaterialUI {
onDismiss?(): void;
onFocus?: React.FocusEventHandler<{}>;
onShow?(): void;
onTouchTap?: TouchTapEventHandler;
onClick?: React.MouseEventHandler<{}>;
pedantic?: boolean;
style?: React.CSSProperties;
textFieldStyle?: React.CSSProperties;
@ -9015,7 +8995,6 @@ declare module 'material-ui/internal/Overlay' {
style?: React.CSSProperties;
transitionEnabled?: boolean;
onClick?: React.MouseEventHandler<{}>;
onTouchTap?: __MaterialUI.TouchTapEventHandler;
}
class Overlay extends React.Component<OverlayProps> { }
export default Overlay;

View File

@ -2344,7 +2344,7 @@ const AppBarExampleIcon = () => (
const AppBarExampleIconButton = () => (
<AppBar
title={<span style={styles.title}>Title</span>}
onTitleTouchTap={handleTouchTap}
onTitleClick={handleTouchTap}
iconElementLeft={<IconButton><NavigationClose /></IconButton>}
iconElementRight={<FlatButton label="Save" />}
/>
@ -3014,8 +3014,8 @@ class CardExampleControlled extends Component<{}, {expanded: boolean}> {
Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio.
</CardText>
<CardActions>
<FlatButton label="Expand" onTouchTap={this.handleExpand}/>
<FlatButton label="Reduce" onTouchTap={this.handleReduce}/>
<FlatButton label="Expand" onClick={this.handleExpand}/>
<FlatButton label="Reduce" onClick={this.handleReduce}/>
</CardActions>
</Card>
);
@ -3247,19 +3247,19 @@ class DialogExampleSimple extends Component<{}, {open?: boolean}> {
<FlatButton
label="Cancel"
primary={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
<FlatButton
label="Submit"
primary={true}
keyboardFocused={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
];
return (
<div>
<RaisedButton label="Dialog" onTouchTap={this.handleOpen}/>
<RaisedButton label="Dialog" onClick={this.handleOpen}/>
<Dialog
title="Dialog With Actions"
actions={actions}
@ -3292,19 +3292,19 @@ class DialogExampleModal extends Component<{}, {open?: boolean}> {
<FlatButton
label="Cancel"
primary={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
<FlatButton
label="Submit"
primary={true}
disabled={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
];
return (
<div>
<RaisedButton label="Modal Dialog" onTouchTap={this.handleOpen}/>
<RaisedButton label="Modal Dialog" onClick={this.handleOpen}/>
<Dialog
title="Dialog With Actions"
actions={actions}
@ -3336,18 +3336,18 @@ class DialogExampleCustomWidth extends Component<{}, {open?: boolean}> {
<FlatButton
label="Cancel"
primary={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
<FlatButton
label="Submit"
primary={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
];
return (
<div>
<RaisedButton label="Dialog With Custom Width" onTouchTap={this.handleOpen}/>
<RaisedButton label="Dialog With Custom Width" onClick={this.handleOpen}/>
<Dialog
title="Dialog With Custom Width"
actions={actions}
@ -3381,13 +3381,13 @@ class DialogExampleDialogDatePicker extends Component<{}, {open?: boolean}> {
label="Ok"
primary={true}
keyboardFocused={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
];
return (
<div>
<RaisedButton label="Dialog With Date Picker" onTouchTap={this.handleOpen}/>
<RaisedButton label="Dialog With Date Picker" onClick={this.handleOpen}/>
<Dialog
title="Dialog With Date Picker"
actions={actions}
@ -3421,13 +3421,13 @@ class DialogExampleScrollable extends Component<{}, {open?: boolean}> {
<FlatButton
label="Cancel"
primary={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
<FlatButton
label="Submit"
primary={true}
keyboardFocused={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
];
@ -3445,7 +3445,7 @@ class DialogExampleScrollable extends Component<{}, {open?: boolean}> {
return (
<div>
<RaisedButton label="Scrollable Dialog" onTouchTap={this.handleOpen}/>
<RaisedButton label="Scrollable Dialog" onClick={this.handleOpen}/>
<Dialog
title="Scrollable Dialog"
actions={actions}
@ -3481,18 +3481,18 @@ class DialogExampleAlert extends Component<{}, {open?: boolean}> {
<FlatButton
label="Cancel"
primary={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
<FlatButton
label="Discard"
primary={true}
onTouchTap={this.handleClose}
onClick={this.handleClose}
/>,
];
return (
<div>
<RaisedButton label="Alert" onTouchTap={this.handleOpen}/>
<RaisedButton label="Alert" onClick={this.handleOpen}/>
<Dialog
actions={actions}
modal={false}
@ -3557,7 +3557,7 @@ class DrawerSimpleExample extends Component<{}, {open?: boolean}> {
<div>
<RaisedButton
label="Toggle Drawer"
onTouchTap={this.handleToggle}
onClick={this.handleToggle}
/>
<Drawer open={this.state.open}>
<MenuItem>Menu Item</MenuItem>
@ -3583,7 +3583,7 @@ class DrawerUndockedExample extends Component<{}, {open?: boolean}> {
<div>
<RaisedButton
label="Open Drawer"
onTouchTap={this.handleToggle}
onClick={this.handleToggle}
/>
<Drawer
docked={false}
@ -3591,8 +3591,8 @@ class DrawerUndockedExample extends Component<{}, {open?: boolean}> {
open={this.state.open}
onRequestChange={(open) => this.setState({open})}
>
<MenuItem onTouchTap={this.handleClose}>Menu Item</MenuItem>
<MenuItem onTouchTap={this.handleClose}>Menu Item 2</MenuItem>
<MenuItem onClick={this.handleClose}>Menu Item</MenuItem>
<MenuItem onClick={this.handleClose}>Menu Item 2</MenuItem>
</Drawer>
</div>
);
@ -3612,7 +3612,7 @@ class DrawerOpenRightExample extends Component<{}, {open?: boolean}> {
<div>
<RaisedButton
label="Toggle Drawer"
onTouchTap={this.handleToggle}
onClick={this.handleToggle}
/>
<Drawer width="20%" openSecondary={true} open={this.state.open}>
<AppBar title="AppBar"/>
@ -4567,7 +4567,7 @@ class IconMenuExampleControlled extends Component<{}, IconMenuExampleControlledS
<MenuItem value="3" primaryText="Android App"/>
<MenuItem value="4" primaryText="iOS App"/>
</IconMenu>
<RaisedButton onTouchTap={this.handleOpenMenu} label="Downloads"/>
<RaisedButton onClick={this.handleOpenMenu} label="Downloads"/>
</div>
);
}
@ -4844,7 +4844,7 @@ class PopoverExampleSimple extends Component<{}, {open?: boolean, anchorEl?: Rea
return (
<div>
<RaisedButton
onTouchTap={this.handleTouchTap}
onClick={this.handleTouchTap}
label="Click me"
/>
<Popover
@ -4894,7 +4894,7 @@ class PopoverExampleAnimation extends Component<{}, {open?: boolean, anchorEl?:
return (
<div>
<RaisedButton
onTouchTap={this.handleTouchTap}
onClick={this.handleTouchTap}
label="Click me"
/>
<Popover
@ -4978,7 +4978,7 @@ class PopoverExampleConfigurable extends Component<{}, PopoverExampleConfigurabl
return (
<div>
<RaisedButton
onTouchTap={this.handleTouchTap}
onClick={this.handleTouchTap}
label="Click me"
/>
<h3 style={styles.h3}>Current Settings</h3>
@ -5705,7 +5705,7 @@ class SnackbarExampleSimple extends Component<{}, {open?: boolean}> {
return (
<div>
<RaisedButton
onTouchTap={this.handleTouchTap}
onClick={this.handleTouchTap}
label="Add to my calendar"
/>
<Snackbar
@ -5760,7 +5760,7 @@ class SnackbarExampleAction extends Component<{}, {open?: boolean, autoHideDurat
return (
<div>
<RaisedButton
onTouchTap={this.handleTouchTap}
onClick={this.handleTouchTap}
label="Add to my calendar"
/>
<br />
@ -5820,7 +5820,7 @@ class SnackbarExampleTwice extends Component<{}, {open?: boolean, message?: stri
return (
<div>
<RaisedButton
onTouchTap={this.handleTouchTap}
onClick={this.handleTouchTap}
label="Add to my calendar two times"
/>
<Snackbar
@ -5907,13 +5907,13 @@ class HorizontalLinearStepper extends Component<{}, {stepIndex?: number, finishe
<FlatButton
label="Back"
disabled={stepIndex === 0}
onTouchTap={this.handlePrev}
onClick={this.handlePrev}
style={{marginRight: 12}}
/>
<RaisedButton
label={stepIndex === 2 ? 'Finish' : 'Next'}
primary={true}
onTouchTap={this.handleNext}
onClick={this.handleNext}
/>
</div>
</div>
@ -5955,7 +5955,7 @@ class VerticalLinearStepper extends Component<{}, {stepIndex?: number, finished?
disableTouchRipple={true}
disableFocusRipple={true}
primary={true}
onTouchTap={this.handleNext}
onClick={this.handleNext}
style={{marginRight: 12}}
/>
{step > 0 && (
@ -5964,7 +5964,7 @@ class VerticalLinearStepper extends Component<{}, {stepIndex?: number, finished?
disabled={stepIndex === 0}
disableTouchRipple={true}
disableFocusRipple={true}
onTouchTap={this.handlePrev}
onClick={this.handlePrev}
/>
)}
</div>
@ -6087,14 +6087,14 @@ class HorizontalNonLinearStepper extends Component<{}, {stepIndex?: number}> {
<FlatButton
label="Back"
disabled={stepIndex === 0}
onTouchTap={this.handlePrev}
onClick={this.handlePrev}
style={{marginRight: 12}}
/>
<RaisedButton
label="Next"
disabled={stepIndex === 2}
primary={true}
onTouchTap={this.handleNext}
onClick={this.handleNext}
/>
</div>
</div>
@ -6130,7 +6130,7 @@ class VerticalNonLinear extends Component<{}, {stepIndex?: number}> {
disableTouchRipple={true}
disableFocusRipple={true}
primary={true}
onTouchTap={this.handleNext}
onClick={this.handleNext}
style={{marginRight: 12}}
/>
{step > 0 && (
@ -6138,7 +6138,7 @@ class VerticalNonLinear extends Component<{}, {stepIndex?: number}> {
label="Back"
disableTouchRipple={true}
disableFocusRipple={true}
onTouchTap={this.handlePrev}
onClick={this.handlePrev}
/>
)}
</div>
@ -6302,13 +6302,13 @@ class GranularControlStepper extends Component<{}, {stepIndex?: number, visited?
<FlatButton
label="Back"
disabled={stepIndex === 0}
onTouchTap={this.handlePrev}
onClick={this.handlePrev}
style={styles.backButton}
/>
<RaisedButton
label="Next"
primary={true}
onTouchTap={this.handleNext}
onClick={this.handleNext}
/>
</div>
)}
@ -7011,8 +7011,8 @@ class BottomNavigationExample extends Component<{}, {
}
render() {
return <BottomNavigation selectedIndex={this.state.index}>
<BottomNavigationItem label='0' icon={<ActionHome/>} onTouchTap={() => this.setState({index: 0})}/>
<BottomNavigationItem label='1' icon={<ActionInfo/>} onTouchTap={() => this.setState({index: 1})}/>
<BottomNavigationItem label='0' icon={<ActionHome/>} onClick={() => this.setState({index: 0})}/>
<BottomNavigationItem label='1' icon={<ActionInfo/>} onClick={() => this.setState({index: 1})}/>
</BottomNavigation>;
}
}