'use client'; import { type MRTColumnDef, MantineReactTable } from…
- User
'use client';
import { type MRT_ColumnDef, MantineReactTable } from 'mantine-react-table'; import { faker } from '@faker-js/faker'; import { type Meta } from '@storybook/react'; import React from 'react';
const meta: Meta = { title: 'MantineReactTable/Tables', };
export default meta;
const columns: MRT_ColumnDef<(typeof data)[0]>[] = [ { accessorKey: 'firstName', header: 'First Name', }, { accessorKey: 'lastName', header: 'Last Name', }, { accessorKey: 'address', header: 'Address', }, { accessorKey: 'state', header: 'State', }, { accessorKey: 'phoneNumber', header: 'Phone Number', }, ];
const data = [...Array(100)].map(() => ({ address: faker.location.streetAddress(), firstName: faker.person.firstName(), lastName: faker.person.lastName(), phoneNumber: faker.phone.number(), state: faker.location.state(), }));
export const DefaultSemantic = () => ( );
export const Grid = () => ( );
export const GridWithResizing = () => ( <MantineReactTable columns={columns} data={data} enableColumnOrdering enableColumnResizing enableRowSelection layoutMode="grid" initialState={{ pagination: { pageSize: 5, pageIndex: 0 } }} mantinePaginationProps={{ rowsPerPageOptions: ['5', '10', '20'], withEdges: false, }} /> );
import { Metadata } from 'next'; import { Grid } from '@/components/MantineReactTable/MantineReactTable.stories';
export const metadata: Metadata = { title: 'Topology Page' };
export default function Page() { return ( Topology Page ) }
как в компонент Grid прокидывать данные со страницы Topology
- Assistant
To pass data from the "Topology Page" into the
Gridcomponent, you need to adjust your code structure to make the components more dynamic and able to receive data as props. Here's how you can modify your setup to achieve this:- Modify the
GridComponent: Ensure that yourGridcomponent inMantineReactTable.stories.tsxcan receive data through props rather than using thedataarray that's hardcoded inside it.
- Modify the
- User
Binding element 'tableData' implicitly has an 'any' type.
- Assistant
- User
import type { StoryObj } from '@storybook/react';
import Buttons from './Buttons'; import { IconNotebook } from '@tabler/icons-react'; import React from 'react';
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export const meta = { title: 'Mantine/Buttons/Button', component: Buttons, parameters: { // Optional parameter to center the component in the Canvas. More info: layout: 'centered', }, // This component will have an automatically generated Autodocs entry: tags: ['autodocs'], argTypes: { variant: { options: [ 'filled', 'outline', 'subtle', 'transparent', 'white', 'light', 'gradient', 'default', ], control: { type: 'select' }, }, size: { options: [ 'xl', 'lg', 'md', 'sm', 'xs', 'compact-xl', 'compact-lg', 'compact-md', 'compact-sm', 'compact-xs', ], control: { type: 'select' }, }, radius: { options: ['xl', 'lg', 'md', 'sm', 'xs'], control: { type: 'inline-radio' }, }, disabled: { options: [true, false], control: { type: 'inline-radio' }, }, loading: { options: [true, false], control: { type: 'inline-radio' }, }, }, };
- Assistant
- User
import { Button, ButtonProps } from '@mantine/core'; import React from 'react';
type ButtonsProps = ButtonProps;
/**
- For more docs see - https://mantine.dev/core/button/
- @param others
- @constructor */ const Buttons = ({ ...others }: ButtonsProps) => { return ( <Button variant="filled" {...others}> {others.children || 'Button'} ); };
export default Buttons;
- Assistant
- User
- Assistant
- User
- Assistant