Add `accept` property to `BrowseButton` (#1533)

* Corresponds to `accept` attribute on `<input type="file"`
* Allows defining which type of files are to be listed
* Defaults to `*/*` which means all MIME types

Not documented nor tested in the original, it remains so.
old
Daniel Barreiro 2017-08-02 18:26:20 +02:00 committed by Javi Velasco
parent de69a1414f
commit 934ffd2000
1 changed files with 9 additions and 1 deletions

View File

@ -10,6 +10,7 @@ const factory = (ripple, FontIcon) => {
class SimpleBrowseButton extends Component {
static propTypes = {
accent: PropTypes.bool,
accept: PropTypes.string,
children: PropTypes.node,
className: PropTypes.string,
disabled: PropTypes.bool,
@ -47,6 +48,7 @@ const factory = (ripple, FontIcon) => {
static defaultProps = {
accent: false,
accept: '*/*',
className: '',
flat: false,
floating: false,
@ -85,6 +87,7 @@ const factory = (ripple, FontIcon) => {
render() {
const {
accent, // eslint-disable-line
accept,
children,
className,
flat, // eslint-disable-line
@ -123,7 +126,12 @@ const factory = (ripple, FontIcon) => {
return React.createElement(element, props,
icon ? <FontIcon className={theme.icon} value={icon} /> : null,
<span>{label}</span>,
<input className={classes} type="file" onChange={this.handleFileChange} />,
<input
className={classes}
type="file"
accept={accept}
onChange={this.handleFileChange}
/>,
children,
);
}