UNPKG

choerodon-ui

Version:

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

35 lines (27 loc) 960 B
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"]; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = resetLeftForCells; var React = _interopRequireWildcard(require("react")); /** * 重置数组中所有 cell 的相对 left 的距离。 * @param cells * @param extraWidth 额外为最后一个元素添加的的宽度,当存在纵向滚动条的时候设置。 */ function resetLeftForCells(cells, extraWidth) { var left = 0; var nextCells = []; for (var i = 0; i < cells.length; i++) { var cell = cells[i]; var nextCell = /*#__PURE__*/React.cloneElement(cell, { left: left, width: i === cells.length - 1 && extraWidth ? cell.props.width + extraWidth : cell.props.width }); left += cell.props.width; // @ts-ignore nextCells.push(nextCell); } return nextCells; } //# sourceMappingURL=resetLeftForCells.js.map