1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import _mergeJSXProps from 'babel-helper-vue-jsx-merge-props';
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _extends from 'babel-runtime/helpers/extends';
import classNames from 'classnames';
import PropTypes from '../../_util/vue-types';
import { connect } from '../../_util/store';
import { mergeProps } from '../../_util/props-util';
var TableHeaderRow = {
props: {
index: PropTypes.number,
fixed: PropTypes.string,
columns: PropTypes.array,
rows: PropTypes.array,
row: PropTypes.array,
components: PropTypes.object,
height: PropTypes.any,
customHeaderRow: PropTypes.func,
prefixCls: PropTypes.prefixCls
},
name: 'TableHeaderRow',
render: function render(h) {
var row = this.row,
index = this.index,
height = this.height,
components = this.components,
customHeaderRow = this.customHeaderRow,
prefixCls = this.prefixCls;
var HeaderRow = components.header.row;
var HeaderCell = components.header.cell;
var rowProps = customHeaderRow(row.map(function (cell) {
return cell.column;
}), index);
var customStyle = rowProps ? rowProps.style : {};
var style = _extends({ height: height }, customStyle);
if (style.height === null) {
delete style.height;
}
return h(
HeaderRow,
_mergeJSXProps([rowProps, { style: style }]),
[row.map(function (cell, i) {
var column = cell.column,
children = cell.children,
className = cell.className,
cellProps = _objectWithoutProperties(cell, ['column', 'children', 'className']);
var cls = cell['class'] || className;
var customProps = column.customHeaderCell ? column.customHeaderCell(column) : {};
var headerCellProps = mergeProps({
attrs: _extends({}, cellProps),
'class': cls
}, _extends({}, customProps, {
key: column.key || column.dataIndex || i
}));
if (column.align) {
headerCellProps.style = _extends({}, customProps.style, { textAlign: column.align });
headerCellProps['class'] = classNames(customProps.cls, column['class'], column.className, _defineProperty({}, prefixCls + '-align-' + column.align, !!column.align));
}
if (typeof HeaderCell === 'function') {
return HeaderCell(h, headerCellProps, children);
}
return h(
HeaderCell,
headerCellProps,
[children]
);
})]
);
}
};
function getRowHeight(state, props) {
var fixedColumnsHeadRowsHeight = state.fixedColumnsHeadRowsHeight;
var columns = props.columns,
rows = props.rows,
fixed = props.fixed;
var headerHeight = fixedColumnsHeadRowsHeight[0];
if (!fixed) {
return null;
}
if (headerHeight && columns) {
if (headerHeight === 'auto') {
return 'auto';
}
return headerHeight / rows.length + 'px';
}
return null;
}
export default connect(function (state, props) {
return {
height: getRowHeight(state, props)
};
})(TableHeaderRow);