@carbon/react
Version:
React components for the Carbon Design System
59 lines (52 loc) • 1.76 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 PropTypes = require('prop-types');
var React = require('react');
var cx = require('classnames');
var usePrefix = require('../../internal/usePrefix.js');
var deprecateComponent = require('../../prop-types/deprecateComponent.js');
const TableSlugRow = ({
className,
slug
}) => {
React.useEffect(() => {
deprecateComponent.deprecateComponent('TableSlugRow', 'The `TableSlugRow` component has been deprecated and will be removed in the next major version. Use the TableDecoratorRow component instead.');
}, []);
const prefix = usePrefix.usePrefix();
const TableSlugRowClasses = cx({
...(className && {
[className]: true
}),
[`${prefix}--table-column-slug`]: true,
[`${prefix}--table-column-slug--active`]: slug
});
// Slug is always size `mini`
let normalizedSlug;
if (slug) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
normalizedSlug = /*#__PURE__*/React.cloneElement(slug, {
size: 'mini'
});
}
return /*#__PURE__*/React.createElement("td", {
className: TableSlugRowClasses
}, normalizedSlug);
};
TableSlugRow.displayName = 'TableSlugRow';
TableSlugRow.propTypes = {
/**
* The CSS class names of the cell that wraps the underlying input control
*/
className: PropTypes.string,
/**
* Provide a `Slug` component to be rendered inside the `TableSlugRow` component
*/
slug: PropTypes.node
};
exports.default = TableSlugRow;