import { IExtra, IFormatterValueType, OnCheckChange, OnTreeRowCollapse, OnToggleRowDetails } from '../../TableTypes'; import { css } from '@patternfly/react-styles'; import styles from '@patternfly/react-styles/css/components/Table/table'; import stylesTreeView from '@patternfly/react-styles/css/components/Table/table-tree-view'; import { Button } from '@patternfly/react-core/dist/esm/components/Button'; import { Checkbox } from '@patternfly/react-core/dist/esm/components/Checkbox'; import RhMicronsCaretDownIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-caret-down-icon'; import RhUiEllipsisHorizontalFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ellipsis-horizontal-fill-icon'; export const treeRow = (onCollapse: OnTreeRowCollapse, onCheckChange?: OnCheckChange, onToggleRowDetails?: OnToggleRowDetails) => (value: IFormatterValueType, { rowIndex, rowData }: IExtra) => { const { isExpanded, isDetailsExpanded, 'aria-level': level, 'aria-setsize': setsize, toggleAriaLabel, checkAriaLabel, showDetailsAriaLabel, isChecked, checkboxId, icon } = rowData.props; const content = value.title || value; const text = (
{icon && ( {icon} )} {content as React.ReactNode}
); const onChange = (isChecked: boolean, event: React.FormEvent) => { onCheckChange(event, isChecked, rowIndex, content as React.ReactNode, rowData); }; return { component: 'th', className: stylesTreeView.tableTreeViewTitleCell, children: level !== undefined ? (
{setsize > 0 && (
) : ( text ) }; };