import type { Meta, StoryObj } from "@storybook/react";
import {
AdminContext,
InfiniteList,
defaultI18nProvider,
Resource,
TextInput,
Datagrid,
TextField,
DateField,
useInfinitePaginationContext,
} from "react-admin";
import { generatorProp } from "@amplicode/storybook-extensions";
import { delayDataProvider } from "../../../dataProvider";
import { Box, Button } from "@mui/material";
const LoadMoreButton = () => {
const { hasNextPage, fetchNextPage, isFetchingNextPage } =
useInfinitePaginationContext();
return hasNextPage ? (
) : null;
};
const defaultDecorator = (Story: () => JSX.Element) => (
);
const meta = {
title: "Pages/Lists/InfiniteList",
component: InfiniteList as any,
decorators: [(Story) => defaultDecorator(Story)],
args: {},
argTypes: {
perPage: {
control: "select",
description: "Items per page",
options: [5, 10, 20],
},
filters: generatorProp({
description: "The filters to display in the toolbar.",
generatorId: "amplicode.reactAdmin.filtersGenerator",
hideInStoryBook: true,
defaultValue: [],
}),
disableAuthentication: {
control: "boolean",
},
disableSyncWithLocation: {
control: "boolean",
},
sort: {
control: "text",
},
filter: {
control: "text",
},
queryOptions: {
control: "text",
},
pagination: {
control: "select",
options: ["default", "LoadMoreButton"],
mapping: {
default: undefined,
LoadMoreButton: ,
},
},
},
} satisfies Meta;
export default meta;
type Story = StoryObj;
export const Default: Story = {
render: ({ ...props }) => {
return (
);
},
};
const Test = () => {
return Test
}
export const LoadMore: Story = {
render: ({ ...props }) => {
const LoadMoreButton = () => {
const { hasNextPage, fetchNextPage, isFetchingNextPage } =
useInfinitePaginationContext();
return hasNextPage ? (
) : null;
};
return (
}>
);
},
};