import { Button, Select } from "antd";
import { ChevronLeft, ChevronRight, RotateCcw } from "lucide-react";
import type { ReactNode } from "react";
import { cn } from "@/lib/utils";
export function WorkspacePage({ children, className, grid = false, fluid = false }: { children: ReactNode; className?: string; grid?: boolean; fluid?: boolean }) {
return (
{children}
);
}
export function PageHeader({ title, description, meta, actions }: { title: string; description?: string; meta?: ReactNode; actions?: ReactNode }) {
return (
{title}
{meta}
{description ?
{description}
: null}
{actions ? {actions}
: null}
);
}
export function ListToolbar({ children, trailing, active, onReset, className }: { children: ReactNode; trailing?: ReactNode; active?: boolean; onReset?: () => void; className?: string }) {
return (
{children}
{active && onReset ? } onClick={onReset}>重置 : null}
{trailing}
);
}
export function TableSurface({ children, className }: { children: ReactNode; className?: string }) {
return {children}
;
}
export function CollectionGrid({ children, className }: { children: ReactNode; className?: string }) {
return {children}
;
}
/* 自研轻量分页:页码胶囊 + 省略号 + 每页条数 + 总数,替代 AntD Pagination(无 AntD 残留样式,与工具栏容器同语言)。 */
function pageItems(current: number, pages: number): (number | "…")[] {
if (pages <= 7) return Array.from({ length: pages }, (_, i) => i + 1);
if (current <= 4) return [1, 2, 3, 4, 5, "…", pages];
if (current >= pages - 3) return [1, "…", pages - 4, pages - 3, pages - 2, pages - 1, pages];
return [1, "…", current - 1, current, current + 1, "…", pages];
}
export function PaginationBar({ current, pageSize, total, onChange, pageSizeOptions = [20, 50, 100] }: { current: number; pageSize: number; total: number; onChange: (page: number, pageSize: number) => void; pageSizeOptions?: number[] }) {
if (total <= pageSize && current === 1) return null;
const pages = Math.max(1, Math.ceil(total / pageSize));
const start = (current - 1) * pageSize + 1;
const end = Math.min(total, current * pageSize);
const items = pageItems(current, pages);
return (
{start}-{end} / 共 {total} 条
);
}