1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _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 |
|
9 | var _count_row_span = require('./count_row_span');
|
10 |
|
11 | var _count_row_span2 = _interopRequireDefault(_count_row_span);
|
12 |
|
13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14 |
|
15 | function _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 |
|
17 | function 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 |
|
51 | exports.default = resolveHeaderRows; |
\ | No newline at end of file |