Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DataTable): allow additional contents to expand cells #5060

Merged
merged 15 commits into from
Jan 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;