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