ExpandedRow.js
1.87 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _Cell = _interopRequireDefault(require("../Cell"));
var _TableContext = _interopRequireDefault(require("../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.default),
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.default, {
component: cellComponent,
prefixCls: prefixCls,
colSpan: colSpan
}, contentNode));
}, [children, Component, fixHeader, horizonScroll, className, expanded, componentWidth, colSpan, scrollbarSize]);
}
var _default = ExpandedRow;
exports.default = _default;