|
| 1 | +import { AppBar, Box, CssBaseline, Toolbar } from '@mui/material'; |
| 2 | +import { type Meta } from '@storybook/react'; |
| 3 | +import { MaterialReactTable, useMaterialReactTable, type MRT_ColumnDef } from '../../src'; |
| 4 | + |
| 5 | +const meta: Meta = { |
| 6 | + title: 'Fixed Bugs/AppBar overlaps with Fullscreen Modal', |
| 7 | +}; |
| 8 | + |
| 9 | +export default meta; |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +//example data type |
| 14 | +type Person = { |
| 15 | + name: { |
| 16 | + firstName: string; |
| 17 | + lastName: string; |
| 18 | + }; |
| 19 | + address: string; |
| 20 | + city: string; |
| 21 | + state: string; |
| 22 | +}; |
| 23 | + |
| 24 | +//nested data is ok, see accessorKeys in ColumnDef below |
| 25 | +const data: Person[] = [ |
| 26 | + { |
| 27 | + name: { |
| 28 | + firstName: 'John', |
| 29 | + lastName: 'Doe', |
| 30 | + }, |
| 31 | + address: '261 Erdman Ford', |
| 32 | + city: 'East Daphne', |
| 33 | + state: 'Kentucky', |
| 34 | + }, |
| 35 | + { |
| 36 | + name: { |
| 37 | + firstName: 'Jane', |
| 38 | + lastName: 'Doe', |
| 39 | + }, |
| 40 | + address: '769 Dominic Grove', |
| 41 | + city: 'Columbus', |
| 42 | + state: 'Ohio', |
| 43 | + }, |
| 44 | + { |
| 45 | + name: { |
| 46 | + firstName: 'Joe', |
| 47 | + lastName: 'Doe', |
| 48 | + }, |
| 49 | + address: '566 Brakus Inlet', |
| 50 | + city: 'South Linda', |
| 51 | + state: 'West Virginia', |
| 52 | + }, |
| 53 | + { |
| 54 | + name: { |
| 55 | + firstName: 'Kevin', |
| 56 | + lastName: 'Vandy', |
| 57 | + }, |
| 58 | + address: '722 Emie Stream', |
| 59 | + city: 'Lincoln', |
| 60 | + state: 'Nebraska', |
| 61 | + }, |
| 62 | + { |
| 63 | + name: { |
| 64 | + firstName: 'Joshua', |
| 65 | + lastName: 'Rolluffs', |
| 66 | + }, |
| 67 | + address: '32188 Larkin Turnpike', |
| 68 | + city: 'Omaha', |
| 69 | + state: 'Nebraska', |
| 70 | + }, |
| 71 | +]; |
| 72 | + |
| 73 | +const columns: MRT_ColumnDef<Person>[] = [ |
| 74 | + { |
| 75 | + accessorKey: 'name.firstName', //access nested data with dot notation |
| 76 | + header: 'First Name', |
| 77 | + size: 150, |
| 78 | + }, |
| 79 | + { |
| 80 | + accessorKey: 'name.lastName', |
| 81 | + header: 'Last Name', |
| 82 | + size: 150, |
| 83 | + }, |
| 84 | + { |
| 85 | + accessorKey: 'address', //normal accessorKey |
| 86 | + header: 'Address', |
| 87 | + size: 200, |
| 88 | + }, |
| 89 | + { |
| 90 | + accessorKey: 'city', |
| 91 | + header: 'City', |
| 92 | + size: 150, |
| 93 | + }, |
| 94 | + { |
| 95 | + accessorKey: 'state', |
| 96 | + header: 'State', |
| 97 | + size: 150, |
| 98 | + }, |
| 99 | +]; |
| 100 | + |
| 101 | + |
| 102 | +export const FullscreenIsAboveAppbar = () => { |
| 103 | + |
| 104 | + |
| 105 | + const table = useMaterialReactTable({ |
| 106 | + columns, |
| 107 | + data, //data must be memoized or stable (useState, useMemo, defined outside of this component, etc.) |
| 108 | + }); |
| 109 | + |
| 110 | + return <> |
| 111 | + <CssBaseline /> |
| 112 | + <AppBar position="sticky"> |
| 113 | + <Toolbar> |
| 114 | + <p>App</p> |
| 115 | + </Toolbar> |
| 116 | + </AppBar> |
| 117 | + <Box padding={2}> |
| 118 | + <MaterialReactTable table={table} /> |
| 119 | + </Box> |
| 120 | + </>; |
| 121 | +}; |
| 122 | + |
0 commit comments