Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import type { Meta, StoryObj } from "@storybook/react";
import { useState } from "react";
import { Pagination } from "./pagination";
 
const meta: Meta<typeof Pagination> = {
  component: Pagination,
  title: "UI/Pagination",
  argTypes: {
    currentPage: { control: "number" },
    totalPages: { control: "number" },
    pageSize: { control: "number" },
    totalItems: { control: "number" },
    label: { control: "text" },
    allowInput: { control: "boolean" },
    allowRewind: { control: "boolean" },
    disabled: { control: "boolean" },
    alwaysVisible: { control: "boolean" },
    showLabel: { control: "boolean" },
    showPageSize: { control: "boolean" },
  },
};
 
export default meta;
type Story = StoryObj<typeof Pagination>;
 
export const Default: Story = {
  args: {
    currentPage: 1,
    totalPages: 10,
    pageSize: 20,
    totalItems: 200,
    label: "Items",
    allowInput: true,
    allowRewind: true,
    disabled: false,
    alwaysVisible: false,
    showLabel: true,
    showPageSize: true,
    pageSizeOptions: [10, 20, 50, 100],
  },
};
 
export const Interactive: Story = {
  render: (args) => {
    const [currentPage, setCurrentPage] = useState(1);
    const [pageSize, setPageSize] = useState(20);
    const totalItems = 237;
    const totalPages = Math.ceil(totalItems / pageSize);
 
    return (
      <div className="flex flex-col gap-4">
        <div className="p-4 bg-neutral-surface rounded-md">
          <p className="text-sm text-neutral-content-subtle">
            Try navigating pages, changing page size, or clicking on the page number to edit it directly.
          </p>
        </div>
        <Pagination
          {...args}
          currentPage={currentPage}
          totalPages={totalPages}
          pageSize={pageSize}
          totalItems={totalItems}
          label="Members"
          onPageChange={setCurrentPage}
          onPageSizeChange={(newSize) => {
            setPageSize(newSize);
            setCurrentPage(1); // Reset to first page when changing page size
          }}
        />
      </div>
    );
  },
};
 
export const WithoutRewindButtons: Story = {
  args: {
    currentPage: 5,
    totalPages: 10,
    pageSize: 20,
    totalItems: 200,
    label: "Projects",
    allowRewind: false,
  },
};
 
export const WithoutPageSizeSelector: Story = {
  args: {
    currentPage: 3,
    totalPages: 10,
    pageSize: 20,
    totalItems: 200,
    label: "Tasks",
    showPageSize: false,
  },
};
 
export const WithoutLabel: Story = {
  args: {
    currentPage: 2,
    totalPages: 10,
    pageSize: 20,
    totalItems: 200,
    showLabel: false,
  },
};
 
export const Disabled: Story = {
  args: {
    currentPage: 3,
    totalPages: 10,
    pageSize: 20,
    totalItems: 200,
    label: "Items",
    disabled: true,
  },
};
 
export const SinglePage: Story = {
  args: {
    currentPage: 1,
    totalPages: 1,
    pageSize: 20,
    totalItems: 15,
    label: "Items",
  },
};
 
export const AlwaysVisibleWithSinglePage: Story = {
  args: {
    currentPage: 1,
    totalPages: 1,
    pageSize: 20,
    totalItems: 15,
    label: "Items",
    alwaysVisible: true,
  },
};
 
export const LargeDataset: Story = {
  args: {
    currentPage: 1,
    totalPages: 500,
    pageSize: 50,
    totalItems: 25000,
    label: "Records",
    pageSizeOptions: [25, 50, 100, 250, 500],
  },
};
 
export const Minimal: Story = {
  args: {
    currentPage: 1,
    totalPages: 5,
    pageSize: 10,
    totalItems: 50,
    allowRewind: false,
    showLabel: false,
    showPageSize: false,
  },
};