-
Notifications
You must be signed in to change notification settings - Fork 381
Expand file tree
/
Copy pathThead.tsx
More file actions
50 lines (47 loc) · 1.43 KB
/
Thead.tsx
File metadata and controls
50 lines (47 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { forwardRef } from 'react';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/react-styles/css/components/Table/table';
export interface TheadProps extends React.HTMLProps<HTMLTableSectionElement> {
/** Content rendered inside the <thead> row group */
children?: React.ReactNode;
/** Additional classes added to the <thead> element */
className?: string;
/** Won't wrap the table head if true */
noWrap?: boolean;
/** @hide Forwarded ref */
innerRef?: React.Ref<any>;
/** Indicates the <thead> contains a nested header */
hasNestedHeader?: boolean;
/**
* When true, applies the placeholder `PINNED` class for styling while the sticky header is scrolled
* within its scroll container. Drive this from app logic or a hook (see table examples).
*/
isPinned?: boolean;
}
const TheadBase: React.FunctionComponent<TheadProps> = ({
children,
className,
noWrap = false,
innerRef,
hasNestedHeader,
isPinned,
...props
}: TheadProps) => (
<thead
className={css(
styles.tableThead,
className,
noWrap && styles.modifiers.nowrap,
hasNestedHeader && styles.modifiers.nestedColumnHeader,
isPinned && 'PINNED'
)}
ref={innerRef}
{...props}
>
{children}
</thead>
);
export const Thead = forwardRef((props: TheadProps, ref: React.Ref<HTMLTableSectionElement>) => (
<TheadBase {...props} innerRef={ref} />
));
Thead.displayName = 'Thead';