-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new useMantineReactTableHook beta 12
- Loading branch information
1 parent
ccec503
commit 0c5d162
Showing
35 changed files
with
1,318 additions
and
1,197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/mantine-react-table-docs/components/prop-tables/rootProps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/mantine-react-table-docs/examples/localization-i18n-no/sandbox/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
195 changes: 40 additions & 155 deletions
195
packages/mantine-react-table/src/MantineReactTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,164 +1,49 @@ | ||
import { useMemo } from 'react'; | ||
import { MRT_AggregationFns } from './aggregationFns'; | ||
import { MRT_DefaultColumn, MRT_DefaultDisplayColumn } from './column.utils'; | ||
import { MRT_FilterFns } from './filterFns'; | ||
import { MRT_Default_Icons } from './icons'; | ||
import { MRT_SortingFns } from './sortingFns'; | ||
import { MRT_TableRoot } from './table/MRT_TableRoot'; | ||
import { MRT_Localization_EN } from './_locales/en'; | ||
import { type MantineReactTableProps } from './types'; | ||
import { MRT_TablePaper } from './table/MRT_TablePaper'; | ||
import { useMantineReactTable } from './useMantineReactTable'; | ||
import { type MRT_TableOptions, type MRT_TableInstance } from './types'; | ||
import { useEffect, useRef } from 'react'; | ||
|
||
export { MRT_AggregationFns, MRT_FilterFns, MRT_SortingFns }; | ||
type TableInstanceProp<TData extends Record<string, any>> = { | ||
table: MRT_TableInstance<TData>; | ||
}; | ||
|
||
export const MantineReactTable = <TData extends Record<string, any> = {}>({ | ||
aggregationFns, | ||
autoResetExpanded = false, | ||
columnResizeMode = 'onChange', | ||
defaultColumn, | ||
defaultDisplayColumn, | ||
editingMode = 'modal', | ||
enableBottomToolbar = true, | ||
enableColumnActions = true, | ||
enableColumnFilters = true, | ||
enableColumnOrdering = false, | ||
enableColumnResizing = false, | ||
enableDensityToggle = true, | ||
enableExpandAll = true, | ||
enableFilterMatchHighlighting = true, | ||
enableFilters = true, | ||
enableFullScreenToggle = true, | ||
enableGlobalFilter = true, | ||
enableGlobalFilterRankedResults = true, | ||
enableGrouping = false, | ||
enableHiding = true, | ||
enableMultiRowSelection = true, | ||
enableMultiSort = true, | ||
enablePagination = true, | ||
enablePinning = false, | ||
enableRowSelection = false, | ||
enableSelectAll = true, | ||
enableSorting = true, | ||
enableStickyHeader = false, | ||
enableTableFooter = true, | ||
enableTableHead = true, | ||
enableToolbarInternalActions = true, | ||
enableTopToolbar = true, | ||
filterFns, | ||
icons, | ||
layoutMode = 'semantic', | ||
localization, | ||
manualFiltering, | ||
manualGrouping, | ||
manualPagination, | ||
manualSorting, | ||
positionActionsColumn = 'first', | ||
positionExpandColumn = 'first', | ||
positionGlobalFilter = 'right', | ||
positionPagination = 'bottom', | ||
positionToolbarAlertBanner = 'top', | ||
positionToolbarDropZone = 'top', | ||
rowNumberMode = 'original', | ||
selectAllMode = 'page', | ||
sortingFns, | ||
...rest | ||
}: MantineReactTableProps<TData>): JSX.Element => { | ||
const _icons = useMemo(() => ({ ...MRT_Default_Icons, ...icons }), [icons]); | ||
const _localization = useMemo( | ||
() => ({ | ||
...MRT_Localization_EN, | ||
...localization, | ||
}), | ||
[localization], | ||
); | ||
const _aggregationFns = useMemo( | ||
() => ({ ...MRT_AggregationFns, ...aggregationFns }), | ||
[], | ||
); | ||
const _filterFns = useMemo(() => ({ ...MRT_FilterFns, ...filterFns }), []); | ||
const _sortingFns = useMemo(() => ({ ...MRT_SortingFns, ...sortingFns }), []); | ||
const _defaultColumn = useMemo( | ||
() => ({ ...MRT_DefaultColumn, ...defaultColumn }), | ||
[defaultColumn], | ||
); | ||
const _defaultDisplayColumn = useMemo( | ||
() => ({ | ||
...MRT_DefaultDisplayColumn, | ||
...defaultDisplayColumn, | ||
}), | ||
[defaultDisplayColumn], | ||
); | ||
type Props<TData extends Record<string, any>> = | ||
| TableInstanceProp<TData> | ||
| MRT_TableOptions<TData>; | ||
|
||
if (rest.enableRowVirtualization || rest.enableColumnVirtualization) { | ||
layoutMode = 'grid'; | ||
} | ||
const isTableInstanceProp = <TData extends Record<string, any>>( | ||
props: Props<TData>, | ||
): props is TableInstanceProp<TData> => | ||
(props as TableInstanceProp<TData>).table !== undefined; | ||
|
||
if (rest.enableRowVirtualization) { | ||
enableStickyHeader = true; | ||
} | ||
export const MantineReactTable = <TData extends Record<string, any>>( | ||
props: Props<TData>, | ||
) => { | ||
let table: MRT_TableInstance<TData>; | ||
|
||
if (enablePagination === false && manualPagination === undefined) { | ||
manualPagination = true; | ||
if (isTableInstanceProp(props)) { | ||
table = props.table; | ||
} else { | ||
table = useMantineReactTable(props); | ||
} | ||
|
||
if (!rest.data?.length) { | ||
manualFiltering = true; | ||
manualGrouping = true; | ||
manualPagination = true; | ||
manualSorting = true; | ||
} | ||
const initialBodyHeight = useRef<string>(); | ||
|
||
useEffect(() => { | ||
if (typeof window !== 'undefined') { | ||
initialBodyHeight.current = document.body.style.height; | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (typeof window !== 'undefined') { | ||
if (table.getState().isFullScreen) { | ||
document.body.style.height = '100vh'; | ||
} else { | ||
document.body.style.height = initialBodyHeight.current as string; | ||
} | ||
} | ||
}, [table.getState().isFullScreen]); | ||
|
||
return ( | ||
<MRT_TableRoot | ||
aggregationFns={_aggregationFns} | ||
autoResetExpanded={autoResetExpanded} | ||
columnResizeMode={columnResizeMode} | ||
defaultColumn={_defaultColumn} | ||
defaultDisplayColumn={_defaultDisplayColumn} | ||
editingMode={editingMode} | ||
enableBottomToolbar={enableBottomToolbar} | ||
enableColumnActions={enableColumnActions} | ||
enableColumnFilters={enableColumnFilters} | ||
enableColumnOrdering={enableColumnOrdering} | ||
enableColumnResizing={enableColumnResizing} | ||
enableDensityToggle={enableDensityToggle} | ||
enableExpandAll={enableExpandAll} | ||
enableFilterMatchHighlighting={enableFilterMatchHighlighting} | ||
enableFilters={enableFilters} | ||
enableFullScreenToggle={enableFullScreenToggle} | ||
enableGlobalFilter={enableGlobalFilter} | ||
enableGlobalFilterRankedResults={enableGlobalFilterRankedResults} | ||
enableGrouping={enableGrouping} | ||
enableHiding={enableHiding} | ||
enableMultiRowSelection={enableMultiRowSelection} | ||
enableMultiSort={enableMultiSort} | ||
enablePagination={enablePagination} | ||
enablePinning={enablePinning} | ||
enableRowSelection={enableRowSelection} | ||
enableSelectAll={enableSelectAll} | ||
enableSorting={enableSorting} | ||
enableStickyHeader={enableStickyHeader} | ||
enableTableFooter={enableTableFooter} | ||
enableTableHead={enableTableHead} | ||
enableToolbarInternalActions={enableToolbarInternalActions} | ||
enableTopToolbar={enableTopToolbar} | ||
filterFns={_filterFns} | ||
icons={_icons} | ||
layoutMode={layoutMode} | ||
localization={_localization} | ||
manualFiltering={manualFiltering} | ||
manualGrouping={manualGrouping} | ||
manualPagination={manualPagination} | ||
manualSorting={manualSorting} | ||
positionActionsColumn={positionActionsColumn} | ||
positionExpandColumn={positionExpandColumn} | ||
positionGlobalFilter={positionGlobalFilter} | ||
positionPagination={positionPagination} | ||
positionToolbarAlertBanner={positionToolbarAlertBanner} | ||
positionToolbarDropZone={positionToolbarDropZone} | ||
rowNumberMode={rowNumberMode} | ||
selectAllMode={selectAllMode} | ||
sortingFns={_sortingFns} | ||
{...rest} | ||
/> | ||
); | ||
return <MRT_TablePaper table={table as any} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export * from './MRT_TableBody'; | ||
export * from './MRT_TableBodyCell'; | ||
export * from './MRT_TableBodyCellValue'; | ||
export * from './MRT_TableBodyRow'; | ||
export * from './MRT_TableBodyRowGrabHandle'; | ||
export * from './MRT_TableDetailPanel'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
0c5d162
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mantine-react-table-storybook – ./
mantine-react-table-storybook-kevinvandy.vercel.app
mantine-react-table-storybook.vercel.app
mantine-react-table-storybook-git-main-kevinvandy.vercel.app
www.mantine-react-table.dev
mantine-react-table.dev
0c5d162
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mantine-react-table – ./apps/mantine-react-table-docs
mantine-react-table-git-main-kevinvandy-s-team.vercel.app
mantine-react-table-kevinvandy-s-team.vercel.app
mantine-react-table.vercel.app
mantine-react-table.com
www.mantine-react-table.com