Skip to content

Commit

Permalink
Lint and Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Dec 10, 2024
1 parent 44fd9c7 commit 6b05a38
Show file tree
Hide file tree
Showing 10 changed files with 5,978 additions and 7,438 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export const SourceCodeSnippet = ({
setColorScheme(
value?.startsWith('dark') ? 'dark' : 'light',
);

if (value === 'darkDark') {
setDarkDark(true);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { useMemo } from 'react';

import { createRow } from '@tanstack/react-table';

import { type TableProps, TableTd, type TableTrProps, Text } from '@mantine/core';
import {
type TableProps,
TableTd,
type TableTrProps,
Text,
} from '@mantine/core';

import { MRT_TableBodyRow } from './MRT_TableBodyRow';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,37 +195,39 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
{virtualPaddingLeft ? (
<Box component="td" display="flex" w={virtualPaddingLeft} />
) : null}
{children ? children : (virtualColumns ?? row.getVisibleCells()).map(
(cellOrVirtualCell, renderedColumnIndex) => {
let cell = cellOrVirtualCell as MRT_Cell<TData>;
if (columnVirtualizer) {
renderedColumnIndex = (cellOrVirtualCell as MRT_VirtualItem)
.index;
cell = visibleCells[renderedColumnIndex];
}
const cellProps = {
cell,
numRows,
renderedColumnIndex,
renderedRowIndex,
rowRef,
table,
virtualCell: columnVirtualizer
? (cellOrVirtualCell as MRT_VirtualItem)
: undefined,
};
return memoMode === 'cells' &&
cell.column.columnDef.columnDefType === 'data' &&
!draggingColumn &&
!draggingRow &&
editingCell?.id !== cell.id &&
editingRow?.id !== row.id ? (
<Memo_MRT_TableBodyCell key={cell.id} {...cellProps} />
) : (
<MRT_TableBodyCell key={cell.id} {...cellProps} />
);
},
)}
{children
? children
: (virtualColumns ?? row.getVisibleCells()).map(
(cellOrVirtualCell, renderedColumnIndex) => {
let cell = cellOrVirtualCell as MRT_Cell<TData>;
if (columnVirtualizer) {
renderedColumnIndex = (cellOrVirtualCell as MRT_VirtualItem)
.index;
cell = visibleCells[renderedColumnIndex];
}
const cellProps = {
cell,
numRows,
renderedColumnIndex,
renderedRowIndex,
rowRef,
table,
virtualCell: columnVirtualizer
? (cellOrVirtualCell as MRT_VirtualItem)
: undefined,
};
return memoMode === 'cells' &&
cell.column.columnDef.columnDefType === 'data' &&
!draggingColumn &&
!draggingRow &&
editingCell?.id !== cell.id &&
editingRow?.id !== row.id ? (
<Memo_MRT_TableBodyCell key={cell.id} {...cellProps} />
) : (
<MRT_TableBodyCell key={cell.id} {...cellProps} />
);
},
)}
{virtualPaddingRight ? (
<Box component="td" display="flex" w={virtualPaddingRight} />
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export const MRT_TableDetailPanel = <TData extends MRT_RowData>({
));

const DetailPanel =
!isLoading && row.getIsExpanded() && renderDetailPanel?.({ internalEditComponents, row, table });
!isLoading &&
row.getIsExpanded() &&
renderDetailPanel?.({ internalEditComponents, row, table });

return (
<TableTr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export const MRT_ExpandButton = <TData extends MRT_RowData>({
const canExpand = row.getCanExpand();
const isExpanded = row.getIsExpanded();

const DetailPanel = !!renderDetailPanel?.({ internalEditComponents, row, table });
const DetailPanel = !!renderDetailPanel?.({
internalEditComponents,
row,
table,
});

const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
Expand Down
76 changes: 31 additions & 45 deletions packages/mantine-react-table/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,36 +341,32 @@ export type MRT_TableInstance<TData extends MRT_RowData> = {
export type MRT_DefinedTableOptions<TData extends MRT_RowData> = {
icons: MRT_Icons;
localization: MRT_Localization;
} & Omit<
MRT_TableOptions<TData>,
'icons' | 'localization'
>;
} & Omit<MRT_TableOptions<TData>, 'icons' | 'localization'>;

export type MRT_StatefulTableOptions<TData extends MRT_RowData> =
{
state: Pick<
MRT_TableState<TData>,
| 'columnFilterFns'
| 'columnOrder'
| 'columnSizingInfo'
| 'creatingRow'
| 'density'
| 'draggingColumn'
| 'draggingRow'
| 'editingCell'
| 'editingRow'
| 'globalFilterFn'
| 'grouping'
| 'hoveredColumn'
| 'hoveredRow'
| 'isFullScreen'
| 'pagination'
| 'showAlertBanner'
| 'showColumnFilters'
| 'showGlobalFilter'
| 'showToolbarDropZone'
>;
} & MRT_DefinedTableOptions<TData>;
export type MRT_StatefulTableOptions<TData extends MRT_RowData> = {
state: Pick<
MRT_TableState<TData>,
| 'columnFilterFns'
| 'columnOrder'
| 'columnSizingInfo'
| 'creatingRow'
| 'density'
| 'draggingColumn'
| 'draggingRow'
| 'editingCell'
| 'editingRow'
| 'globalFilterFn'
| 'grouping'
| 'hoveredColumn'
| 'hoveredRow'
| 'isFullScreen'
| 'pagination'
| 'showAlertBanner'
| 'showColumnFilters'
| 'showGlobalFilter'
| 'showToolbarDropZone'
>;
} & MRT_DefinedTableOptions<TData>;

export type MRT_TableState<TData extends MRT_RowData> = Prettify<
{
Expand Down Expand Up @@ -661,10 +657,9 @@ export type MRT_DisplayColumnDef<
TValue = unknown,
> = Omit<MRT_ColumnDef<TData, TValue>, 'accessorFn' | 'accessorKey'>;

export type MRT_GroupColumnDef<TData extends MRT_RowData> =
{
columns: MRT_ColumnDef<TData>[];
} & MRT_DisplayColumnDef<TData, any>;
export type MRT_GroupColumnDef<TData extends MRT_RowData> = {
columns: MRT_ColumnDef<TData>[];
} & MRT_DisplayColumnDef<TData, any>;

export type MRT_DefinedColumnDef<
TData extends MRT_RowData,
Expand All @@ -688,17 +683,11 @@ export type MRT_Column<TData extends MRT_RowData, TValue = unknown> = {

export type MRT_Header<TData extends MRT_RowData, TValue = unknown> = {
column: MRT_Column<TData, TValue>;
} & Omit<
Header<TData, MRT_CellValue>,
'column'
>;
} & Omit<Header<TData, MRT_CellValue>, 'column'>;

export type MRT_HeaderGroup<TData extends MRT_RowData> = {
headers: MRT_Header<TData>[];
} & Omit<
HeaderGroup<TData>,
'headers'
>;
} & Omit<HeaderGroup<TData>, 'headers'>;

export type MRT_Row<TData extends MRT_RowData> = {
_valuesCache: Record<LiteralUnion<DeepKeys<TData> & string>, any>;
Expand All @@ -713,10 +702,7 @@ export type MRT_Row<TData extends MRT_RowData> = {
export type MRT_Cell<TData extends MRT_RowData, TValue = unknown> = {
column: MRT_Column<TData, TValue>;
row: MRT_Row<TData>;
} & Omit<
Cell<TData, TValue>,
'column' | 'row'
>;
} & Omit<Cell<TData, TValue>, 'column' | 'row'>;

export type MRT_AggregationOption = keyof typeof MRT_AggregationFns & string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const columns: MRT_ColumnDef<(typeof data)[0]>[] = [
const data = [...Array(120)].map(() => ({
address: faker.location.streetAddress(),
age: faker.number.int(100),
birthDate: faker.date.birthdate({ max: 2020, min: 1990, mode: "year" }),
birthDate: faker.date.birthdate({ max: 2020, min: 1990, mode: 'year' }),
firstName: faker.person.firstName(),
gender: faker.person.sex(),
hireDate: faker.date.past(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Button, Container } from '@mantine/core';

import {
MantineReactTable, useMantineReactTable
} from '../../src';
import { MantineReactTable, useMantineReactTable } from '../../src';

import { type Meta } from '@storybook/react';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MantineReactTable } from "../../src";
import { MantineReactTable } from '../../src';

import { type Meta } from '@storybook/react';

Expand All @@ -22,11 +22,20 @@ export const SwitchFromEmptyToEqualsArray = () => (
filterVariant: 'multi-select',
header: 'State',
mantineFilterMultiSelectProps: {
data: ["Wyoming", "Delaware", "South Dakota", "Vermont", "Rhode Island"]
}
data: [
'Wyoming',
'Delaware',
'South Dakota',
'Vermont',
'Rhode Island',
],
},
},
]}
data={[{id: 1, state: ""}, {id: 2, state: "Wyoming"}]}
data={[
{ id: 1, state: '' },
{ id: 2, state: 'Wyoming' },
]}
enableColumnFilterModes
initialState={{ showColumnFilters: true }}
/>
Expand Down
Loading

0 comments on commit 6b05a38

Please sign in to comment.