import type { Meta, StoryObj } from '@storybook/react' import { useState } from 'react' import { Typography } from '../Typography' import { Pagination } from './Pagination' import { PaginationControls } from './PaginationControls' import { PaginationDisplay } from './PaginationDisplay' const meta: Meta = { title: 'Blocks/Pagination', component: Pagination, parameters: { layout: 'padded', docs: { source: { type: 'code' }, }, }, argTypes: { pageControlMode: { control: { type: 'select' }, options: ['select', 'display'], table: { type: { summary: 'select | display' }, defaultValue: { summary: 'select' }, }, }, totalCount: { control: 'number', description: 'Total number of records. When absent, "of X" is hidden and the page control falls back to a static label.', }, currentPageCount: { control: 'number', description: 'Number of records in the current page. Useful when totalCount is unknown.', }, canNextPage: { control: 'boolean', description: 'Controls the next button when totalCount is absent. Mirrors TanStack table.getCanNextPage().', }, isLoading: { control: 'boolean', description: 'Disables pagination interactions while data is loading.', }, pageSize: { control: 'number', }, onPageChange: { control: false }, className: { control: false }, }, } export default meta type Story = StoryObj export const Default: Story = { render: (args) => { function DefaultStory() { const [pageIndex, setPageIndex] = useState(0) return ( ) } return }, } export const DisplayMode: Story = { render: (args) => { function DisplayModeStory() { const [pageIndex, setPageIndex] = useState(0) return ( ) } return }, } export const WithoutTotal: Story = { render: (args) => { function WithoutTotalStory() { const [pageIndex, setPageIndex] = useState(0) const canNextPage = pageIndex < 4 // e.g. from data?.has_more when totalCount unknown const currentPageCount = pageIndex < 4 ? 10 : 7 return ( ) } return }, } export const DisplayOnly: Story = { render: () => ( ), } export const ControlsOnlyDisplay: Story = { render: (args) => { function ControlsOnlyDisplayStory() { const [pageIndex, setPageIndex] = useState(0) return ( ) } return }, } export const ControlsOnlySelect: Story = { render: (args) => { function ControlsOnlySelectStory() { const [pageIndex, setPageIndex] = useState(0) return ( ) } return }, } export const Comparisons: Story = { render: (args) => { function ComparisonsStory() { const [defaultPageIndex, setDefaultPageIndex] = useState(0) const [displayModePageIndex, setDisplayModePageIndex] = useState(0) const [withoutTotalPageIndex, setWithoutTotalPageIndex] = useState(0) const withoutTotalCanNextPage = withoutTotalPageIndex < 4 const withoutTotalCurrentPageCount = withoutTotalPageIndex < 4 ? 10 : 7 return (
Default
Page Control in Display Mode
No Total (Page Control in Display Mode)
Loading
) } return }, }