UNPKG

@procore/core-react

Version:
98 lines (97 loc) 4.02 kB
var _excluded = ["as", "alignContent", "alignItems", "alignSelf", "children", "display", "flex", "flexBasis", "flexDirection", "flexGrow", "flexShrink", "flexWrap", "gap", "justifyContent", "margin", "marginBottom", "marginLeft", "marginRight", "marginTop", "order", "padding", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "textAlign"]; function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } import * as React from 'react'; import { StyledBox } from './Box.styles'; // TODO remove this after we decommission the LegacyDisplay type function getLegacyDisplayAndDirection(d) { if (!d) { return {}; } var display = d; var direction = display.includes('flex') ? 'row' : undefined; if (d.includes('flex-inline') || d.includes('inline-flex')) { display = 'inline-flex'; } else if (d.includes('flex')) { display = 'flex'; } if (d.includes('column-reverse')) { direction = 'column-reverse'; } else if (d.includes('column')) { direction = 'column'; } if (d.includes('row-reverse')) { direction = 'row-reverse'; } else if (d.includes('row')) { direction = 'row'; } return { display: display, direction: direction }; } /** * `Box` is a general layout utility for CSS properties like `display`, `text-align`, * flex, spacing, and layout properties. */ export var Box = /*#__PURE__*/React.forwardRef(function Box(_ref, ref) { var as = _ref.as, alignContent = _ref.alignContent, alignItems = _ref.alignItems, alignSelf = _ref.alignSelf, children = _ref.children, display = _ref.display, flex = _ref.flex, flexBasis = _ref.flexBasis, flexDirection = _ref.flexDirection, flexGrow = _ref.flexGrow, flexShrink = _ref.flexShrink, flexWrap = _ref.flexWrap, gap = _ref.gap, justifyContent = _ref.justifyContent, margin = _ref.margin, marginBottom = _ref.marginBottom, marginLeft = _ref.marginLeft, marginRight = _ref.marginRight, marginTop = _ref.marginTop, order = _ref.order, padding = _ref.padding, paddingBottom = _ref.paddingBottom, paddingLeft = _ref.paddingLeft, paddingRight = _ref.paddingRight, paddingTop = _ref.paddingTop, textAlign = _ref.textAlign, props = _objectWithoutProperties(_ref, _excluded); var legacyProps = getLegacyDisplayAndDirection(display); return /*#__PURE__*/React.createElement(StyledBox, _extends({}, props, { ref: ref, as: as, $alignContent: alignContent, $alignItems: alignItems, $alignSelf: alignSelf, $display: legacyProps.display, $flex: flex, $flexBasis: flexBasis, $flexDirection: flexDirection !== null && flexDirection !== void 0 ? flexDirection : legacyProps.direction, $flexGrow: flexGrow, $flexShrink: flexShrink, $flexWrap: flexWrap, $gap: gap, $justifyContent: justifyContent, $margin: margin, $marginBottom: marginBottom, $marginLeft: marginLeft, $marginRight: marginRight, $marginTop: marginTop, $order: order, $padding: padding, $paddingBottom: paddingBottom, $paddingLeft: paddingLeft, $paddingRight: paddingRight, $paddingTop: paddingTop, $textAlign: textAlign }), children); }); Box.displayName = 'Box'; //# sourceMappingURL=Box.js.map