@trellixio/roaster-coffee
Version:
Beans' product component library
81 lines • 4.29 kB
TypeScript
import * as React from 'react';
import { ButtonProps } from '@/components/Button';
import { PaginationProps } from '@/components/Pagination';
import { TableBody } from './components/TableBody';
import { TableCell } from './components/TableCell';
import { TableHead } from './components/TableHead';
import { TablePaginationProps } from './components/TablePagination';
import { TableRow } from './components/TableRow';
import { TableProviderProps } from './utils/table';
export interface NativeTableProps extends React.ComponentProps<'table'> {
/** The table content (optional). */
children?: React.ReactNode;
/** Whether the table rows should be selectable (optional). */
selectable?: boolean;
/** Whether the table is browsable (optional). */
browsable?: boolean;
/** The actions to be displayed when a row in the table is selected (optional). */
selectActions?: React.ReactNode;
}
/**
* This interface defines the props that can be passed to a table component that includes pagination.
* It extends the `NativeTableProps` interface, and includes additional props related to pagination.
*/
interface TableBaseWithPagination extends NativeTableProps, Omit<TablePaginationProps, keyof PaginationProps> {
/** A boolean indicating whether pagination should be displayed (required). */
showPagination: true;
/** A function that is called when the "Next" button is clicked (required). */
onNextPage: () => void;
/** A function that is called when the "Previous" button is clicked (required). */
onPreviousPage: () => void;
/** A boolean indicating whether there is a next page (required). */
hasNextPage: boolean;
/** A boolean indicating whether there is a previous page (required). */
hasPreviousPage: boolean;
/** The props to be applied to the "Next" button (optional). */
nextPageButtonProps: ButtonProps;
/** The props to be applied to the "Previous" button (optional). */
previousPageButtonProps: ButtonProps;
/** CSS class names to be applied to the pagination element (optional). */
paginationClassName?: string;
}
/**
* This interface defines the props that can be passed to a table component that does not include pagination.
* It extends the `NativeTableProps` interface, and does not include any additional props.
*/
interface TableBaseWithoutPagination extends NativeTableProps {
/** A boolean indicating whether pagination should be displayed (optional). */
showPagination?: never;
/** A function that is called when the "Next" button is clicked (optional). */
onNextPage?: never;
/** A function that is called when the "Previous" button is clicked (optional). */
onPreviousPage?: never;
/** A boolean indicating whether there is a next page (optional). */
hasNextPage?: never;
/** A boolean indicating whether there is a previous page (optional). */
hasPreviousPage?: never;
/** The props to be applied to the "Next" button (optional). */
nextPageButtonProps?: never;
/** The props to be applied to the "Previous" button (optional). */
previousPageButtonProps?: never;
/** CSS class names to be applied to the pagination element (optional). */
paginationClassName?: never;
}
/**
* This type defines the props that can be passed to a table component.
* It includes the `TableBaseWithPagination` and `TableBaseWithoutPagination` interfaces,
* and ensures that only one set of props is used at a time.
*/
export declare type TableBaseProps = TableBaseWithPagination | TableBaseWithoutPagination;
export declare type TableProps = TableBaseProps & TableProviderProps;
export declare function Table({ children, selectable, itemCount, selectedItemsCount, onSelectionChange, ...tableBaseProps }: TableProps): React.JSX.Element;
export declare namespace Table {
var displayName: string;
var Head: typeof TableHead;
var Body: typeof TableBody;
var Row: typeof TableRow;
var HeadCell: React.ForwardRefExoticComponent<(Omit<import("./components/TableHeadCell").TableHeadCellPropsWithChildren, "ref"> | Omit<import("./components/TableHeadCell").TableHeadCellPropsWithTitle, "ref">) & React.RefAttributes<HTMLTableCellElement>>;
var Cell: typeof TableCell;
}
export {};
//# sourceMappingURL=Table.d.ts.map