Skip to content

Commit

Permalink
feat(DataTable): allow additional contents to expand cells (#5060)
Browse files Browse the repository at this point in the history
This change adds `children` prop support to `<TableExpandHeader>`. This
provides applications with more control so application can better
describe the expand cell.

Fixes #5028.
  • Loading branch information
asudoh committed Jan 25, 2020
1 parent e97a7ed commit f3422c4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/react/src/components/DataTable/TableExpandHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -19,6 +20,7 @@ const TableExpandHeader = ({
isExpanded,
onExpand,
expandIconDescription,
children,
...rest
}) => {
const className = cx(`${prefix}--table-expand`, headerClassName);
Expand All @@ -42,8 +44,36 @@ const TableExpandHeader = ({
/>
</button>
)}
{children}
</th>
);
};

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 `<title>` element.
*/
expandIconDescription: PropTypes.string,
};

export default TableExpandHeader;

0 comments on commit f3422c4

Please sign in to comment.