importtype{ ReactElement }from"react";import{ useIndeterminateChecked }from"@react-md/form";import{
Table,
TableBody,
TableCell,
TableCheckbox,
TableContainer,
TableHeader,
TableRow,}from"@react-md/table";import styles from"./StickyColumnsPart4.module.scss";const rows =Array.from({ length:30},(_, i)=>`row-${i +1}`);const headers =Array.from({ length:20},(_, i)=>`Header ${i +1}`);exportdefaultfunctionDemo(): ReactElement {const{ rootProps, getProps }=useIndeterminateChecked(rows);return(<TableContainerclassName={styles.container}><TablefullWidth><TableHeadersticky><TableRow>
<TableCheckbox
id="sticky-header-checkbox"
{...rootProps}
colSpan={2}
/**
* Manually set sticky to "header-cell" so it is fixed to the
* `top` and `left` instead of the default of just `top`
*/
sticky="header-cell"
/>
{headers.map((header)=>(<TableCellkey={header}>{header}</TableCell>))}</TableRow></TableHeader><TableBody>{rows.map((row, rowIndex)=>{const checkboxProps =getProps(row);const{ checked, onChange }= checkboxProps;return(<TableRowkey={row}clickableselected={checked}onClick={onChange}><TableCheckboxid={`${row}-checkbox`}{...checkboxProps}sticky/>
<TableCell
header
/**
* Set the sticky behavior to "cell" so it applies the `left`
* styling instead of the the default header cell behavior of
* `top`
*/
sticky="cell"
className={styles.sticky}
>
Row Header
</TableCell>{headers.map((header, cellIndex)=>(<TableCellkey={header}>{`Cell ${rowIndex +1} - ${cellIndex +1}`}</TableCell>))}</TableRow>);})}</TableBody></Table></TableContainer>);}