From ef31389965d2942bfa1770c88aeaf471542edc2e Mon Sep 17 00:00:00 2001 From: wangxueliang Date: Wed, 31 Oct 2018 19:06:21 +0800 Subject: [PATCH 1/2] feat: update upload to 2.6.0 --- components/vc-upload/demo/drag.jsx | 4 ++++ components/vc-upload/index.js | 2 +- components/vc-upload/src/AjaxUploader.jsx | 7 ++++--- components/vc-upload/src/Upload.jsx | 2 ++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/components/vc-upload/demo/drag.jsx b/components/vc-upload/demo/drag.jsx index 48c1f343d..a56434894 100644 --- a/components/vc-upload/demo/drag.jsx +++ b/components/vc-upload/demo/drag.jsx @@ -10,6 +10,7 @@ export default { beforeUpload (file) { console.log('beforeUpload', file.name) }, + openFileDialogOnClick: false, }, on: { start (file) { @@ -24,6 +25,9 @@ export default { error (err) { console.log('error', err) }, + click () { + alert('click') + }, }, style: { display: 'inline-block', width: '200px', height: '200px', background: '#eee' }, } diff --git a/components/vc-upload/index.js b/components/vc-upload/index.js index 2a2f3e4d5..7b0871dec 100644 --- a/components/vc-upload/index.js +++ b/components/vc-upload/index.js @@ -1,4 +1,4 @@ -// rc-upload 2.5.1 +// rc-upload 2.6.0 import upload from './src' export default upload diff --git a/components/vc-upload/src/AjaxUploader.jsx b/components/vc-upload/src/AjaxUploader.jsx index ad7f4c735..991df58d3 100644 --- a/components/vc-upload/src/AjaxUploader.jsx +++ b/components/vc-upload/src/AjaxUploader.jsx @@ -31,6 +31,7 @@ const upLoadPropTypes = { customRequest: PropTypes.func, // onProgress: PropTypes.func, withCredentials: PropTypes.bool, + openFileDialogOnClick: PropTypes.bool, } const AjaxUploader = { @@ -184,22 +185,22 @@ const AjaxUploader = { }, render () { const { - componentTag: Tag, prefixCls, disabled, multiple, accept, directory, + componentTag: Tag, prefixCls, disabled, multiple, accept, directory, openFileDialogOnClick, } = this.$props const cls = classNames({ [prefixCls]: true, [`${prefixCls}-disabled`]: disabled, }) const events = disabled ? {} : { - click: this.onClick, + click: openFileDialogOnClick ? this.onClick : () => {}, keydown: this.onKeyDown, drop: this.onFileDrop, dragover: this.onFileDrop, } const tagProps = { on: { - ...events, ...this.$listeners, + ...events, }, attrs: { role: 'button', diff --git a/components/vc-upload/src/Upload.jsx b/components/vc-upload/src/Upload.jsx index 5b7c2f8e2..2087d7511 100644 --- a/components/vc-upload/src/Upload.jsx +++ b/components/vc-upload/src/Upload.jsx @@ -34,6 +34,7 @@ const uploadProps = { // onReady: PropTypes.func, withCredentials: PropTypes.bool, supportServerRender: PropTypes.bool, + openFileDialogOnClick: PropTypes.bool, } export default { name: 'Upload', @@ -53,6 +54,7 @@ export default { multiple: false, beforeUpload: empty, withCredentials: false, + openFileDialogOnClick: true, }), data () { return { From 1370d4b7e91ec68f4261f3d85c929c30708f496a Mon Sep 17 00:00:00 2001 From: wangxueliang Date: Wed, 31 Oct 2018 19:28:53 +0800 Subject: [PATCH 2/2] feat: update switch to 1.8.0 --- components/vc-switch/PropTypes.js | 1 + components/vc-switch/Switch.jsx | 15 ++++++++------- components/vc-switch/assets/index.less | 2 ++ components/vc-switch/index.js | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/components/vc-switch/PropTypes.js b/components/vc-switch/PropTypes.js index 7c2a8938f..bd38eee6f 100644 --- a/components/vc-switch/PropTypes.js +++ b/components/vc-switch/PropTypes.js @@ -12,4 +12,5 @@ export const switchPropTypes = { checked: PropTypes.bool.def(false), defaultChecked: PropTypes.bool.def(false), autoFocus: PropTypes.bool.def(false), + loadingIcon: PropTypes.any, } diff --git a/components/vc-switch/Switch.jsx b/components/vc-switch/Switch.jsx index 6cd25a514..e39151fdf 100644 --- a/components/vc-switch/Switch.jsx +++ b/components/vc-switch/Switch.jsx @@ -62,8 +62,6 @@ export default { this.setChecked(false) } else if (e.keyCode === 39) { // Right this.setChecked(true) - } else if (e.keyCode === 32 || e.keyCode === 13) { // Space, Enter - this.toggle() } }, handleMouseUp (e) { @@ -80,9 +78,8 @@ export default { }, }, render () { - const { prefixCls, disabled, tabIndex, ...restProps } = getOptionProps(this) + const { prefixCls, disabled, loadingIcon, ...restProps } = getOptionProps(this) const checked = this.stateChecked - const switchTabIndex = disabled ? -1 : (tabIndex || 0) const switchClassName = { [prefixCls]: true, [`${prefixCls}-checked`]: checked, @@ -97,17 +94,21 @@ export default { mouseup: this.handleMouseUp, }, attrs: { - tabIndex: switchTabIndex, + type: 'button', + role: 'switch', + 'aria-checked': checked, + disabled, }, class: switchClassName, ref: 'refSwitchNode', } return ( - + ) }, } diff --git a/components/vc-switch/assets/index.less b/components/vc-switch/assets/index.less index 0f7eb65e1..a3f94ad4f 100644 --- a/components/vc-switch/assets/index.less +++ b/components/vc-switch/assets/index.less @@ -9,6 +9,7 @@ width: 44px; height: 22px; line-height: 20px; + padding: 0; vertical-align: middle; border-radius: 20px 20px; border: 1px solid #ccc; @@ -21,6 +22,7 @@ font-size: 12px; position: absolute; left: 24px; + top: 0; } &:after { diff --git a/components/vc-switch/index.js b/components/vc-switch/index.js index 4414beed7..4f98fda47 100644 --- a/components/vc-switch/index.js +++ b/components/vc-switch/index.js @@ -1,4 +1,4 @@ -// base rc-switch 1.6.0 +// base rc-switch 1.8.0 import Switch from './Switch' export default Switch