1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | var _typeof = require("@babel/runtime/helpers/typeof");
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.default = void 0;
|
9 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
10 | var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11 | var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
12 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
13 | var _context = require("@rc-component/context");
|
14 | var _classnames = _interopRequireDefault(require("classnames"));
|
15 | var React = _interopRequireWildcard(require("react"));
|
16 | var _Cell = _interopRequireDefault(require("../Cell"));
|
17 | var _TableContext = _interopRequireWildcard(require("../context/TableContext"));
|
18 | var _useRowInfo = _interopRequireDefault(require("../hooks/useRowInfo"));
|
19 | var _VirtualCell = _interopRequireDefault(require("./VirtualCell"));
|
20 | var _context2 = require("./context");
|
21 | var _excluded = ["data", "index", "className", "rowKey", "style", "extra", "getHeight"];
|
22 | function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
23 | function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
24 | var BodyLine = React.forwardRef(function (props, ref) {
|
25 | var data = props.data,
|
26 | index = props.index,
|
27 | className = props.className,
|
28 | rowKey = props.rowKey,
|
29 | style = props.style,
|
30 | extra = props.extra,
|
31 | getHeight = props.getHeight,
|
32 | restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
33 | var record = data.record,
|
34 | indent = data.indent,
|
35 | renderIndex = data.index;
|
36 | var _useContext = (0, _context.useContext)(_TableContext.default, ['prefixCls', 'flattenColumns', 'fixColumn', 'componentWidth', 'scrollX']),
|
37 | scrollX = _useContext.scrollX,
|
38 | flattenColumns = _useContext.flattenColumns,
|
39 | prefixCls = _useContext.prefixCls,
|
40 | fixColumn = _useContext.fixColumn,
|
41 | componentWidth = _useContext.componentWidth;
|
42 | var _useContext2 = (0, _context.useContext)(_context2.StaticContext, ['getComponent']),
|
43 | getComponent = _useContext2.getComponent;
|
44 | var rowInfo = (0, _useRowInfo.default)(record, rowKey, index, indent);
|
45 | var RowComponent = getComponent(['body', 'row'], 'div');
|
46 | var cellComponent = getComponent(['body', 'cell'], 'div');
|
47 |
|
48 |
|
49 | var rowSupportExpand = rowInfo.rowSupportExpand,
|
50 | expanded = rowInfo.expanded,
|
51 | rowProps = rowInfo.rowProps,
|
52 | expandedRowRender = rowInfo.expandedRowRender,
|
53 | expandedRowClassName = rowInfo.expandedRowClassName;
|
54 | var expandRowNode;
|
55 | if (rowSupportExpand && expanded) {
|
56 | var expandContent = expandedRowRender(record, index, indent + 1, expanded);
|
57 | var computedExpandedRowClassName = expandedRowClassName === null || expandedRowClassName === void 0 ? void 0 : expandedRowClassName(record, index, indent);
|
58 | var additionalProps = {};
|
59 | if (fixColumn) {
|
60 | additionalProps = {
|
61 | style: (0, _defineProperty2.default)({}, '--virtual-width', "".concat(componentWidth, "px"))
|
62 | };
|
63 | }
|
64 | var rowCellCls = "".concat(prefixCls, "-expanded-row-cell");
|
65 | expandRowNode = React.createElement(RowComponent, {
|
66 | className: (0, _classnames.default)("".concat(prefixCls, "-expanded-row"), "".concat(prefixCls, "-expanded-row-level-").concat(indent + 1), computedExpandedRowClassName)
|
67 | }, React.createElement(_Cell.default, {
|
68 | component: cellComponent,
|
69 | prefixCls: prefixCls,
|
70 | className: (0, _classnames.default)(rowCellCls, (0, _defineProperty2.default)({}, "".concat(rowCellCls, "-fixed"), fixColumn)),
|
71 | additionalProps: additionalProps
|
72 | }, expandContent));
|
73 | }
|
74 |
|
75 |
|
76 | var rowStyle = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, style), {}, {
|
77 | width: scrollX
|
78 | });
|
79 | if (extra) {
|
80 | rowStyle.position = 'absolute';
|
81 | rowStyle.pointerEvents = 'none';
|
82 | }
|
83 | var rowNode = React.createElement(RowComponent, (0, _extends2.default)({}, rowProps, restProps, {
|
84 | "data-row-key": rowKey,
|
85 | ref: rowSupportExpand ? null : ref,
|
86 | className: (0, _classnames.default)(className, "".concat(prefixCls, "-row"), rowProps === null || rowProps === void 0 ? void 0 : rowProps.className, (0, _defineProperty2.default)({}, "".concat(prefixCls, "-row-extra"), extra)),
|
87 | style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, rowStyle), rowProps === null || rowProps === void 0 ? void 0 : rowProps.style)
|
88 | }), flattenColumns.map(function (column, colIndex) {
|
89 | return React.createElement(_VirtualCell.default, {
|
90 | key: colIndex,
|
91 | component: cellComponent,
|
92 | rowInfo: rowInfo,
|
93 | column: column,
|
94 | colIndex: colIndex,
|
95 | indent: indent,
|
96 | index: index,
|
97 | renderIndex: renderIndex,
|
98 | record: record,
|
99 | inverse: extra,
|
100 | getHeight: getHeight
|
101 | });
|
102 | }));
|
103 | if (rowSupportExpand) {
|
104 | return React.createElement("div", {
|
105 | ref: ref
|
106 | }, rowNode, expandRowNode);
|
107 | }
|
108 | return rowNode;
|
109 | });
|
110 | var ResponseBodyLine = (0, _TableContext.responseImmutable)(BodyLine);
|
111 | if (process.env.NODE_ENV !== 'production') {
|
112 | ResponseBodyLine.displayName = 'BodyLine';
|
113 | }
|
114 | var _default = exports.default = ResponseBodyLine; |
\ | No newline at end of file |