diff --git a/HISTORY.md b/HISTORY.md index 11b70c76..3316ccf4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,10 @@ # History ---- +### 3.2.0 + +- support `onClick` `onMouseEnter` `onMouseLeave`. + ### 3.1.0 - `data` could return Promise. diff --git a/package.json b/package.json index 8f9aff9d..1772139d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-upload", - "version": "3.1.4", + "version": "3.2.0", "description": "upload ui component for react", "keywords": [ "react", diff --git a/src/AjaxUploader.jsx b/src/AjaxUploader.jsx index f1d32248..2a7612b9 100644 --- a/src/AjaxUploader.jsx +++ b/src/AjaxUploader.jsx @@ -29,17 +29,20 @@ class AjaxUploader extends Component { this.reset(); } - onClick = () => { + onClick = (e) => { const el = this.fileInput; if (!el) { return; } - const { children } = this.props; + const { children, onClick } = this.props; if (children && children.type === 'button') { el.parentNode.focus(); el.parentNode.querySelector('button').blur(); } el.click(); + if (onClick) { + onClick(e); + } } onKeyDown = e => { @@ -216,6 +219,7 @@ class AjaxUploader extends Component { const { component: Tag, prefixCls, className, disabled, id, style, multiple, accept, children, directory, openFileDialogOnClick, + onMouseEnter, onMouseLeave, ...otherProps } = this.props; const cls = classNames({ @@ -224,8 +228,10 @@ class AjaxUploader extends Component { [className]: className, }); const events = disabled ? {} : { - onClick: openFileDialogOnClick ? this.onClick : () => { }, - onKeyDown: openFileDialogOnClick ? this.onKeyDown : () => { }, + onClick: openFileDialogOnClick ? this.onClick : () => {}, + onKeyDown: openFileDialogOnClick ? this.onKeyDown : () => {}, + onMouseEnter, + onMouseLeave, onDrop: this.onFileDrop, onDragOver: this.onFileDrop, tabIndex: '0',