Skip to content

Commit 75e5f04

Browse files
committed
feat: update vc-table vc-upload
1 parent 6395479 commit 75e5f04

File tree

7 files changed

+48
-13
lines changed

7 files changed

+48
-13
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import addDOMEventListener from 'add-dom-event-listener'
22

3-
export default function addEventListenerWrap (target, eventType, cb) {
4-
return addDOMEventListener(target, eventType, cb)
3+
export default function addEventListenerWrap (target, eventType, cb, option) {
4+
return addDOMEventListener(target, eventType, cb, option)
55
}

components/upload/Upload.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { T, fileToObject, genPercentAdd, getFileItem, removeFileItem } from './u
1414
export { UploadProps }
1515

1616
export default {
17+
inheritAttrs: false,
1718
name: 'AUpload',
1819
Dragger: Dragger,
1920
mixins: [BaseMixin],
@@ -231,6 +232,7 @@ export default {
231232
},
232233
ref: 'uploadRef',
233234
class: `${prefixCls}-btn`,
235+
attrs: this.$attrs,
234236
}
235237

236238
const uploadList = showUploadList ? (

components/vc-table/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// base rc-table 6.4.0
1+
// base rc-table 6.4.2
22
import T from './src/Table'
33
import Column from './src/Column'
44
import ColumnGroup from './src/ColumnGroup'

components/vc-table/src/ExpandableTable.jsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import PropTypes from '../../_util/vue-types'
22
import BaseMixin from '../../_util/BaseMixin'
33
import { connect } from '../../_util/store'
4+
import shallowEqual from 'shallowequal'
45
import TableRow from './TableRow'
56
import { remove } from './utils'
67
import { initDefaultProps, getOptionProps } from '../../_util/props-util'
@@ -71,6 +72,12 @@ const ExpandableTable = {
7172
})
7273
return {}
7374
},
75+
mounted () {
76+
this.handleUpdated()
77+
},
78+
updated () {
79+
this.handleUpdated()
80+
},
7481
watch: {
7582
expandedRowKeys (val) {
7683
this.$nextTick(() => {
@@ -81,6 +88,10 @@ const ExpandableTable = {
8188
},
8289
},
8390
methods: {
91+
handleUpdated () {
92+
// We should record latest expanded rows to avoid multiple rows remove cause `onExpandedRowsChange` trigger many times
93+
this.latestExpandedRows = null
94+
},
8495
handleExpandChange (expanded, record, event, rowKey, destroy = false) {
8596
if (event) {
8697
event.preventDefault()
@@ -103,7 +114,12 @@ const ExpandableTable = {
103114
if (!this.expandedRowKeys) {
104115
this.store.setState({ expandedRowKeys })
105116
}
106-
this.__emit('expandedRowsChange', expandedRowKeys)
117+
// De-dup of repeat call
118+
if (!this.latestExpandedRows || !shallowEqual(this.latestExpandedRows, expandedRowKeys)) {
119+
this.latestExpandedRows = expandedRowKeys
120+
this.__emit('expandedRowsChange', expandedRowKeys)
121+
}
122+
107123
if (!destroy) {
108124
this.__emit('expand', expanded, record)
109125
}

components/vc-table/src/utils.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import warning from 'warning'
22

3-
let scrollbarSize
3+
let scrollbarVerticalSize
4+
let scrollbarHorizontalSize
45

56
// Measure scrollbar width for padding body during modal show/hide
67
const scrollbarMeasure = {
@@ -15,24 +16,34 @@ export function measureScrollbar (direction = 'vertical') {
1516
if (typeof document === 'undefined' || typeof window === 'undefined') {
1617
return 0
1718
}
18-
if (scrollbarSize) {
19-
return scrollbarSize
19+
const isVertical = direction === 'vertical'
20+
if (isVertical && scrollbarVerticalSize) {
21+
return scrollbarVerticalSize
22+
} else if (!isVertical && scrollbarHorizontalSize) {
23+
return scrollbarHorizontalSize
2024
}
2125
const scrollDiv = document.createElement('div')
2226
Object.keys(scrollbarMeasure).forEach(scrollProp => {
2327
scrollDiv.style[scrollProp] = scrollbarMeasure[scrollProp]
2428
})
29+
// Append related overflow style
30+
if (isVertical) {
31+
scrollDiv.style.overflowY = 'scroll'
32+
} else {
33+
scrollDiv.style.overflowX = 'scroll'
34+
}
2535
document.body.appendChild(scrollDiv)
2636
let size = 0
27-
if (direction === 'vertical') {
37+
if (isVertical) {
2838
size = scrollDiv.offsetWidth - scrollDiv.clientWidth
29-
} else if (direction === 'horizontal') {
39+
scrollbarVerticalSize = size
40+
} else if (!isVertical) {
3041
size = scrollDiv.offsetHeight - scrollDiv.clientHeight
42+
scrollbarHorizontalSize = size
3143
}
3244

3345
document.body.removeChild(scrollDiv)
34-
scrollbarSize = size
35-
return scrollbarSize
46+
return size
3647
}
3748

3849
export function debounce (func, wait, immediate) {

components/vc-upload/src/AjaxUploader.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const upLoadPropTypes = {
3535
}
3636

3737
const AjaxUploader = {
38+
inheritAttrs: false,
3839
name: 'ajaxUploader',
3940
mixins: [BaseMixin],
4041
props: upLoadPropTypes,
@@ -184,9 +185,11 @@ const AjaxUploader = {
184185
this.abort()
185186
},
186187
render () {
188+
const { $props, $attrs } = this
187189
const {
188-
componentTag: Tag, prefixCls, disabled, multiple, accept, directory, openFileDialogOnClick,
189-
} = this.$props
190+
componentTag: Tag, prefixCls, disabled,
191+
multiple, accept, directory, openFileDialogOnClick,
192+
} = $props
190193
const cls = classNames({
191194
[prefixCls]: true,
192195
[`${prefixCls}-disabled`]: disabled,
@@ -213,6 +216,7 @@ const AjaxUploader = {
213216
{...tagProps}
214217
>
215218
<input
219+
id={$attrs.id}
216220
type='file'
217221
ref='fileInputRef'
218222
key={this.uid}

components/vc-upload/src/Upload.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const uploadProps = {
3737
openFileDialogOnClick: PropTypes.bool,
3838
}
3939
export default {
40+
inheritAttrs: false,
4041
name: 'Upload',
4142
mixins: [BaseMixin],
4243
props: initDefaultProps(uploadProps, {
@@ -89,6 +90,7 @@ export default {
8990
},
9091
on: this.$listeners,
9192
ref: 'uploaderRef',
93+
attrs: this.$attrs,
9294
}
9395
if (this.supportServerRender) {
9496
const ComponentUploader = this.Component

0 commit comments

Comments
 (0)