UNPKG

@carbon/react

Version:

React components for the Carbon Design System

70 lines (62 loc) 2.35 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'; 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'); 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 Row({ as: BaseComponent = 'div', condensed = false, narrow = false, className: containerClassName, children, ...rest }) { const prefix = usePrefix.usePrefix(); const className = cx__default["default"](containerClassName, { [`${prefix}--row`]: true, [`${prefix}--row--condensed`]: condensed, [`${prefix}--row--narrow`]: narrow }); // TypeScript type validation reports conflicts on different instances of keyof JSX.IntrinsicElements const BaseComponentAsAny = BaseComponent; return /*#__PURE__*/React__default["default"].createElement(BaseComponentAsAny, _rollupPluginBabelHelpers["extends"]({ className: className }, rest), children); } Row.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 `Row` */ children: PropTypes__default["default"].node, /** * Specify a custom className to be applied to the `Row` */ className: PropTypes__default["default"].string, /** * Specify a single row as condensed.Rows that are adjacent * and are condensed will have 2px of margin between them to match gutter. */ condensed: PropTypes__default["default"].bool, /** * Specify a single row as narrow. The container will hang * 16px into the gutter. */ narrow: PropTypes__default["default"].bool }; exports["default"] = Row;