@braineet/ui
Version:
Braineet design system
32 lines (31 loc) • 1.56 kB
JavaScript
var _excluded = ["children", "isInlineCss"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
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;