@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
46 lines (42 loc) • 1.23 kB
JavaScript
/**
* MSKCC 2021, 2024
*/
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import PropTypes from 'prop-types';
import React__default from 'react';
import { LayoutDirectionContext } from './LayoutDirectionContext.js';
export { LayoutDirectionContext } from './LayoutDirectionContext.js';
function LayoutDirection(_ref) {
let {
as: BaseComponent = 'div',
children,
dir,
...rest
} = _ref;
const value = React__default.useMemo(() => {
return {
direction: dir
};
}, [dir]);
return /*#__PURE__*/React__default.createElement(LayoutDirectionContext.Provider, {
value: value
}, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({
dir: dir
}, rest), children));
}
LayoutDirection.propTypes = {
/**
* Customize the element type used to render the outermost node
*/
as: PropTypes.oneOfType([PropTypes.func, PropTypes.string, PropTypes.elementType]),
/**
* Provide child elements or components to be rendered inside of this
* component
*/
children: PropTypes.node,
/**
* Specify the layout direction of this part of the page
*/
dir: PropTypes.oneOf(['ltr', 'rtl']).isRequired
};
export { LayoutDirection };