@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
79 lines (71 loc) • 2.64 kB
JavaScript
/**
* MSKCC 2021, 2024
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var cx = require('classnames');
var PropTypes = require('prop-types');
var React = require('react');
var usePrefix = require('../../internal/usePrefix.js');
var GridContext = require('./GridContext.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
function FlexGrid(_ref) {
let {
as: BaseComponent = 'div',
condensed = false,
narrow = false,
fullWidth = false,
className: containerClassName,
children,
...rest
} = _ref;
const prefix = usePrefix.usePrefix();
const className = cx__default["default"](containerClassName, {
[`${prefix}--grid`]: true,
[`${prefix}--grid--condensed`]: condensed,
[`${prefix}--grid--narrow`]: narrow,
[`${prefix}--grid--full-width`]: fullWidth
});
// cast as any to let TypeScript allow passing in attributes to base component
const BaseComponentAsAny = BaseComponent;
return /*#__PURE__*/React__default["default"].createElement(GridContext.GridSettings, {
mode: "flexbox",
subgrid: false
}, /*#__PURE__*/React__default["default"].createElement(BaseComponentAsAny, _rollupPluginBabelHelpers["extends"]({
className: className
}, rest), children));
}
FlexGrid.propTypes = {
/**
* Provide a custom element to render instead of the default <div>
*/
as: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].elementType]),
/**
* Pass in content that will be rendered within the `FlexGrid`
*/
children: PropTypes__default["default"].node,
/**
* Specify a custom className to be applied to the `FlexGrid`
*/
className: PropTypes__default["default"].string,
/**
* Collapse the gutter to 1px. Useful for fluid layouts.
* Rows have 1px of margin between them to match gutter.
*/
condensed: PropTypes__default["default"].bool,
/**
* Remove the default max width that the grid has set
*/
fullWidth: PropTypes__default["default"].bool,
/**
* Container hangs 16px into the gutter. Useful for
* typographic alignment with and without containers.
*/
narrow: PropTypes__default["default"].bool
};
const FlexGridComponent = FlexGrid;
exports.FlexGrid = FlexGridComponent;