UNPKG

@carbon/react

Version:

React components for the Carbon Design System

52 lines (47 loc) 1.68 kB
/** * Copyright IBM Corp. 2016, 2023 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; 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'); /** * Helper component for rendering content that hangs on the column. Useful when * trying to align content across different gutter modes */ function ColumnHang({ as: BaseComponent = 'div', className: customClassName, children, ...rest }) { const prefix = usePrefix.usePrefix(); const className = cx(customClassName, `${prefix}--grid-column-hang`); // cast as any to let TypeScript allow passing in attributes to base component // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452 const BaseComponentAsAny = BaseComponent; return /*#__PURE__*/React.createElement(BaseComponentAsAny, _rollupPluginBabelHelpers.extends({}, rest, { className: className }), children); } ColumnHang.propTypes = { /** * Provide a custom element to render instead of the default <div> */ as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]), /** * Pass in content that will be rendered within the `Grid` */ children: PropTypes.node, /** * Specify a custom className to be applied to the `Grid` */ className: PropTypes.string }; const ColumnHangComponent = ColumnHang; exports.ColumnHang = ColumnHangComponent;