UNPKG

acud

Version:

acg react 组件库

36 lines • 1.21 kB
import * as React from 'react'; import toArray from "rc-util/es/Children/toArray"; import { ConfigContext } from '../config-provider'; import useFlexGapSupport from '../_util/hooks/useFlexGapSupport'; var Space = function Space(props) { var customizePrefixCls = props.prefixCls, _props$space = props.space, space = _props$space === void 0 ? 12 : _props$space, children = props.children; var supportFlexGap = useFlexGapSupport(); var spaceStyle = {}; var childrenMap = children; if (!supportFlexGap) { var childNodes = toArray(children, { keepEmpty: true }); childrenMap = childNodes.map(function (child, index) { return /*#__PURE__*/React.createElement("span", { style: { marginRight: index === childNodes.length - 1 ? 0 : space } }, child); }); } if (supportFlexGap) { spaceStyle.columnGap = space; } var _React$useContext = React.useContext(ConfigContext), getPrefixCls = _React$useContext.getPrefixCls; var prefixCls = getPrefixCls('table-space', customizePrefixCls); return /*#__PURE__*/React.createElement("div", { className: prefixCls, style: spaceStyle }, childrenMap); }; export default Space;