Row.js
3.12 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
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 _extends from "@babel/runtime/helpers/extends";
import * as React from 'react';
import Cell from './Cell';
function renderCells(items, _ref, _ref2) {
var colon = _ref.colon,
prefixCls = _ref.prefixCls,
bordered = _ref.bordered;
var component = _ref2.component,
type = _ref2.type,
showLabel = _ref2.showLabel,
showContent = _ref2.showContent;
return items.map(function (_ref3, index) {
var _ref3$props = _ref3.props,
label = _ref3$props.label,
children = _ref3$props.children,
_ref3$props$prefixCls = _ref3$props.prefixCls,
itemPrefixCls = _ref3$props$prefixCls === void 0 ? prefixCls : _ref3$props$prefixCls,
className = _ref3$props.className,
style = _ref3$props.style,
labelStyle = _ref3$props.labelStyle,
contentStyle = _ref3$props.contentStyle,
_ref3$props$span = _ref3$props.span,
span = _ref3$props$span === void 0 ? 1 : _ref3$props$span,
key = _ref3.key;
if (typeof component === 'string') {
return /*#__PURE__*/React.createElement(Cell, {
key: "".concat(type, "-").concat(key || index),
className: className,
style: style,
labelStyle: labelStyle,
contentStyle: contentStyle,
span: span,
colon: colon,
component: component,
itemPrefixCls: itemPrefixCls,
bordered: bordered,
label: showLabel ? label : null,
content: showContent ? children : null
});
}
return [/*#__PURE__*/React.createElement(Cell, {
key: "label-".concat(key || index),
className: className,
style: _extends(_extends({}, style), labelStyle),
span: 1,
colon: colon,
component: component[0],
itemPrefixCls: itemPrefixCls,
bordered: bordered,
label: label
}), /*#__PURE__*/React.createElement(Cell, {
key: "content-".concat(key || index),
className: className,
style: _extends(_extends({}, style), contentStyle),
span: span * 2 - 1,
component: component[1],
itemPrefixCls: itemPrefixCls,
bordered: bordered,
content: children
})];
});
}
var Row = function Row(props) {
var prefixCls = props.prefixCls,
vertical = props.vertical,
row = props.row,
index = props.index,
bordered = props.bordered;
if (vertical) {
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("tr", {
key: "label-".concat(index),
className: "".concat(prefixCls, "-row")
}, renderCells(row, props, {
component: 'th',
type: 'label',
showLabel: true
})), /*#__PURE__*/React.createElement("tr", {
key: "content-".concat(index),
className: "".concat(prefixCls, "-row")
}, renderCells(row, props, {
component: 'td',
type: 'content',
showContent: true
})));
}
return /*#__PURE__*/React.createElement("tr", {
key: index,
className: "".concat(prefixCls, "-row")
}, renderCells(row, props, {
component: bordered ? ['th', 'td'] : 'td',
type: 'item',
showLabel: true,
showContent: true
}));
};
export default Row;