ExpandedRow.js
1.46 KB
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
import * as React from 'react';
import Cell from '../Cell';
import TableContext from '../context/TableContext';
function ExpandedRow(_ref) {
var prefixCls = _ref.prefixCls,
children = _ref.children,
Component = _ref.component,
cellComponent = _ref.cellComponent,
fixHeader = _ref.fixHeader,
fixColumn = _ref.fixColumn,
horizonScroll = _ref.horizonScroll,
className = _ref.className,
expanded = _ref.expanded,
componentWidth = _ref.componentWidth,
colSpan = _ref.colSpan;
var _React$useContext = React.useContext(TableContext),
scrollbarSize = _React$useContext.scrollbarSize; // Cache render node
return React.useMemo(function () {
var contentNode = children;
if (fixColumn) {
contentNode = React.createElement("div", {
style: {
width: componentWidth - (fixHeader ? scrollbarSize : 0),
position: 'sticky',
left: 0,
overflow: 'hidden'
},
className: "".concat(prefixCls, "-expanded-row-fixed")
}, contentNode);
}
return React.createElement(Component, {
className: className,
style: {
display: expanded ? null : 'none'
}
}, React.createElement(Cell, {
component: cellComponent,
prefixCls: prefixCls,
colSpan: colSpan
}, contentNode));
}, [children, Component, fixHeader, horizonScroll, className, expanded, componentWidth, colSpan, scrollbarSize]);
}
export default ExpandedRow;