feat: update vc-table to 6.4.0
parent
3ed9fc811d
commit
8f1ea64c35
|
@ -51,7 +51,7 @@ exports[`renders ./components/steps/demo/error.md correctly 1`] = `
|
||||||
</div>
|
</div>
|
||||||
<div class="ant-steps-item ant-steps-item-error">
|
<div class="ant-steps-item ant-steps-item-error">
|
||||||
<div class="ant-steps-item-tail"></div>
|
<div class="ant-steps-item-tail"></div>
|
||||||
<div class="ant-steps-item-icon"><span class="ant-steps-icon anticon anticon-cross"></span></div>
|
<div class="ant-steps-item-icon"><span class="ant-steps-icon anticon anticon-close"></span></div>
|
||||||
<div class="ant-steps-item-content">
|
<div class="ant-steps-item-content">
|
||||||
<div class="ant-steps-item-title">In Progress</div>
|
<div class="ant-steps-item-title">In Progress</div>
|
||||||
<div class="ant-steps-item-description">This is a description.</div>
|
<div class="ant-steps-item-description">This is a description.</div>
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/* eslint-disable no-console,func-names,react/no-multi-comp */
|
||||||
|
import Table from '../index'
|
||||||
|
import '../assets/index.less'
|
||||||
|
|
||||||
|
const data = [
|
||||||
|
{ key: 0, a: '123' },
|
||||||
|
{ key: 1, a: 'cdd', b: 'edd' },
|
||||||
|
{ key: 2, a: '1333', c: 'eee', d: 2 },
|
||||||
|
]
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{ title: 'title 1', dataIndex: 'a', key: 'a', width: 100 },
|
||||||
|
{ title: 'title 2', dataIndex: 'b', key: 'b', width: 100 },
|
||||||
|
{ title: 'title 3', dataIndex: 'c', key: 'c', width: 200 },
|
||||||
|
]
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
CustomExpandIcon (props) {
|
||||||
|
let text
|
||||||
|
if (props.expanded) {
|
||||||
|
text = <span>⇧ collapse</span>
|
||||||
|
} else {
|
||||||
|
text = <span>⇩ expand</span>
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
class='expand-row-icon'
|
||||||
|
onClick={e => props.onExpand(props.record, e)}
|
||||||
|
style={{ color: 'blue', cursor: 'pointer' }}
|
||||||
|
>{text}</a>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onExpand (expanded, record) {
|
||||||
|
console.log('onExpand', expanded, record)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h2>expandIcon</h2>
|
||||||
|
<div>
|
||||||
|
<Table
|
||||||
|
columns={columns}
|
||||||
|
expandedRowRender={record => <p>extra: {record.a}</p>}
|
||||||
|
onExpand={this.onExpand}
|
||||||
|
expandIcon={this.CustomExpandIcon}
|
||||||
|
expandIconAsCell
|
||||||
|
data={data}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
@ -80,10 +80,10 @@ export default {
|
||||||
customRender: (text) => (
|
customRender: (text) => (
|
||||||
<span>{text} (Trigger Cell Click)</span>
|
<span>{text} (Trigger Cell Click)</span>
|
||||||
),
|
),
|
||||||
customCell: (record) => ({
|
customCell: (record, index) => ({
|
||||||
on: {
|
on: {
|
||||||
click (e) {
|
click (e) {
|
||||||
console.log('Click cell', record, e.target)
|
console.log('Click cell', ` row ${index}`, record, e.target)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// base rc-table 6.2.9
|
// base rc-table 6.4.0
|
||||||
import T from './src/Table'
|
import T from './src/Table'
|
||||||
import Column from './src/Column'
|
import Column from './src/Column'
|
||||||
import ColumnGroup from './src/ColumnGroup'
|
import ColumnGroup from './src/ColumnGroup'
|
||||||
|
|
|
@ -25,6 +25,7 @@ const ExpandableRow = {
|
||||||
expandIconColumnIndex: PropTypes.number,
|
expandIconColumnIndex: PropTypes.number,
|
||||||
childrenColumnName: PropTypes.string,
|
childrenColumnName: PropTypes.string,
|
||||||
expandedRowRender: PropTypes.func,
|
expandedRowRender: PropTypes.func,
|
||||||
|
expandIcon: PropTypes.func,
|
||||||
// onExpandedChange: PropTypes.func.isRequired,
|
// onExpandedChange: PropTypes.func.isRequired,
|
||||||
// onRowClick: PropTypes.func,
|
// onRowClick: PropTypes.func,
|
||||||
// children: PropTypes.func.isRequired,
|
// children: PropTypes.func.isRequired,
|
||||||
|
@ -60,8 +61,17 @@ const ExpandableRow = {
|
||||||
},
|
},
|
||||||
|
|
||||||
renderExpandIcon () {
|
renderExpandIcon () {
|
||||||
const { prefixCls, expanded, record, needIndentSpaced } = this
|
const { prefixCls, expanded, record, needIndentSpaced, expandIcon } = this
|
||||||
|
if (expandIcon) {
|
||||||
|
return expandIcon({
|
||||||
|
prefixCls,
|
||||||
|
expanded,
|
||||||
|
record,
|
||||||
|
needIndentSpaced,
|
||||||
|
expandable: this.expandable,
|
||||||
|
onExpand: this.handleExpandChange,
|
||||||
|
})
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<ExpandIcon
|
<ExpandIcon
|
||||||
expandable={this.expandable}
|
expandable={this.expandable}
|
||||||
|
@ -99,6 +109,7 @@ const ExpandableRow = {
|
||||||
record,
|
record,
|
||||||
fixed,
|
fixed,
|
||||||
$scopedSlots,
|
$scopedSlots,
|
||||||
|
expanded,
|
||||||
} = this
|
} = this
|
||||||
|
|
||||||
this.tempExpandIconAsCell = fixed !== 'right' ? this.expandIconAsCell : false
|
this.tempExpandIconAsCell = fixed !== 'right' ? this.expandIconAsCell : false
|
||||||
|
@ -108,6 +119,7 @@ const ExpandableRow = {
|
||||||
const expandableRowProps = {
|
const expandableRowProps = {
|
||||||
props: {
|
props: {
|
||||||
indentSize,
|
indentSize,
|
||||||
|
expanded, // not used in TableRow, but it's required to re-render TableRow when `expanded` changes
|
||||||
hasExpandIcon: this.hasExpandIcon,
|
hasExpandIcon: this.hasExpandIcon,
|
||||||
renderExpandIcon: this.renderExpandIcon,
|
renderExpandIcon: this.renderExpandIcon,
|
||||||
renderExpandIconCell: this.renderExpandIconCell,
|
renderExpandIconCell: this.renderExpandIconCell,
|
||||||
|
|
|
@ -14,6 +14,7 @@ export const ExpandableTableProps = () => ({
|
||||||
defaultExpandedRowKeys: PropTypes.array,
|
defaultExpandedRowKeys: PropTypes.array,
|
||||||
expandIconColumnIndex: PropTypes.number,
|
expandIconColumnIndex: PropTypes.number,
|
||||||
expandedRowRender: PropTypes.func,
|
expandedRowRender: PropTypes.func,
|
||||||
|
expandIcon: PropTypes.func,
|
||||||
childrenColumnName: PropTypes.string,
|
childrenColumnName: PropTypes.string,
|
||||||
indentSize: PropTypes.number,
|
indentSize: PropTypes.number,
|
||||||
// onExpand: PropTypes.func,
|
// onExpand: PropTypes.func,
|
||||||
|
|
|
@ -63,6 +63,7 @@ export default {
|
||||||
childrenColumnName: PropTypes.string,
|
childrenColumnName: PropTypes.string,
|
||||||
indentSize: PropTypes.number,
|
indentSize: PropTypes.number,
|
||||||
expandRowByClick: PropTypes.bool,
|
expandRowByClick: PropTypes.bool,
|
||||||
|
expandIcon: PropTypes.func,
|
||||||
}, {
|
}, {
|
||||||
data: [],
|
data: [],
|
||||||
useFixedHeader: false,
|
useFixedHeader: false,
|
||||||
|
@ -175,6 +176,13 @@ export default {
|
||||||
window, 'resize', this.debouncedWindowResize
|
window, 'resize', this.debouncedWindowResize
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
// https://github.com/ant-design/ant-design/issues/11635
|
||||||
|
if (this.ref_headTable) {
|
||||||
|
this.ref_headTable.scrollLeft = 0
|
||||||
|
}
|
||||||
|
if (this.ref_bodyTable) {
|
||||||
|
this.ref_bodyTable.scrollLeft = 0
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column.customCell) {
|
if (column.customCell) {
|
||||||
tdProps = mergeProps(tdProps, column.customCell(record))
|
tdProps = mergeProps(tdProps, column.customCell(record, index))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix https://github.com/ant-design/ant-design/issues/1202
|
// Fix https://github.com/ant-design/ant-design/issues/1202
|
||||||
|
|
|
@ -64,6 +64,7 @@ export default {
|
||||||
{
|
{
|
||||||
rows.map((row, index) => (
|
rows.map((row, index) => (
|
||||||
<TableHeaderRow
|
<TableHeaderRow
|
||||||
|
prefixCls={prefixCls}
|
||||||
key={index}
|
key={index}
|
||||||
index={index}
|
index={index}
|
||||||
fixed={fixed}
|
fixed={fixed}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import classNames from 'classnames'
|
||||||
import PropTypes from '../../_util/vue-types'
|
import PropTypes from '../../_util/vue-types'
|
||||||
import { connect } from '../../_util/store'
|
import { connect } from '../../_util/store'
|
||||||
import { mergeProps } from '../../_util/props-util'
|
import { mergeProps } from '../../_util/props-util'
|
||||||
|
@ -12,10 +13,11 @@ const TableHeaderRow = {
|
||||||
components: PropTypes.object,
|
components: PropTypes.object,
|
||||||
height: PropTypes.any,
|
height: PropTypes.any,
|
||||||
customHeaderRow: PropTypes.func,
|
customHeaderRow: PropTypes.func,
|
||||||
|
prefixCls: PropTypes.prefixCls,
|
||||||
},
|
},
|
||||||
name: 'TableHeaderRow',
|
name: 'TableHeaderRow',
|
||||||
render (h) {
|
render (h) {
|
||||||
const { row, index, height, components, customHeaderRow } = this
|
const { row, index, height, components, customHeaderRow, prefixCls } = this
|
||||||
const HeaderRow = components.header.row
|
const HeaderRow = components.header.row
|
||||||
const HeaderCell = components.header.cell
|
const HeaderCell = components.header.cell
|
||||||
const rowProps = customHeaderRow(row.map(cell => cell.column), index)
|
const rowProps = customHeaderRow(row.map(cell => cell.column), index)
|
||||||
|
@ -43,6 +45,9 @@ const TableHeaderRow = {
|
||||||
|
|
||||||
if (column.align) {
|
if (column.align) {
|
||||||
headerCellProps.style = { ...customProps.style, textAlign: column.align }
|
headerCellProps.style = { ...customProps.style, textAlign: column.align }
|
||||||
|
headerCellProps.class = classNames(customProps.cls, column.class, column.className, {
|
||||||
|
[`${prefixCls}-align-${column.align}`]: !!column.align,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof HeaderCell === 'function') {
|
if (typeof HeaderCell === 'function') {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import classNames from 'classnames'
|
||||||
import PropTypes from '../../_util/vue-types'
|
import PropTypes from '../../_util/vue-types'
|
||||||
import { connect } from '../../_util/store'
|
import { connect } from '../../_util/store'
|
||||||
import TableCell from './TableCell'
|
import TableCell from './TableCell'
|
||||||
|
@ -229,11 +230,8 @@ const TableRow = {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const rowClassName =
|
const { class: customClass, className: customClassName, style: customStyle, ...rowProps } = customRow(record, index) || {}
|
||||||
`${prefixCls} ${className} ${prefixCls}-level-${indent}`.trim()
|
|
||||||
|
|
||||||
const rowProps = customRow(record, index)
|
|
||||||
const customStyle = rowProps ? rowProps.style : {}
|
|
||||||
let style = { height: typeof height === 'number' ? `${height}px` : height }
|
let style = { height: typeof height === 'number' ? `${height}px` : height }
|
||||||
|
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
|
@ -241,6 +239,13 @@ const TableRow = {
|
||||||
}
|
}
|
||||||
|
|
||||||
style = { ...style, ...customStyle }
|
style = { ...style, ...customStyle }
|
||||||
|
const rowClassName = classNames(
|
||||||
|
prefixCls,
|
||||||
|
className,
|
||||||
|
`${prefixCls}-level-${indent}`,
|
||||||
|
customClassName,
|
||||||
|
customClass
|
||||||
|
)
|
||||||
const bodyRowProps = mergeProps({
|
const bodyRowProps = mergeProps({
|
||||||
on: {
|
on: {
|
||||||
click: this.onRowClick,
|
click: this.onRowClick,
|
||||||
|
|
Loading…
Reference in New Issue