UNPKG

@carbon/react

Version:

React components for the Carbon Design System

54 lines (49 loc) 1.52 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. */ import PropTypes from 'prop-types'; import React, { useEffect } from 'react'; import cx from 'classnames'; import { usePrefix } from '../../internal/usePrefix.js'; import deprecateComponent from '../../prop-types/deprecateComponent.js'; const TableSlugRow = ({ className, slug }) => { useEffect(() => { 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(); 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) { 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 }; export { TableSlugRow as default };