UNPKG

1.62 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
9var _count_row_span = require('./count_row_span');
10
11var _count_row_span2 = _interopRequireDefault(_count_row_span);
12
13function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
16
17function resolveHeaderRows() {
18 var columns = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
19
20 var resolvedChildren = [];
21
22 var ret = columns.map(function (column) {
23 var children = column.children;
24
25 var col = _objectWithoutProperties(column, ['children']);
26
27 if (children && children.length) {
28 resolvedChildren = resolvedChildren.concat(resolveHeaderRows(children)[0]);
29
30 return _extends({}, col, {
31 props: _extends({}, col.props, {
32 colSpan: children.length
33 })
34 });
35 }
36
37 return _extends({}, col, {
38 props: _extends({}, col.props, {
39 rowSpan: (0, _count_row_span2.default)(columns)
40 })
41 });
42 });
43
44 if (resolvedChildren.length) {
45 return [ret].concat([resolvedChildren]);
46 }
47
48 return [ret];
49}
50
51exports.default = resolveHeaderRows;
\No newline at end of file