import * as React from "react";
import { useStyletron } from "baseui";
import { Checkbox } from "baseui/checkbox";
import {
Filter,
StyledTable,
StyledHead,
StyledHeadCell,
StyledBody,
StyledRow,
StyledCell,
} from "baseui/table";
const FilterCheckbox = (props: any) => (
({
marginTop: $theme.sizing.scale400,
marginBottom: $theme.sizing.scale400,
}),
},
Checkmark: { style: { marginLeft: 0 } },
}}
>
{props.children}
);
class FilterTable extends React.Component {
state = {
filters: [],
};
FILTER_FUNCTIONS = Array.from(
{ length: 10 },
(_, i) => (row: any) => row[0] % (i + 1) === 0,
);
onFilter = (index: number) => {
const isActive = !!this.state.filters[index];
const filters: any = [...this.state.filters];
if (isActive) {
filters[index] = null;
} else {
filters[index] = this.FILTER_FUNCTIONS[index];
}
this.setState({ filters });
};
handleReset = () => this.setState({ filters: [] });
handleSelectAll = () => this.setState({ filters: this.FILTER_FUNCTIONS });
render() {
const filteredData = this.state.filters
.filter(Boolean)
.reduce((data, filter) => data.filter(filter), this.props.data);
return (
Number
{this.FILTER_FUNCTIONS.map((_, index) => (
this.onFilter(index)}
>
{`Divisible by ${index + 1}`}
))}
Title
{filteredData.map((row: any, index: number) => (
{row.map((cell: any, cellIndex: number) => (
{cell}
))}
))}
);
}
}
export default function Example() {
const [css] = useStyletron();
const FILTER_DATA = Array.from({ length: 100 }, (_, i) => [i, "row title"]);
return (
);
}