UNPKG

@carbon/react

Version:

React components for the Carbon Design System

65 lines (63 loc) 3.17 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_deprecate = require("../../prop-types/deprecate.js"); const require_requiredIfGivenPropIsTruthy = require("../../prop-types/requiredIfGivenPropIsTruthy.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"); let _carbon_icons_react = require("@carbon/icons-react"); //#region src/components/DataTable/TableExpandHeader.tsx /** * Copyright IBM Corp. 2016, 2025 * * 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 TableExpandHeader = ({ ["aria-controls"]: ariaControls, ["aria-label"]: ariaLabel, ariaLabel: deprecatedAriaLabel, className: headerClassName, enableExpando, enableToggle, id = "expand", isExpanded, onExpand, expandIconDescription, children, ...rest }) => { const prefix = require_usePrefix.usePrefix(); return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { scope: "col", className: (0, classnames.default)(`${prefix}--table-expand`, headerClassName), "data-previous-value": isExpanded ? "collapsed" : void 0, id, ...rest, children: [enableExpando || enableToggle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", { type: "button", className: `${prefix}--table-expand__button`, onClick: onExpand, title: expandIconDescription, "aria-label": deprecatedAriaLabel || ariaLabel, "aria-expanded": isExpanded, "aria-controls": ariaControls, children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_carbon_icons_react.ChevronRight, { className: `${prefix}--table-expand__svg`, "aria-label": expandIconDescription }) }) : null, children] }); }; TableExpandHeader.propTypes = { ["aria-controls"]: prop_types.default.string, ["aria-label"]: prop_types.default.string, ariaLabel: prop_types.default.string, children: prop_types.default.node, className: prop_types.default.string, enableExpando: require_deprecate.deprecate(prop_types.default.bool, "The `enableExpando` prop has been deprecated in favor of `enableToggle`. This prop will be removed in the next major release."), enableToggle: prop_types.default.bool, expandIconDescription: prop_types.default.string, id: prop_types.default.string, isExpanded: require_requiredIfGivenPropIsTruthy.requiredIfGivenPropIsTruthy("enableToggle", prop_types.default.bool), onExpand: prop_types.default.oneOfType([require_requiredIfGivenPropIsTruthy.requiredIfGivenPropIsTruthy("enableExpando", prop_types.default.func), require_requiredIfGivenPropIsTruthy.requiredIfGivenPropIsTruthy("enableToggle", prop_types.default.func)]) }; //#endregion exports.default = TableExpandHeader;