From f3422c43819222edf20a2b431414bcc04a8d19e5 Mon Sep 17 00:00:00 2001 From: Akira Sudoh Date: Sat, 25 Jan 2020 09:42:20 +0900 Subject: [PATCH] feat(DataTable): allow additional contents to expand cells (#5060) This change adds `children` prop support to ``. This provides applications with more control so application can better describe the expand cell. Fixes #5028. --- .../components/DataTable/TableExpandHeader.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/react/src/components/DataTable/TableExpandHeader.js b/packages/react/src/components/DataTable/TableExpandHeader.js index f28a8f8c969f..e8228cd6e288 100644 --- a/packages/react/src/components/DataTable/TableExpandHeader.js +++ b/packages/react/src/components/DataTable/TableExpandHeader.js @@ -6,6 +6,7 @@ */ import cx from 'classnames'; +import PropTypes from 'prop-types'; import React from 'react'; import { ChevronRight16 } from '@carbon/icons-react'; import { settings } from 'carbon-components'; @@ -19,6 +20,7 @@ const TableExpandHeader = ({ isExpanded, onExpand, expandIconDescription, + children, ...rest }) => { const className = cx(`${prefix}--table-expand`, headerClassName); @@ -42,8 +44,36 @@ const TableExpandHeader = ({ /> )} + {children} ); }; +TableExpandHeader.propTypes = { + className: PropTypes.string, + children: PropTypes.node, + + /** + * Specify the string read by a voice reader when the expand trigger is + * focused + */ + ariaLabel: PropTypes.string.isRequired, + + /** + * Specify whether this row is expanded or not. This helps coordinate data + * attributes so that `TableExpandRow` and `TableExapndedRow` work together + */ + isExpanded: PropTypes.bool.isRequired, + + /** + * Hook for when a listener initiates a request to expand the given row + */ + onExpand: PropTypes.func.isRequired, + + /** + * The description of the chevron right icon, to be put in its SVG `` element. + */ + expandIconDescription: PropTypes.string, +}; + export default TableExpandHeader;