diff --git a/apps/material-react-table-docs/examples/editing-crud-cell/sandbox/src/TS.tsx b/apps/material-react-table-docs/examples/editing-crud-cell/sandbox/src/TS.tsx index c0705f5a0..94147a32d 100644 --- a/apps/material-react-table-docs/examples/editing-crud-cell/sandbox/src/TS.tsx +++ b/apps/material-react-table-docs/examples/editing-crud-cell/sandbox/src/TS.tsx @@ -297,13 +297,11 @@ function useUpdateUsers() { }, //client side optimistic update onMutate: (newUsers: User[]) => { - queryClient.setQueryData( - ['users'], - (prevUsers: any) => - prevUsers?.map((user: User) => { - const newUser = newUsers.find((u) => u.id === user.id); - return newUser ? newUser : user; - }), + queryClient.setQueryData(['users'], (prevUsers: any) => + prevUsers?.map((user: User) => { + const newUser = newUsers.find((u) => u.id === user.id); + return newUser ? newUser : user; + }), ); }, // onSettled: () => queryClient.invalidateQueries({ queryKey: ['users'] }), //refetch users after mutation, disabled for demo @@ -321,10 +319,8 @@ function useDeleteUser() { }, //client side optimistic update onMutate: (userId: string) => { - queryClient.setQueryData( - ['users'], - (prevUsers: any) => - prevUsers?.filter((user: User) => user.id !== userId), + queryClient.setQueryData(['users'], (prevUsers: any) => + prevUsers?.filter((user: User) => user.id !== userId), ); }, // onSettled: () => queryClient.invalidateQueries({ queryKey: ['users'] }), //refetch users after mutation, disabled for demo diff --git a/apps/material-react-table-docs/examples/editing-crud-modal/sandbox/src/TS.tsx b/apps/material-react-table-docs/examples/editing-crud-modal/sandbox/src/TS.tsx index 2855cf81f..93c9d5245 100644 --- a/apps/material-react-table-docs/examples/editing-crud-modal/sandbox/src/TS.tsx +++ b/apps/material-react-table-docs/examples/editing-crud-modal/sandbox/src/TS.tsx @@ -299,12 +299,10 @@ function useUpdateUser() { }, //client side optimistic update onMutate: (newUserInfo: User) => { - queryClient.setQueryData( - ['users'], - (prevUsers: any) => - prevUsers?.map((prevUser: User) => - prevUser.id === newUserInfo.id ? newUserInfo : prevUser, - ), + queryClient.setQueryData(['users'], (prevUsers: any) => + prevUsers?.map((prevUser: User) => + prevUser.id === newUserInfo.id ? newUserInfo : prevUser, + ), ); }, // onSettled: () => queryClient.invalidateQueries({ queryKey: ['users'] }), //refetch users after mutation, disabled for demo @@ -322,10 +320,8 @@ function useDeleteUser() { }, //client side optimistic update onMutate: (userId: string) => { - queryClient.setQueryData( - ['users'], - (prevUsers: any) => - prevUsers?.filter((user: User) => user.id !== userId), + queryClient.setQueryData(['users'], (prevUsers: any) => + prevUsers?.filter((user: User) => user.id !== userId), ); }, // onSettled: () => queryClient.invalidateQueries({ queryKey: ['users'] }), //refetch users after mutation, disabled for demo diff --git a/apps/material-react-table-docs/examples/editing-crud-row/sandbox/src/TS.tsx b/apps/material-react-table-docs/examples/editing-crud-row/sandbox/src/TS.tsx index 5b8fb31bd..7e62f1cdc 100644 --- a/apps/material-react-table-docs/examples/editing-crud-row/sandbox/src/TS.tsx +++ b/apps/material-react-table-docs/examples/editing-crud-row/sandbox/src/TS.tsx @@ -262,12 +262,10 @@ function useUpdateUser() { }, //client side optimistic update onMutate: (newUserInfo: User) => { - queryClient.setQueryData( - ['users'], - (prevUsers: any) => - prevUsers?.map((prevUser: User) => - prevUser.id === newUserInfo.id ? newUserInfo : prevUser, - ), + queryClient.setQueryData(['users'], (prevUsers: any) => + prevUsers?.map((prevUser: User) => + prevUser.id === newUserInfo.id ? newUserInfo : prevUser, + ), ); }, // onSettled: () => queryClient.invalidateQueries({ queryKey: ['users'] }), //refetch users after mutation, disabled for demo @@ -285,10 +283,8 @@ function useDeleteUser() { }, //client side optimistic update onMutate: (userId: string) => { - queryClient.setQueryData( - ['users'], - (prevUsers: any) => - prevUsers?.filter((user: User) => user.id !== userId), + queryClient.setQueryData(['users'], (prevUsers: any) => + prevUsers?.filter((user: User) => user.id !== userId), ); }, // onSettled: () => queryClient.invalidateQueries({ queryKey: ['users'] }), //refetch users after mutation, disabled for demo diff --git a/apps/material-react-table-docs/examples/editing-crud-table/sandbox/src/TS.tsx b/apps/material-react-table-docs/examples/editing-crud-table/sandbox/src/TS.tsx index b0873dadd..8aebf14e7 100644 --- a/apps/material-react-table-docs/examples/editing-crud-table/sandbox/src/TS.tsx +++ b/apps/material-react-table-docs/examples/editing-crud-table/sandbox/src/TS.tsx @@ -297,13 +297,11 @@ function useUpdateUsers() { }, //client side optimistic update onMutate: (newUsers: User[]) => { - queryClient.setQueryData( - ['users'], - (prevUsers: any) => - prevUsers?.map((user: User) => { - const newUser = newUsers.find((u) => u.id === user.id); - return newUser ? newUser : user; - }), + queryClient.setQueryData(['users'], (prevUsers: any) => + prevUsers?.map((user: User) => { + const newUser = newUsers.find((u) => u.id === user.id); + return newUser ? newUser : user; + }), ); }, // onSettled: () => queryClient.invalidateQueries({ queryKey: ['users'] }), //refetch users after mutation, disabled for demo @@ -321,10 +319,8 @@ function useDeleteUser() { }, //client side optimistic update onMutate: (userId: string) => { - queryClient.setQueryData( - ['users'], - (prevUsers: any) => - prevUsers?.filter((user: User) => user.id !== userId), + queryClient.setQueryData(['users'], (prevUsers: any) => + prevUsers?.filter((user: User) => user.id !== userId), ); }, // onSettled: () => queryClient.invalidateQueries({ queryKey: ['users'] }), //refetch users after mutation, disabled for demo diff --git a/apps/material-react-table-docs/pages/api/data.ts b/apps/material-react-table-docs/pages/api/data.ts index 0496269a9..b4a7f21f9 100644 --- a/apps/material-react-table-docs/pages/api/data.ts +++ b/apps/material-react-table-docs/pages/api/data.ts @@ -13,7 +13,7 @@ export default async function handler( if (process.env.NODE_ENV === 'development') { await new Promise((resolve) => setTimeout(resolve, 500)); } - + let dbData = getData(); const { start, size, filters, sorting, globalFilter } = req.query as Record< string, @@ -40,12 +40,11 @@ export default async function handler( if (globalFilter) { dbData = dbData.filter((row) => - Object.keys(row).some( - (columnId) => - row[columnId] - ?.toString() - ?.toLowerCase() - ?.includes?.((globalFilter as string).toLowerCase()), + Object.keys(row).some((columnId) => + row[columnId] + ?.toString() + ?.toLowerCase() + ?.includes?.((globalFilter as string).toLowerCase()), ), ); } diff --git a/apps/material-react-table-docs/pages/docs/api/mrt-components.mdx b/apps/material-react-table-docs/pages/docs/api/mrt-components.mdx index 1935b65c8..a2a28e9a8 100644 --- a/apps/material-react-table-docs/pages/docs/api/mrt-components.mdx +++ b/apps/material-react-table-docs/pages/docs/api/mrt-components.mdx @@ -35,7 +35,7 @@ In previous versions of `material-react-table`, you only had the option to use t ### \ -[View Source Code on GitHub](https://github.com/KevinVandy/material-react-table/blob/v2/packages/material-react-table/src/MaterialReactTable.tsx) +[View Source Code on GitHub](https://github.com/KevinVandy/material-react-table/blob/v2/packages/material-react-table/src/components/MaterialReactTable.tsx) For most use cases, you will probably just use the default `` component. @@ -69,7 +69,7 @@ Material React Table now exports all of its internal components. You can use the #### Table Components -[View Table Components Source Code on GitHub](https://github.com/KevinVandy/material-react-table/tree/v2/packages/material-react-table/src/table) +[View Table Components Source Code on GitHub](https://github.com/KevinVandy/material-react-table/tree/v2/packages/material-react-table/src/components/table) ##### \ @@ -95,7 +95,7 @@ Shows a loading spinner over the table above the `MRT_Table` component when the #### TableHead Components -[View TableHead Components Source Code on GitHub](https://github.com/KevinVandy/material-react-table/tree/v2/packages/material-react-table/src/head) +[View TableHead Components Source Code on GitHub](https://github.com/KevinVandy/material-react-table/tree/v2/packages/material-react-table/src/components/head) ##### \ @@ -135,7 +135,7 @@ The Filter Container that contains the filter input and filter actions #### TableBody Components -[View TableBody Components Source Code on GitHub](https://github.com/KevinVandy/material-react-table/tree/v2/packages/material-react-table/src/body) +[View TableBody Components Source Code on GitHub](https://github.com/KevinVandy/material-react-table/tree/v2/packages/material-react-table/src/components/body) ##### \ @@ -167,7 +167,7 @@ A button or buttons for pinning a row. #### TableFooter Components -[View TableFooter Components Source Code on GitHub](https://github.com/KevinVandy/material-react-table/tree/v2/packages/material-react-table/src/footer) +[View TableFooter Components Source Code on GitHub](https://github.com/KevinVandy/material-react-table/tree/v2/packages/material-react-table/src/components/footer) ##### \ @@ -183,7 +183,7 @@ The `` is a `` element that surrounds the cell value #### Input Components -[View Input Components Source Code on GitHub](https://github.com/KevinVandy/material-react-table/tree/v2/packages/material-react-table/src/inputs) +[View Input Components Source Code on GitHub](https://github.com/KevinVandy/material-react-table/tree/v2/packages/material-react-table/src/components/inputs) ##### \ diff --git a/apps/material-react-table-docs/pages/docs/api/mrt-hooks.mdx b/apps/material-react-table-docs/pages/docs/api/mrt-hooks.mdx index dc8976dc6..14eaa4e02 100644 --- a/apps/material-react-table-docs/pages/docs/api/mrt-hooks.mdx +++ b/apps/material-react-table-docs/pages/docs/api/mrt-hooks.mdx @@ -32,7 +32,7 @@ MRT has been adopting more and more of a hooks based approach for its internal l ### useMaterialReactTable -[Source Code](https://github.com/KevinVandy/material-react-table/blob/v2/packages/material-react-table/src/useMaterialReactTable.ts) +[Source Code](https://github.com/KevinVandy/material-react-table/blob/v2/packages/material-react-table/src/hooks/useMaterialReactTable.ts) > This is probably the only MRT hook you will need to use, unless you are writing a custom headless table. diff --git a/packages/material-react-table/rollup.config.mjs b/packages/material-react-table/rollup.config.mjs index d3e8944ff..0df8a3467 100644 --- a/packages/material-react-table/rollup.config.mjs +++ b/packages/material-react-table/rollup.config.mjs @@ -8,6 +8,7 @@ export default [ external: [ '@mui/icons-material', '@mui/material', + '@mui/x-date-pickers', '@tanstack/match-sorter-utils', '@tanstack/react-table', '@tanstack/react-virtual', diff --git a/packages/material-react-table/src/MaterialReactTable.tsx b/packages/material-react-table/src/components/MaterialReactTable.tsx similarity index 90% rename from packages/material-react-table/src/MaterialReactTable.tsx rename to packages/material-react-table/src/components/MaterialReactTable.tsx index b6c9fb390..078c9851c 100644 --- a/packages/material-react-table/src/MaterialReactTable.tsx +++ b/packages/material-react-table/src/components/MaterialReactTable.tsx @@ -1,11 +1,11 @@ -import { MRT_TablePaper } from './table/MRT_TablePaper'; +import { useMaterialReactTable } from '../hooks/useMaterialReactTable'; import { type MRT_RowData, type MRT_TableInstance, type MRT_TableOptions, type Xor, -} from './types'; -import { useMaterialReactTable } from './useMaterialReactTable'; +} from '../types'; +import { MRT_TablePaper } from './table/MRT_TablePaper'; type TableInstanceProp = { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/body/MRT_TableBody.tsx b/packages/material-react-table/src/components/body/MRT_TableBody.tsx similarity index 97% rename from packages/material-react-table/src/body/MRT_TableBody.tsx rename to packages/material-react-table/src/components/body/MRT_TableBody.tsx index e1092227c..4d827d03f 100644 --- a/packages/material-react-table/src/body/MRT_TableBody.tsx +++ b/packages/material-react-table/src/components/body/MRT_TableBody.tsx @@ -3,15 +3,15 @@ import { type VirtualItem } from '@tanstack/react-virtual'; import TableBody, { type TableBodyProps } from '@mui/material/TableBody'; import Typography from '@mui/material/Typography'; import { MRT_TableBodyRow, Memo_MRT_TableBodyRow } from './MRT_TableBodyRow'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { useMRT_RowVirtualizer } from '../hooks/useMRT_RowVirtualizer'; -import { useMRT_Rows } from '../hooks/useMRT_Rows'; +import { useMRT_RowVirtualizer } from '../../hooks/useMRT_RowVirtualizer'; +import { useMRT_Rows } from '../../hooks/useMRT_Rows'; import { type MRT_ColumnVirtualizer, type MRT_Row, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends TableBodyProps { columnVirtualizer?: MRT_ColumnVirtualizer; diff --git a/packages/material-react-table/src/body/MRT_TableBodyCell.tsx b/packages/material-react-table/src/components/body/MRT_TableBodyCell.tsx similarity index 97% rename from packages/material-react-table/src/body/MRT_TableBodyCell.tsx rename to packages/material-react-table/src/components/body/MRT_TableBodyCell.tsx index 3ec24f9c7..0af5023c7 100644 --- a/packages/material-react-table/src/body/MRT_TableBodyCell.tsx +++ b/packages/material-react-table/src/components/body/MRT_TableBodyCell.tsx @@ -11,19 +11,16 @@ import Skeleton from '@mui/material/Skeleton'; import TableCell, { type TableCellProps } from '@mui/material/TableCell'; import { useTheme } from '@mui/material/styles'; import { MRT_TableBodyCellValue } from './MRT_TableBodyCellValue'; -import { MRT_CopyButton } from '../buttons/MRT_CopyButton'; -import { - getIsFirstColumn, - getIsLastColumn, - parseFromValuesOrFunc, -} from '../column.utils'; -import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField'; -import { getCommonMRTCellStyles, getMRTTheme } from '../style.utils'; import { type MRT_Cell, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getIsFirstColumn, getIsLastColumn } from '../../utils/column.utils'; +import { getCommonMRTCellStyles, getMRTTheme } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; +import { MRT_CopyButton } from '../buttons/MRT_CopyButton'; +import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField'; interface Props extends TableCellProps { cell: MRT_Cell; diff --git a/packages/material-react-table/src/body/MRT_TableBodyCellValue.tsx b/packages/material-react-table/src/components/body/MRT_TableBodyCellValue.tsx similarity index 97% rename from packages/material-react-table/src/body/MRT_TableBodyCellValue.tsx rename to packages/material-react-table/src/components/body/MRT_TableBodyCellValue.tsx index 7e8f7bbdf..b96797d8f 100644 --- a/packages/material-react-table/src/body/MRT_TableBodyCellValue.tsx +++ b/packages/material-react-table/src/components/body/MRT_TableBodyCellValue.tsx @@ -1,11 +1,11 @@ import { type ReactNode, type RefObject } from 'react'; import Box from '@mui/material/Box'; -import { getMRTTheme } from '../style.utils'; import { type MRT_Cell, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getMRTTheme } from '../../utils/style.utils'; import highlightWords from 'highlight-words'; const allowedTypes = ['string', 'number']; diff --git a/packages/material-react-table/src/body/MRT_TableBodyRow.tsx b/packages/material-react-table/src/components/body/MRT_TableBodyRow.tsx similarity index 98% rename from packages/material-react-table/src/body/MRT_TableBodyRow.tsx rename to packages/material-react-table/src/components/body/MRT_TableBodyRow.tsx index 26c6f1887..e5d2d1581 100644 --- a/packages/material-react-table/src/body/MRT_TableBodyRow.tsx +++ b/packages/material-react-table/src/components/body/MRT_TableBodyRow.tsx @@ -10,8 +10,6 @@ import { } from '@mui/material/styles'; import { MRT_TableBodyCell, Memo_MRT_TableBodyCell } from './MRT_TableBodyCell'; import { MRT_TableDetailPanel } from './MRT_TableDetailPanel'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getMRTTheme } from '../style.utils'; import { type MRT_Cell, type MRT_ColumnVirtualizer, @@ -19,7 +17,9 @@ import { type MRT_RowData, type MRT_RowVirtualizer, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getMRTTheme } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props { columnVirtualizer?: MRT_ColumnVirtualizer; diff --git a/packages/material-react-table/src/body/MRT_TableBodyRowGrabHandle.tsx b/packages/material-react-table/src/components/body/MRT_TableBodyRowGrabHandle.tsx similarity index 94% rename from packages/material-react-table/src/body/MRT_TableBodyRowGrabHandle.tsx rename to packages/material-react-table/src/components/body/MRT_TableBodyRowGrabHandle.tsx index 4e346100a..e28fce413 100644 --- a/packages/material-react-table/src/body/MRT_TableBodyRowGrabHandle.tsx +++ b/packages/material-react-table/src/components/body/MRT_TableBodyRowGrabHandle.tsx @@ -1,12 +1,12 @@ import { type DragEvent, type RefObject } from 'react'; import { type IconButtonProps } from '@mui/material/IconButton'; -import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton'; -import { parseFromValuesOrFunc } from '../column.utils'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; +import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton'; interface Props extends IconButtonProps { row: MRT_Row; diff --git a/packages/material-react-table/src/body/MRT_TableBodyRowPinButton.tsx b/packages/material-react-table/src/components/body/MRT_TableBodyRowPinButton.tsx similarity index 94% rename from packages/material-react-table/src/body/MRT_TableBodyRowPinButton.tsx rename to packages/material-react-table/src/components/body/MRT_TableBodyRowPinButton.tsx index 7d3ff11c9..ca5d4a3e4 100644 --- a/packages/material-react-table/src/body/MRT_TableBodyRowPinButton.tsx +++ b/packages/material-react-table/src/components/body/MRT_TableBodyRowPinButton.tsx @@ -1,12 +1,12 @@ import Box from '@mui/material/Box'; import { type IconButtonProps } from '@mui/material/IconButton'; -import { MRT_RowPinButton } from '../buttons/MRT_RowPinButton'; -import { parseFromValuesOrFunc } from '../column.utils'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; +import { MRT_RowPinButton } from '../buttons/MRT_RowPinButton'; interface Props extends IconButtonProps { row: MRT_Row; diff --git a/packages/material-react-table/src/body/MRT_TableDetailPanel.tsx b/packages/material-react-table/src/components/body/MRT_TableDetailPanel.tsx similarity index 95% rename from packages/material-react-table/src/body/MRT_TableDetailPanel.tsx rename to packages/material-react-table/src/components/body/MRT_TableDetailPanel.tsx index 197cbb4fe..21c23175b 100644 --- a/packages/material-react-table/src/body/MRT_TableDetailPanel.tsx +++ b/packages/material-react-table/src/components/body/MRT_TableDetailPanel.tsx @@ -2,15 +2,15 @@ import { type RefObject } from 'react'; import Collapse from '@mui/material/Collapse'; import TableCell, { type TableCellProps } from '@mui/material/TableCell'; import TableRow from '@mui/material/TableRow'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getMRTTheme } from '../style.utils'; import { type MRT_Row, type MRT_RowData, type MRT_RowVirtualizer, type MRT_TableInstance, type MRT_VirtualItem, -} from '../types'; +} from '../../types'; +import { getMRTTheme } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends TableCellProps { parentRowRef: RefObject; diff --git a/packages/material-react-table/src/buttons/MRT_ColumnPinningButtons.tsx b/packages/material-react-table/src/components/buttons/MRT_ColumnPinningButtons.tsx similarity index 95% rename from packages/material-react-table/src/buttons/MRT_ColumnPinningButtons.tsx rename to packages/material-react-table/src/components/buttons/MRT_ColumnPinningButtons.tsx index cc72f72e6..68eaddb14 100644 --- a/packages/material-react-table/src/buttons/MRT_ColumnPinningButtons.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_ColumnPinningButtons.tsx @@ -1,12 +1,12 @@ import Box, { type BoxProps } from '@mui/material/Box'; import IconButton from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { parseFromValuesOrFunc } from '../column.utils'; import { type MRT_Column, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends BoxProps { column: MRT_Column; diff --git a/packages/material-react-table/src/buttons/MRT_CopyButton.tsx b/packages/material-react-table/src/components/buttons/MRT_CopyButton.tsx similarity index 93% rename from packages/material-react-table/src/buttons/MRT_CopyButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_CopyButton.tsx index 954fcd0c5..b4ebf4802 100644 --- a/packages/material-react-table/src/buttons/MRT_CopyButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_CopyButton.tsx @@ -1,13 +1,13 @@ import { type MouseEvent, useState } from 'react'; import Button, { type ButtonProps } from '@mui/material/Button'; import Tooltip from '@mui/material/Tooltip'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getCommonTooltipProps } from '../style.utils'; import { type MRT_Cell, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getCommonTooltipProps } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends ButtonProps { cell: MRT_Cell; diff --git a/packages/material-react-table/src/buttons/MRT_EditActionButtons.tsx b/packages/material-react-table/src/components/buttons/MRT_EditActionButtons.tsx similarity index 97% rename from packages/material-react-table/src/buttons/MRT_EditActionButtons.tsx rename to packages/material-react-table/src/components/buttons/MRT_EditActionButtons.tsx index e4ebf61a1..025283316 100644 --- a/packages/material-react-table/src/buttons/MRT_EditActionButtons.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_EditActionButtons.tsx @@ -3,12 +3,12 @@ import Button from '@mui/material/Button'; import CircularProgress from '@mui/material/CircularProgress'; import IconButton from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { parseFromValuesOrFunc } from '../column.utils'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends BoxProps { row: MRT_Row; diff --git a/packages/material-react-table/src/buttons/MRT_ExpandAllButton.tsx b/packages/material-react-table/src/components/buttons/MRT_ExpandAllButton.tsx similarity index 91% rename from packages/material-react-table/src/buttons/MRT_ExpandAllButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_ExpandAllButton.tsx index b604a6621..b0d0228d1 100644 --- a/packages/material-react-table/src/buttons/MRT_ExpandAllButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_ExpandAllButton.tsx @@ -1,8 +1,8 @@ import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getCommonTooltipProps } from '../style.utils'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { getCommonTooltipProps } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends IconButtonProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/buttons/MRT_ExpandButton.tsx b/packages/material-react-table/src/components/buttons/MRT_ExpandButton.tsx similarity index 94% rename from packages/material-react-table/src/buttons/MRT_ExpandButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_ExpandButton.tsx index c242928fc..766b49fb6 100644 --- a/packages/material-react-table/src/buttons/MRT_ExpandButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_ExpandButton.tsx @@ -2,13 +2,13 @@ import { type MouseEvent } from 'react'; import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; import { useTheme } from '@mui/material/styles'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getCommonTooltipProps } from '../style.utils'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getCommonTooltipProps } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends IconButtonProps { row: MRT_Row; diff --git a/packages/material-react-table/src/buttons/MRT_GrabHandleButton.tsx b/packages/material-react-table/src/components/buttons/MRT_GrabHandleButton.tsx similarity index 90% rename from packages/material-react-table/src/buttons/MRT_GrabHandleButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_GrabHandleButton.tsx index d173ce614..c49cbdfcc 100644 --- a/packages/material-react-table/src/buttons/MRT_GrabHandleButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_GrabHandleButton.tsx @@ -1,9 +1,9 @@ import { type DragEventHandler } from 'react'; import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getCommonTooltipProps } from '../style.utils'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { getCommonTooltipProps } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends IconButtonProps { iconButtonProps?: IconButtonProps; diff --git a/packages/material-react-table/src/buttons/MRT_RowPinButton.tsx b/packages/material-react-table/src/components/buttons/MRT_RowPinButton.tsx similarity index 93% rename from packages/material-react-table/src/buttons/MRT_RowPinButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_RowPinButton.tsx index fa78730b4..c3ad27175 100644 --- a/packages/material-react-table/src/buttons/MRT_RowPinButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_RowPinButton.tsx @@ -2,13 +2,13 @@ import { type MouseEvent, useState } from 'react'; import { type RowPinningPosition } from '@tanstack/react-table'; import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getCommonTooltipProps } from '../style.utils'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getCommonTooltipProps } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends IconButtonProps { pinningPosition: RowPinningPosition; diff --git a/packages/material-react-table/src/buttons/MRT_ShowHideColumnsButton.tsx b/packages/material-react-table/src/components/buttons/MRT_ShowHideColumnsButton.tsx similarity index 94% rename from packages/material-react-table/src/buttons/MRT_ShowHideColumnsButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_ShowHideColumnsButton.tsx index 5b7945983..dea039ac8 100644 --- a/packages/material-react-table/src/buttons/MRT_ShowHideColumnsButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_ShowHideColumnsButton.tsx @@ -1,8 +1,8 @@ import { type MouseEvent, useState } from 'react'; import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; interface Props extends IconButtonProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/buttons/MRT_ToggleDensePaddingButton.tsx b/packages/material-react-table/src/components/buttons/MRT_ToggleDensePaddingButton.tsx similarity index 94% rename from packages/material-react-table/src/buttons/MRT_ToggleDensePaddingButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_ToggleDensePaddingButton.tsx index a1edad2c3..4f4daf2b8 100644 --- a/packages/material-react-table/src/buttons/MRT_ToggleDensePaddingButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_ToggleDensePaddingButton.tsx @@ -1,6 +1,6 @@ import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; interface Props extends IconButtonProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/buttons/MRT_ToggleFiltersButton.tsx b/packages/material-react-table/src/components/buttons/MRT_ToggleFiltersButton.tsx similarity index 93% rename from packages/material-react-table/src/buttons/MRT_ToggleFiltersButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_ToggleFiltersButton.tsx index eb10c5058..f9b3b8ad5 100644 --- a/packages/material-react-table/src/buttons/MRT_ToggleFiltersButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_ToggleFiltersButton.tsx @@ -1,6 +1,6 @@ import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; interface Props extends IconButtonProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/buttons/MRT_ToggleFullScreenButton.tsx b/packages/material-react-table/src/components/buttons/MRT_ToggleFullScreenButton.tsx similarity index 94% rename from packages/material-react-table/src/buttons/MRT_ToggleFullScreenButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_ToggleFullScreenButton.tsx index b061458aa..dafe39a1f 100644 --- a/packages/material-react-table/src/buttons/MRT_ToggleFullScreenButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_ToggleFullScreenButton.tsx @@ -1,7 +1,7 @@ import { useState } from 'react'; import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; interface Props extends IconButtonProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/buttons/MRT_ToggleGlobalFilterButton.tsx b/packages/material-react-table/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx similarity index 93% rename from packages/material-react-table/src/buttons/MRT_ToggleGlobalFilterButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx index 1c0e5bad6..560b2f0be 100644 --- a/packages/material-react-table/src/buttons/MRT_ToggleGlobalFilterButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx @@ -1,6 +1,6 @@ import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; interface Props extends IconButtonProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/buttons/MRT_ToggleRowActionMenuButton.tsx b/packages/material-react-table/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx similarity index 95% rename from packages/material-react-table/src/buttons/MRT_ToggleRowActionMenuButton.tsx rename to packages/material-react-table/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx index f183049ff..f8e71db41 100644 --- a/packages/material-react-table/src/buttons/MRT_ToggleRowActionMenuButton.tsx +++ b/packages/material-react-table/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx @@ -2,15 +2,15 @@ import { type MouseEvent, useState } from 'react'; import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; import { MRT_EditActionButtons } from './MRT_EditActionButtons'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu'; -import { getCommonTooltipProps } from '../style.utils'; import { type MRT_Cell, type MRT_Row, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getCommonTooltipProps } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; +import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu'; const commonIconButtonStyles = { '&:hover': { diff --git a/packages/material-react-table/src/footer/MRT_TableFooter.tsx b/packages/material-react-table/src/components/footer/MRT_TableFooter.tsx similarity index 96% rename from packages/material-react-table/src/footer/MRT_TableFooter.tsx rename to packages/material-react-table/src/components/footer/MRT_TableFooter.tsx index 414376dae..ed38172c7 100644 --- a/packages/material-react-table/src/footer/MRT_TableFooter.tsx +++ b/packages/material-react-table/src/components/footer/MRT_TableFooter.tsx @@ -1,11 +1,11 @@ import TableFooter, { type TableFooterProps } from '@mui/material/TableFooter'; import { MRT_TableFooterRow } from './MRT_TableFooterRow'; -import { parseFromValuesOrFunc } from '../column.utils'; import { type MRT_ColumnVirtualizer, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends TableFooterProps { columnVirtualizer?: MRT_ColumnVirtualizer; diff --git a/packages/material-react-table/src/footer/MRT_TableFooterCell.tsx b/packages/material-react-table/src/components/footer/MRT_TableFooterCell.tsx similarity index 93% rename from packages/material-react-table/src/footer/MRT_TableFooterCell.tsx rename to packages/material-react-table/src/components/footer/MRT_TableFooterCell.tsx index 22f2ff1c8..b4d0392f4 100644 --- a/packages/material-react-table/src/footer/MRT_TableFooterCell.tsx +++ b/packages/material-react-table/src/components/footer/MRT_TableFooterCell.tsx @@ -1,12 +1,12 @@ import TableCell, { type TableCellProps } from '@mui/material/TableCell'; import { useTheme } from '@mui/material/styles'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getCommonMRTCellStyles } from '../style.utils'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getCommonMRTCellStyles } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends TableCellProps { footer: MRT_Header; diff --git a/packages/material-react-table/src/footer/MRT_TableFooterRow.tsx b/packages/material-react-table/src/components/footer/MRT_TableFooterRow.tsx similarity index 94% rename from packages/material-react-table/src/footer/MRT_TableFooterRow.tsx rename to packages/material-react-table/src/components/footer/MRT_TableFooterRow.tsx index 16d2db311..2427033af 100644 --- a/packages/material-react-table/src/footer/MRT_TableFooterRow.tsx +++ b/packages/material-react-table/src/components/footer/MRT_TableFooterRow.tsx @@ -1,14 +1,14 @@ import TableRow, { type TableRowProps } from '@mui/material/TableRow'; import { MRT_TableFooterCell } from './MRT_TableFooterCell'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getMRTTheme } from '../style.utils'; import { type MRT_ColumnVirtualizer, type MRT_Header, type MRT_HeaderGroup, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; +import { getMRTTheme } from '../../utils/style.utils'; interface Props extends TableRowProps { columnVirtualizer?: MRT_ColumnVirtualizer; diff --git a/packages/material-react-table/src/head/MRT_TableHead.tsx b/packages/material-react-table/src/components/head/MRT_TableHead.tsx similarity index 96% rename from packages/material-react-table/src/head/MRT_TableHead.tsx rename to packages/material-react-table/src/components/head/MRT_TableHead.tsx index ee20a17c3..31fb4e19d 100644 --- a/packages/material-react-table/src/head/MRT_TableHead.tsx +++ b/packages/material-react-table/src/components/head/MRT_TableHead.tsx @@ -1,12 +1,12 @@ import TableHead, { type TableHeadProps } from '@mui/material/TableHead'; import { MRT_TableHeadRow } from './MRT_TableHeadRow'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { MRT_ToolbarAlertBanner } from '../toolbar/MRT_ToolbarAlertBanner'; import { type MRT_ColumnVirtualizer, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; +import { MRT_ToolbarAlertBanner } from '../toolbar/MRT_ToolbarAlertBanner'; interface Props extends TableHeadProps { columnVirtualizer?: MRT_ColumnVirtualizer; diff --git a/packages/material-react-table/src/head/MRT_TableHeadCell.tsx b/packages/material-react-table/src/components/head/MRT_TableHeadCell.tsx similarity index 98% rename from packages/material-react-table/src/head/MRT_TableHeadCell.tsx rename to packages/material-react-table/src/components/head/MRT_TableHeadCell.tsx index 1966598ce..c32610cb7 100644 --- a/packages/material-react-table/src/head/MRT_TableHeadCell.tsx +++ b/packages/material-react-table/src/components/head/MRT_TableHeadCell.tsx @@ -9,13 +9,13 @@ import { MRT_TableHeadCellFilterLabel } from './MRT_TableHeadCellFilterLabel'; import { MRT_TableHeadCellGrabHandle } from './MRT_TableHeadCellGrabHandle'; import { MRT_TableHeadCellResizeHandle } from './MRT_TableHeadCellResizeHandle'; import { MRT_TableHeadCellSortLabel } from './MRT_TableHeadCellSortLabel'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getCommonMRTCellStyles, getMRTTheme } from '../style.utils'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getCommonMRTCellStyles, getMRTTheme } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends TableCellProps { header: MRT_Header; diff --git a/packages/material-react-table/src/head/MRT_TableHeadCellColumnActionsButton.tsx b/packages/material-react-table/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx similarity index 94% rename from packages/material-react-table/src/head/MRT_TableHeadCellColumnActionsButton.tsx rename to packages/material-react-table/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx index e6eaeb16a..8e7d6650c 100644 --- a/packages/material-react-table/src/head/MRT_TableHeadCellColumnActionsButton.tsx +++ b/packages/material-react-table/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx @@ -1,14 +1,14 @@ import { type MouseEvent, useState } from 'react'; import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu'; -import { getCommonTooltipProps } from '../style.utils'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getCommonTooltipProps } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; +import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu'; interface Props extends IconButtonProps { header: MRT_Header; diff --git a/packages/material-react-table/src/head/MRT_TableHeadCellFilterContainer.tsx b/packages/material-react-table/src/components/head/MRT_TableHeadCellFilterContainer.tsx similarity index 98% rename from packages/material-react-table/src/head/MRT_TableHeadCellFilterContainer.tsx rename to packages/material-react-table/src/components/head/MRT_TableHeadCellFilterContainer.tsx index 59937e418..d5e8d01f1 100644 --- a/packages/material-react-table/src/head/MRT_TableHeadCellFilterContainer.tsx +++ b/packages/material-react-table/src/components/head/MRT_TableHeadCellFilterContainer.tsx @@ -1,13 +1,13 @@ import Collapse, { type CollapseProps } from '@mui/material/Collapse'; -import { MRT_FilterCheckbox } from '../inputs/MRT_FilterCheckbox'; -import { MRT_FilterRangeFields } from '../inputs/MRT_FilterRangeFields'; -import { MRT_FilterRangeSlider } from '../inputs/MRT_FilterRangeSlider'; -import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { MRT_FilterCheckbox } from '../inputs/MRT_FilterCheckbox'; +import { MRT_FilterRangeFields } from '../inputs/MRT_FilterRangeFields'; +import { MRT_FilterRangeSlider } from '../inputs/MRT_FilterRangeSlider'; +import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField'; interface Props extends CollapseProps { header: MRT_Header; diff --git a/packages/material-react-table/src/head/MRT_TableHeadCellFilterLabel.tsx b/packages/material-react-table/src/components/head/MRT_TableHeadCellFilterLabel.tsx similarity index 98% rename from packages/material-react-table/src/head/MRT_TableHeadCellFilterLabel.tsx rename to packages/material-react-table/src/components/head/MRT_TableHeadCellFilterLabel.tsx index 316dbc6dc..ee6ad097f 100644 --- a/packages/material-react-table/src/head/MRT_TableHeadCellFilterLabel.tsx +++ b/packages/material-react-table/src/components/head/MRT_TableHeadCellFilterLabel.tsx @@ -5,12 +5,12 @@ import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Popover from '@mui/material/Popover'; import Tooltip from '@mui/material/Tooltip'; import { MRT_TableHeadCellFilterContainer } from './MRT_TableHeadCellFilterContainer'; -import { parseFromValuesOrFunc } from '../column.utils'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends IconButtonProps { header: MRT_Header; diff --git a/packages/material-react-table/src/head/MRT_TableHeadCellGrabHandle.tsx b/packages/material-react-table/src/components/head/MRT_TableHeadCellGrabHandle.tsx similarity index 93% rename from packages/material-react-table/src/head/MRT_TableHeadCellGrabHandle.tsx rename to packages/material-react-table/src/components/head/MRT_TableHeadCellGrabHandle.tsx index 0e6ca93e1..06189aa64 100644 --- a/packages/material-react-table/src/head/MRT_TableHeadCellGrabHandle.tsx +++ b/packages/material-react-table/src/components/head/MRT_TableHeadCellGrabHandle.tsx @@ -1,12 +1,13 @@ import { type DragEvent, type RefObject } from 'react'; import { type IconButtonProps } from '@mui/material/IconButton'; -import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton'; -import { parseFromValuesOrFunc, reorderColumn } from '../column.utils'; import { type MRT_Column, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { reorderColumn } from '../../utils/column.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; +import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton'; interface Props extends IconButtonProps { column: MRT_Column; diff --git a/packages/material-react-table/src/head/MRT_TableHeadCellResizeHandle.tsx b/packages/material-react-table/src/components/head/MRT_TableHeadCellResizeHandle.tsx similarity index 96% rename from packages/material-react-table/src/head/MRT_TableHeadCellResizeHandle.tsx rename to packages/material-react-table/src/components/head/MRT_TableHeadCellResizeHandle.tsx index 58295b9b6..a9a8cedca 100644 --- a/packages/material-react-table/src/head/MRT_TableHeadCellResizeHandle.tsx +++ b/packages/material-react-table/src/components/head/MRT_TableHeadCellResizeHandle.tsx @@ -1,11 +1,11 @@ import Box from '@mui/material/Box'; import Divider, { type DividerProps } from '@mui/material/Divider'; -import { parseFromValuesOrFunc } from '../column.utils'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends DividerProps { header: MRT_Header; diff --git a/packages/material-react-table/src/head/MRT_TableHeadCellSortLabel.tsx b/packages/material-react-table/src/components/head/MRT_TableHeadCellSortLabel.tsx similarity index 97% rename from packages/material-react-table/src/head/MRT_TableHeadCellSortLabel.tsx rename to packages/material-react-table/src/components/head/MRT_TableHeadCellSortLabel.tsx index b91d3dd9b..843ad84c8 100644 --- a/packages/material-react-table/src/head/MRT_TableHeadCellSortLabel.tsx +++ b/packages/material-react-table/src/components/head/MRT_TableHeadCellSortLabel.tsx @@ -3,12 +3,12 @@ import TableSortLabel, { type TableSortLabelProps, } from '@mui/material/TableSortLabel'; import Tooltip from '@mui/material/Tooltip'; -import { parseFromValuesOrFunc } from '../column.utils'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends TableSortLabelProps { header: MRT_Header; diff --git a/packages/material-react-table/src/head/MRT_TableHeadRow.tsx b/packages/material-react-table/src/components/head/MRT_TableHeadRow.tsx similarity index 93% rename from packages/material-react-table/src/head/MRT_TableHeadRow.tsx rename to packages/material-react-table/src/components/head/MRT_TableHeadRow.tsx index bc931570b..2f207a30b 100644 --- a/packages/material-react-table/src/head/MRT_TableHeadRow.tsx +++ b/packages/material-react-table/src/components/head/MRT_TableHeadRow.tsx @@ -1,15 +1,15 @@ import TableRow, { type TableRowProps } from '@mui/material/TableRow'; import { alpha } from '@mui/material/styles'; import { MRT_TableHeadCell } from './MRT_TableHeadCell'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getMRTTheme } from '../style.utils'; import { type MRT_ColumnVirtualizer, type MRT_Header, type MRT_HeaderGroup, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getMRTTheme } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends TableRowProps { columnVirtualizer?: MRT_ColumnVirtualizer; diff --git a/packages/material-react-table/src/inputs/MRT_EditCellTextField.tsx b/packages/material-react-table/src/components/inputs/MRT_EditCellTextField.tsx similarity index 97% rename from packages/material-react-table/src/inputs/MRT_EditCellTextField.tsx rename to packages/material-react-table/src/components/inputs/MRT_EditCellTextField.tsx index d702dd666..0b3f696ac 100644 --- a/packages/material-react-table/src/inputs/MRT_EditCellTextField.tsx +++ b/packages/material-react-table/src/components/inputs/MRT_EditCellTextField.tsx @@ -7,12 +7,12 @@ import { import MenuItem from '@mui/material/MenuItem'; import TextField from '@mui/material/TextField'; import { type TextFieldProps } from '@mui/material/TextField'; -import { getValueAndLabel, parseFromValuesOrFunc } from '../column.utils'; import { type MRT_Cell, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getValueAndLabel, parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends TextFieldProps<'standard'> { cell: MRT_Cell; diff --git a/packages/material-react-table/src/inputs/MRT_FilterCheckbox.tsx b/packages/material-react-table/src/components/inputs/MRT_FilterCheckbox.tsx similarity index 94% rename from packages/material-react-table/src/inputs/MRT_FilterCheckbox.tsx rename to packages/material-react-table/src/components/inputs/MRT_FilterCheckbox.tsx index be0e52f7c..7bf88cd06 100644 --- a/packages/material-react-table/src/inputs/MRT_FilterCheckbox.tsx +++ b/packages/material-react-table/src/components/inputs/MRT_FilterCheckbox.tsx @@ -1,13 +1,13 @@ import Checkbox, { type CheckboxProps } from '@mui/material/Checkbox'; import FormControlLabel from '@mui/material/FormControlLabel'; import Tooltip from '@mui/material/Tooltip'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getCommonTooltipProps } from '../style.utils'; import { type MRT_Column, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getCommonTooltipProps } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends CheckboxProps { column: MRT_Column; diff --git a/packages/material-react-table/src/inputs/MRT_FilterRangeFields.tsx b/packages/material-react-table/src/components/inputs/MRT_FilterRangeFields.tsx similarity index 91% rename from packages/material-react-table/src/inputs/MRT_FilterRangeFields.tsx rename to packages/material-react-table/src/components/inputs/MRT_FilterRangeFields.tsx index b667de904..0060f0dca 100644 --- a/packages/material-react-table/src/inputs/MRT_FilterRangeFields.tsx +++ b/packages/material-react-table/src/components/inputs/MRT_FilterRangeFields.tsx @@ -1,11 +1,11 @@ import Box, { type BoxProps } from '@mui/material/Box'; import { MRT_FilterTextField } from './MRT_FilterTextField'; -import { parseFromValuesOrFunc } from '../column.utils'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends BoxProps { header: MRT_Header; diff --git a/packages/material-react-table/src/inputs/MRT_FilterRangeSlider.tsx b/packages/material-react-table/src/components/inputs/MRT_FilterRangeSlider.tsx similarity index 97% rename from packages/material-react-table/src/inputs/MRT_FilterRangeSlider.tsx rename to packages/material-react-table/src/components/inputs/MRT_FilterRangeSlider.tsx index b106bc9c8..49cc40dd8 100644 --- a/packages/material-react-table/src/inputs/MRT_FilterRangeSlider.tsx +++ b/packages/material-react-table/src/components/inputs/MRT_FilterRangeSlider.tsx @@ -2,12 +2,12 @@ import { useEffect, useRef, useState } from 'react'; import FormHelperText from '@mui/material/FormHelperText'; import Slider, { type SliderProps } from '@mui/material/Slider'; import Stack from '@mui/material/Stack'; -import { parseFromValuesOrFunc } from '../column.utils'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends SliderProps { header: MRT_Header; diff --git a/packages/material-react-table/src/inputs/MRT_FilterTextField.tsx b/packages/material-react-table/src/components/inputs/MRT_FilterTextField.tsx similarity index 99% rename from packages/material-react-table/src/inputs/MRT_FilterTextField.tsx rename to packages/material-react-table/src/components/inputs/MRT_FilterTextField.tsx index 416609c52..a773cf75b 100644 --- a/packages/material-react-table/src/inputs/MRT_FilterTextField.tsx +++ b/packages/material-react-table/src/components/inputs/MRT_FilterTextField.tsx @@ -29,13 +29,13 @@ import { TimePicker, type TimePickerProps, } from '@mui/x-date-pickers/TimePicker'; -import { getValueAndLabel, parseFromValuesOrFunc } from '../column.utils'; -import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getValueAndLabel, parseFromValuesOrFunc } from '../../utils/utils'; +import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu'; interface Props extends TextFieldProps<'standard'> { header: MRT_Header; diff --git a/packages/material-react-table/src/inputs/MRT_GlobalFilterTextField.tsx b/packages/material-react-table/src/components/inputs/MRT_GlobalFilterTextField.tsx similarity index 97% rename from packages/material-react-table/src/inputs/MRT_GlobalFilterTextField.tsx rename to packages/material-react-table/src/components/inputs/MRT_GlobalFilterTextField.tsx index 5a913d7b2..215677f11 100644 --- a/packages/material-react-table/src/inputs/MRT_GlobalFilterTextField.tsx +++ b/packages/material-react-table/src/components/inputs/MRT_GlobalFilterTextField.tsx @@ -12,9 +12,9 @@ import InputAdornment from '@mui/material/InputAdornment'; import TextField, { type TextFieldProps } from '@mui/material/TextField'; import Tooltip from '@mui/material/Tooltip'; import { debounce } from '@mui/material/utils'; -import { parseFromValuesOrFunc } from '../column.utils'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; interface Props extends TextFieldProps<'standard'> { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/inputs/MRT_SelectCheckbox.tsx b/packages/material-react-table/src/components/inputs/MRT_SelectCheckbox.tsx similarity index 96% rename from packages/material-react-table/src/inputs/MRT_SelectCheckbox.tsx rename to packages/material-react-table/src/components/inputs/MRT_SelectCheckbox.tsx index 8e18ffb63..f91f399c0 100644 --- a/packages/material-react-table/src/inputs/MRT_SelectCheckbox.tsx +++ b/packages/material-react-table/src/components/inputs/MRT_SelectCheckbox.tsx @@ -3,13 +3,13 @@ import Checkbox, { type CheckboxProps } from '@mui/material/Checkbox'; import Radio, { type RadioProps } from '@mui/material/Radio'; import Tooltip from '@mui/material/Tooltip'; import { type Theme } from '@mui/material/styles'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getCommonTooltipProps } from '../style.utils'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getCommonTooltipProps } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends CheckboxProps { row?: MRT_Row; diff --git a/packages/material-react-table/src/menus/MRT_ColumnActionMenu.tsx b/packages/material-react-table/src/components/menus/MRT_ColumnActionMenu.tsx similarity index 98% rename from packages/material-react-table/src/menus/MRT_ColumnActionMenu.tsx rename to packages/material-react-table/src/components/menus/MRT_ColumnActionMenu.tsx index 59d3853f0..9e9a47f42 100644 --- a/packages/material-react-table/src/menus/MRT_ColumnActionMenu.tsx +++ b/packages/material-react-table/src/components/menus/MRT_ColumnActionMenu.tsx @@ -7,12 +7,12 @@ import Menu, { type MenuProps } from '@mui/material/Menu'; import MenuItem from '@mui/material/MenuItem'; import { useTheme } from '@mui/material/styles'; import { MRT_FilterOptionMenu } from './MRT_FilterOptionMenu'; -import { getMRTTheme } from '../style.utils'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getMRTTheme } from '../../utils/style.utils'; export const commonMenuItemStyles = { alignItems: 'center', @@ -403,12 +403,12 @@ export const MRT_ColumnActionMenu = ({ return ( setAnchorEl(null)} open={!!anchorEl} diff --git a/packages/material-react-table/src/menus/MRT_FilterOptionMenu.tsx b/packages/material-react-table/src/components/menus/MRT_FilterOptionMenu.tsx similarity index 99% rename from packages/material-react-table/src/menus/MRT_FilterOptionMenu.tsx rename to packages/material-react-table/src/components/menus/MRT_FilterOptionMenu.tsx index bf3ed4eb6..0fea235c9 100644 --- a/packages/material-react-table/src/menus/MRT_FilterOptionMenu.tsx +++ b/packages/material-react-table/src/components/menus/MRT_FilterOptionMenu.tsx @@ -3,7 +3,6 @@ import Box from '@mui/material/Box'; import Menu, { type MenuProps } from '@mui/material/Menu'; import MenuItem from '@mui/material/MenuItem'; import { useTheme } from '@mui/material/styles'; -import { getMRTTheme } from '../style.utils'; import { type MRT_FilterOption, type MRT_Header, @@ -11,7 +10,8 @@ import { type MRT_Localization, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getMRTTheme } from '../../utils/style.utils'; export const mrtFilterOptions = ( localization: MRT_Localization, diff --git a/packages/material-react-table/src/menus/MRT_RowActionMenu.tsx b/packages/material-react-table/src/components/menus/MRT_RowActionMenu.tsx similarity index 87% rename from packages/material-react-table/src/menus/MRT_RowActionMenu.tsx rename to packages/material-react-table/src/components/menus/MRT_RowActionMenu.tsx index 50cd46ebd..8c7fc3afc 100644 --- a/packages/material-react-table/src/menus/MRT_RowActionMenu.tsx +++ b/packages/material-react-table/src/components/menus/MRT_RowActionMenu.tsx @@ -8,13 +8,13 @@ import { commonListItemStyles, commonMenuItemStyles, } from './MRT_ColumnActionMenu'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getMRTTheme } from '../style.utils'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getMRTTheme } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends Partial { anchorEl: HTMLElement | null; @@ -51,12 +51,12 @@ export const MRT_RowActionMenu = ({ return ( event.stopPropagation()} onClose={() => setAnchorEl(null)} diff --git a/packages/material-react-table/src/menus/MRT_ShowHideColumnsMenu.tsx b/packages/material-react-table/src/components/menus/MRT_ShowHideColumnsMenu.tsx similarity index 95% rename from packages/material-react-table/src/menus/MRT_ShowHideColumnsMenu.tsx rename to packages/material-react-table/src/components/menus/MRT_ShowHideColumnsMenu.tsx index b9002e290..50aa649b3 100644 --- a/packages/material-react-table/src/menus/MRT_ShowHideColumnsMenu.tsx +++ b/packages/material-react-table/src/components/menus/MRT_ShowHideColumnsMenu.tsx @@ -1,17 +1,17 @@ import { useMemo, useState } from 'react'; -import { useTheme } from '@mui/material'; import Box from '@mui/material/Box'; import Button from '@mui/material/Button'; import Divider from '@mui/material/Divider'; import Menu, { type MenuProps } from '@mui/material/Menu'; +import { useTheme } from '@mui/material/styles'; import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems'; -import { getDefaultColumnOrderIds } from '../column.utils'; -import { getMRTTheme } from '../style.utils'; import { type MRT_Column, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { getDefaultColumnOrderIds } from '../../utils/column.utils'; +import { getMRTTheme } from '../../utils/style.utils'; interface Props extends Partial { anchorEl: HTMLElement | null; diff --git a/packages/material-react-table/src/menus/MRT_ShowHideColumnsMenuItems.tsx b/packages/material-react-table/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx similarity index 96% rename from packages/material-react-table/src/menus/MRT_ShowHideColumnsMenuItems.tsx rename to packages/material-react-table/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx index 0da7f054e..999c3400b 100644 --- a/packages/material-react-table/src/menus/MRT_ShowHideColumnsMenuItems.tsx +++ b/packages/material-react-table/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx @@ -11,15 +11,16 @@ import MenuItem, { type MenuItemProps } from '@mui/material/MenuItem'; import Switch from '@mui/material/Switch'; import Tooltip from '@mui/material/Tooltip'; import Typography from '@mui/material/Typography'; -import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons'; -import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton'; -import { parseFromValuesOrFunc, reorderColumn } from '../column.utils'; -import { getCommonTooltipProps, getMRTTheme } from '../style.utils'; import { type MRT_Column, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { reorderColumn } from '../../utils/column.utils'; +import { getCommonTooltipProps, getMRTTheme } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; +import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons'; +import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton'; interface Props extends MenuItemProps { allColumns: MRT_Column[]; diff --git a/packages/material-react-table/src/modals/MRT_EditRowModal.tsx b/packages/material-react-table/src/components/modals/MRT_EditRowModal.tsx similarity index 97% rename from packages/material-react-table/src/modals/MRT_EditRowModal.tsx rename to packages/material-react-table/src/components/modals/MRT_EditRowModal.tsx index d3fc65aa7..9fac90146 100644 --- a/packages/material-react-table/src/modals/MRT_EditRowModal.tsx +++ b/packages/material-react-table/src/components/modals/MRT_EditRowModal.tsx @@ -3,14 +3,14 @@ import DialogActions from '@mui/material/DialogActions'; import DialogContent from '@mui/material/DialogContent'; import DialogTitle from '@mui/material/DialogTitle'; import Stack from '@mui/material/Stack'; -import { MRT_EditActionButtons } from '../buttons/MRT_EditActionButtons'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, -} from '../types'; +} from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; +import { MRT_EditActionButtons } from '../buttons/MRT_EditActionButtons'; +import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField'; interface Props extends Partial { open: boolean; diff --git a/packages/material-react-table/src/table/MRT_Table.tsx b/packages/material-react-table/src/components/table/MRT_Table.tsx similarity index 89% rename from packages/material-react-table/src/table/MRT_Table.tsx rename to packages/material-react-table/src/components/table/MRT_Table.tsx index b18154a1e..3a9cd37a6 100644 --- a/packages/material-react-table/src/table/MRT_Table.tsx +++ b/packages/material-react-table/src/components/table/MRT_Table.tsx @@ -1,12 +1,12 @@ import { useMemo } from 'react'; import Table, { type TableProps } from '@mui/material/Table'; +import { useMRT_ColumnVirtualizer } from '../../hooks/useMRT_ColumnVirtualizer'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { parseCSSVarId } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; import { MRT_TableBody, Memo_MRT_TableBody } from '../body/MRT_TableBody'; -import { parseFromValuesOrFunc } from '../column.utils'; import { MRT_TableFooter } from '../footer/MRT_TableFooter'; import { MRT_TableHead } from '../head/MRT_TableHead'; -import { useMRT_ColumnVirtualizer } from '../hooks/useMRT_ColumnVirtualizer'; -import { parseCSSVarId } from '../style.utils'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; interface Props extends TableProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/table/MRT_TableContainer.tsx b/packages/material-react-table/src/components/table/MRT_TableContainer.tsx similarity index 95% rename from packages/material-react-table/src/table/MRT_TableContainer.tsx rename to packages/material-react-table/src/components/table/MRT_TableContainer.tsx index fc00e25c7..19b51a017 100644 --- a/packages/material-react-table/src/table/MRT_TableContainer.tsx +++ b/packages/material-react-table/src/components/table/MRT_TableContainer.tsx @@ -4,9 +4,9 @@ import TableContainer, { } from '@mui/material/TableContainer'; import { MRT_Table } from './MRT_Table'; import { MRT_TableLoadingOverlay } from './MRT_TableLoadingOverlay'; -import { parseFromValuesOrFunc } from '../column.utils'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; import { MRT_EditRowModal } from '../modals/MRT_EditRowModal'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect; diff --git a/packages/material-react-table/src/table/MRT_TableLoadingOverlay.tsx b/packages/material-react-table/src/components/table/MRT_TableLoadingOverlay.tsx similarity index 86% rename from packages/material-react-table/src/table/MRT_TableLoadingOverlay.tsx rename to packages/material-react-table/src/components/table/MRT_TableLoadingOverlay.tsx index cac01db48..771b7ebed 100644 --- a/packages/material-react-table/src/table/MRT_TableLoadingOverlay.tsx +++ b/packages/material-react-table/src/components/table/MRT_TableLoadingOverlay.tsx @@ -3,9 +3,9 @@ import CircularProgress, { type CircularProgressProps, } from '@mui/material/CircularProgress'; import { alpha } from '@mui/material/styles'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getMRTTheme } from '../style.utils'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { getMRTTheme } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends CircularProgressProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/table/MRT_TablePaper.tsx b/packages/material-react-table/src/components/table/MRT_TablePaper.tsx similarity index 92% rename from packages/material-react-table/src/table/MRT_TablePaper.tsx rename to packages/material-react-table/src/components/table/MRT_TablePaper.tsx index 18279144b..54c4445f0 100644 --- a/packages/material-react-table/src/table/MRT_TablePaper.tsx +++ b/packages/material-react-table/src/components/table/MRT_TablePaper.tsx @@ -1,10 +1,10 @@ import Paper, { type PaperProps } from '@mui/material/Paper'; import { MRT_TableContainer } from './MRT_TableContainer'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getMRTTheme } from '../style.utils'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { getMRTTheme } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; import { MRT_BottomToolbar } from '../toolbar/MRT_BottomToolbar'; import { MRT_TopToolbar } from '../toolbar/MRT_TopToolbar'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; interface Props extends PaperProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/toolbar/MRT_BottomToolbar.tsx b/packages/material-react-table/src/components/toolbar/MRT_BottomToolbar.tsx similarity index 93% rename from packages/material-react-table/src/toolbar/MRT_BottomToolbar.tsx rename to packages/material-react-table/src/components/toolbar/MRT_BottomToolbar.tsx index 8092a9913..6bf82b380 100644 --- a/packages/material-react-table/src/toolbar/MRT_BottomToolbar.tsx +++ b/packages/material-react-table/src/components/toolbar/MRT_BottomToolbar.tsx @@ -5,9 +5,9 @@ import { MRT_LinearProgressBar } from './MRT_LinearProgressBar'; import { MRT_TablePagination } from './MRT_TablePagination'; import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner'; import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { getCommonToolbarStyles } from '../style.utils'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { getCommonToolbarStyles } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends BoxProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/toolbar/MRT_LinearProgressBar.tsx b/packages/material-react-table/src/components/toolbar/MRT_LinearProgressBar.tsx similarity index 89% rename from packages/material-react-table/src/toolbar/MRT_LinearProgressBar.tsx rename to packages/material-react-table/src/components/toolbar/MRT_LinearProgressBar.tsx index 3e43fddd4..d4d6cb3c3 100644 --- a/packages/material-react-table/src/toolbar/MRT_LinearProgressBar.tsx +++ b/packages/material-react-table/src/components/toolbar/MRT_LinearProgressBar.tsx @@ -2,8 +2,8 @@ import Collapse from '@mui/material/Collapse'; import LinearProgress, { type LinearProgressProps, } from '@mui/material/LinearProgress'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends LinearProgressProps { isTopToolbar: boolean; diff --git a/packages/material-react-table/src/toolbar/MRT_TablePagination.tsx b/packages/material-react-table/src/components/toolbar/MRT_TablePagination.tsx similarity index 97% rename from packages/material-react-table/src/toolbar/MRT_TablePagination.tsx rename to packages/material-react-table/src/components/toolbar/MRT_TablePagination.tsx index e17991638..16b8f367f 100644 --- a/packages/material-react-table/src/toolbar/MRT_TablePagination.tsx +++ b/packages/material-react-table/src/components/toolbar/MRT_TablePagination.tsx @@ -8,9 +8,9 @@ import Select, { type SelectProps } from '@mui/material/Select'; import Tooltip from '@mui/material/Tooltip'; import Typography from '@mui/material/Typography'; import { useTheme } from '@mui/material/styles'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { flipIconStyles, getCommonTooltipProps } from '../style.utils'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { flipIconStyles, getCommonTooltipProps } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100]; diff --git a/packages/material-react-table/src/toolbar/MRT_ToolbarAlertBanner.tsx b/packages/material-react-table/src/components/toolbar/MRT_ToolbarAlertBanner.tsx similarity index 97% rename from packages/material-react-table/src/toolbar/MRT_ToolbarAlertBanner.tsx rename to packages/material-react-table/src/components/toolbar/MRT_ToolbarAlertBanner.tsx index a1efa316f..678d73d9f 100644 --- a/packages/material-react-table/src/toolbar/MRT_ToolbarAlertBanner.tsx +++ b/packages/material-react-table/src/components/toolbar/MRT_ToolbarAlertBanner.tsx @@ -5,9 +5,9 @@ import Box from '@mui/material/Box'; import Chip from '@mui/material/Chip'; import Collapse from '@mui/material/Collapse'; import Stack from '@mui/material/Stack'; -import { parseFromValuesOrFunc } from '../column.utils'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; interface Props extends AlertProps { stackAlertBanner?: boolean; diff --git a/packages/material-react-table/src/toolbar/MRT_ToolbarDropZone.tsx b/packages/material-react-table/src/components/toolbar/MRT_ToolbarDropZone.tsx similarity index 94% rename from packages/material-react-table/src/toolbar/MRT_ToolbarDropZone.tsx rename to packages/material-react-table/src/components/toolbar/MRT_ToolbarDropZone.tsx index 570d17fde..704a8ddd1 100644 --- a/packages/material-react-table/src/toolbar/MRT_ToolbarDropZone.tsx +++ b/packages/material-react-table/src/components/toolbar/MRT_ToolbarDropZone.tsx @@ -3,8 +3,8 @@ import Box, { type BoxProps } from '@mui/material/Box'; import Fade from '@mui/material/Fade'; import Typography from '@mui/material/Typography'; import { alpha } from '@mui/material/styles'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends BoxProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/toolbar/MRT_ToolbarInternalButtons.tsx b/packages/material-react-table/src/components/toolbar/MRT_ToolbarInternalButtons.tsx similarity index 94% rename from packages/material-react-table/src/toolbar/MRT_ToolbarInternalButtons.tsx rename to packages/material-react-table/src/components/toolbar/MRT_ToolbarInternalButtons.tsx index 7b949431f..1c9aad973 100644 --- a/packages/material-react-table/src/toolbar/MRT_ToolbarInternalButtons.tsx +++ b/packages/material-react-table/src/components/toolbar/MRT_ToolbarInternalButtons.tsx @@ -1,11 +1,11 @@ import Box, { type BoxProps } from '@mui/material/Box'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { parseFromValuesOrFunc } from '../../utils/utils'; import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton'; import { MRT_ToggleDensePaddingButton } from '../buttons/MRT_ToggleDensePaddingButton'; import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton'; import { MRT_ToggleFullScreenButton } from '../buttons/MRT_ToggleFullScreenButton'; import { MRT_ToggleGlobalFilterButton } from '../buttons/MRT_ToggleGlobalFilterButton'; -import { parseFromValuesOrFunc } from '../column.utils'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; interface Props extends BoxProps { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/toolbar/MRT_TopToolbar.tsx b/packages/material-react-table/src/components/toolbar/MRT_TopToolbar.tsx similarity index 95% rename from packages/material-react-table/src/toolbar/MRT_TopToolbar.tsx rename to packages/material-react-table/src/components/toolbar/MRT_TopToolbar.tsx index d9a5d70ae..52aa5e8b1 100644 --- a/packages/material-react-table/src/toolbar/MRT_TopToolbar.tsx +++ b/packages/material-react-table/src/components/toolbar/MRT_TopToolbar.tsx @@ -5,10 +5,10 @@ import { MRT_TablePagination } from './MRT_TablePagination'; import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner'; import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone'; import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons'; -import { parseFromValuesOrFunc } from '../column.utils'; +import { type MRT_RowData, type MRT_TableInstance } from '../../types'; +import { getCommonToolbarStyles } from '../../utils/style.utils'; +import { parseFromValuesOrFunc } from '../../utils/utils'; import { MRT_GlobalFilterTextField } from '../inputs/MRT_GlobalFilterTextField'; -import { getCommonToolbarStyles } from '../style.utils'; -import { type MRT_RowData, type MRT_TableInstance } from '../types'; interface Props { table: MRT_TableInstance; diff --git a/packages/material-react-table/src/aggregationFns.ts b/packages/material-react-table/src/fns/aggregationFns.ts similarity index 100% rename from packages/material-react-table/src/aggregationFns.ts rename to packages/material-react-table/src/fns/aggregationFns.ts diff --git a/packages/material-react-table/src/filterFns.ts b/packages/material-react-table/src/fns/filterFns.ts similarity index 99% rename from packages/material-react-table/src/filterFns.ts rename to packages/material-react-table/src/fns/filterFns.ts index c71e36e50..01c3b2971 100644 --- a/packages/material-react-table/src/filterFns.ts +++ b/packages/material-react-table/src/fns/filterFns.ts @@ -4,7 +4,7 @@ import { rankings, } from '@tanstack/match-sorter-utils'; import { type Row, filterFns } from '@tanstack/react-table'; -import { type MRT_RowData } from './types'; +import { type MRT_RowData } from '../types'; const fuzzy = ( row: Row, diff --git a/packages/material-react-table/src/sortingFns.ts b/packages/material-react-table/src/fns/sortingFns.ts similarity index 94% rename from packages/material-react-table/src/sortingFns.ts rename to packages/material-react-table/src/fns/sortingFns.ts index 03c30bcd8..a86bbea70 100644 --- a/packages/material-react-table/src/sortingFns.ts +++ b/packages/material-react-table/src/fns/sortingFns.ts @@ -1,6 +1,6 @@ import { type RankingInfo, compareItems } from '@tanstack/match-sorter-utils'; import { type Row, sortingFns } from '@tanstack/react-table'; -import { type MRT_Row, type MRT_RowData } from './types'; +import { type MRT_Row, type MRT_RowData } from '../types'; const fuzzy = ( rowA: Row, diff --git a/packages/material-react-table/src/hooks/useMRT_ColumnVirtualizer.ts b/packages/material-react-table/src/hooks/useMRT_ColumnVirtualizer.ts index 19d54976b..59c385098 100644 --- a/packages/material-react-table/src/hooks/useMRT_ColumnVirtualizer.ts +++ b/packages/material-react-table/src/hooks/useMRT_ColumnVirtualizer.ts @@ -1,14 +1,12 @@ import { useCallback, useMemo } from 'react'; import { type Range, useVirtualizer } from '@tanstack/react-virtual'; -import { - extraIndexRangeExtractor, - parseFromValuesOrFunc, -} from '../column.utils'; import { type MRT_ColumnVirtualizer, type MRT_RowData, type MRT_TableInstance, } from '../types'; +import { parseFromValuesOrFunc } from '../utils/utils'; +import { extraIndexRangeExtractor } from '../utils/virtualization.utils'; export const useMRT_ColumnVirtualizer = < TData extends MRT_RowData, diff --git a/packages/material-react-table/src/hooks/useMRT_DisplayColumns.tsx b/packages/material-react-table/src/hooks/useMRT_DisplayColumns.tsx index 7c0b2a44d..16e3d045e 100644 --- a/packages/material-react-table/src/hooks/useMRT_DisplayColumns.tsx +++ b/packages/material-react-table/src/hooks/useMRT_DisplayColumns.tsx @@ -1,14 +1,12 @@ import { type ReactNode, type RefObject, useMemo } from 'react'; import Stack from '@mui/material/Stack'; import Tooltip from '@mui/material/Tooltip'; -import { MRT_TableBodyRowGrabHandle } from '../body/MRT_TableBodyRowGrabHandle'; -import { MRT_TableBodyRowPinButton } from '../body/MRT_TableBodyRowPinButton'; -import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton'; -import { MRT_ExpandButton } from '../buttons/MRT_ExpandButton'; -import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMenuButton'; -import { showExpandColumn } from '../column.utils'; -import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox'; -import { getCommonTooltipProps } from '../style.utils'; +import { MRT_TableBodyRowGrabHandle } from '../components/body/MRT_TableBodyRowGrabHandle'; +import { MRT_TableBodyRowPinButton } from '../components/body/MRT_TableBodyRowPinButton'; +import { MRT_ExpandAllButton } from '../components/buttons/MRT_ExpandAllButton'; +import { MRT_ExpandButton } from '../components/buttons/MRT_ExpandButton'; +import { MRT_ToggleRowActionMenuButton } from '../components/buttons/MRT_ToggleRowActionMenuButton'; +import { MRT_SelectCheckbox } from '../components/inputs/MRT_SelectCheckbox'; import { type MRT_ColumnDef, type MRT_DefinedTableOptions, @@ -16,6 +14,8 @@ import { type MRT_Localization, type MRT_RowData, } from '../types'; +import { showExpandColumn } from '../utils/column.utils'; +import { getCommonTooltipProps } from '../utils/style.utils'; import { MRT_DefaultDisplayColumn } from './useMRT_TableOptions'; export const useMRT_DisplayColumns = ( diff --git a/packages/material-react-table/src/hooks/useMRT_Effects.ts b/packages/material-react-table/src/hooks/useMRT_Effects.ts index 390314b92..2bbeeefa9 100644 --- a/packages/material-react-table/src/hooks/useMRT_Effects.ts +++ b/packages/material-react-table/src/hooks/useMRT_Effects.ts @@ -1,10 +1,10 @@ import { useEffect, useReducer, useRef } from 'react'; -import { getCanRankRows } from '../column.utils'; import { type MRT_RowData, type MRT_SortingState, type MRT_TableInstance, } from '../types'; +import { getCanRankRows } from '../utils/row.utils'; export const useMRT_Effects = ( table: MRT_TableInstance, diff --git a/packages/material-react-table/src/hooks/useMRT_RowVirtualizer.ts b/packages/material-react-table/src/hooks/useMRT_RowVirtualizer.ts index 71d607d9b..7801fad7a 100644 --- a/packages/material-react-table/src/hooks/useMRT_RowVirtualizer.ts +++ b/packages/material-react-table/src/hooks/useMRT_RowVirtualizer.ts @@ -1,15 +1,13 @@ import { useCallback } from 'react'; import { type Range, useVirtualizer } from '@tanstack/react-virtual'; -import { - extraIndexRangeExtractor, - parseFromValuesOrFunc, -} from '../column.utils'; import { type MRT_Row, type MRT_RowData, type MRT_RowVirtualizer, type MRT_TableInstance, } from '../types'; +import { parseFromValuesOrFunc } from '../utils/utils'; +import { extraIndexRangeExtractor } from '../utils/virtualization.utils'; export const useMRT_RowVirtualizer = < TData extends MRT_RowData, diff --git a/packages/material-react-table/src/hooks/useMRT_Rows.ts b/packages/material-react-table/src/hooks/useMRT_Rows.ts index 13cc74275..ae3174fa2 100644 --- a/packages/material-react-table/src/hooks/useMRT_Rows.ts +++ b/packages/material-react-table/src/hooks/useMRT_Rows.ts @@ -1,11 +1,11 @@ import { useMemo } from 'react'; -import { getCanRankRows } from '../column.utils'; -import { rankGlobalFuzzy } from '../sortingFns'; +import { rankGlobalFuzzy } from '../fns/sortingFns'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, } from '../types'; +import { getCanRankRows } from '../utils/row.utils'; export const useMRT_Rows = ( table: MRT_TableInstance, diff --git a/packages/material-react-table/src/hooks/useMRT_TableInstance.ts b/packages/material-react-table/src/hooks/useMRT_TableInstance.ts index f6e6c5f7b..d692fb907 100644 --- a/packages/material-react-table/src/hooks/useMRT_TableInstance.ts +++ b/packages/material-react-table/src/hooks/useMRT_TableInstance.ts @@ -11,14 +11,6 @@ import { getSortedRowModel, useReactTable, } from '@tanstack/react-table'; -import { - createRow, - getAllLeafColumnDefs, - getColumnId, - getDefaultColumnFilterFn, - getDefaultColumnOrderIds, - prepareColumns, -} from '../column.utils'; import { type MRT_Cell, type MRT_Column, @@ -36,6 +28,14 @@ import { type MRT_TableState, type MRT_Updater, } from '../types'; +import { + getAllLeafColumnDefs, + getColumnId, + getDefaultColumnFilterFn, + getDefaultColumnOrderIds, + prepareColumns, +} from '../utils/column.utils'; +import { createRow } from '../utils/tanstack.helpers'; import { useMRT_DisplayColumns } from './useMRT_DisplayColumns'; import { useMRT_Effects } from './useMRT_Effects'; diff --git a/packages/material-react-table/src/hooks/useMRT_TableOptions.ts b/packages/material-react-table/src/hooks/useMRT_TableOptions.ts index 6b0d90f24..b30a56956 100644 --- a/packages/material-react-table/src/hooks/useMRT_TableOptions.ts +++ b/packages/material-react-table/src/hooks/useMRT_TableOptions.ts @@ -1,10 +1,10 @@ import { useMemo } from 'react'; import { useTheme } from '@mui/material/styles'; -import { MRT_AggregationFns } from '../aggregationFns'; -import { MRT_FilterFns } from '../filterFns'; +import { MRT_AggregationFns } from '../fns/aggregationFns'; +import { MRT_FilterFns } from '../fns/filterFns'; +import { MRT_SortingFns } from '../fns/sortingFns'; import { MRT_Default_Icons } from '../icons'; import { MRT_Localization_EN } from '../locales/en'; -import { MRT_SortingFns } from '../sortingFns'; import { type MRT_DefinedTableOptions, type MRT_RowData, diff --git a/packages/material-react-table/src/useMaterialReactTable.ts b/packages/material-react-table/src/hooks/useMaterialReactTable.ts similarity index 64% rename from packages/material-react-table/src/useMaterialReactTable.ts rename to packages/material-react-table/src/hooks/useMaterialReactTable.ts index d8d084950..c4029c7dc 100644 --- a/packages/material-react-table/src/useMaterialReactTable.ts +++ b/packages/material-react-table/src/hooks/useMaterialReactTable.ts @@ -1,10 +1,10 @@ -import { useMRT_TableInstance } from './hooks/useMRT_TableInstance'; -import { useMRT_TableOptions } from './hooks/useMRT_TableOptions'; import { type MRT_RowData, type MRT_TableInstance, type MRT_TableOptions, -} from './types'; +} from '../types'; +import { useMRT_TableInstance } from './useMRT_TableInstance'; +import { useMRT_TableOptions } from './useMRT_TableOptions'; export const useMaterialReactTable = ( tableOptions: MRT_TableOptions, diff --git a/packages/material-react-table/src/index.ts b/packages/material-react-table/src/index.ts index 7171251c3..ffd17f65a 100644 --- a/packages/material-react-table/src/index.ts +++ b/packages/material-react-table/src/index.ts @@ -1,14 +1,15 @@ -//root -export * from './MaterialReactTable'; -export * from './aggregationFns'; -export * from './column.utils'; -export * from './filterFns'; -export * from './sortingFns'; -export * from './style.utils'; export * from './types'; -export * from './useMaterialReactTable'; + +//helpers +export * from './utils/tanstack.helpers'; + +//fns +export * from './fns/aggregationFns'; +export * from './fns/filterFns'; +export * from './fns/sortingFns'; //hooks +export * from './hooks/useMaterialReactTable'; export * from './hooks/useMRT_ColumnVirtualizer'; export * from './hooks/useMRT_DisplayColumns'; export * from './hooks/useMRT_Effects'; @@ -17,76 +18,70 @@ export * from './hooks/useMRT_Rows'; export * from './hooks/useMRT_TableInstance'; export * from './hooks/useMRT_TableOptions'; -//body -export * from './body/MRT_TableBody'; -export * from './body/MRT_TableBodyCell'; -export * from './body/MRT_TableBodyCellValue'; -export * from './body/MRT_TableBodyRow'; -export * from './body/MRT_TableBodyRowGrabHandle'; -export * from './body/MRT_TableBodyRowPinButton'; -export * from './body/MRT_TableDetailPanel'; - -//buttons -export * from './buttons/MRT_ColumnPinningButtons'; -export * from './buttons/MRT_CopyButton'; -export * from './buttons/MRT_EditActionButtons'; -export * from './buttons/MRT_ExpandAllButton'; -export * from './buttons/MRT_ExpandButton'; -export * from './buttons/MRT_GrabHandleButton'; -export * from './buttons/MRT_RowPinButton'; -export * from './buttons/MRT_ShowHideColumnsButton'; -export * from './buttons/MRT_ToggleDensePaddingButton'; -export * from './buttons/MRT_ToggleFiltersButton'; -export * from './buttons/MRT_ToggleFullScreenButton'; -export * from './buttons/MRT_ToggleGlobalFilterButton'; -export * from './buttons/MRT_ToggleRowActionMenuButton'; - -//footer -export * from './footer/MRT_TableFooter'; -export * from './footer/MRT_TableFooterCell'; -export * from './footer/MRT_TableFooterRow'; - -//head -export * from './head/MRT_TableHead'; -export * from './head/MRT_TableHeadCell'; -export * from './head/MRT_TableHeadCellColumnActionsButton'; -export * from './head/MRT_TableHeadCellFilterContainer'; -export * from './head/MRT_TableHeadCellFilterLabel'; -export * from './head/MRT_TableHeadCellGrabHandle'; -export * from './head/MRT_TableHeadCellResizeHandle'; -export * from './head/MRT_TableHeadCellSortLabel'; -export * from './head/MRT_TableHeadRow'; - -//inputs -export * from './inputs/MRT_EditCellTextField'; -export * from './inputs/MRT_FilterCheckbox'; -export * from './inputs/MRT_FilterRangeFields'; -export * from './inputs/MRT_FilterRangeSlider'; -export * from './inputs/MRT_FilterTextField'; -export * from './inputs/MRT_GlobalFilterTextField'; -export * from './inputs/MRT_SelectCheckbox'; - -//menus -export * from './menus/MRT_ColumnActionMenu'; -export * from './menus/MRT_FilterOptionMenu'; -export * from './menus/MRT_RowActionMenu'; -export * from './menus/MRT_ShowHideColumnsMenu'; -export * from './menus/MRT_ShowHideColumnsMenuItems'; - -//modals -export * from './modals/MRT_EditRowModal'; - -//table -export * from './table/MRT_Table'; -export * from './table/MRT_TableContainer'; -export * from './table/MRT_TableLoadingOverlay'; -export * from './table/MRT_TablePaper'; - -//toolbar -export * from './toolbar/MRT_BottomToolbar'; -export * from './toolbar/MRT_LinearProgressBar'; -export * from './toolbar/MRT_TablePagination'; -export * from './toolbar/MRT_ToolbarAlertBanner'; -export * from './toolbar/MRT_ToolbarDropZone'; -export * from './toolbar/MRT_ToolbarInternalButtons'; -export * from './toolbar/MRT_TopToolbar'; +//components +export * from './components/MaterialReactTable'; +//body components +export * from './components/body/MRT_TableBody'; +export * from './components/body/MRT_TableBodyCell'; +export * from './components/body/MRT_TableBodyCellValue'; +export * from './components/body/MRT_TableBodyRow'; +export * from './components/body/MRT_TableBodyRowGrabHandle'; +export * from './components/body/MRT_TableBodyRowPinButton'; +export * from './components/body/MRT_TableDetailPanel'; +//button components +export * from './components/buttons/MRT_ColumnPinningButtons'; +export * from './components/buttons/MRT_CopyButton'; +export * from './components/buttons/MRT_EditActionButtons'; +export * from './components/buttons/MRT_ExpandAllButton'; +export * from './components/buttons/MRT_ExpandButton'; +export * from './components/buttons/MRT_GrabHandleButton'; +export * from './components/buttons/MRT_RowPinButton'; +export * from './components/buttons/MRT_ShowHideColumnsButton'; +export * from './components/buttons/MRT_ToggleDensePaddingButton'; +export * from './components/buttons/MRT_ToggleFiltersButton'; +export * from './components/buttons/MRT_ToggleFullScreenButton'; +export * from './components/buttons/MRT_ToggleGlobalFilterButton'; +export * from './components/buttons/MRT_ToggleRowActionMenuButton'; +//footer components +export * from './components/footer/MRT_TableFooter'; +export * from './components/footer/MRT_TableFooterCell'; +export * from './components/footer/MRT_TableFooterRow'; +//head components +export * from './components/head/MRT_TableHead'; +export * from './components/head/MRT_TableHeadCell'; +export * from './components/head/MRT_TableHeadCellColumnActionsButton'; +export * from './components/head/MRT_TableHeadCellFilterContainer'; +export * from './components/head/MRT_TableHeadCellFilterLabel'; +export * from './components/head/MRT_TableHeadCellGrabHandle'; +export * from './components/head/MRT_TableHeadCellResizeHandle'; +export * from './components/head/MRT_TableHeadCellSortLabel'; +export * from './components/head/MRT_TableHeadRow'; +//input components +export * from './components/inputs/MRT_EditCellTextField'; +export * from './components/inputs/MRT_FilterCheckbox'; +export * from './components/inputs/MRT_FilterRangeFields'; +export * from './components/inputs/MRT_FilterRangeSlider'; +export * from './components/inputs/MRT_FilterTextField'; +export * from './components/inputs/MRT_GlobalFilterTextField'; +export * from './components/inputs/MRT_SelectCheckbox'; +//menu components +export * from './components/menus/MRT_ColumnActionMenu'; +export * from './components/menus/MRT_FilterOptionMenu'; +export * from './components/menus/MRT_RowActionMenu'; +export * from './components/menus/MRT_ShowHideColumnsMenu'; +export * from './components/menus/MRT_ShowHideColumnsMenuItems'; +//modal components +export * from './components/modals/MRT_EditRowModal'; +//table components +export * from './components/table/MRT_Table'; +export * from './components/table/MRT_TableContainer'; +export * from './components/table/MRT_TableLoadingOverlay'; +export * from './components/table/MRT_TablePaper'; +//toolbar components +export * from './components/toolbar/MRT_BottomToolbar'; +export * from './components/toolbar/MRT_LinearProgressBar'; +export * from './components/toolbar/MRT_TablePagination'; +export * from './components/toolbar/MRT_ToolbarAlertBanner'; +export * from './components/toolbar/MRT_ToolbarDropZone'; +export * from './components/toolbar/MRT_ToolbarInternalButtons'; +export * from './components/toolbar/MRT_TopToolbar'; diff --git a/packages/material-react-table/src/types.ts b/packages/material-react-table/src/types.ts index ea92a26aa..f2b4565da 100644 --- a/packages/material-react-table/src/types.ts +++ b/packages/material-react-table/src/types.ts @@ -71,10 +71,10 @@ import { type DateTimePickerProps, type TimePickerProps, } from '@mui/x-date-pickers'; -import { type MRT_AggregationFns } from './aggregationFns'; -import { type MRT_FilterFns } from './filterFns'; +import { type MRT_AggregationFns } from './fns/aggregationFns'; +import { type MRT_FilterFns } from './fns/filterFns'; +import { type MRT_SortingFns } from './fns/sortingFns'; import { type MRT_Icons } from './icons'; -import { type MRT_SortingFns } from './sortingFns'; export type { MRT_Icons }; export type LiteralUnion = diff --git a/packages/material-react-table/src/utils.ts b/packages/material-react-table/src/utils.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/material-react-table/src/column.utils.ts b/packages/material-react-table/src/utils/column.utils.ts similarity index 69% rename from packages/material-react-table/src/column.utils.ts rename to packages/material-react-table/src/utils/column.utils.ts index c86af429d..f76ba1b87 100644 --- a/packages/material-react-table/src/column.utils.ts +++ b/packages/material-react-table/src/utils/column.utils.ts @@ -1,28 +1,17 @@ -import { type ReactNode } from 'react'; -import { - createRow as _createRow, - flexRender as _flexRender, - type Renderable, - type Row, -} from '@tanstack/react-table'; -import { type Range, defaultRangeExtractor } from '@tanstack/react-virtual'; +import { type Row } from '@tanstack/react-table'; import { type MRT_Column, type MRT_ColumnDef, - type MRT_ColumnHelper, type MRT_ColumnOrderState, type MRT_DefinedColumnDef, type MRT_DefinedTableOptions, - type MRT_DisplayColumnDef, type MRT_DisplayColumnIds, type MRT_FilterOption, - type MRT_GroupColumnDef, type MRT_GroupingState, - type MRT_Row, type MRT_RowData, type MRT_TableInstance, type MRT_TableOptions, -} from './types'; +} from '../types'; export const getColumnId = ( columnDef: MRT_ColumnDef, @@ -81,8 +70,8 @@ export const prepareColumns = ({ leafRows: Row[], childRows: Row[], ) => - aggFns.map( - (fn) => aggregationFns[fn]?.(columnId, leafRows, childRows), + aggFns.map((fn) => + aggregationFns[fn]?.(columnId, leafRows, childRows), ); } @@ -245,117 +234,3 @@ export const getTotalRight = ( .slice(column.getPinnedIndex() + 1) .reduce((acc, col) => acc + col.getSize(), 0); }; - -export const getCanRankRows = ( - table: MRT_TableInstance, -) => { - const { getState, options } = table; - const { - enableGlobalFilterRankedResults, - manualExpanding, - manualFiltering, - manualGrouping, - manualSorting, - } = options; - const { expanded, globalFilterFn } = getState(); - - return ( - !manualExpanding && - !manualFiltering && - !manualGrouping && - !manualSorting && - enableGlobalFilterRankedResults && - globalFilterFn === 'fuzzy' && - expanded !== true && - !Object.values(expanded).some(Boolean) - ); -}; - -export const parseFromValuesOrFunc = ( - fn: ((arg: U) => T) | T | undefined, - arg: U, -): T | undefined => (fn instanceof Function ? fn(arg) : fn); - -export const flexRender = _flexRender as ( - Comp: Renderable, - props: any, -) => JSX.Element | ReactNode; - -export const createRow = ( - table: MRT_TableInstance, - originalRow?: TData, - rowIndex = -1, - depth = 0, - subRows?: MRT_Row[], - parentId?: string, -): MRT_Row => - _createRow( - table as any, - 'mrt-row-create', - originalRow ?? - Object.assign( - {}, - ...getAllLeafColumnDefs(table.options.columns).map((col) => ({ - [getColumnId(col)]: '', - })), - ), - rowIndex, - depth, - subRows as any, - parentId, - ) as MRT_Row; - -export const extraIndexRangeExtractor = ( - range: Range, - draggingIndex?: number, -) => { - const newIndexes = defaultRangeExtractor(range); - if (draggingIndex === undefined) return newIndexes; - if ( - draggingIndex >= 0 && - draggingIndex < Math.max(range.startIndex - range.overscan, 0) - ) { - newIndexes.unshift(draggingIndex); - } - if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) { - newIndexes.push(draggingIndex); - } - return newIndexes; -}; - -export function createMRTColumnHelper< - TData extends MRT_RowData, ->(): MRT_ColumnHelper { - return { - accessor: (accessor, column) => { - return typeof accessor === 'function' - ? ({ - ...column, - accessorFn: accessor, - } as any) - : { - ...column, - accessorKey: accessor, - }; - }, - display: (column) => column as MRT_DisplayColumnDef, - group: (column) => column as MRT_GroupColumnDef, - }; -} - -export const getValueAndLabel = ( - option: { label?: string; text?: string; value: string } | string, -): { label: string; value: string } => { - let label: string = ''; - let value: string = ''; - if (option) { - if (typeof option !== 'object') { - label = option; - value = option; - } else { - label = option.label ?? option.text ?? option.value; - value = option.value ?? label; - } - } - return { label, value }; -}; diff --git a/packages/material-react-table/src/utils/row.utils.ts b/packages/material-react-table/src/utils/row.utils.ts new file mode 100644 index 000000000..9342e4ff7 --- /dev/null +++ b/packages/material-react-table/src/utils/row.utils.ts @@ -0,0 +1,26 @@ +import { type MRT_RowData, type MRT_TableInstance } from '../types'; + +export const getCanRankRows = ( + table: MRT_TableInstance, +) => { + const { getState, options } = table; + const { + enableGlobalFilterRankedResults, + manualExpanding, + manualFiltering, + manualGrouping, + manualSorting, + } = options; + const { expanded, globalFilterFn } = getState(); + + return ( + !manualExpanding && + !manualFiltering && + !manualGrouping && + !manualSorting && + enableGlobalFilterRankedResults && + globalFilterFn === 'fuzzy' && + expanded !== true && + !Object.values(expanded).some(Boolean) + ); +}; diff --git a/packages/material-react-table/src/style.utils.ts b/packages/material-react-table/src/utils/style.utils.ts similarity index 97% rename from packages/material-react-table/src/style.utils.ts rename to packages/material-react-table/src/utils/style.utils.ts index bf3505175..c1618af06 100644 --- a/packages/material-react-table/src/style.utils.ts +++ b/packages/material-react-table/src/utils/style.utils.ts @@ -3,18 +3,18 @@ import { type TableCellProps } from '@mui/material/TableCell'; import { type TooltipProps } from '@mui/material/Tooltip'; import { alpha, darken, lighten } from '@mui/material/styles'; import { type Theme } from '@mui/material/styles'; -import { - getIsFirstRightPinnedColumn, - getIsLastLeftPinnedColumn, - getTotalRight, - parseFromValuesOrFunc, -} from './column.utils'; import { type MRT_Column, type MRT_Header, type MRT_RowData, type MRT_TableInstance, -} from './types'; +} from '../types'; +import { + getIsFirstRightPinnedColumn, + getIsLastLeftPinnedColumn, + getTotalRight, +} from '../utils/column.utils'; +import { parseFromValuesOrFunc } from './utils'; export const parseCSSVarId = (id: string) => id.replace(/[^a-zA-Z0-9]/g, '_'); diff --git a/packages/material-react-table/src/utils/tanstack.helpers.ts b/packages/material-react-table/src/utils/tanstack.helpers.ts new file mode 100644 index 000000000..717c5ec14 --- /dev/null +++ b/packages/material-react-table/src/utils/tanstack.helpers.ts @@ -0,0 +1,64 @@ +import { type ReactNode } from 'react'; +import { + createRow as _createRow, + flexRender as _flexRender, + type Renderable, +} from '@tanstack/react-table'; +import { + type MRT_ColumnHelper, + type MRT_DisplayColumnDef, + type MRT_GroupColumnDef, + type MRT_Row, + type MRT_RowData, + type MRT_TableInstance, +} from '../types'; +import { getAllLeafColumnDefs, getColumnId } from './column.utils'; + +export const flexRender = _flexRender as ( + Comp: Renderable, + props: any, +) => JSX.Element | ReactNode; + +export function createMRTColumnHelper< + TData extends MRT_RowData, +>(): MRT_ColumnHelper { + return { + accessor: (accessor, column) => { + return typeof accessor === 'function' + ? ({ + ...column, + accessorFn: accessor, + } as any) + : { + ...column, + accessorKey: accessor, + }; + }, + display: (column) => column as MRT_DisplayColumnDef, + group: (column) => column as MRT_GroupColumnDef, + }; +} + +export const createRow = ( + table: MRT_TableInstance, + originalRow?: TData, + rowIndex = -1, + depth = 0, + subRows?: MRT_Row[], + parentId?: string, +): MRT_Row => + _createRow( + table as any, + 'mrt-row-create', + originalRow ?? + Object.assign( + {}, + ...getAllLeafColumnDefs(table.options.columns).map((col) => ({ + [getColumnId(col)]: '', + })), + ), + rowIndex, + depth, + subRows as any, + parentId, + ) as MRT_Row; diff --git a/packages/material-react-table/src/utils/utils.ts b/packages/material-react-table/src/utils/utils.ts new file mode 100644 index 000000000..9cfe862fc --- /dev/null +++ b/packages/material-react-table/src/utils/utils.ts @@ -0,0 +1,21 @@ +export const parseFromValuesOrFunc = ( + fn: ((arg: U) => T) | T | undefined, + arg: U, +): T | undefined => (fn instanceof Function ? fn(arg) : fn); + +export const getValueAndLabel = ( + option: { label?: string; text?: string; value: string } | string, +): { label: string; value: string } => { + let label: string = ''; + let value: string = ''; + if (option) { + if (typeof option !== 'object') { + label = option; + value = option; + } else { + label = option.label ?? option.text ?? option.value; + value = option.value ?? label; + } + } + return { label, value }; +}; diff --git a/packages/material-react-table/src/utils/virtualization.utils.ts b/packages/material-react-table/src/utils/virtualization.utils.ts new file mode 100644 index 000000000..2b5e8a2d2 --- /dev/null +++ b/packages/material-react-table/src/utils/virtualization.utils.ts @@ -0,0 +1,19 @@ +import { type Range, defaultRangeExtractor } from '@tanstack/react-virtual'; + +export const extraIndexRangeExtractor = ( + range: Range, + draggingIndex?: number, +) => { + const newIndexes = defaultRangeExtractor(range); + if (draggingIndex === undefined) return newIndexes; + if ( + draggingIndex >= 0 && + draggingIndex < Math.max(range.startIndex - range.overscan, 0) + ) { + newIndexes.unshift(draggingIndex); + } + if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) { + newIndexes.push(draggingIndex); + } + return newIndexes; +};