UNPKG

@carbon/react

Version:

React components for the Carbon Design System

56 lines (54 loc) 2.38 kB
/** * Copyright IBM Corp. 2016, 2026 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ const require_runtime = require("../../_virtual/_rolldown/runtime.js"); const require_usePrefix = require("../../internal/usePrefix.js"); const require_utils = require("../../internal/utils.js"); const require_index = require("../AILabel/index.js"); const require_TableDecoratorRow = require("./TableDecoratorRow.js"); const require_TableSlugRow = require("./TableSlugRow.js"); let classnames = require("classnames"); classnames = require_runtime.__toESM(classnames); let react = require("react"); react = require_runtime.__toESM(react); let prop_types = require("prop-types"); prop_types = require_runtime.__toESM(prop_types); let react_jsx_runtime = require("react/jsx-runtime"); //#region src/components/DataTable/TableRow.tsx /** * Copyright IBM Corp. 2016, 2026 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ const TableRow = (0, react.forwardRef)((props, ref) => { const { ariaLabel, "aria-label": ariaLabelAlt, "aria-controls": ariaControls, onExpand, isExpanded, isSelected, expandHeader, ...cleanProps } = props; const prefix = require_usePrefix.usePrefix(); const rowHasAILabel = react.Children.toArray(props.children).some((child) => { if (require_utils.isComponentElement(child, require_TableSlugRow.default)) return !!child.props.slug; return require_utils.isComponentElement(child, require_TableDecoratorRow.default) && require_utils.isComponentElement(child.props.decorator, require_index.AILabel); }); const className = (0, classnames.default)(props.className, { [`${prefix}--data-table--selected`]: isSelected, [`${prefix}--data-table--slug-row ${prefix}--data-table--ai-label-row`]: rowHasAILabel }); if (className) cleanProps.className = className; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", { ref, ...cleanProps }); }); TableRow.propTypes = { className: prop_types.default.string, isSelected: prop_types.default.bool, ariaLabel: prop_types.default.string, "aria-label": prop_types.default.string, "aria-controls": prop_types.default.string, onExpand: prop_types.default.func, isExpanded: prop_types.default.bool }; //#endregion exports.default = TableRow;