| 1 |
import { forwardRef } from 'react'; |
| 2 |
import { css } from '@patternfly/react-styles'; |
| 3 |
import styles from '@patternfly/react-styles/css/components/Table/table'; |
| 4 |
|
| 5 |
export interface TheadProps extends React.HTMLProps<HTMLTableSectionElement> { |
| 6 |
/** Content rendered inside the <thead> row group */ |
| 7 |
children?: React.ReactNode; |
| 8 |
/** Additional classes added to the <thead> element */ |
| 9 |
className?: string; |
| 10 |
/** Won't wrap the table head if true */ |
| 11 |
noWrap?: boolean; |
| 12 |
/** @hide Forwarded ref */ |
| 13 |
innerRef?: React.Ref<any>; |
| 14 |
/** Indicates the <thead> contains a nested header */ |
| 15 |
hasNestedHeader?: boolean; |
| 16 |
} |
| 17 |
|
| 18 |
const TheadBase: React.FunctionComponent<TheadProps> = ({ |
| 19 |
children, |
| 20 |
className, |
| 21 |
noWrap = false, |
| 22 |
innerRef, |
| 23 |
hasNestedHeader, |
| 24 |
...props |
| 25 |
}: TheadProps) => ( |
| 26 |
<thead |
| 27 |
className={css( |
| 28 |
styles.tableThead, |
| 29 |
className, |
| 30 |
noWrap && styles.modifiers.nowrap, |
| 31 |
hasNestedHeader && styles.modifiers.nestedColumnHeader |
| 32 |
)} |
| 33 |
ref={innerRef} |
| 34 |
{...props} |
| 35 |
> |
| 36 |
{children} |
| 37 |
</thead> |
| 38 |
); |
| 39 |
|
| 40 |
export const Thead = forwardRef((props: TheadProps, ref: React.Ref<HTMLTableSectionElement>) => ( |
| 41 |
<TheadBase {...props} innerRef={ref} /> |
| 42 |
)); |
| 43 |
Thead.displayName = 'Thead'; |