UNPKG

@carbon/react

Version:

React components for the Carbon Design System

62 lines (56 loc) 1.8 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 React = require('react'); var cx = require('classnames'); var usePrefix = require('../../internal/usePrefix.js'); var PropTypes = require('prop-types'); const frFn = React.forwardRef; const TableCell = frFn((props, ref) => { const { children, className, hasAILabelHeader, colSpan, ...rest } = props; const prefix = usePrefix.usePrefix(); const tableCellClassNames = cx(className, { [`${prefix}--table-cell--column-slug`]: hasAILabelHeader }); return /*#__PURE__*/React.createElement("td", _rollupPluginBabelHelpers.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 }; exports.default = TableCell;