UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

45 lines (38 loc) 1.41 kB
import * as React from 'react'; import isPlainObject from 'lodash/isPlainObject'; function getTotalByColumns(columns, state) { var totalFlexGrow = 0; var totalWidth = 0; var count = function count(items) { Array.from(items).forEach(function (column, index) { var dataIndex = column.props.dataIndex; // @ts-ignore if ( /*#__PURE__*/React.isValidElement(column)) { // @ts-ignore var _column$props = column.props, flexGrow = _column$props.flexGrow, _column$props$width = _column$props.width, width = _column$props$width === void 0 ? 0 : _column$props$width; totalFlexGrow += flexGrow || 0; totalWidth += flexGrow ? 0 : state["".concat(dataIndex, "_").concat(index, "_width")] || width; } else if (Array.isArray(column)) { count(column); } }); }; if (Array.isArray(columns)) { count(columns); } else if (isPlainObject(columns)) { var _columns$props = columns.props, flexGrow = _columns$props.flexGrow, _columns$props$width = _columns$props.width, width = _columns$props$width === void 0 ? 0 : _columns$props$width; totalFlexGrow = flexGrow || 0; totalWidth = flexGrow ? 0 : width; } return { totalFlexGrow: totalFlexGrow, totalWidth: totalWidth }; } export default getTotalByColumns; //# sourceMappingURL=getTotalByColumns.js.map