rename some of the types

This commit is contained in:
Dawid Wysokiński 2021-03-08 21:40:21 +01:00
parent 9b128e1e57
commit 550c0d30e4
5 changed files with 16 additions and 12 deletions

View File

@ -5,7 +5,7 @@ import { Action, Column, OrderDirection } from './types';
import {
Table as MUITable,
TableBody,
TableProps,
TableProps as MUITableProps,
TableBodyProps,
TableContainer,
} from '@material-ui/core';
@ -15,7 +15,7 @@ import TableLoading from './TableLoading';
import TableEmpty from './TableEmpty';
import TableFooter, { TableFooterProps } from './TableFooter';
export interface Props<T> {
export interface TableProps<T> {
columns: Column<T>[];
actions?: Action<T>[];
data: T[];
@ -30,7 +30,7 @@ export interface Props<T> {
) => void | Promise<void>;
onSelect?: (rows: T[]) => void;
loading?: boolean;
tableProps?: TableProps;
tableProps?: MUITableProps;
tableBodyProps?: TableBodyProps;
footerProps?: TableFooterProps;
hideFooter?: boolean;
@ -56,7 +56,7 @@ function Table<T>({
selected,
onSelect,
getRowKey,
}: Props<T>) {
}: TableProps<T>) {
const headColumns =
actions.length > 0
? [...columns, { field: 'action', label: 'Akcje' }]

View File

@ -10,7 +10,7 @@ import {
SortDirection,
} from '@material-ui/core';
export interface Props {
export interface TableHeadProps {
columns: Column[];
selection: boolean;
onSelectAll?: () => void;
@ -33,7 +33,7 @@ function TableHead({
allSelected = false,
onRequestSort,
size = 'medium',
}: Props) {
}: TableHeadProps) {
const createSortHandler = (property: string) => () => {
if (onRequestSort) {
if (property === orderBy) {

View File

@ -4,13 +4,17 @@ import { Column } from './types';
import { TableRow, TableCell } from '@material-ui/core';
import { Skeleton } from '@material-ui/lab';
export interface Props {
export interface TableLoadingProps {
rowsPerPage: number;
columns: Column[];
size?: 'small' | 'medium';
}
function TableLoading({ rowsPerPage, columns, size = 'medium' }: Props) {
function TableLoading({
rowsPerPage,
columns,
size = 'medium',
}: TableLoadingProps) {
return (
<Fragment>
{new Array(rowsPerPage).fill(0).map((_, index) => {

View File

@ -8,7 +8,7 @@ import { TableRow, TableCell, Checkbox, Tooltip } from '@material-ui/core';
import { Action, Column } from './types';
export interface Props<T> {
export interface TableRowProps<T> {
actions: Action<T>[];
columns: Column<T>[];
row: T;
@ -28,7 +28,7 @@ function EnhancedTableRow<T>({
onSelect,
size = 'medium',
index,
}: Props<T>) {
}: TableRowProps<T>) {
const handleSelect = () => {
if (onSelect) {
onSelect(row);

View File

@ -4,7 +4,7 @@ import clsx from 'clsx';
import { makeStyles } from '@material-ui/core/styles';
import { Toolbar, ToolbarProps } from '@material-ui/core';
export type Props = ToolbarProps;
export type TableToolbarProps = ToolbarProps;
const useStyles = makeStyles(theme => {
return {
@ -15,7 +15,7 @@ const useStyles = makeStyles(theme => {
};
});
function TableToolbar({ children, className, ...rest }: Props) {
function TableToolbar({ children, className, ...rest }: TableToolbarProps) {
const classes = useStyles();
return (
<Toolbar {...rest} className={clsx(classes.toolbar, className)}>