import { forwardRef } from "react";

/**
 * Table
 *
 * bordered:  boolean - row divider lines
 * fixed:     boolean - equal column widths (table-layout: fixed)
 * striped:   boolean - alternating row highlight
 * compact:   boolean - reduced cell padding
 * pinRows:   boolean - sticky thead/tfoot
 * pinCols:   boolean - sticky first/last th columns
 */
const Table = forwardRef(function Table(
  {
    bordered = false,
    fixed = false,
    striped = false,
    compact = false,
    pinRows = false,
    pinCols = false,
    className = "",
    children,
    ...props
  },
  ref
) {
  const classes = [
    "prs-table",
    bordered && "prs-table-bordered",
    fixed && "prs-table-fixed",
    striped && "prs-table-striped",
    compact && "prs-table-compact",
    pinRows && "prs-table-pin-rows",
    pinCols && "prs-table-pin-cols",
    className,
  ]
    .filter(Boolean)
    .join(" ");

  return (
    <table ref={ref} className={classes} {...props}>
      {children}
    </table>
  );
});

export default Table;
