UNPKG

phx-react

Version:

PHX REACT

41 lines (40 loc) 1.17 kB
import React from 'react'; import { ReactNode } from 'react'; export type PrimaryCell = { title: string; titleSuffix?: string; description?: string | null; action?: { icon: ReactNode; onClick: () => void; } | null; }; export type PHXTableGroupColumn<Row> = { key: string; header: string; width?: string; align?: 'left' | 'center' | 'right'; mobileFullWidth?: boolean; } & ({ getValue: (row: Row, section: PHXTableGroupSection<Row>) => PrimaryCell; render?: undefined; } | { render: (row: Row, section: PHXTableGroupSection<Row>) => ReactNode; getValue?: undefined; }); export type PHXTableGroupSubSection<Row> = { id: string | number; label?: string; rows: Row[]; }; export type PHXTableGroupSection<Row> = { id: string | number; label: string; subSections: PHXTableGroupSubSection<Row>[]; }; export type PHXTableGroupProps<Row> = { sections: PHXTableGroupSection<Row>[]; columns: PHXTableGroupColumn<Row>[]; rowKey: (row: Row) => string; }; export default function PHXTableGroup<Row>({ sections, columns, rowKey }: PHXTableGroupProps<Row>): React.JSX.Element;