aural-ui 2.0.0
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/LICENSE +21 -0
- package/README.md +456 -0
- package/dist/components/aspect-ratio/AspectRatio.stories.tsx +1327 -0
- package/dist/components/aspect-ratio/index.tsx +10 -0
- package/dist/components/aspect-ratio/meta.ts +8 -0
- package/dist/components/avatar/Avatar.stories.tsx +645 -0
- package/dist/components/avatar/index.tsx +50 -0
- package/dist/components/avatar/meta.ts +8 -0
- package/dist/components/badge/Badge.stories.tsx +169 -0
- package/dist/components/badge/index.tsx +28 -0
- package/dist/components/badge/meta.ts +6 -0
- package/dist/components/banner/Banner.stories.tsx +475 -0
- package/dist/components/banner/index.tsx +256 -0
- package/dist/components/banner/meta.ts +36 -0
- package/dist/components/button/Button.stories.tsx +74 -0
- package/dist/components/button/index.tsx +158 -0
- package/dist/components/button/meta.ts +33 -0
- package/dist/components/card/Card.stories.tsx +377 -0
- package/dist/components/card/index.tsx +85 -0
- package/dist/components/card/meta.ts +14 -0
- package/dist/components/char-count/CharCount.stories.tsx +334 -0
- package/dist/components/char-count/index.tsx +51 -0
- package/dist/components/char-count/meta.ts +13 -0
- package/dist/components/checkbox/Checkbox.stories.tsx +209 -0
- package/dist/components/checkbox/index.tsx +34 -0
- package/dist/components/checkbox/meta.ts +19 -0
- package/dist/components/chip/Chip.stories.tsx +207 -0
- package/dist/components/chip/index.tsx +92 -0
- package/dist/components/chip/meta.ts +17 -0
- package/dist/components/circular-loader/CircularLoader.stories.tsx +741 -0
- package/dist/components/circular-loader/index.tsx +138 -0
- package/dist/components/circular-loader/meta.ts +11 -0
- package/dist/components/collapsible/Collapsible.stories.tsx +319 -0
- package/dist/components/collapsible/index.tsx +158 -0
- package/dist/components/collapsible/meta.ts +22 -0
- package/dist/components/command/Command.stories.tsx +996 -0
- package/dist/components/command/index.tsx +324 -0
- package/dist/components/command/meta.ts +18 -0
- package/dist/components/dialog/Dialog.stories.tsx +963 -0
- package/dist/components/dialog/index.tsx +250 -0
- package/dist/components/dialog/meta.ts +28 -0
- package/dist/components/divider/Divider.stories.tsx +633 -0
- package/dist/components/divider/index.tsx +181 -0
- package/dist/components/divider/meta.ts +12 -0
- package/dist/components/dot-loader/DotLoader.stories.tsx +352 -0
- package/dist/components/dot-loader/index.tsx +78 -0
- package/dist/components/dot-loader/meta.ts +14 -0
- package/dist/components/dropdown/Dropdown.stories.tsx +1210 -0
- package/dist/components/dropdown/index.tsx +479 -0
- package/dist/components/dropdown/meta.ts +21 -0
- package/dist/components/form/Form.stories.tsx +320 -0
- package/dist/components/form/index.tsx +183 -0
- package/dist/components/form/meta.ts +11 -0
- package/dist/components/helper-text/HelperText.stories.tsx +254 -0
- package/dist/components/helper-text/index.tsx +102 -0
- package/dist/components/helper-text/meta.ts +18 -0
- package/dist/components/hover-card/HoverCard.stories.tsx +1328 -0
- package/dist/components/hover-card/index.tsx +42 -0
- package/dist/components/hover-card/meta.ts +12 -0
- package/dist/components/icon-button/IconButton.stories.tsx +252 -0
- package/dist/components/icon-button/index.tsx +130 -0
- package/dist/components/icon-button/meta.ts +20 -0
- package/dist/components/if-else/if-else.stories.tsx +100 -0
- package/dist/components/if-else/index.tsx +56 -0
- package/dist/components/if-else/meta.ts +6 -0
- package/dist/components/index.ts +70 -0
- package/dist/components/input/Input.stories.tsx +431 -0
- package/dist/components/input/index.tsx +487 -0
- package/dist/components/input/meta.ts +28 -0
- package/dist/components/label/Label.stories.tsx +200 -0
- package/dist/components/label/index.tsx +43 -0
- package/dist/components/label/meta.ts +14 -0
- package/dist/components/list/List.stories.tsx +963 -0
- package/dist/components/list/index.tsx +567 -0
- package/dist/components/list/meta.ts +24 -0
- package/dist/components/marquee/Marquee.stories.tsx +819 -0
- package/dist/components/marquee/index.tsx +107 -0
- package/dist/components/marquee/meta.ts +6 -0
- package/dist/components/overlay/Overlay.stories.tsx +954 -0
- package/dist/components/overlay/index.tsx +58 -0
- package/dist/components/overlay/meta.ts +10 -0
- package/dist/components/pagination/Pagination.stories.tsx +354 -0
- package/dist/components/pagination/index.tsx +455 -0
- package/dist/components/pagination/meta.ts +29 -0
- package/dist/components/popover/Popover.stories.tsx +1037 -0
- package/dist/components/popover/index.tsx +67 -0
- package/dist/components/popover/meta.ts +12 -0
- package/dist/components/radio/Radio.stories.tsx +146 -0
- package/dist/components/radio/index.tsx +41 -0
- package/dist/components/radio/meta.ts +19 -0
- package/dist/components/resizable/Resizable.stories.tsx +866 -0
- package/dist/components/resizable/index.tsx +55 -0
- package/dist/components/resizable/meta.ts +12 -0
- package/dist/components/scroll-area/ScrollArea.stories.tsx +1104 -0
- package/dist/components/scroll-area/index.tsx +55 -0
- package/dist/components/scroll-area/meta.ts +8 -0
- package/dist/components/search/Search.stories.tsx +678 -0
- package/dist/components/search/index.tsx +141 -0
- package/dist/components/search/meta.ts +6 -0
- package/dist/components/select/Select.stories.tsx +962 -0
- package/dist/components/select/index.tsx +512 -0
- package/dist/components/select/meta.ts +40 -0
- package/dist/components/sheet/Sheet.stories.tsx +1060 -0
- package/dist/components/sheet/index.tsx +440 -0
- package/dist/components/sheet/meta.ts +38 -0
- package/dist/components/skelton/Skelton.stories.tsx +859 -0
- package/dist/components/skelton/index.tsx +17 -0
- package/dist/components/skelton/meta.ts +6 -0
- package/dist/components/slider/Slider.stories.tsx +876 -0
- package/dist/components/slider/index.tsx +156 -0
- package/dist/components/slider/meta.ts +29 -0
- package/dist/components/stepper/Stepper.stories.tsx +639 -0
- package/dist/components/stepper/index.tsx +650 -0
- package/dist/components/stepper/meta.ts +19 -0
- package/dist/components/switch/Switch.stories.tsx +85 -0
- package/dist/components/switch/index.tsx +37 -0
- package/dist/components/switch/meta.ts +24 -0
- package/dist/components/switch-case/SwitchCase.stories.tsx +209 -0
- package/dist/components/switch-case/index.tsx +89 -0
- package/dist/components/switch-case/meta.ts +6 -0
- package/dist/components/table/Table.stories.tsx +1095 -0
- package/dist/components/table/index.tsx +113 -0
- package/dist/components/table/meta.ts +20 -0
- package/dist/components/tabs/Tabs.stories.tsx +1379 -0
- package/dist/components/tabs/index.tsx +186 -0
- package/dist/components/tabs/meta.ts +25 -0
- package/dist/components/tag/Tag.stories.tsx +625 -0
- package/dist/components/tag/index.tsx +320 -0
- package/dist/components/tag/meta.ts +52 -0
- package/dist/components/textarea/TextArea.stories.tsx +723 -0
- package/dist/components/textarea/index.tsx +480 -0
- package/dist/components/textarea/meta.ts +23 -0
- package/dist/components/toast/Toast.stories.tsx +1427 -0
- package/dist/components/toast/index.tsx +26 -0
- package/dist/components/toast/meta.ts +19 -0
- package/dist/components/toggle/Toggle.stories.tsx +1093 -0
- package/dist/components/toggle/index.tsx +44 -0
- package/dist/components/toggle/meta.ts +19 -0
- package/dist/components/tooltip/Tooltip.stories.tsx +1548 -0
- package/dist/components/tooltip/index.tsx +304 -0
- package/dist/components/tooltip/meta.ts +21 -0
- package/dist/components/typography/Typography.stories.tsx +197 -0
- package/dist/components/typography/index.tsx +184 -0
- package/dist/components/typography/meta.ts +38 -0
- package/dist/fonts/LabGrotesque-Regular.ttf +0 -0
- package/dist/fonts/LabGrotesqueTRIAL-Bold.otf +0 -0
- package/dist/fonts/LabGrotesqueTRIAL-Light.otf +0 -0
- package/dist/fonts/LabGrotesqueTRIAL-Medium.otf +0 -0
- package/dist/fonts/LabGrotesqueTRIAL-Regular.otf +0 -0
- package/dist/fonts/PPSupplySans-Regular (1).otf +0 -0
- package/dist/fonts/PPSupplySans-Regular.otf +0 -0
- package/dist/fonts/PPSupplySans-Ultralight.otf +0 -0
- package/dist/hooks/index.ts +3 -0
- package/dist/hooks/use-previous/UsePrevious.stories.tsx +997 -0
- package/dist/hooks/use-previous/index.ts +15 -0
- package/dist/hooks/use-previous/meta.ts +6 -0
- package/dist/hooks/use-standalone-pagination/UseStandalonePagination.stories.tsx +983 -0
- package/dist/hooks/use-standalone-pagination/index.ts +146 -0
- package/dist/hooks/use-standalone-pagination/meta.ts +6 -0
- package/dist/icons/Icons.stories.tsx +29 -0
- package/dist/icons/alert-icon/AlertIcon.stories.tsx +991 -0
- package/dist/icons/alert-icon/index.tsx +48 -0
- package/dist/icons/alert-icon/meta.ts +8 -0
- package/dist/icons/all-icons.tsx +738 -0
- package/dist/icons/angle-down-icon/AngleDownIcon.stories.tsx +1031 -0
- package/dist/icons/angle-down-icon/index.tsx +25 -0
- package/dist/icons/angle-down-icon/meta.ts +8 -0
- package/dist/icons/arrow-box-left-icon/ArrowBoxLeftIcon.stories.tsx +1080 -0
- package/dist/icons/arrow-box-left-icon/index.tsx +24 -0
- package/dist/icons/arrow-box-left-icon/meta.ts +8 -0
- package/dist/icons/arrow-right-icon/ArrowRightIcon.stories.tsx +1151 -0
- package/dist/icons/arrow-right-icon/index.tsx +26 -0
- package/dist/icons/arrow-right-icon/meta.ts +8 -0
- package/dist/icons/arrow-right-up-icon/ArrowRightUpIcon.stories.tsx +1273 -0
- package/dist/icons/arrow-right-up-icon/index.tsx +24 -0
- package/dist/icons/arrow-right-up-icon/meta.ts +8 -0
- package/dist/icons/art-board-icon/ArtBoardIcon.stories.tsx +670 -0
- package/dist/icons/art-board-icon/index.tsx +24 -0
- package/dist/icons/art-board-icon/meta.ts +7 -0
- package/dist/icons/audio-bar-icon/AudioBarIcon.stories.tsx +1244 -0
- package/dist/icons/audio-bar-icon/index.tsx +19 -0
- package/dist/icons/audio-bar-icon/meta.ts +8 -0
- package/dist/icons/bubble-check-icon/BubbleCheckIcon.stories.tsx +1239 -0
- package/dist/icons/bubble-check-icon/index.tsx +24 -0
- package/dist/icons/bubble-check-icon/meta.ts +8 -0
- package/dist/icons/bubble-crossed-icon/BubbleCrossedIcon.stories.tsx +1228 -0
- package/dist/icons/bubble-crossed-icon/index.tsx +24 -0
- package/dist/icons/bubble-crossed-icon/meta.ts +8 -0
- package/dist/icons/bubble-sparkle-icon/BubbleSparkleIcon.stories.tsx +912 -0
- package/dist/icons/bubble-sparkle-icon/index.tsx +26 -0
- package/dist/icons/bubble-sparkle-icon/meta.ts +8 -0
- package/dist/icons/chevron-double-left-icon/ChevronDoubleLeftIcon.stories.tsx +1021 -0
- package/dist/icons/chevron-double-left-icon/index.tsx +34 -0
- package/dist/icons/chevron-double-left-icon/meta.ts +8 -0
- package/dist/icons/chevron-double-right-icon/ChevronDoubleRightIcon.stories.tsx +1021 -0
- package/dist/icons/chevron-double-right-icon/index.tsx +34 -0
- package/dist/icons/chevron-double-right-icon/meta.ts +8 -0
- package/dist/icons/chevron-down-icon/ChevronDownIcon.stories.tsx +1001 -0
- package/dist/icons/chevron-down-icon/index.tsx +27 -0
- package/dist/icons/chevron-down-icon/meta.ts +8 -0
- package/dist/icons/chevron-left-icon/ChevronLeftIcon.stories.tsx +1029 -0
- package/dist/icons/chevron-left-icon/index.tsx +27 -0
- package/dist/icons/chevron-left-icon/meta.ts +8 -0
- package/dist/icons/chevron-right-icon/ChevronRightIcon.stories.tsx +1021 -0
- package/dist/icons/chevron-right-icon/index.tsx +27 -0
- package/dist/icons/chevron-right-icon/meta.ts +8 -0
- package/dist/icons/chevron-up-icon/ChevronUpIcon.stories.tsx +1036 -0
- package/dist/icons/chevron-up-icon/index.tsx +27 -0
- package/dist/icons/chevron-up-icon/meta.ts +8 -0
- package/dist/icons/command-icon/CommandIcon.stories.tsx +1098 -0
- package/dist/icons/command-icon/index.tsx +24 -0
- package/dist/icons/command-icon/meta.ts +8 -0
- package/dist/icons/cross-circle-icon/CrossCircleIcon.stories.tsx +1061 -0
- package/dist/icons/cross-circle-icon/index.tsx +23 -0
- package/dist/icons/cross-circle-icon/meta.ts +8 -0
- package/dist/icons/cross-icon/CrossIcon.stories.tsx +1027 -0
- package/dist/icons/cross-icon/index.tsx +24 -0
- package/dist/icons/cross-icon/meta.ts +8 -0
- package/dist/icons/edit-big-icon/EditBigIcon.stories.tsx +1092 -0
- package/dist/icons/edit-big-icon/index.tsx +22 -0
- package/dist/icons/edit-big-icon/meta.ts +8 -0
- package/dist/icons/eye-close-icon/EyeCloseIcon.stories.tsx +1090 -0
- package/dist/icons/eye-close-icon/index.tsx +26 -0
- package/dist/icons/eye-close-icon/meta.ts +8 -0
- package/dist/icons/eye-open-icon/EyeOpenIcon.stories.tsx +1098 -0
- package/dist/icons/eye-open-icon/index.tsx +24 -0
- package/dist/icons/eye-open-icon/meta.ts +8 -0
- package/dist/icons/feature-shine-icon/FeatureShineIcon.stories.tsx +1071 -0
- package/dist/icons/feature-shine-icon/index.tsx +29 -0
- package/dist/icons/feature-shine-icon/meta.ts +8 -0
- package/dist/icons/file-chart-icon/FileChartIcon.stories.tsx +1115 -0
- package/dist/icons/file-chart-icon/index.tsx +24 -0
- package/dist/icons/file-chart-icon/meta.ts +8 -0
- package/dist/icons/file-text-icon/FileTextIcon.stories.tsx +668 -0
- package/dist/icons/file-text-icon/index.tsx +24 -0
- package/dist/icons/file-text-icon/meta.ts +8 -0
- package/dist/icons/grip-vertical-icon/GripVerticalIcon.stories.tsx +1239 -0
- package/dist/icons/grip-vertical-icon/index.tsx +28 -0
- package/dist/icons/grip-vertical-icon/meta.ts +8 -0
- package/dist/icons/image-icon/ImageIcon.stories.tsx +1181 -0
- package/dist/icons/image-icon/index.tsx +24 -0
- package/dist/icons/image-icon/meta.ts +8 -0
- package/dist/icons/import-folder-icon/ImportFolderIcon.stories.tsx +1248 -0
- package/dist/icons/import-folder-icon/index.tsx +22 -0
- package/dist/icons/import-folder-icon/meta.ts +8 -0
- package/dist/icons/index.ts +46 -0
- package/dist/icons/light-bulb-simple-icon/LightBulbSimpleIcon.stories.tsx +1272 -0
- package/dist/icons/light-bulb-simple-icon/index.tsx +24 -0
- package/dist/icons/light-bulb-simple-icon/meta.ts +8 -0
- package/dist/icons/magic-book-icon/MagicBookIcon.stories.tsx +1245 -0
- package/dist/icons/magic-book-icon/index.tsx +32 -0
- package/dist/icons/magic-book-icon/meta.ts +8 -0
- package/dist/icons/maintenance-icon/MaintenanceIcon.stories.tsx +1251 -0
- package/dist/icons/maintenance-icon/index.tsx +23 -0
- package/dist/icons/maintenance-icon/meta.ts +8 -0
- package/dist/icons/message-icon/MessageIcon.stories.tsx +595 -0
- package/dist/icons/message-icon/index.tsx +30 -0
- package/dist/icons/message-icon/meta.ts +8 -0
- package/dist/icons/move-horizontal-icon/MoveHorizontalIcon.stories.tsx +1245 -0
- package/dist/icons/move-horizontal-icon/index.tsx +23 -0
- package/dist/icons/move-horizontal-icon/meta.ts +8 -0
- package/dist/icons/move-vertical-icon/MoveVerticalIcon.stories.tsx +1196 -0
- package/dist/icons/move-vertical-icon/index.tsx +23 -0
- package/dist/icons/move-vertical-icon/meta.ts +8 -0
- package/dist/icons/page-search-icon/PageSearchIcon.stories.tsx +1167 -0
- package/dist/icons/page-search-icon/index.tsx +21 -0
- package/dist/icons/page-search-icon/meta.ts +8 -0
- package/dist/icons/pencil-icon/PencilIcon.stories.tsx +1131 -0
- package/dist/icons/pencil-icon/index.tsx +21 -0
- package/dist/icons/pencil-icon/meta.ts +8 -0
- package/dist/icons/plus-icon/PlusIcon.stories.tsx +1151 -0
- package/dist/icons/plus-icon/index.tsx +24 -0
- package/dist/icons/plus-icon/meta.ts +8 -0
- package/dist/icons/search-icon/SearchIcon.stories.tsx +1181 -0
- package/dist/icons/search-icon/index.tsx +24 -0
- package/dist/icons/search-icon/meta.ts +8 -0
- package/dist/icons/site-logo-icon/SiteLogoIcon.stories.tsx +1167 -0
- package/dist/icons/site-logo-icon/index.tsx +79 -0
- package/dist/icons/site-logo-icon/meta.ts +8 -0
- package/dist/icons/spinner-gradient-icon/SpinnerGradientIcon.stories.tsx +637 -0
- package/dist/icons/spinner-gradient-icon/index.tsx +53 -0
- package/dist/icons/spinner-gradient-icon/meta.ts +8 -0
- package/dist/icons/spinner-solid-icon/SpinnerSolidIcon.stories.tsx +644 -0
- package/dist/icons/spinner-solid-icon/index.tsx +59 -0
- package/dist/icons/spinner-solid-icon/meta.ts +8 -0
- package/dist/icons/spinner-solid-neutral-icon/SpinnerSolidINeutralcon.stories.tsx +736 -0
- package/dist/icons/spinner-solid-neutral-icon/index.tsx +53 -0
- package/dist/icons/spinner-solid-neutral-icon/meta.ts +8 -0
- package/dist/icons/tick-circle-icon/TickCircleIcon.stories.tsx +1204 -0
- package/dist/icons/tick-circle-icon/index.tsx +23 -0
- package/dist/icons/tick-circle-icon/meta.ts +8 -0
- package/dist/icons/tick-icon/TickIcon.stories.tsx +1340 -0
- package/dist/icons/tick-icon/index.tsx +24 -0
- package/dist/icons/tick-icon/meta.ts +8 -0
- package/dist/icons/trash-icon/TrashIcon.stories.tsx +996 -0
- package/dist/icons/trash-icon/index.tsx +24 -0
- package/dist/icons/trash-icon/meta.ts +8 -0
- package/dist/icons/upload-icon/UploadIcon.stories.tsx +947 -0
- package/dist/icons/upload-icon/index.tsx +24 -0
- package/dist/icons/upload-icon/meta.ts +8 -0
- package/dist/icons/vertical-menu-icon/VerticalMenuIcon.stories.tsx +1045 -0
- package/dist/icons/vertical-menu-icon/index.tsx +27 -0
- package/dist/icons/vertical-menu-icon/meta.ts +8 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +206 -0
- package/dist/lib/utils.ts +6 -0
- package/dist/styles/aural-theme.css +1008 -0
- package/package.json +142 -0
|
@@ -0,0 +1,983 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
|
|
4
|
+
import { useStandalonePagination, UseStandalonePaginationProps } from "."
|
|
5
|
+
|
|
6
|
+
// Example component that uses the hook
|
|
7
|
+
const PaginationDemo: React.FC<
|
|
8
|
+
UseStandalonePaginationProps & { title?: string }
|
|
9
|
+
> = ({ title = "Pagination Demo", ...props }) => {
|
|
10
|
+
const {
|
|
11
|
+
currentPage,
|
|
12
|
+
totalPages,
|
|
13
|
+
pageSize,
|
|
14
|
+
totalItems,
|
|
15
|
+
setPage,
|
|
16
|
+
nextPage,
|
|
17
|
+
prevPage,
|
|
18
|
+
firstPage,
|
|
19
|
+
lastPage,
|
|
20
|
+
setPageSize,
|
|
21
|
+
isFirstPage,
|
|
22
|
+
isLastPage,
|
|
23
|
+
visiblePages,
|
|
24
|
+
} = useStandalonePagination(props)
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className="!space-y-6 rounded-lg border border-white/10 bg-white/5 !p-6">
|
|
28
|
+
<div className="!space-y-4">
|
|
29
|
+
<h3 className="!text-xl font-semibold !text-white">{title}</h3>
|
|
30
|
+
|
|
31
|
+
{/* Current State Display */}
|
|
32
|
+
<div className="grid grid-cols-2 gap-4 md:grid-cols-4">
|
|
33
|
+
<div className="rounded-lg border border-blue-500/20 bg-blue-500/10 !p-3">
|
|
34
|
+
<div className="!text-sm !text-blue-300">Current Page</div>
|
|
35
|
+
<div className="!text-2xl font-bold !text-blue-100">
|
|
36
|
+
{currentPage}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<div className="rounded-lg border border-purple-500/20 bg-purple-500/10 !p-3">
|
|
40
|
+
<div className="!text-sm !text-purple-300">Total Pages</div>
|
|
41
|
+
<div className="!text-2xl font-bold !text-purple-100">
|
|
42
|
+
{totalPages}
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<div className="rounded-lg border border-green-500/20 bg-green-500/10 !p-3">
|
|
46
|
+
<div className="!text-sm !text-green-300">Page Size</div>
|
|
47
|
+
<div className="!text-2xl font-bold !text-green-100">
|
|
48
|
+
{pageSize}
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
<div className="rounded-lg border border-orange-500/20 bg-orange-500/10 !p-3">
|
|
52
|
+
<div className="!text-sm !text-orange-300">Total Items</div>
|
|
53
|
+
<div className="!text-2xl font-bold !text-orange-100">
|
|
54
|
+
{totalItems}
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
{/* Page Size Controls */}
|
|
60
|
+
<div className="!space-y-2">
|
|
61
|
+
<label className="!text-sm font-medium !text-white">Page Size</label>
|
|
62
|
+
<div className="flex gap-2">
|
|
63
|
+
{[5, 10, 20, 50].map((size) => (
|
|
64
|
+
<button
|
|
65
|
+
key={size}
|
|
66
|
+
onClick={() => setPageSize(size)}
|
|
67
|
+
className={`rounded-lg !px-3 !py-1 !text-sm transition-colors ${
|
|
68
|
+
pageSize === size
|
|
69
|
+
? "bg-blue-500 !text-white"
|
|
70
|
+
: "border border-white/20 bg-white/5 !text-white/70 hover:bg-white/10"
|
|
71
|
+
}`}
|
|
72
|
+
>
|
|
73
|
+
{size}
|
|
74
|
+
</button>
|
|
75
|
+
))}
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
{/* Navigation Controls */}
|
|
80
|
+
<div className="!space-y-2">
|
|
81
|
+
<label className="!text-sm font-medium !text-white">
|
|
82
|
+
Navigation Controls
|
|
83
|
+
</label>
|
|
84
|
+
<div className="flex gap-2">
|
|
85
|
+
<button
|
|
86
|
+
onClick={firstPage}
|
|
87
|
+
disabled={isFirstPage}
|
|
88
|
+
className="rounded-lg border border-white/20 bg-white/5 !px-3 !py-2 !text-sm !text-white transition-colors hover:bg-white/10 disabled:cursor-not-allowed disabled:opacity-50"
|
|
89
|
+
>
|
|
90
|
+
First
|
|
91
|
+
</button>
|
|
92
|
+
<button
|
|
93
|
+
onClick={prevPage}
|
|
94
|
+
disabled={isFirstPage}
|
|
95
|
+
className="rounded-lg border border-white/20 bg-white/5 !px-3 !py-2 !text-sm !text-white transition-colors hover:bg-white/10 disabled:cursor-not-allowed disabled:opacity-50"
|
|
96
|
+
>
|
|
97
|
+
Previous
|
|
98
|
+
</button>
|
|
99
|
+
<button
|
|
100
|
+
onClick={nextPage}
|
|
101
|
+
disabled={isLastPage}
|
|
102
|
+
className="rounded-lg border border-white/20 bg-white/5 !px-3 !py-2 !text-sm !text-white transition-colors hover:bg-white/10 disabled:cursor-not-allowed disabled:opacity-50"
|
|
103
|
+
>
|
|
104
|
+
Next
|
|
105
|
+
</button>
|
|
106
|
+
<button
|
|
107
|
+
onClick={lastPage}
|
|
108
|
+
disabled={isLastPage}
|
|
109
|
+
className="rounded-lg border border-white/20 bg-white/5 !px-3 !py-2 !text-sm !text-white transition-colors hover:bg-white/10 disabled:cursor-not-allowed disabled:opacity-50"
|
|
110
|
+
>
|
|
111
|
+
Last
|
|
112
|
+
</button>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
{/* Visible Pages */}
|
|
117
|
+
<div className="!space-y-2">
|
|
118
|
+
<label className="!text-sm font-medium !text-white">
|
|
119
|
+
Visible Pages
|
|
120
|
+
</label>
|
|
121
|
+
<div className="flex flex-wrap gap-1">
|
|
122
|
+
{visiblePages.map((page, index) => (
|
|
123
|
+
<button
|
|
124
|
+
key={index}
|
|
125
|
+
onClick={() => page > 0 && setPage(page)}
|
|
126
|
+
disabled={page < 0}
|
|
127
|
+
className={`!h-10 !w-10 rounded-lg !text-sm transition-colors ${
|
|
128
|
+
page === currentPage
|
|
129
|
+
? "bg-blue-500 !text-white"
|
|
130
|
+
: page > 0
|
|
131
|
+
? "border border-white/20 bg-white/5 !text-white/70 hover:bg-white/10"
|
|
132
|
+
: "cursor-default !text-white/40"
|
|
133
|
+
}`}
|
|
134
|
+
>
|
|
135
|
+
{page > 0 ? page : "..."}
|
|
136
|
+
</button>
|
|
137
|
+
))}
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
{/* Direct Page Input */}
|
|
142
|
+
<div className="!space-y-2">
|
|
143
|
+
<label className="!text-sm font-medium !text-white">Go to Page</label>
|
|
144
|
+
<div className="flex gap-2">
|
|
145
|
+
<input
|
|
146
|
+
type="number"
|
|
147
|
+
min="1"
|
|
148
|
+
max={totalPages}
|
|
149
|
+
value={currentPage}
|
|
150
|
+
onChange={(e) => {
|
|
151
|
+
const page = parseInt(e.target.value)
|
|
152
|
+
if (!isNaN(page)) setPage(page)
|
|
153
|
+
}}
|
|
154
|
+
className="w-20 rounded-lg border border-white/20 bg-white/5 !px-3 !py-2 !text-sm !text-white placeholder-white/50"
|
|
155
|
+
/>
|
|
156
|
+
<span className="flex items-center !text-sm !text-white/60">
|
|
157
|
+
of {totalPages}
|
|
158
|
+
</span>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
{/* Status Information */}
|
|
163
|
+
<div className="rounded-lg border border-white/10 bg-black/20 !p-4">
|
|
164
|
+
<div className="!space-y-1 !text-sm">
|
|
165
|
+
<div className="!text-white/70">
|
|
166
|
+
<span className="font-medium !text-white">State:</span>{" "}
|
|
167
|
+
isFirstPage: {String(isFirstPage)}, isLastPage:{" "}
|
|
168
|
+
{String(isLastPage)}
|
|
169
|
+
</div>
|
|
170
|
+
<div className="!text-white/70">
|
|
171
|
+
<span className="font-medium !text-white">Items:</span> Showing{" "}
|
|
172
|
+
{(currentPage - 1) * pageSize + 1}-
|
|
173
|
+
{Math.min(currentPage * pageSize, totalItems)} of {totalItems}
|
|
174
|
+
</div>
|
|
175
|
+
<div className="!text-white/70">
|
|
176
|
+
<span className="font-medium !text-white">Pages:</span>{" "}
|
|
177
|
+
{currentPage} of {totalPages}
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const meta: Meta<typeof PaginationDemo> = {
|
|
187
|
+
title: "Hooks/useStandalonePagination",
|
|
188
|
+
component: PaginationDemo,
|
|
189
|
+
parameters: {
|
|
190
|
+
layout: "fullscreen",
|
|
191
|
+
backgrounds: {
|
|
192
|
+
default: "dark",
|
|
193
|
+
values: [
|
|
194
|
+
{ name: "dark", value: "#0a0a0a" },
|
|
195
|
+
{ name: "darker", value: "#000000" },
|
|
196
|
+
{ name: "light", value: "#ffffff" },
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
docs: {
|
|
200
|
+
page: () => (
|
|
201
|
+
<>
|
|
202
|
+
{/* Override default docs styling */}
|
|
203
|
+
<style>
|
|
204
|
+
{`
|
|
205
|
+
.sbdocs-wrapper {
|
|
206
|
+
padding: 0 !important;
|
|
207
|
+
max-width: none !important;
|
|
208
|
+
background: transparent !important;
|
|
209
|
+
}
|
|
210
|
+
.sbdocs-content {
|
|
211
|
+
max-width: none !important;
|
|
212
|
+
padding: 0 !important;
|
|
213
|
+
margin: 0 !important;
|
|
214
|
+
background: transparent !important;
|
|
215
|
+
}
|
|
216
|
+
.docs-story {
|
|
217
|
+
background: transparent !important;
|
|
218
|
+
}
|
|
219
|
+
.sbdocs {
|
|
220
|
+
background: transparent !important;
|
|
221
|
+
}
|
|
222
|
+
body {
|
|
223
|
+
background: #0a0a0a !important;
|
|
224
|
+
}
|
|
225
|
+
#storybook-docs {
|
|
226
|
+
background: #0a0a0a !important;
|
|
227
|
+
}
|
|
228
|
+
.sbdocs-preview {
|
|
229
|
+
background: transparent !important;
|
|
230
|
+
border: none !important;
|
|
231
|
+
}
|
|
232
|
+
.sbdocs-h1, .sbdocs-h2, .sbdocs-h3, .sbdocs-h4, .sbdocs-h5, .sbdocs-h6 {
|
|
233
|
+
color: white !important;
|
|
234
|
+
}
|
|
235
|
+
.sbdocs-p, .sbdocs-li {
|
|
236
|
+
color: rgba(255, 255, 255, 0.7) !important;
|
|
237
|
+
}
|
|
238
|
+
.sbdocs-code {
|
|
239
|
+
background: rgba(255, 255, 255, 0.1) !important;
|
|
240
|
+
color: rgba(168, 85, 247, 1) !important;
|
|
241
|
+
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
|
242
|
+
}
|
|
243
|
+
.sbdocs-pre {
|
|
244
|
+
background: rgba(0, 0, 0, 0.4) !important;
|
|
245
|
+
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
|
246
|
+
}
|
|
247
|
+
.sbdocs-table {
|
|
248
|
+
background: rgba(255, 255, 255, 0.05) !important;
|
|
249
|
+
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
|
250
|
+
}
|
|
251
|
+
.sbdocs-table th {
|
|
252
|
+
background: rgba(255, 255, 255, 0.05) !important;
|
|
253
|
+
color: white !important;
|
|
254
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
|
|
255
|
+
}
|
|
256
|
+
.sbdocs-table td {
|
|
257
|
+
color: rgba(255, 255, 255, 0.7) !important;
|
|
258
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
|
|
259
|
+
}
|
|
260
|
+
`}
|
|
261
|
+
</style>
|
|
262
|
+
|
|
263
|
+
<div className="min-h-screen bg-gradient-to-br from-gray-900 via-indigo-900/20 to-gray-900">
|
|
264
|
+
{/* Header */}
|
|
265
|
+
<div className="relative overflow-hidden border-b border-white/10 bg-black/20 backdrop-blur-xl">
|
|
266
|
+
<div className="absolute inset-0 bg-gradient-to-r from-indigo-500/10 via-transparent to-purple-500/10" />
|
|
267
|
+
<div className="relative !mx-auto max-w-7xl !px-6 !py-16">
|
|
268
|
+
<div className="!space-y-6 text-center">
|
|
269
|
+
<div className="!mx-auto flex !h-24 !w-24 items-center justify-center rounded-2xl border border-indigo-500/30 bg-gradient-to-br from-indigo-500/20 to-purple-500/20">
|
|
270
|
+
<span className="!text-4xl">📄</span>
|
|
271
|
+
</div>
|
|
272
|
+
<h1 className="!text-fm-primary !text-5xl font-bold">
|
|
273
|
+
useStandalonePagination
|
|
274
|
+
</h1>
|
|
275
|
+
<p className="!mx-auto max-w-3xl !text-xl leading-relaxed !text-white/70">
|
|
276
|
+
A comprehensive React hook for managing pagination state
|
|
277
|
+
without external data dependencies. Perfect for client-side
|
|
278
|
+
pagination, API integration, and complex data navigation
|
|
279
|
+
scenarios.
|
|
280
|
+
</p>
|
|
281
|
+
|
|
282
|
+
{/* Stats */}
|
|
283
|
+
<div className="flex items-center justify-center gap-8 !pt-8">
|
|
284
|
+
<div className="text-center">
|
|
285
|
+
<div className="!text-3xl font-bold !text-indigo-300">
|
|
286
|
+
Stateful
|
|
287
|
+
</div>
|
|
288
|
+
<div className="!text-sm !text-white/60">
|
|
289
|
+
Complete state management
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
<div className="!h-8 !w-px bg-white/20" />
|
|
293
|
+
<div className="text-center">
|
|
294
|
+
<div className="!text-3xl font-bold !text-purple-300">
|
|
295
|
+
Flexible
|
|
296
|
+
</div>
|
|
297
|
+
<div className="!text-sm !text-white/60">
|
|
298
|
+
Configurable page sizes
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
<div className="!h-8 !w-px bg-white/20" />
|
|
302
|
+
<div className="text-center">
|
|
303
|
+
<div className="!text-3xl font-bold !text-cyan-300">
|
|
304
|
+
Smart
|
|
305
|
+
</div>
|
|
306
|
+
<div className="!text-sm !text-white/60">
|
|
307
|
+
Intelligent page calculation
|
|
308
|
+
</div>
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
</div>
|
|
312
|
+
</div>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
{/* Content */}
|
|
316
|
+
<div className="!mx-auto max-w-7xl !space-y-16 !px-6 !py-12">
|
|
317
|
+
{/* Quick Usage */}
|
|
318
|
+
<div className="!space-y-8">
|
|
319
|
+
<h2 className="text-center !text-3xl font-bold !text-white">
|
|
320
|
+
Quick Start
|
|
321
|
+
</h2>
|
|
322
|
+
<div className="grid grid-cols-1 gap-8 lg:grid-cols-2">
|
|
323
|
+
<div className="!space-y-4">
|
|
324
|
+
<h3 className="!text-xl font-semibold !text-indigo-300">
|
|
325
|
+
Basic Usage
|
|
326
|
+
</h3>
|
|
327
|
+
<div className="rounded-lg bg-black/40 !p-4">
|
|
328
|
+
<pre className="overflow-x-auto !text-sm !text-green-300">
|
|
329
|
+
{`import { useStandalonePagination } from "@hooks/use-standalone-pagination"
|
|
330
|
+
|
|
331
|
+
function MyComponent() {
|
|
332
|
+
const {
|
|
333
|
+
currentPage,
|
|
334
|
+
totalPages,
|
|
335
|
+
setPage,
|
|
336
|
+
nextPage,
|
|
337
|
+
prevPage,
|
|
338
|
+
visiblePages,
|
|
339
|
+
isFirstPage,
|
|
340
|
+
isLastPage
|
|
341
|
+
} = useStandalonePagination({
|
|
342
|
+
totalItems: 1000,
|
|
343
|
+
initialPageSize: 10,
|
|
344
|
+
siblingCount: 1
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
return (
|
|
348
|
+
<div>
|
|
349
|
+
<div>Page {currentPage} of {totalPages}</div>
|
|
350
|
+
<div>
|
|
351
|
+
{visiblePages.map(page => (
|
|
352
|
+
<button
|
|
353
|
+
key={page}
|
|
354
|
+
onClick={() => page > 0 && setPage(page)}
|
|
355
|
+
disabled={page < 0}
|
|
356
|
+
>
|
|
357
|
+
{page > 0 ? page : "..."}
|
|
358
|
+
</button>
|
|
359
|
+
))}
|
|
360
|
+
</div>
|
|
361
|
+
</div>
|
|
362
|
+
)
|
|
363
|
+
}`}
|
|
364
|
+
</pre>
|
|
365
|
+
</div>
|
|
366
|
+
</div>
|
|
367
|
+
|
|
368
|
+
<div className="!space-y-4">
|
|
369
|
+
<h3 className="!text-xl font-semibold !text-indigo-300">
|
|
370
|
+
Hook Properties
|
|
371
|
+
</h3>
|
|
372
|
+
<div className="!space-y-3 rounded-lg border border-white/10 bg-white/5 !p-4">
|
|
373
|
+
<div className="flex justify-between">
|
|
374
|
+
<span className="!text-sm !text-white/70">
|
|
375
|
+
Total Items:
|
|
376
|
+
</span>
|
|
377
|
+
<span className="!text-sm font-medium !text-white">
|
|
378
|
+
Configurable
|
|
379
|
+
</span>
|
|
380
|
+
</div>
|
|
381
|
+
<div className="flex justify-between">
|
|
382
|
+
<span className="!text-sm !text-white/70">
|
|
383
|
+
Page Size:
|
|
384
|
+
</span>
|
|
385
|
+
<span className="!text-sm font-medium !text-white">
|
|
386
|
+
Dynamic
|
|
387
|
+
</span>
|
|
388
|
+
</div>
|
|
389
|
+
<div className="flex justify-between">
|
|
390
|
+
<span className="!text-sm !text-white/70">
|
|
391
|
+
Sibling Count:
|
|
392
|
+
</span>
|
|
393
|
+
<span className="!text-sm font-medium !text-white">
|
|
394
|
+
Customizable
|
|
395
|
+
</span>
|
|
396
|
+
</div>
|
|
397
|
+
<div className="flex justify-between">
|
|
398
|
+
<span className="!text-sm !text-white/70">
|
|
399
|
+
Navigation:
|
|
400
|
+
</span>
|
|
401
|
+
<span className="!text-sm font-medium !text-white">
|
|
402
|
+
Built-in
|
|
403
|
+
</span>
|
|
404
|
+
</div>
|
|
405
|
+
</div>
|
|
406
|
+
</div>
|
|
407
|
+
</div>
|
|
408
|
+
</div>
|
|
409
|
+
|
|
410
|
+
{/* Props Documentation */}
|
|
411
|
+
<div className="!space-y-8">
|
|
412
|
+
<h2 className="text-center !text-3xl font-bold !text-white">
|
|
413
|
+
Props & Configuration
|
|
414
|
+
</h2>
|
|
415
|
+
|
|
416
|
+
<div className="overflow-hidden rounded-lg border border-white/10 bg-white/5">
|
|
417
|
+
<div className="bg-white/5 !p-4">
|
|
418
|
+
<h3 className="!text-xl font-semibold !text-white">
|
|
419
|
+
Input Props
|
|
420
|
+
</h3>
|
|
421
|
+
</div>
|
|
422
|
+
<table className="!my-0 w-full">
|
|
423
|
+
<thead className="bg-white/5">
|
|
424
|
+
<tr className="border-b border-white/10">
|
|
425
|
+
<th className="!px-6 !py-4 text-left !text-sm font-semibold !text-white">
|
|
426
|
+
Prop
|
|
427
|
+
</th>
|
|
428
|
+
<th className="!px-6 !py-4 text-left !text-sm font-semibold !text-white">
|
|
429
|
+
Type
|
|
430
|
+
</th>
|
|
431
|
+
<th className="!px-6 !py-4 text-left !text-sm font-semibold !text-white">
|
|
432
|
+
Default
|
|
433
|
+
</th>
|
|
434
|
+
<th className="!px-6 !py-4 text-left !text-sm font-semibold !text-white">
|
|
435
|
+
Description
|
|
436
|
+
</th>
|
|
437
|
+
</tr>
|
|
438
|
+
</thead>
|
|
439
|
+
<tbody>
|
|
440
|
+
<tr className="border-b border-white/5">
|
|
441
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
442
|
+
totalItems
|
|
443
|
+
</td>
|
|
444
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
445
|
+
number
|
|
446
|
+
</td>
|
|
447
|
+
<td className="!px-6 !py-4 !text-sm !text-white/50">
|
|
448
|
+
required
|
|
449
|
+
</td>
|
|
450
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
451
|
+
Total number of items to paginate
|
|
452
|
+
</td>
|
|
453
|
+
</tr>
|
|
454
|
+
<tr className="border-b border-white/5 !bg-black/10">
|
|
455
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
456
|
+
initialPage
|
|
457
|
+
</td>
|
|
458
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
459
|
+
number
|
|
460
|
+
</td>
|
|
461
|
+
<td className="!px-6 !py-4 !text-sm !text-white/50">
|
|
462
|
+
1
|
|
463
|
+
</td>
|
|
464
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
465
|
+
Starting page number
|
|
466
|
+
</td>
|
|
467
|
+
</tr>
|
|
468
|
+
<tr className="border-b border-white/5">
|
|
469
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
470
|
+
initialPageSize
|
|
471
|
+
</td>
|
|
472
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
473
|
+
number
|
|
474
|
+
</td>
|
|
475
|
+
<td className="!px-6 !py-4 !text-sm !text-white/50">
|
|
476
|
+
10
|
|
477
|
+
</td>
|
|
478
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
479
|
+
Number of items per page
|
|
480
|
+
</td>
|
|
481
|
+
</tr>
|
|
482
|
+
<tr className="!bg-black/10">
|
|
483
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
484
|
+
siblingCount
|
|
485
|
+
</td>
|
|
486
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
487
|
+
number
|
|
488
|
+
</td>
|
|
489
|
+
<td className="!px-6 !py-4 !text-sm !text-white/50">
|
|
490
|
+
1
|
|
491
|
+
</td>
|
|
492
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
493
|
+
Number of sibling pages to show around current page
|
|
494
|
+
</td>
|
|
495
|
+
</tr>
|
|
496
|
+
</tbody>
|
|
497
|
+
</table>
|
|
498
|
+
</div>
|
|
499
|
+
|
|
500
|
+
<div className="overflow-hidden rounded-lg border border-white/10 bg-white/5">
|
|
501
|
+
<div className="bg-white/5 !p-4">
|
|
502
|
+
<h3 className="!text-xl font-semibold !text-white">
|
|
503
|
+
Return Values
|
|
504
|
+
</h3>
|
|
505
|
+
</div>
|
|
506
|
+
<table className="!my-0 w-full">
|
|
507
|
+
<thead className="bg-white/5">
|
|
508
|
+
<tr className="border-b border-white/10">
|
|
509
|
+
<th className="!px-6 !py-4 text-left !text-sm font-semibold !text-white">
|
|
510
|
+
Property
|
|
511
|
+
</th>
|
|
512
|
+
<th className="!px-6 !py-4 text-left !text-sm font-semibold !text-white">
|
|
513
|
+
Type
|
|
514
|
+
</th>
|
|
515
|
+
<th className="!px-6 !py-4 text-left !text-sm font-semibold !text-white">
|
|
516
|
+
Description
|
|
517
|
+
</th>
|
|
518
|
+
</tr>
|
|
519
|
+
</thead>
|
|
520
|
+
<tbody>
|
|
521
|
+
<tr className="border-b border-white/5">
|
|
522
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
523
|
+
currentPage
|
|
524
|
+
</td>
|
|
525
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
526
|
+
number
|
|
527
|
+
</td>
|
|
528
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
529
|
+
Current active page number
|
|
530
|
+
</td>
|
|
531
|
+
</tr>
|
|
532
|
+
<tr className="border-b border-white/5 !bg-black/10">
|
|
533
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
534
|
+
totalPages
|
|
535
|
+
</td>
|
|
536
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
537
|
+
number
|
|
538
|
+
</td>
|
|
539
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
540
|
+
Total number of pages
|
|
541
|
+
</td>
|
|
542
|
+
</tr>
|
|
543
|
+
<tr className="border-b border-white/5">
|
|
544
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
545
|
+
setPage
|
|
546
|
+
</td>
|
|
547
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">{`(page: number) => void`}</td>
|
|
548
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
549
|
+
Navigate to specific page
|
|
550
|
+
</td>
|
|
551
|
+
</tr>
|
|
552
|
+
<tr className="border-b border-white/5 !bg-black/10">
|
|
553
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
554
|
+
nextPage
|
|
555
|
+
</td>
|
|
556
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">{`() => void`}</td>
|
|
557
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
558
|
+
Navigate to next page
|
|
559
|
+
</td>
|
|
560
|
+
</tr>
|
|
561
|
+
<tr className="border-b border-white/5">
|
|
562
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
563
|
+
prevPage
|
|
564
|
+
</td>
|
|
565
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">{`() => void`}</td>
|
|
566
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
567
|
+
Navigate to previous page
|
|
568
|
+
</td>
|
|
569
|
+
</tr>
|
|
570
|
+
<tr className="border-b border-white/5 !bg-black/10">
|
|
571
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
572
|
+
visiblePages
|
|
573
|
+
</td>
|
|
574
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
575
|
+
number[]
|
|
576
|
+
</td>
|
|
577
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
578
|
+
Array of page numbers to display (negative values
|
|
579
|
+
represent dots)
|
|
580
|
+
</td>
|
|
581
|
+
</tr>
|
|
582
|
+
<tr className="border-b border-white/5">
|
|
583
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
584
|
+
isFirstPage
|
|
585
|
+
</td>
|
|
586
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
587
|
+
boolean
|
|
588
|
+
</td>
|
|
589
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
590
|
+
Whether currently on first page
|
|
591
|
+
</td>
|
|
592
|
+
</tr>
|
|
593
|
+
<tr className="!bg-black/10">
|
|
594
|
+
<td className="!px-6 !py-4 font-mono !text-sm !text-indigo-300">
|
|
595
|
+
isLastPage
|
|
596
|
+
</td>
|
|
597
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
598
|
+
boolean
|
|
599
|
+
</td>
|
|
600
|
+
<td className="!px-6 !py-4 !text-sm !text-white/70">
|
|
601
|
+
Whether currently on last page
|
|
602
|
+
</td>
|
|
603
|
+
</tr>
|
|
604
|
+
</tbody>
|
|
605
|
+
</table>
|
|
606
|
+
</div>
|
|
607
|
+
</div>
|
|
608
|
+
|
|
609
|
+
{/* Features */}
|
|
610
|
+
<div className="!space-y-8">
|
|
611
|
+
<h2 className="text-center !text-3xl font-bold !text-white">
|
|
612
|
+
Key Features
|
|
613
|
+
</h2>
|
|
614
|
+
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
|
|
615
|
+
<div className="rounded-lg border border-white/10 bg-white/5 !p-6">
|
|
616
|
+
<div className="!mb-4 flex !h-12 !w-12 items-center justify-center rounded-lg bg-blue-500/20">
|
|
617
|
+
<span className="!text-2xl">🔄</span>
|
|
618
|
+
</div>
|
|
619
|
+
<h3 className="!mb-2 !text-lg font-semibold !text-white">
|
|
620
|
+
State Management
|
|
621
|
+
</h3>
|
|
622
|
+
<p className="!text-sm !text-white/70">
|
|
623
|
+
Complete pagination state with automatic page validation
|
|
624
|
+
and boundary checks.
|
|
625
|
+
</p>
|
|
626
|
+
</div>
|
|
627
|
+
|
|
628
|
+
<div className="rounded-lg border border-white/10 bg-white/5 !p-6">
|
|
629
|
+
<div className="!mb-4 flex !h-12 !w-12 items-center justify-center rounded-lg bg-green-500/20">
|
|
630
|
+
<span className="!text-2xl">📊</span>
|
|
631
|
+
</div>
|
|
632
|
+
<h3 className="!mb-2 !text-lg font-semibold !text-white">
|
|
633
|
+
Smart Pagination
|
|
634
|
+
</h3>
|
|
635
|
+
<p className="!text-sm !text-white/70">
|
|
636
|
+
Intelligent page number calculation with customizable
|
|
637
|
+
sibling count and ellipsis.
|
|
638
|
+
</p>
|
|
639
|
+
</div>
|
|
640
|
+
|
|
641
|
+
<div className="rounded-lg border border-white/10 bg-white/5 !p-6">
|
|
642
|
+
<div className="!mb-4 flex !h-12 !w-12 items-center justify-center rounded-lg bg-purple-500/20">
|
|
643
|
+
<span className="!text-2xl">⚙️</span>
|
|
644
|
+
</div>
|
|
645
|
+
<h3 className="!mb-2 !text-lg font-semibold !text-white">
|
|
646
|
+
Dynamic Page Size
|
|
647
|
+
</h3>
|
|
648
|
+
<p className="!text-sm !text-white/70">
|
|
649
|
+
Change page size on the fly with automatic page adjustment
|
|
650
|
+
to maintain context.
|
|
651
|
+
</p>
|
|
652
|
+
</div>
|
|
653
|
+
|
|
654
|
+
<div className="rounded-lg border border-white/10 bg-white/5 !p-6">
|
|
655
|
+
<div className="!mb-4 flex !h-12 !w-12 items-center justify-center rounded-lg bg-orange-500/20">
|
|
656
|
+
<span className="!text-2xl">🎯</span>
|
|
657
|
+
</div>
|
|
658
|
+
<h3 className="!mb-2 !text-lg font-semibold !text-white">
|
|
659
|
+
Navigation Methods
|
|
660
|
+
</h3>
|
|
661
|
+
<p className="!text-sm !text-white/70">
|
|
662
|
+
Multiple navigation options: next, previous, first, last,
|
|
663
|
+
and direct page selection.
|
|
664
|
+
</p>
|
|
665
|
+
</div>
|
|
666
|
+
|
|
667
|
+
<div className="rounded-lg border border-white/10 bg-white/5 !p-6">
|
|
668
|
+
<div className="!mb-4 flex !h-12 !w-12 items-center justify-center rounded-lg bg-cyan-500/20">
|
|
669
|
+
<span className="!text-2xl">🔍</span>
|
|
670
|
+
</div>
|
|
671
|
+
<h3 className="!mb-2 !text-lg font-semibold !text-white">
|
|
672
|
+
State Indicators
|
|
673
|
+
</h3>
|
|
674
|
+
<p className="!text-sm !text-white/70">
|
|
675
|
+
Built-in boolean flags for first/last page states and
|
|
676
|
+
comprehensive pagination info.
|
|
677
|
+
</p>
|
|
678
|
+
</div>
|
|
679
|
+
|
|
680
|
+
<div className="rounded-lg border border-white/10 bg-white/5 !p-6">
|
|
681
|
+
<div className="!mb-4 flex !h-12 !w-12 items-center justify-center rounded-lg bg-pink-500/20">
|
|
682
|
+
<span className="!text-2xl">⚡</span>
|
|
683
|
+
</div>
|
|
684
|
+
<h3 className="!mb-2 !text-lg font-semibold !text-white">
|
|
685
|
+
Performance Optimized
|
|
686
|
+
</h3>
|
|
687
|
+
<p className="!text-sm !text-white/70">
|
|
688
|
+
Memoized calculations and optimized re-renders for smooth
|
|
689
|
+
user experience.
|
|
690
|
+
</p>
|
|
691
|
+
</div>
|
|
692
|
+
</div>
|
|
693
|
+
</div>
|
|
694
|
+
|
|
695
|
+
{/* Usage Patterns */}
|
|
696
|
+
<div className="!space-y-8">
|
|
697
|
+
<h2 className="text-center !text-3xl font-bold !text-white">
|
|
698
|
+
Usage Patterns
|
|
699
|
+
</h2>
|
|
700
|
+
<div className="grid grid-cols-1 gap-8 lg:grid-cols-2">
|
|
701
|
+
<div className="!space-y-4">
|
|
702
|
+
<h3 className="!text-xl font-semibold !text-indigo-300">
|
|
703
|
+
Table Pagination
|
|
704
|
+
</h3>
|
|
705
|
+
<div className="rounded-lg bg-black/40 !p-4">
|
|
706
|
+
<pre className="overflow-x-auto !text-sm !text-green-300">
|
|
707
|
+
{`// Table with pagination
|
|
708
|
+
function DataTable({ data }) {
|
|
709
|
+
const {
|
|
710
|
+
currentPage,
|
|
711
|
+
pageSize,
|
|
712
|
+
setPage,
|
|
713
|
+
setPageSize,
|
|
714
|
+
visiblePages
|
|
715
|
+
} = useStandalonePagination({
|
|
716
|
+
totalItems: data.length,
|
|
717
|
+
initialPageSize: 10
|
|
718
|
+
})
|
|
719
|
+
|
|
720
|
+
const startIndex = (currentPage - 1) * pageSize
|
|
721
|
+
const paginatedData = data.slice(
|
|
722
|
+
startIndex,
|
|
723
|
+
startIndex + pageSize
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
return (
|
|
727
|
+
<div>
|
|
728
|
+
<table>
|
|
729
|
+
{paginatedData.map(item => (
|
|
730
|
+
<tr key={item.id}>
|
|
731
|
+
<td>{item.name}</td>
|
|
732
|
+
</tr>
|
|
733
|
+
))}
|
|
734
|
+
</table>
|
|
735
|
+
|
|
736
|
+
<PaginationControls
|
|
737
|
+
visiblePages={visiblePages}
|
|
738
|
+
onPageChange={setPage}
|
|
739
|
+
/>
|
|
740
|
+
</div>
|
|
741
|
+
)
|
|
742
|
+
}`}
|
|
743
|
+
</pre>
|
|
744
|
+
</div>
|
|
745
|
+
</div>
|
|
746
|
+
|
|
747
|
+
<div className="!space-y-4">
|
|
748
|
+
<h3 className="!text-xl font-semibold !text-indigo-300">
|
|
749
|
+
API Integration
|
|
750
|
+
</h3>
|
|
751
|
+
<div className="rounded-lg bg-black/40 !p-4">
|
|
752
|
+
<pre className="overflow-x-auto !text-sm !text-green-300">
|
|
753
|
+
{`// API with pagination
|
|
754
|
+
function ApiDataList() {
|
|
755
|
+
const [data, setData] = useState([])
|
|
756
|
+
const [totalItems, setTotalItems] = useState(0)
|
|
757
|
+
|
|
758
|
+
const pagination = useStandalonePagination({
|
|
759
|
+
totalItems,
|
|
760
|
+
initialPageSize: 20
|
|
761
|
+
})
|
|
762
|
+
|
|
763
|
+
useEffect(() => {
|
|
764
|
+
fetchData({
|
|
765
|
+
page: pagination.currentPage,
|
|
766
|
+
limit: pagination.pageSize
|
|
767
|
+
}).then(response => {
|
|
768
|
+
setData(response.data)
|
|
769
|
+
setTotalItems(response.total)
|
|
770
|
+
})
|
|
771
|
+
}, [pagination.currentPage, pagination.pageSize])
|
|
772
|
+
|
|
773
|
+
return (
|
|
774
|
+
<div>
|
|
775
|
+
<DataList items={data} />
|
|
776
|
+
<Pagination {...pagination} />
|
|
777
|
+
</div>
|
|
778
|
+
)
|
|
779
|
+
}`}
|
|
780
|
+
</pre>
|
|
781
|
+
</div>
|
|
782
|
+
</div>
|
|
783
|
+
</div>
|
|
784
|
+
</div>
|
|
785
|
+
</div>
|
|
786
|
+
|
|
787
|
+
{/* Footer */}
|
|
788
|
+
<div className="border-t border-white/10 bg-black/20 backdrop-blur-xl">
|
|
789
|
+
<div className="!mx-auto max-w-7xl !px-6 !py-8">
|
|
790
|
+
<div className="!space-y-4 text-center">
|
|
791
|
+
<p className="!text-white/60">
|
|
792
|
+
useStandalonePagination provides complete pagination logic
|
|
793
|
+
without external dependencies, making it perfect for any
|
|
794
|
+
data display scenario.
|
|
795
|
+
</p>
|
|
796
|
+
<p className="!text-sm !text-white/40">
|
|
797
|
+
Built with performance and developer experience in mind,
|
|
798
|
+
featuring TypeScript support and comprehensive state
|
|
799
|
+
management.
|
|
800
|
+
</p>
|
|
801
|
+
</div>
|
|
802
|
+
</div>
|
|
803
|
+
</div>
|
|
804
|
+
</div>
|
|
805
|
+
</>
|
|
806
|
+
),
|
|
807
|
+
},
|
|
808
|
+
},
|
|
809
|
+
tags: ["autodocs"],
|
|
810
|
+
argTypes: {
|
|
811
|
+
totalItems: {
|
|
812
|
+
control: { type: "number", min: 1, max: 10000, step: 1 },
|
|
813
|
+
description: "Total number of items to paginate",
|
|
814
|
+
},
|
|
815
|
+
initialPage: {
|
|
816
|
+
control: { type: "number", min: 1, max: 100, step: 1 },
|
|
817
|
+
description: "Starting page number",
|
|
818
|
+
},
|
|
819
|
+
initialPageSize: {
|
|
820
|
+
control: { type: "select", options: [5, 10, 20, 50, 100] },
|
|
821
|
+
description: "Number of items per page",
|
|
822
|
+
},
|
|
823
|
+
siblingCount: {
|
|
824
|
+
control: { type: "number", min: 0, max: 5, step: 1 },
|
|
825
|
+
description: "Number of sibling pages to show around current page",
|
|
826
|
+
},
|
|
827
|
+
title: {
|
|
828
|
+
control: "text",
|
|
829
|
+
description: "Title for the demo component",
|
|
830
|
+
},
|
|
831
|
+
},
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
export default meta
|
|
835
|
+
type Story = StoryObj<typeof PaginationDemo>
|
|
836
|
+
|
|
837
|
+
// Story parameters for consistent dark theme
|
|
838
|
+
const storyParameters = {
|
|
839
|
+
backgrounds: {
|
|
840
|
+
default: "dark",
|
|
841
|
+
values: [
|
|
842
|
+
{ name: "dark", value: "#0a0a0a" },
|
|
843
|
+
{ name: "darker", value: "#000000" },
|
|
844
|
+
],
|
|
845
|
+
},
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
export const Default: Story = {
|
|
849
|
+
args: {
|
|
850
|
+
totalItems: 100,
|
|
851
|
+
initialPage: 1,
|
|
852
|
+
initialPageSize: 10,
|
|
853
|
+
siblingCount: 1,
|
|
854
|
+
title: "Basic Pagination",
|
|
855
|
+
},
|
|
856
|
+
parameters: storyParameters,
|
|
857
|
+
render: (args) => (
|
|
858
|
+
<div className="min-h-dvh bg-gradient-to-br from-gray-900 to-gray-800 !p-8">
|
|
859
|
+
<PaginationDemo {...args} />
|
|
860
|
+
</div>
|
|
861
|
+
),
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
export const LargeDataset: Story = {
|
|
865
|
+
args: {
|
|
866
|
+
totalItems: 10000,
|
|
867
|
+
initialPage: 50,
|
|
868
|
+
initialPageSize: 20,
|
|
869
|
+
siblingCount: 2,
|
|
870
|
+
title: "Large Dataset Pagination",
|
|
871
|
+
},
|
|
872
|
+
parameters: {
|
|
873
|
+
...storyParameters,
|
|
874
|
+
docs: {
|
|
875
|
+
description: {
|
|
876
|
+
story:
|
|
877
|
+
"Pagination with a large dataset showing intelligent page number calculation.",
|
|
878
|
+
},
|
|
879
|
+
},
|
|
880
|
+
},
|
|
881
|
+
render: (args) => (
|
|
882
|
+
<div className="min-h-dvh bg-gradient-to-br from-gray-900 to-gray-800 !p-8">
|
|
883
|
+
<PaginationDemo {...args} />
|
|
884
|
+
</div>
|
|
885
|
+
),
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
export const SmallDataset: Story = {
|
|
889
|
+
args: {
|
|
890
|
+
totalItems: 25,
|
|
891
|
+
initialPage: 1,
|
|
892
|
+
initialPageSize: 5,
|
|
893
|
+
siblingCount: 1,
|
|
894
|
+
title: "Small Dataset Pagination",
|
|
895
|
+
},
|
|
896
|
+
parameters: {
|
|
897
|
+
...storyParameters,
|
|
898
|
+
docs: {
|
|
899
|
+
description: {
|
|
900
|
+
story: "Pagination with a small dataset where all pages are visible.",
|
|
901
|
+
},
|
|
902
|
+
},
|
|
903
|
+
},
|
|
904
|
+
render: (args) => (
|
|
905
|
+
<div className="min-h-dvh bg-gradient-to-br from-gray-900 to-gray-800 !p-8">
|
|
906
|
+
<PaginationDemo {...args} />
|
|
907
|
+
</div>
|
|
908
|
+
),
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
export const CustomSiblingCount: Story = {
|
|
912
|
+
args: {
|
|
913
|
+
totalItems: 1000,
|
|
914
|
+
initialPage: 25,
|
|
915
|
+
initialPageSize: 10,
|
|
916
|
+
siblingCount: 3,
|
|
917
|
+
title: "Custom Sibling Count",
|
|
918
|
+
},
|
|
919
|
+
parameters: {
|
|
920
|
+
...storyParameters,
|
|
921
|
+
docs: {
|
|
922
|
+
description: {
|
|
923
|
+
story:
|
|
924
|
+
"Pagination with increased sibling count showing more page numbers around current page.",
|
|
925
|
+
},
|
|
926
|
+
},
|
|
927
|
+
},
|
|
928
|
+
render: (args) => (
|
|
929
|
+
<div className="min-h-dvh bg-gradient-to-br from-gray-900 to-gray-800 !p-8">
|
|
930
|
+
<PaginationDemo {...args} />
|
|
931
|
+
</div>
|
|
932
|
+
),
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
export const InteractiveDemo: Story = {
|
|
936
|
+
args: {
|
|
937
|
+
totalItems: 500,
|
|
938
|
+
initialPage: 1,
|
|
939
|
+
initialPageSize: 10,
|
|
940
|
+
siblingCount: 1,
|
|
941
|
+
title: "Interactive Pagination Demo",
|
|
942
|
+
},
|
|
943
|
+
parameters: {
|
|
944
|
+
...storyParameters,
|
|
945
|
+
docs: {
|
|
946
|
+
description: {
|
|
947
|
+
story:
|
|
948
|
+
"Full interactive demo showing all features of the pagination hook with real-time state updates.",
|
|
949
|
+
},
|
|
950
|
+
},
|
|
951
|
+
},
|
|
952
|
+
render: (args) => (
|
|
953
|
+
<div className="min-h-dvh bg-gradient-to-br from-gray-900 to-gray-800 !p-8">
|
|
954
|
+
<div className="!space-y-8">
|
|
955
|
+
<PaginationDemo {...args} />
|
|
956
|
+
</div>
|
|
957
|
+
</div>
|
|
958
|
+
),
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
export const Playground: Story = {
|
|
962
|
+
parameters: {
|
|
963
|
+
...storyParameters,
|
|
964
|
+
docs: {
|
|
965
|
+
description: {
|
|
966
|
+
story:
|
|
967
|
+
"Interactive playground to experiment with different pagination configurations.",
|
|
968
|
+
},
|
|
969
|
+
},
|
|
970
|
+
},
|
|
971
|
+
args: {
|
|
972
|
+
totalItems: 300,
|
|
973
|
+
initialPage: 5,
|
|
974
|
+
initialPageSize: 15,
|
|
975
|
+
siblingCount: 2,
|
|
976
|
+
title: "Pagination Playground",
|
|
977
|
+
},
|
|
978
|
+
render: (args) => (
|
|
979
|
+
<div className="min-h-dvh bg-gradient-to-br from-gray-900 to-gray-800 !p-8">
|
|
980
|
+
<PaginationDemo {...args} />
|
|
981
|
+
</div>
|
|
982
|
+
),
|
|
983
|
+
}
|