UNPKG

@flatbiz/antd

Version:
51 lines (47 loc) 1.82 kB
/*! @flatjs/forge MIT @flatbiz/antd */ import { b as _objectSpread2 } from './_rollupPluginBabelHelpers-BYm17lo8.js'; import { classNames } from '@dimjs/utils/class-names/class-names'; import { Children, cloneElement } from 'react'; import { toArray } from '@flatbiz/utils'; import { jsx } from 'react/jsx-runtime'; /** * flex布局,主要用于Flex结构性布局 * ``` * 4.2.87版本中将fullIndex改为了必填属性,如果在升级中遇到问题,不确定怎么写,可设置 fullIndex=[] 保持原样 * ``` */ var FlexLayout = function FlexLayout(props) { var childrens = Children.toArray(props.children); var direction = props.direction || 'vertical'; var gap = props.gap ? props.gap : 0; var fullIndexList = toArray(props.fullIndex); return /*#__PURE__*/jsx("div", { className: classNames('v-flex-layout', "v-flex-".concat(direction), props.className), style: _objectSpread2(_objectSpread2({}, props.style), {}, { gap: gap }), onClick: props.onClick, children: childrens.map(function (children, index) { var _children$props; var childrenStyle = ((_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.style) || {}; var style = fullIndexList.includes(index) ? _objectSpread2({ flex: 1 }, childrenStyle) : _objectSpread2({ flexShrink: 0 }, childrenStyle); // if (index < childrens.length - 1 && gap > 0) { // if (direction === 'horizontal') { // style.marginRight = gap; // } else { // style.marginBottom = gap; // } // } return /*#__PURE__*/cloneElement(children, { style: style, key: index }); }) }); }; export { FlexLayout as F }; //# sourceMappingURL=flex-layout-BaDncU_Z.js.map