@braineet/ui
Version:
Braineet design system
32 lines (31 loc) • 1.39 kB
JavaScript
var _excluded = ["children", "isInlineCss"];
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 _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 React, { useMemo } from 'react';
import { Box as StyledBox, DefaultBox, getCssProperties } from './styled';
/**
* The `Box` component.
*/
import { jsx as _jsx } from "react/jsx-runtime";
export var Box = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
var children = _ref.children,
isInlineCss = _ref.isInlineCss,
props = _objectWithoutPropertiesLoose(_ref, _excluded);
var inlineStyles = useMemo(function () {
if (!isInlineCss) return {};
return getCssProperties(props);
}, [isInlineCss]);
var shouldForwardProp = typeof props.as === 'object';
var BoxComponent = shouldForwardProp ? DefaultBox : StyledBox;
return /*#__PURE__*/_jsx(BoxComponent, _extends({
style: inlineStyles,
ref: ref
}, props, {
children: children
}));
});
Box.defaultProps = {
children: null,
isInlineCss: false
};
export default Box;