UNPKG

@carbon/react

Version:

React components for the Carbon Design System

58 lines (54 loc) 1.69 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 { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js'; import React, { forwardRef } from 'react'; import cx from 'classnames'; import { usePrefix } from '../../internal/usePrefix.js'; import PropTypes from 'prop-types'; const frFn = forwardRef; const TableCell = frFn((props, ref) => { const { children, className, hasAILabelHeader, colSpan, ...rest } = props; const prefix = usePrefix(); const tableCellClassNames = cx(className, { [`${prefix}--table-cell--column-slug`]: hasAILabelHeader }); return /*#__PURE__*/React.createElement("td", _extends({ className: tableCellClassNames ? tableCellClassNames : undefined, ref: ref, colSpan: colSpan }, rest), children); }); TableCell.displayName = 'TableCell'; TableCell.propTypes = { /** * Pass in children that will be embedded in the table header label */ children: PropTypes.node, /** * Specify an optional className to be applied to the container node */ className: PropTypes.string, /** * The width of the expanded row's internal cell */ colSpan: PropTypes.number, /** * Specify if the table cell is in an AI column */ hasAILabelHeader: PropTypes.bool, /** * The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43 */ headers: PropTypes.string }; export { TableCell as default };