@carbon/react
Version:
React components for the Carbon Design System
52 lines (46 loc) • 1.54 kB
JavaScript
/**
* 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.
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var cx = require('classnames');
var PropTypes = require('prop-types');
var React = require('react');
var usePrefix = require('../../internal/usePrefix.js');
var index = require('../AILabel/index.js');
var utils = require('../../internal/utils.js');
const TableDecoratorRow = ({
className,
decorator
}) => {
const prefix = usePrefix.usePrefix();
const TableDecoratorRowClasses = cx({
...(className && {
[className]: true
}),
[`${prefix}--table-column-decorator`]: true,
[`${prefix}--table-column-decorator--active`]: decorator
});
const decoratorIsAILabel = utils.isComponentElement(decorator, index.AILabel);
const normalizedDecorator = decoratorIsAILabel ? /*#__PURE__*/React.cloneElement(decorator, {
size: 'mini'
}) : null;
return /*#__PURE__*/React.createElement("td", {
className: TableDecoratorRowClasses
}, normalizedDecorator);
};
TableDecoratorRow.displayName = 'TableDecoratorRow';
TableDecoratorRow.propTypes = {
/**
* The CSS class names of the cell that wraps the underlying input control
*/
className: PropTypes.string,
/**
* **Experimental**: Provide a `decorator` component to be rendered inside the `TableDecoratorRow` component
*/
decorator: PropTypes.node
};
exports.default = TableDecoratorRow;