import * as React from "react";
import { useStyletron } from "baseui";
import { Button, KIND } from "baseui/button";
import { TriangleDown } from "baseui/icon";
import { StatefulMenu } from "baseui/menu";
import { Pagination } from "baseui/pagination";
import { StatefulPopover, PLACEMENT } from "baseui/popover";
import { Table } from "baseui/table";
function PaginatedTable(props: { data: any[]; columns: any[] }) {
const [css, theme] = useStyletron();
const [page, setPage] = React.useState(1);
const [limit, setLimit] = React.useState(12);
const handlePageChange = (nextPage: number) => {
if (nextPage < 1) {
return;
}
if (nextPage > Math.ceil(props.data.length / limit)) {
return;
}
setPage(nextPage);
};
const handleLimitChange = (nextLimit: number) => {
const nextPageNum = Math.ceil(props.data.length / nextLimit);
if (nextPageNum < page) {
setLimit(nextLimit);
setPage(nextPageNum);
} else {
setLimit(nextLimit);
}
};
const window = () => {
const min = (page - 1) * limit;
return props.data.slice(min, min + limit);
};
return (
(
({
label: i + 1,
}))}
onItemSelect={({ item }) => {
handleLimitChange(item.label);
close();
}}
overrides={{
List: {
style: { height: "150px", width: "100px" },
},
}}
/>
)}
placement={PLACEMENT.bottom}
>
handlePageChange(nextPage)}
/>
);
}
const COLUMNS = Array.from({ length: 5 }, () => "Label");
const DATA = Array.from({ length: 45 }, (_, i) =>
Array.from({ length: 5 }, () => `row: ${i + 1}`)
);
export default function Example() {
return ;
}