@carbon/react
Version:
React components for the Carbon Design System
68 lines (60 loc) • 2.26 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 _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var cx = require('classnames');
var usePrefix = require('../../internal/usePrefix.js');
var PropTypes = require('prop-types');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
const frFn = React.forwardRef;
const TableCell = frFn((props, ref) => {
const {
children,
className,
hasAILabelHeader,
colSpan,
...rest
} = props;
const prefix = usePrefix.usePrefix();
const tableCellClassNames = cx__default["default"](className, {
[`${prefix}--table-cell--column-slug`]: hasAILabelHeader
});
return /*#__PURE__*/React__default["default"].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__default["default"].node,
/**
* Specify an optional className to be applied to the container node
*/
className: PropTypes__default["default"].string,
/**
* The width of the expanded row's internal cell
*/
colSpan: PropTypes__default["default"].number,
/**
* Specify if the table cell is in an AI column
*/
hasAILabelHeader: PropTypes__default["default"].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__default["default"].string
};
exports["default"] = TableCell;