rupoui 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -567,6 +567,109 @@ import { Tabs, Tab } from "rupoui";
|
|
|
567
567
|
- `isVertical`: Whether to render tabs vertically.
|
|
568
568
|
- `fullWidth`: Whether to take up the full width of the container.
|
|
569
569
|
|
|
570
|
+
### Pagination
|
|
571
|
+
|
|
572
|
+
A navigation component that allows users to navigate through pages of content with smooth animations.
|
|
573
|
+
|
|
574
|
+
```tsx
|
|
575
|
+
import { Pagination } from "rupoui";
|
|
576
|
+
|
|
577
|
+
// One-Liner API (Recommended)
|
|
578
|
+
<Pagination
|
|
579
|
+
page={currentPage}
|
|
580
|
+
totalPages={10}
|
|
581
|
+
onPageChange={setCurrentPage}
|
|
582
|
+
/>
|
|
583
|
+
|
|
584
|
+
// With variant and size
|
|
585
|
+
<Pagination
|
|
586
|
+
page={currentPage}
|
|
587
|
+
totalPages={20}
|
|
588
|
+
onPageChange={setCurrentPage}
|
|
589
|
+
variant="outline"
|
|
590
|
+
size="lg"
|
|
591
|
+
/>
|
|
592
|
+
|
|
593
|
+
// Uncontrolled mode
|
|
594
|
+
<Pagination
|
|
595
|
+
defaultPage={5}
|
|
596
|
+
totalPages={10}
|
|
597
|
+
onPageChange={(page) => console.log("Page:", page)}
|
|
598
|
+
variant="ghost"
|
|
599
|
+
/>
|
|
600
|
+
|
|
601
|
+
// Hide controls
|
|
602
|
+
<Pagination
|
|
603
|
+
defaultPage={3}
|
|
604
|
+
totalPages={10}
|
|
605
|
+
showPrevious={false}
|
|
606
|
+
showNext={false}
|
|
607
|
+
/>
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
**Advanced Composition:**
|
|
611
|
+
|
|
612
|
+
For full control over the pagination layout, use the composable API:
|
|
613
|
+
|
|
614
|
+
```tsx
|
|
615
|
+
import {
|
|
616
|
+
Pagination,
|
|
617
|
+
PaginationContent,
|
|
618
|
+
PaginationItem,
|
|
619
|
+
PaginationPrevious,
|
|
620
|
+
PaginationNext,
|
|
621
|
+
PaginationEllipsis,
|
|
622
|
+
usePagination,
|
|
623
|
+
} from "rupoui";
|
|
624
|
+
|
|
625
|
+
const MyPagination = () => {
|
|
626
|
+
const [page, setPage] = useState(1);
|
|
627
|
+
const range = usePagination({
|
|
628
|
+
totalPages: 20,
|
|
629
|
+
currentPage: page,
|
|
630
|
+
siblingCount: 2,
|
|
631
|
+
boundaryCount: 1,
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
return (
|
|
635
|
+
<Pagination page={page} totalPages={20} onPageChange={setPage}>
|
|
636
|
+
<PaginationContent>
|
|
637
|
+
<PaginationPrevious />
|
|
638
|
+
{range.map((item, index) =>
|
|
639
|
+
item === "ellipsis" ? (
|
|
640
|
+
<PaginationEllipsis key={`ellipsis-${index}`} />
|
|
641
|
+
) : (
|
|
642
|
+
<PaginationItem key={item} value={item} />
|
|
643
|
+
),
|
|
644
|
+
)}
|
|
645
|
+
<PaginationNext />
|
|
646
|
+
</PaginationContent>
|
|
647
|
+
</Pagination>
|
|
648
|
+
);
|
|
649
|
+
};
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
**Props:**
|
|
653
|
+
|
|
654
|
+
- `page` / `defaultPage`: Current page number (controlled/uncontrolled).
|
|
655
|
+
- `totalPages`: Total number of pages (required).
|
|
656
|
+
- `onPageChange`: Callback when the page changes.
|
|
657
|
+
- `variant`: `solid` (default), `outline`, `ghost`.
|
|
658
|
+
- `size`: `sm`, `md` (default), `lg`.
|
|
659
|
+
- `siblingCount`: Number of pages to show on each side of current page (default: `1`).
|
|
660
|
+
- `boundaryCount`: Number of pages to show at start and end (default: `1`).
|
|
661
|
+
- `showPrevious` / `showNext`: Whether to show navigation buttons (default: `true`).
|
|
662
|
+
- `disabled`: Whether pagination is disabled.
|
|
663
|
+
- `classNames`: Custom styles for component slots (`base`, `content`, `item`, `prev`, `next`, `ellipsis`).
|
|
664
|
+
|
|
665
|
+
**Features:**
|
|
666
|
+
|
|
667
|
+
- **One-Liner API**: Simple and intuitive for common use cases.
|
|
668
|
+
- **Composable**: Full control with advanced composition when needed.
|
|
669
|
+
- **Animated**: Smooth transitions using Framer Motion's `layoutId`.
|
|
670
|
+
- **Accessible**: Full keyboard navigation and ARIA support.
|
|
671
|
+
- **Customizable**: Multiple variants, sizes, and styling options.
|
|
672
|
+
|
|
570
673
|
## 🎨 Customization
|
|
571
674
|
|
|
572
675
|
### Global Configuration
|