@solexllc/usx-react 0.1.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/README.md +45 -0
- package/dist/index.cjs +6017 -0
- package/dist/index.js +6015 -0
- package/package.json +48 -0
- package/src/components/accordion/Accordion.jsx +170 -0
- package/src/components/accordion/accordion.django.html +47 -0
- package/src/components/accordion/accordion.html +304 -0
- package/src/components/accordion/config.json +31 -0
- package/src/components/alert/Alert.tsx +88 -0
- package/src/components/alert/alert.django.html +45 -0
- package/src/components/alert/alert.html +192 -0
- package/src/components/alert/config.json +70 -0
- package/src/components/attribution/Attribution.tsx +40 -0
- package/src/components/attribution/attribution.django.html +21 -0
- package/src/components/attribution/attribution.html +26 -0
- package/src/components/attribution/config.json +32 -0
- package/src/components/avatar/Avatar.tsx +85 -0
- package/src/components/avatar/avatar.django.html +27 -0
- package/src/components/avatar/avatar.html +101 -0
- package/src/components/avatar/config.json +59 -0
- package/src/components/avatar-group/AvatarGroup.tsx +43 -0
- package/src/components/avatar-group/avatar-group.django.html +8 -0
- package/src/components/avatar-group/avatar-group.html +208 -0
- package/src/components/avatar-group/config.json +60 -0
- package/src/components/back-to-top/BackToTop.tsx +60 -0
- package/src/components/back-to-top/back-to-top.django.html +38 -0
- package/src/components/back-to-top/back-to-top.html +107 -0
- package/src/components/back-to-top/config.json +44 -0
- package/src/components/banner/Banner.tsx +111 -0
- package/src/components/banner/banner.django.html +80 -0
- package/src/components/banner/banner.html +411 -0
- package/src/components/banner/config.json +47 -0
- package/src/components/block/Block.tsx +78 -0
- package/src/components/block/block.django.html +26 -0
- package/src/components/block/block.html +162 -0
- package/src/components/block/config.json +88 -0
- package/src/components/breadcrumb/Breadcrumb.tsx +83 -0
- package/src/components/breadcrumb/breadcrumb.django.html +24 -0
- package/src/components/breadcrumb/breadcrumb.html +108 -0
- package/src/components/breadcrumb/config.json +74 -0
- package/src/components/button/Button.tsx +121 -0
- package/src/components/button/button.django.html +58 -0
- package/src/components/button/button.html +363 -0
- package/src/components/button/config.json +103 -0
- package/src/components/button-group/ButtonGroup.tsx +33 -0
- package/src/components/button-group/button-group.django.html +9 -0
- package/src/components/button-group/button-group.html +159 -0
- package/src/components/button-group/config.json +25 -0
- package/src/components/calendar-date/CalendarDate.tsx +40 -0
- package/src/components/calendar-date/calendar-date.django.html +8 -0
- package/src/components/calendar-date/calendar-date.html +17 -0
- package/src/components/calendar-date/config.json +17 -0
- package/src/components/card/Card.tsx +137 -0
- package/src/components/card/card.django.html +40 -0
- package/src/components/card/card.html +67 -0
- package/src/components/card/config.json +115 -0
- package/src/components/card-group/CardGroup.tsx +23 -0
- package/src/components/card-group/card-group.django.html +6 -0
- package/src/components/card-group/card-group.html +164 -0
- package/src/components/card-group/config.json +21 -0
- package/src/components/carousel/Carousel.tsx +101 -0
- package/src/components/carousel/carousel.django.html +41 -0
- package/src/components/carousel/carousel.html +64 -0
- package/src/components/carousel/config.json +38 -0
- package/src/components/character-count/CharacterCount.tsx +77 -0
- package/src/components/character-count/character-count.django.html +19 -0
- package/src/components/character-count/character-count.html +110 -0
- package/src/components/character-count/config.json +78 -0
- package/src/components/checkbox/Checkbox.tsx +90 -0
- package/src/components/checkbox/checkbox.django.html +16 -0
- package/src/components/checkbox/checkbox.html +266 -0
- package/src/components/checkbox/config.json +71 -0
- package/src/components/checkbox-group/CheckboxGroup.tsx +67 -0
- package/src/components/checkbox-group/checkbox-group.django.html +12 -0
- package/src/components/checkbox-group/checkbox-group.html +36 -0
- package/src/components/checkbox-group/config.json +50 -0
- package/src/components/clickable/Clickable.tsx +78 -0
- package/src/components/clickable/clickable.django.html +5 -0
- package/src/components/clickable/clickable.html +133 -0
- package/src/components/clickable/config.json +26 -0
- package/src/components/code/Code.tsx +60 -0
- package/src/components/code/code.django.html +21 -0
- package/src/components/code/code.html +71 -0
- package/src/components/code/config.json +40 -0
- package/src/components/collection/Collection.tsx +99 -0
- package/src/components/collection/collection.django.html +48 -0
- package/src/components/collection/collection.html +384 -0
- package/src/components/collection/config.json +60 -0
- package/src/components/combobox/Combobox.tsx +114 -0
- package/src/components/combobox/combobox.django.html +61 -0
- package/src/components/combobox/combobox.html +509 -0
- package/src/components/combobox/config.json +80 -0
- package/src/components/copy-to-clipboard/CopyToClipboard.tsx +48 -0
- package/src/components/copy-to-clipboard/config.json +30 -0
- package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +16 -0
- package/src/components/copy-to-clipboard/copy-to-clipboard.html +68 -0
- package/src/components/date-picker/DatePicker.jsx +83 -0
- package/src/components/date-picker/config.json +71 -0
- package/src/components/date-picker/date-picker.django.html +67 -0
- package/src/components/date-picker/date-picker.html +104 -0
- package/src/components/date-range-picker/DateRangePicker.jsx +113 -0
- package/src/components/date-range-picker/config.json +92 -0
- package/src/components/date-range-picker/date-range-picker.django.html +66 -0
- package/src/components/date-range-picker/date-range-picker.html +190 -0
- package/src/components/error-message/ErrorMessage.tsx +23 -0
- package/src/components/error-message/config.json +19 -0
- package/src/components/error-message/error-message.django.html +2 -0
- package/src/components/error-message/error-message.html +2 -0
- package/src/components/eyebrow/Eyebrow.tsx +15 -0
- package/src/components/eyebrow/config.json +15 -0
- package/src/components/eyebrow/eyebrow.django.html +4 -0
- package/src/components/eyebrow/eyebrow.html +4 -0
- package/src/components/fieldset/Fieldset.tsx +54 -0
- package/src/components/fieldset/config.json +47 -0
- package/src/components/fieldset/fieldset.django.html +22 -0
- package/src/components/fieldset/fieldset.html +17 -0
- package/src/components/file-input/FileInput.jsx +174 -0
- package/src/components/file-input/config.json +80 -0
- package/src/components/file-input/file-input.django.html +57 -0
- package/src/components/file-input/file-input.html +258 -0
- package/src/components/file-list/FileList.jsx +105 -0
- package/src/components/file-list/config.json +43 -0
- package/src/components/file-list/file-list.django.html +30 -0
- package/src/components/file-list/file-list.html +61 -0
- package/src/components/footer/Footer.tsx +365 -0
- package/src/components/footer/config.json +83 -0
- package/src/components/footer/footer.django.html +260 -0
- package/src/components/footer/footer.html +392 -0
- package/src/components/form-group/FormGroup.tsx +26 -0
- package/src/components/form-group/config.json +22 -0
- package/src/components/form-group/form-group.django.html +4 -0
- package/src/components/form-group/form-group.html +17 -0
- package/src/components/header/Branding.tsx +101 -0
- package/src/components/header/Header.tsx +229 -0
- package/src/components/header/HeaderBranding.jsx +4 -0
- package/src/components/header/config.json +58 -0
- package/src/components/header/header.django.html +194 -0
- package/src/components/header/header.html +823 -0
- package/src/components/hero/Hero.tsx +64 -0
- package/src/components/hero/config.json +70 -0
- package/src/components/hero/hero.django.html +22 -0
- package/src/components/hero/hero.html +75 -0
- package/src/components/hint/Hint.tsx +23 -0
- package/src/components/hint/config.json +19 -0
- package/src/components/hint/hint.django.html +2 -0
- package/src/components/hint/hint.html +2 -0
- package/src/components/icon/Icon.tsx +46 -0
- package/src/components/icon/config.json +60 -0
- package/src/components/icon/icon.django.html +26 -0
- package/src/components/icon/icon.html +289 -0
- package/src/components/icon/icons_list.json +247 -0
- package/src/components/icon-list/IconList.tsx +59 -0
- package/src/components/icon-list/config.json +86 -0
- package/src/components/icon-list/icon-list.django.html +17 -0
- package/src/components/icon-list/icon-list.html +227 -0
- package/src/components/identifier/Identifier.tsx +193 -0
- package/src/components/identifier/config.json +133 -0
- package/src/components/identifier/identifier.django.html +99 -0
- package/src/components/identifier/identifier.html +737 -0
- package/src/components/image/Image.tsx +106 -0
- package/src/components/image/config.json +64 -0
- package/src/components/image/image.django.html +62 -0
- package/src/components/image/image.html +53 -0
- package/src/components/in-page-nav/InPageNav.jsx +76 -0
- package/src/components/in-page-nav/config.json +69 -0
- package/src/components/in-page-nav/in-page-nav.django.html +28 -0
- package/src/components/in-page-nav/in-page-nav.html +183 -0
- package/src/components/indicator/Indicator.tsx +32 -0
- package/src/components/indicator/README.md +1 -0
- package/src/components/indicator/config.json +19 -0
- package/src/components/indicator/indicator.django.html +10 -0
- package/src/components/indicator/indicator.html +42 -0
- package/src/components/input/Input.tsx +85 -0
- package/src/components/input/config.json +73 -0
- package/src/components/input/input.django.html +55 -0
- package/src/components/input/input.html +59 -0
- package/src/components/label/Label.tsx +42 -0
- package/src/components/label/config.json +39 -0
- package/src/components/label/label.django.html +23 -0
- package/src/components/label/label.html +23 -0
- package/src/components/language-selector/LanguageSelector.jsx +224 -0
- package/src/components/language-selector/config.json +107 -0
- package/src/components/language-selector/language-selector.django.html +40 -0
- package/src/components/language-selector/language-selector.html +85 -0
- package/src/components/layout/Layout.tsx +131 -0
- package/src/components/layout/config.json +36 -0
- package/src/components/layout/layout.django.html +28 -0
- package/src/components/layout/layout.html +29 -0
- package/src/components/legend/Legend.tsx +34 -0
- package/src/components/legend/config.json +27 -0
- package/src/components/legend/legend.django.html +11 -0
- package/src/components/legend/legend.html +12 -0
- package/src/components/link/Link.tsx +45 -0
- package/src/components/link/config.json +39 -0
- package/src/components/link/link.django.html +8 -0
- package/src/components/link/link.html +47 -0
- package/src/components/list/List.tsx +82 -0
- package/src/components/list/_list-items.django.html +17 -0
- package/src/components/list/config.json +25 -0
- package/src/components/list/list.django.html +11 -0
- package/src/components/list/list.html +26 -0
- package/src/components/memorable-date/MemorableDate.jsx +167 -0
- package/src/components/memorable-date/config.json +104 -0
- package/src/components/memorable-date/memorable-date.django.html +86 -0
- package/src/components/memorable-date/memorable-date.html +275 -0
- package/src/components/misc-banner/MiscBanner.tsx +112 -0
- package/src/components/misc-banner/config.json +57 -0
- package/src/components/misc-banner/misc-banner.django.html +63 -0
- package/src/components/misc-banner/misc-banner.html +191 -0
- package/src/components/modal/Modal.tsx +71 -0
- package/src/components/modal/config.json +57 -0
- package/src/components/modal/modal.django.html +43 -0
- package/src/components/modal/modal.html +222 -0
- package/src/components/page/Page.jsx +34 -0
- package/src/components/page/config.json +34 -0
- package/src/components/page/page.django.html +5 -0
- package/src/components/page/page.html +23 -0
- package/src/components/pagination/Pagination.tsx +112 -0
- package/src/components/pagination/config.json +135 -0
- package/src/components/pagination/container/PaginationContainer.tsx +38 -0
- package/src/components/pagination/navigation/PaginationNavigation.tsx +219 -0
- package/src/components/pagination/navigation/pagination-navigation.django.html +64 -0
- package/src/components/pagination/pagination.django.html +48 -0
- package/src/components/pagination/pagination.html +613 -0
- package/src/components/pagination/step-options/PaginationStepOptions.tsx +43 -0
- package/src/components/pagination/step-options/pagination-step-options.django.html +7 -0
- package/src/components/pagination/summary/PaginationSummary.tsx +33 -0
- package/src/components/pagination/summary/pagination-summary.django.html +12 -0
- package/src/components/process-list/ProcessList.tsx +52 -0
- package/src/components/process-list/config.json +15 -0
- package/src/components/process-list/process-list.django.html +15 -0
- package/src/components/process-list/process-list.html +90 -0
- package/src/components/prose/Prose.tsx +32 -0
- package/src/components/prose/config.json +28 -0
- package/src/components/prose/prose.django.html +35 -0
- package/src/components/prose/prose.html +91 -0
- package/src/components/radio-buttons/RadioButtons.tsx +82 -0
- package/src/components/radio-buttons/config.json +57 -0
- package/src/components/radio-buttons/radio-buttons.django.html +28 -0
- package/src/components/radio-buttons/radio-buttons.html +189 -0
- package/src/components/range-slider/RangeSlider.jsx +84 -0
- package/src/components/range-slider/config.json +89 -0
- package/src/components/range-slider/range-slider.django.html +65 -0
- package/src/components/range-slider/range-slider.html +106 -0
- package/src/components/required/Required.tsx +25 -0
- package/src/components/required/config.json +20 -0
- package/src/components/required/required.django.html +2 -0
- package/src/components/required/required.html +6 -0
- package/src/components/search/Search.tsx +92 -0
- package/src/components/search/config.json +69 -0
- package/src/components/search/search.django.html +59 -0
- package/src/components/search/search.html +76 -0
- package/src/components/section/Section.tsx +28 -0
- package/src/components/section/config.json +27 -0
- package/src/components/section/section.django.html +5 -0
- package/src/components/section/section.html +16 -0
- package/src/components/select/Select.tsx +107 -0
- package/src/components/select/config.json +80 -0
- package/src/components/select/select.django.html +64 -0
- package/src/components/select/select.html +62 -0
- package/src/components/sidenav/SideNav.tsx +74 -0
- package/src/components/sidenav/config.json +45 -0
- package/src/components/sidenav/sidenav.django.html +29 -0
- package/src/components/sidenav/sidenav.html +84 -0
- package/src/components/site-alert/SiteAlert.tsx +101 -0
- package/src/components/site-alert/config.json +62 -0
- package/src/components/site-alert/site-alert.django.html +34 -0
- package/src/components/site-alert/site-alert.html +312 -0
- package/src/components/skipnav/Skipnav.tsx +41 -0
- package/src/components/skipnav/config.json +29 -0
- package/src/components/skipnav/skipnav.django.html +11 -0
- package/src/components/skipnav/skipnav.html +1 -0
- package/src/components/spinner/Spinner.tsx +46 -0
- package/src/components/spinner/config.json +44 -0
- package/src/components/spinner/spinner.django.html +8 -0
- package/src/components/spinner/spinner.html +219 -0
- package/src/components/status/Status.tsx +28 -0
- package/src/components/status/config.json +47 -0
- package/src/components/status/status.django.html +2 -0
- package/src/components/status/status.html +31 -0
- package/src/components/step-indicator/StepIndicator.tsx +80 -0
- package/src/components/step-indicator/config.json +54 -0
- package/src/components/step-indicator/step-indicator.django.html +29 -0
- package/src/components/step-indicator/step-indicator.html +243 -0
- package/src/components/summary-box/SummaryBox.tsx +41 -0
- package/src/components/summary-box/config.json +30 -0
- package/src/components/summary-box/summary-box.django.html +19 -0
- package/src/components/summary-box/summary-box.html +210 -0
- package/src/components/swap/Swap.tsx +47 -0
- package/src/components/swap/config.json +61 -0
- package/src/components/swap/swap.django.html +14 -0
- package/src/components/swap/swap.html +163 -0
- package/src/components/switch/Switch.tsx +73 -0
- package/src/components/switch/config.json +55 -0
- package/src/components/switch/switch.django.html +28 -0
- package/src/components/switch/switch.html +56 -0
- package/src/components/table/Table.tsx +334 -0
- package/src/components/table/TableBody.tsx +253 -0
- package/src/components/table/TableCell.tsx +37 -0
- package/src/components/table/TableContext.tsx +87 -0
- package/src/components/table/TableFoot.tsx +68 -0
- package/src/components/table/TableGroup.tsx +69 -0
- package/src/components/table/TableHead.tsx +139 -0
- package/src/components/table/TableRow.tsx +56 -0
- package/src/components/table/__pycache__/table_helper.cpython-312.pyc +0 -0
- package/src/components/table/config.json +297 -0
- package/src/components/table/hooks/useRowDetails.ts +34 -0
- package/src/components/table/hooks/useTableGroups.ts +61 -0
- package/src/components/table/hooks/useTableSelect.ts +82 -0
- package/src/components/table/hooks/useTableSort.ts +60 -0
- package/src/components/table/table-body.django.html +68 -0
- package/src/components/table/table-detail-row.django.html +14 -0
- package/src/components/table/table-foot.django.html +31 -0
- package/src/components/table/table-group.django.html +40 -0
- package/src/components/table/table-head.django.html +85 -0
- package/src/components/table/table-row.django.html +98 -0
- package/src/components/table/table.django.html +60 -0
- package/src/components/table/table.html +1186 -0
- package/src/components/table/table_helper.py +298 -0
- package/src/components/table/types.ts +68 -0
- package/src/components/tag/Tag.tsx +75 -0
- package/src/components/tag/config.json +54 -0
- package/src/components/tag/tag.django.html +39 -0
- package/src/components/tag/tag.html +45 -0
- package/src/components/tag-group/TagGroup.tsx +35 -0
- package/src/components/tag-group/config.json +24 -0
- package/src/components/tag-group/tag-group.django.html +11 -0
- package/src/components/tag-group/tag-group.html +36 -0
- package/src/components/task-list/TaskList.tsx +40 -0
- package/src/components/task-list/config.json +41 -0
- package/src/components/task-list/task-list.django.html +21 -0
- package/src/components/task-list/task-list.html +24 -0
- package/src/components/text-area/TextArea.tsx +78 -0
- package/src/components/text-area/config.json +78 -0
- package/src/components/text-area/text-area.django.html +53 -0
- package/src/components/text-area/text-area.html +59 -0
- package/src/components/theme-picker/ThemePicker.tsx +106 -0
- package/src/components/theme-picker/config.json +39 -0
- package/src/components/theme-picker/theme-picker.django.html +32 -0
- package/src/components/theme-picker/theme-picker.html +67 -0
- package/src/components/time-picker/TimePicker.jsx +87 -0
- package/src/components/time-picker/config.json +76 -0
- package/src/components/time-picker/time-picker.django.html +67 -0
- package/src/components/time-picker/time-picker.html +123 -0
- package/src/components/toggle/Toggle.tsx +80 -0
- package/src/components/toggle/config.json +69 -0
- package/src/components/toggle/toggle.django.html +19 -0
- package/src/components/toggle/toggle.html +85 -0
- package/src/components/tooltip/Tooltip.tsx +33 -0
- package/src/components/tooltip/config.json +33 -0
- package/src/components/tooltip/tooltip.django.html +5 -0
- package/src/components/tooltip/tooltip.html +57 -0
- package/src/components/villain/Villain.tsx +47 -0
- package/src/components/villain/config.json +44 -0
- package/src/components/villain/villain.django.html +19 -0
- package/src/components/villain/villain.html +39 -0
- package/src/declarations.d.ts +1 -0
- package/src/index.js +82 -0
- package/src/styles/core.scss +12 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<h3 class="site-preview-heading">Default</h3>
|
|
2
|
+
<hr>
|
|
3
|
+
<main class="usx-page">
|
|
4
|
+
<h1 class="usx-page__title">Page Title</h1>
|
|
5
|
+
<div class="usx-page__content">
|
|
6
|
+
<p>This page wrapper provides consistent spacing between a site header and footer.</p>
|
|
7
|
+
<p>Use this region for page-specific content.</p>
|
|
8
|
+
</div>
|
|
9
|
+
</main>
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
<h3 class="site-preview-heading">With Eyebrow</h3>
|
|
13
|
+
<hr>
|
|
14
|
+
<main class="usx-page">
|
|
15
|
+
<h1 class="usx-page__title">
|
|
16
|
+
<span class="usx-eyebrow">Eyebrow Title</span>
|
|
17
|
+
Page Title
|
|
18
|
+
</h1>
|
|
19
|
+
<div class="usx-page__content">
|
|
20
|
+
<p>This page wrapper provides consistent spacing between a site header and footer.</p>
|
|
21
|
+
<p>Use this region for page-specific content.</p>
|
|
22
|
+
</div>
|
|
23
|
+
</main>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PaginationNavigation from './navigation/PaginationNavigation';
|
|
3
|
+
import PaginationStepOptions from './step-options/PaginationStepOptions';
|
|
4
|
+
import PaginationSummary from './summary/PaginationSummary';
|
|
5
|
+
import PaginationContainer from './container/PaginationContainer';
|
|
6
|
+
|
|
7
|
+
export interface PaginationProps {
|
|
8
|
+
initialPage?: number;
|
|
9
|
+
initialPageSize?: number;
|
|
10
|
+
pageSizeOptions?: number[];
|
|
11
|
+
totalItems?: number;
|
|
12
|
+
unbounded?: boolean;
|
|
13
|
+
onPageChange?: (page: number, pageSize: number) => void;
|
|
14
|
+
onPageSizeChange?: (pageSize: number, page: number) => void;
|
|
15
|
+
ariaLabel?: string;
|
|
16
|
+
prevLabel?: string;
|
|
17
|
+
nextLabel?: string;
|
|
18
|
+
itemLabel?: string;
|
|
19
|
+
showStepOptions?: boolean;
|
|
20
|
+
showSummary?: boolean;
|
|
21
|
+
hideLinkText?: boolean;
|
|
22
|
+
arrowsOnly?: boolean;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function Pagination({
|
|
27
|
+
initialPage = 1,
|
|
28
|
+
initialPageSize = 10,
|
|
29
|
+
pageSizeOptions = [10, 25, 50, 100],
|
|
30
|
+
totalItems,
|
|
31
|
+
unbounded = false,
|
|
32
|
+
onPageChange,
|
|
33
|
+
onPageSizeChange,
|
|
34
|
+
ariaLabel = 'Pagination',
|
|
35
|
+
prevLabel = 'Previous',
|
|
36
|
+
nextLabel = 'Next',
|
|
37
|
+
itemLabel = 'items',
|
|
38
|
+
showStepOptions = true,
|
|
39
|
+
showSummary = true,
|
|
40
|
+
hideLinkText = true,
|
|
41
|
+
arrowsOnly = false,
|
|
42
|
+
className = '',
|
|
43
|
+
}: PaginationProps) {
|
|
44
|
+
const [currentPage, setCurrentPage] = useState(initialPage);
|
|
45
|
+
const [pageSize, setPageSize] = useState(initialPageSize);
|
|
46
|
+
|
|
47
|
+
const totalPages =
|
|
48
|
+
totalItems !== undefined && !unbounded
|
|
49
|
+
? Math.ceil(totalItems / pageSize)
|
|
50
|
+
: undefined;
|
|
51
|
+
|
|
52
|
+
// showSummary defaults to true when totalItems is provided
|
|
53
|
+
const displaySummary = showSummary !== undefined ? showSummary : totalItems !== undefined;
|
|
54
|
+
|
|
55
|
+
const handlePageChange = (pageOrFn: number | ((prev: number) => number)) => {
|
|
56
|
+
setCurrentPage((prev) => {
|
|
57
|
+
const next = typeof pageOrFn === 'function' ? pageOrFn(prev) : pageOrFn;
|
|
58
|
+
onPageChange?.(next, pageSize);
|
|
59
|
+
return next;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handlePageSizeChange = (size: number) => {
|
|
64
|
+
// Clamp current page to the new total if bounded
|
|
65
|
+
const newTotalPages = totalItems ? Math.ceil(totalItems / size) : undefined;
|
|
66
|
+
const newPage = newTotalPages ? Math.min(currentPage, newTotalPages) : 1;
|
|
67
|
+
setPageSize(size);
|
|
68
|
+
setCurrentPage(newPage);
|
|
69
|
+
onPageSizeChange?.(size, newPage);
|
|
70
|
+
onPageChange?.(newPage, size);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const classes = ['usx-pagination', className].filter(Boolean).join(' ');
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div className={classes}>
|
|
77
|
+
<PaginationContainer
|
|
78
|
+
summary={
|
|
79
|
+
displaySummary && typeof totalItems === 'number' ? (
|
|
80
|
+
<PaginationSummary
|
|
81
|
+
currentPage={currentPage}
|
|
82
|
+
pageSize={pageSize}
|
|
83
|
+
totalItems={totalItems}
|
|
84
|
+
itemLabel={itemLabel}
|
|
85
|
+
/>
|
|
86
|
+
) : null
|
|
87
|
+
}
|
|
88
|
+
navigation={
|
|
89
|
+
<PaginationNavigation
|
|
90
|
+
currentPage={currentPage}
|
|
91
|
+
totalPages={totalPages}
|
|
92
|
+
onPageChange={handlePageChange}
|
|
93
|
+
ariaLabel={ariaLabel}
|
|
94
|
+
prevLabel={prevLabel}
|
|
95
|
+
nextLabel={nextLabel}
|
|
96
|
+
hideLinkText={hideLinkText}
|
|
97
|
+
arrowsOnly={arrowsOnly}
|
|
98
|
+
/>
|
|
99
|
+
}
|
|
100
|
+
stepOptions={
|
|
101
|
+
showStepOptions ? (
|
|
102
|
+
<PaginationStepOptions
|
|
103
|
+
pageSize={pageSize}
|
|
104
|
+
pageSizeOptions={pageSizeOptions}
|
|
105
|
+
onPageSizeChange={handlePageSizeChange}
|
|
106
|
+
/>
|
|
107
|
+
) : null
|
|
108
|
+
}
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pagination",
|
|
3
|
+
"template": "pagination/pagination.django.html",
|
|
4
|
+
"version": 1,
|
|
5
|
+
"props": {
|
|
6
|
+
"currentPage": {
|
|
7
|
+
"type": "number",
|
|
8
|
+
"default": 1,
|
|
9
|
+
"description": "Current 1-based page number"
|
|
10
|
+
},
|
|
11
|
+
"totalPages": {
|
|
12
|
+
"type": "number",
|
|
13
|
+
"description": "Total page count — omit for unbounded mode"
|
|
14
|
+
},
|
|
15
|
+
"pages": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"default": [],
|
|
18
|
+
"description": "Pre-computed list of page items: [{type: 'page', page: N} | {type: 'ellipsis'}]. Compute server-side with Django's Paginator.",
|
|
19
|
+
"items": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"description": "Page item — { type: 'page', page } or { type: 'ellipsis' }.",
|
|
22
|
+
"properties": {
|
|
23
|
+
"type": {
|
|
24
|
+
"type": "select",
|
|
25
|
+
"options": [
|
|
26
|
+
"page",
|
|
27
|
+
"ellipsis"
|
|
28
|
+
],
|
|
29
|
+
"description": "Item kind."
|
|
30
|
+
},
|
|
31
|
+
"page": {
|
|
32
|
+
"type": "number",
|
|
33
|
+
"description": "Page number (present when type is \"page\")."
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"unbounded": {
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"default": false,
|
|
41
|
+
"description": "True when total pages is unknown — hides the disabled state on Next"
|
|
42
|
+
},
|
|
43
|
+
"arrowsOnly": {
|
|
44
|
+
"type": "boolean",
|
|
45
|
+
"default": false,
|
|
46
|
+
"description": "Show only the prev/next arrows, no page number buttons"
|
|
47
|
+
},
|
|
48
|
+
"prevLabel": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"default": "Previous",
|
|
51
|
+
"description": "Label for the previous arrow link"
|
|
52
|
+
},
|
|
53
|
+
"nextLabel": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"default": "Next",
|
|
56
|
+
"description": "Label for the next arrow link"
|
|
57
|
+
},
|
|
58
|
+
"hideLinkText": {
|
|
59
|
+
"type": "boolean",
|
|
60
|
+
"default": true,
|
|
61
|
+
"description": "Visually hide prev/next labels (still readable by screen readers)"
|
|
62
|
+
},
|
|
63
|
+
"ariaLabel": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"default": "Pagination",
|
|
66
|
+
"description": "aria-label for the nav element"
|
|
67
|
+
},
|
|
68
|
+
"pageUrlPrefix": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"default": "?page=",
|
|
71
|
+
"description": "URL prefix that the page number is appended to, e.g. '?page='"
|
|
72
|
+
},
|
|
73
|
+
"showSummary": {
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"description": "Show the 'Showing X–Y of Z items' summary"
|
|
76
|
+
},
|
|
77
|
+
"firstItem": {
|
|
78
|
+
"type": "number",
|
|
79
|
+
"default": 1,
|
|
80
|
+
"description": "First item number on the current page (for summary)"
|
|
81
|
+
},
|
|
82
|
+
"lastItem": {
|
|
83
|
+
"type": "number",
|
|
84
|
+
"default": 10,
|
|
85
|
+
"description": "Last item number on the current page (for summary)"
|
|
86
|
+
},
|
|
87
|
+
"totalItems": {
|
|
88
|
+
"type": "number",
|
|
89
|
+
"description": "Total number of items (for summary)"
|
|
90
|
+
},
|
|
91
|
+
"itemLabel": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"default": "items",
|
|
94
|
+
"description": "Noun for items in the summary (e.g. 'results', 'records')"
|
|
95
|
+
},
|
|
96
|
+
"showStepOptions": {
|
|
97
|
+
"type": "boolean",
|
|
98
|
+
"description": "Show the items-per-page selector"
|
|
99
|
+
},
|
|
100
|
+
"pageSize": {
|
|
101
|
+
"type": "number",
|
|
102
|
+
"default": 10,
|
|
103
|
+
"description": "Currently selected page size"
|
|
104
|
+
},
|
|
105
|
+
"pageSizeOptions": {
|
|
106
|
+
"type": "array",
|
|
107
|
+
"default": [
|
|
108
|
+
10,
|
|
109
|
+
25,
|
|
110
|
+
50,
|
|
111
|
+
100
|
|
112
|
+
],
|
|
113
|
+
"description": "Available page size choices",
|
|
114
|
+
"items": {
|
|
115
|
+
"type": "number",
|
|
116
|
+
"description": "Selectable page size."
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"stepOptionsLabel": {
|
|
120
|
+
"type": "string",
|
|
121
|
+
"default": "Items per page",
|
|
122
|
+
"description": "Label for the items-per-page selector"
|
|
123
|
+
},
|
|
124
|
+
"stepOptionsId": {
|
|
125
|
+
"type": "string",
|
|
126
|
+
"default": "pagination-step-options",
|
|
127
|
+
"description": "HTML id for the step options select element"
|
|
128
|
+
},
|
|
129
|
+
"className": {
|
|
130
|
+
"type": "string",
|
|
131
|
+
"default": "",
|
|
132
|
+
"description": "Additional CSS classes on the outer wrapper"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { ReactNode, HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface PaginationContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
summary?: ReactNode;
|
|
5
|
+
navigation?: ReactNode;
|
|
6
|
+
stepOptions?: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Responsive layout container for pagination subcomponents.
|
|
12
|
+
*
|
|
13
|
+
* On mobile: stacks vertically (summary → nav → step options).
|
|
14
|
+
* On desktop: summary on the left, nav centered, step options on the right.
|
|
15
|
+
*/
|
|
16
|
+
export default function PaginationContainer({
|
|
17
|
+
summary,
|
|
18
|
+
navigation,
|
|
19
|
+
stepOptions,
|
|
20
|
+
className = '',
|
|
21
|
+
...props
|
|
22
|
+
}: PaginationContainerProps) {
|
|
23
|
+
const classes = ['usx-pagination__container', className].filter(Boolean).join(' ');
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={classes} {...props}>
|
|
27
|
+
{summary && (
|
|
28
|
+
<div className="usx-pagination__container-summary">{summary}</div>
|
|
29
|
+
)}
|
|
30
|
+
{(stepOptions || navigation) && (
|
|
31
|
+
<div className="usx-pagination__container-end">
|
|
32
|
+
{stepOptions && stepOptions}
|
|
33
|
+
{navigation && navigation}
|
|
34
|
+
</div>
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import ClassNames from 'classnames';
|
|
3
|
+
import Icon from '../../icon/Icon';
|
|
4
|
+
|
|
5
|
+
export interface PaginationNavigationProps {
|
|
6
|
+
currentPage: number;
|
|
7
|
+
totalPages?: number;
|
|
8
|
+
onPageChange: (page: number | ((prev: number) => number)) => void;
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
prevLabel?: string;
|
|
11
|
+
nextLabel?: string;
|
|
12
|
+
hideLinkText?: boolean;
|
|
13
|
+
arrowsOnly?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getPageItems(currentPage: number, totalPages: number) {
|
|
18
|
+
const page = (p: number) => ({ type: 'page' as const, page: p });
|
|
19
|
+
const ellipsis = (key: string) => ({ type: 'ellipsis' as const, key });
|
|
20
|
+
|
|
21
|
+
if (totalPages <= 7) {
|
|
22
|
+
return Array.from({ length: totalPages }, (_, i) => page(i + 1));
|
|
23
|
+
}
|
|
24
|
+
if (currentPage < 5) {
|
|
25
|
+
return [page(1), page(2), page(3), page(4), page(5), ellipsis('ellipsis-end'), page(totalPages)];
|
|
26
|
+
}
|
|
27
|
+
if (currentPage > totalPages - 4) {
|
|
28
|
+
return [
|
|
29
|
+
page(1),
|
|
30
|
+
ellipsis('ellipsis-start'),
|
|
31
|
+
page(totalPages - 4),
|
|
32
|
+
page(totalPages - 3),
|
|
33
|
+
page(totalPages - 2),
|
|
34
|
+
page(totalPages - 1),
|
|
35
|
+
page(totalPages),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
return [
|
|
39
|
+
page(1),
|
|
40
|
+
ellipsis('ellipsis-start'),
|
|
41
|
+
page(currentPage - 1),
|
|
42
|
+
page(currentPage),
|
|
43
|
+
page(currentPage + 1),
|
|
44
|
+
ellipsis('ellipsis-end'),
|
|
45
|
+
page(totalPages),
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getUnboundedPageItems(currentPage: number) {
|
|
50
|
+
const items = [{ type: 'page' as const, page: 1 }];
|
|
51
|
+
if (currentPage <= 3) {
|
|
52
|
+
for (let p = 2; p <= currentPage + 1; p++) {
|
|
53
|
+
items.push({ type: 'page' as const, page: p });
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
items.push({ type: 'ellipsis' as const, key: 'ellipsis-start' });
|
|
57
|
+
for (let p = currentPage - 1; p <= currentPage + 1; p++) {
|
|
58
|
+
items.push({ type: 'page' as const, page: p });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
items.push({ type: 'ellipsis' as const, key: 'ellipsis-end' });
|
|
62
|
+
return items;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default function PaginationNavigation({
|
|
66
|
+
currentPage,
|
|
67
|
+
totalPages,
|
|
68
|
+
onPageChange,
|
|
69
|
+
ariaLabel = 'Pagination',
|
|
70
|
+
prevLabel = 'Previous',
|
|
71
|
+
nextLabel = 'Next',
|
|
72
|
+
hideLinkText = false,
|
|
73
|
+
arrowsOnly = false,
|
|
74
|
+
className = '',
|
|
75
|
+
}: PaginationNavigationProps) {
|
|
76
|
+
const unbounded = totalPages === undefined || totalPages === null;
|
|
77
|
+
const items = unbounded
|
|
78
|
+
? getUnboundedPageItems(currentPage)
|
|
79
|
+
: getPageItems(currentPage, totalPages!);
|
|
80
|
+
|
|
81
|
+
const isFirstPage = currentPage === 1;
|
|
82
|
+
const isLastPage = !unbounded && currentPage === totalPages;
|
|
83
|
+
const lastClickTime = useRef(0);
|
|
84
|
+
|
|
85
|
+
const handlePage = (page: number) => (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
if (e.detail > 1) return;
|
|
88
|
+
if (page !== currentPage) onPageChange(page);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const handlePrev = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
if (e.timeStamp - lastClickTime.current < 50) return;
|
|
94
|
+
lastClickTime.current = e.timeStamp;
|
|
95
|
+
if (!isFirstPage) onPageChange((prev) => Math.max(prev - 1, 1));
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const handleNext = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
if (e.timeStamp - lastClickTime.current < 50) return;
|
|
101
|
+
lastClickTime.current = e.timeStamp;
|
|
102
|
+
if (!isLastPage) onPageChange((prev) => unbounded ? prev + 1 : Math.min(prev + 1, totalPages!));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const navClasses = ClassNames(
|
|
106
|
+
'usa-pagination',
|
|
107
|
+
'usx-pagination__nav',
|
|
108
|
+
{ 'usx-pagination__arrows-only': arrowsOnly },
|
|
109
|
+
className
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<nav aria-label={ariaLabel} className={navClasses}>
|
|
114
|
+
<ul className="usa-pagination__list">
|
|
115
|
+
{/* Previous arrow */}
|
|
116
|
+
<li
|
|
117
|
+
className={
|
|
118
|
+
ClassNames(
|
|
119
|
+
'usa-pagination__item',
|
|
120
|
+
'usa-pagination__arrow',
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
>
|
|
124
|
+
<a
|
|
125
|
+
href="#"
|
|
126
|
+
className={
|
|
127
|
+
ClassNames(
|
|
128
|
+
'usa-pagination__link',
|
|
129
|
+
'usa-pagination__previous-page',
|
|
130
|
+
isFirstPage && 'display-none',
|
|
131
|
+
hideLinkText && 'padding-1 margin-0'
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
aria-label={`${prevLabel} page`}
|
|
135
|
+
aria-disabled={isFirstPage ? 'true' : undefined}
|
|
136
|
+
tabIndex={isFirstPage ? -1 : undefined}
|
|
137
|
+
onClick={isFirstPage ? (e) => e.preventDefault() : handlePrev}
|
|
138
|
+
>
|
|
139
|
+
<Icon name="navigate_before" />
|
|
140
|
+
<span
|
|
141
|
+
className={
|
|
142
|
+
ClassNames(
|
|
143
|
+
'usa-pagination__link-text', hideLinkText && 'usa-sr-only'
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
>{prevLabel}</span>
|
|
147
|
+
</a>
|
|
148
|
+
</li>
|
|
149
|
+
{/* Page number / ellipsis items */}
|
|
150
|
+
{!arrowsOnly && items.map((item, index) => {
|
|
151
|
+
if (item.type === 'ellipsis') {
|
|
152
|
+
return (
|
|
153
|
+
<li
|
|
154
|
+
key={item.key || `ellipsis-${index}`}
|
|
155
|
+
className="usa-pagination__item usa-pagination__overflow"
|
|
156
|
+
aria-hidden="true"
|
|
157
|
+
>
|
|
158
|
+
<span>…</span>
|
|
159
|
+
</li>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
const isCurrent = item.page === currentPage;
|
|
163
|
+
return (
|
|
164
|
+
<li key={item.page} className="usa-pagination__item usa-pagination__page-no">
|
|
165
|
+
<a
|
|
166
|
+
href="#"
|
|
167
|
+
className={
|
|
168
|
+
ClassNames(
|
|
169
|
+
'usa-pagination__button',
|
|
170
|
+
isCurrent && 'usa-current'
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
aria-label={`Page ${item.page}`}
|
|
174
|
+
aria-current={isCurrent ? 'page' : undefined}
|
|
175
|
+
onClick={handlePage(item.page)}
|
|
176
|
+
>
|
|
177
|
+
{item.page}
|
|
178
|
+
</a>
|
|
179
|
+
</li>
|
|
180
|
+
);
|
|
181
|
+
})}
|
|
182
|
+
{/* Next arrow */}
|
|
183
|
+
<li
|
|
184
|
+
className={
|
|
185
|
+
ClassNames(
|
|
186
|
+
'usa-pagination__item',
|
|
187
|
+
'usa-pagination__arrow',
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
>
|
|
191
|
+
<a
|
|
192
|
+
href="#"
|
|
193
|
+
className={
|
|
194
|
+
ClassNames(
|
|
195
|
+
'usa-pagination__link',
|
|
196
|
+
'usa-pagination__next-page',
|
|
197
|
+
isLastPage && 'display-none',
|
|
198
|
+
hideLinkText && 'padding-1 margin-0'
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
aria-label={`${nextLabel} page`}
|
|
202
|
+
aria-disabled={isLastPage ? 'true' : undefined}
|
|
203
|
+
tabIndex={isLastPage ? -1 : undefined}
|
|
204
|
+
onClick={isLastPage ? (e) => e.preventDefault() : handleNext}
|
|
205
|
+
>
|
|
206
|
+
<span
|
|
207
|
+
className={
|
|
208
|
+
ClassNames(
|
|
209
|
+
'usa-pagination__link-text', hideLinkText && 'usa-sr-only'
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
>{nextLabel}</span>
|
|
213
|
+
<Icon name="navigate_next" />
|
|
214
|
+
</a>
|
|
215
|
+
</li>
|
|
216
|
+
</ul>
|
|
217
|
+
</nav>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{# Sub-template: pagination navigation bar #}
|
|
2
|
+
{# Props: currentPage, totalPages, pages, unbounded, arrowsOnly, #}
|
|
3
|
+
{# prevLabel, nextLabel, hideLinkText, ariaLabel, pageUrlPrefix #}
|
|
4
|
+
<nav aria-label="{{ ariaLabel }}" class="usa-pagination usx-pagination__nav{% if arrowsOnly %} usx-pagination__arrows-only{% endif %}">
|
|
5
|
+
<ul class="usa-pagination__list">
|
|
6
|
+
|
|
7
|
+
{# ── Previous arrow ──────────────────────────────────────────────── #}
|
|
8
|
+
<li class="usa-pagination__item usa-pagination__arrow">
|
|
9
|
+
{% if currentPage == 1 %}
|
|
10
|
+
{% comment %} Don't render the previous link when on first page per USWDS recommendation {% endcomment %}
|
|
11
|
+
{% else %}
|
|
12
|
+
<a href="{{ pageUrlPrefix }}{{ currentPage|add:"-1" }}"
|
|
13
|
+
class="usa-pagination__link usa-pagination__previous-page{% if hideLinkText %} padding-1 margin-0{% endif %}"
|
|
14
|
+
aria-label="{{ prevLabel }} page">
|
|
15
|
+
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
|
16
|
+
<use href="./img/sprite.svg#navigate_before"></use>
|
|
17
|
+
</svg>
|
|
18
|
+
<span class="usa-pagination__link-text{% if hideLinkText %} usa-sr-only{% endif %}">{{ prevLabel }}</span>
|
|
19
|
+
</a>
|
|
20
|
+
{% endif %}
|
|
21
|
+
</li>
|
|
22
|
+
|
|
23
|
+
{# ── Page number / ellipsis items (suppressed in arrowsOnly mode) ── #}
|
|
24
|
+
{% if not arrowsOnly %}
|
|
25
|
+
{% for item in pages %}
|
|
26
|
+
{% if item.type == 'ellipsis' %}
|
|
27
|
+
<li class="usa-pagination__item usa-pagination__overflow" aria-hidden="true">
|
|
28
|
+
<span>…</span>
|
|
29
|
+
</li>
|
|
30
|
+
{% else %}
|
|
31
|
+
<li class="usa-pagination__item usa-pagination__page-no">
|
|
32
|
+
{% if item.page == currentPage %}
|
|
33
|
+
<a href="{{ pageUrlPrefix }}{{ item.page }}"
|
|
34
|
+
class="usa-pagination__button usa-current"
|
|
35
|
+
aria-label="Page {{ item.page }}"
|
|
36
|
+
aria-current="page">{{ item.page }}</a>
|
|
37
|
+
{% else %}
|
|
38
|
+
<a href="{{ pageUrlPrefix }}{{ item.page }}"
|
|
39
|
+
class="usa-pagination__button"
|
|
40
|
+
aria-label="Page {{ item.page }}">{{ item.page }}</a>
|
|
41
|
+
{% endif %}
|
|
42
|
+
</li>
|
|
43
|
+
{% endif %}
|
|
44
|
+
{% endfor %}
|
|
45
|
+
{% endif %}
|
|
46
|
+
|
|
47
|
+
{# ── Next arrow ──────────────────────────────────────────────────── #}
|
|
48
|
+
<li class="usa-pagination__item usa-pagination__arrow">
|
|
49
|
+
{% if not unbounded and currentPage == totalPages %}
|
|
50
|
+
{% comment %} Don't render the next link when on last page per USWDS recommendation {% endcomment %}
|
|
51
|
+
{% else %}
|
|
52
|
+
<a href="{{ pageUrlPrefix }}{{ currentPage|add:"1" }}"
|
|
53
|
+
class="usa-pagination__link usa-pagination__next-page{% if hideLinkText %} padding-1 margin-0{% endif %}"
|
|
54
|
+
aria-label="{{ nextLabel }} page">
|
|
55
|
+
<span class="usa-pagination__link-text{% if hideLinkText %} usa-sr-only{% endif %}">{{ nextLabel }}</span>
|
|
56
|
+
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
|
57
|
+
<use href="./img/sprite.svg#navigate_next"></use>
|
|
58
|
+
</svg>
|
|
59
|
+
</a>
|
|
60
|
+
{% endif %}
|
|
61
|
+
</li>
|
|
62
|
+
|
|
63
|
+
</ul>
|
|
64
|
+
</nav>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{% load components %}
|
|
2
|
+
|
|
3
|
+
{# Django template for Pagination #}
|
|
4
|
+
{# ─────────────────────────────────────────────────────────── #}
|
|
5
|
+
{# Required props: #}
|
|
6
|
+
{# currentPage – current 1-based page number #}
|
|
7
|
+
{# pages – list of {type, page} dicts pre-computed #}
|
|
8
|
+
{# server-side (see Paginator helper) #}
|
|
9
|
+
{# Common optional props: #}
|
|
10
|
+
{# totalPages – omit for unbounded mode #}
|
|
11
|
+
{# unbounded – true when total pages is unknown #}
|
|
12
|
+
{# arrowsOnly – hide page number buttons #}
|
|
13
|
+
{# prevLabel – default "Previous" #}
|
|
14
|
+
{# nextLabel – default "Next" #}
|
|
15
|
+
{# hideLinkText – sr-only the prev/next labels #}
|
|
16
|
+
{# ariaLabel – nav aria-label, default "Pagination" #}
|
|
17
|
+
{# pageUrlPrefix – URL prefix for page links, e.g. "?page=" #}
|
|
18
|
+
{# showSummary – display "Showing X–Y of Z items" #}
|
|
19
|
+
{# firstItem, lastItem, totalItems, itemLabel #}
|
|
20
|
+
{# showStepOptions – display items-per-page selector #}
|
|
21
|
+
{# pageSize, pageSizeOptions (list), stepOptionsLabel #}
|
|
22
|
+
{# className – extra classes on the outer wrapper #}
|
|
23
|
+
{# ─────────────────────────────────────────────────────────── #}
|
|
24
|
+
<div class="usx-pagination{% if className %} {{ className }}{% endif %}">
|
|
25
|
+
<div class="usx-pagination__container">
|
|
26
|
+
|
|
27
|
+
{# ── Summary (left slot) ───────────────────────────────── #}
|
|
28
|
+
{% if totalItems %}
|
|
29
|
+
{% if showSummary != False and showSummary != "false" %}
|
|
30
|
+
<div class="usx-pagination__container-summary">
|
|
31
|
+
{% pagination_summary firstItem=firstItem lastItem=lastItem currentPage=currentPage pageSize=pageSize|default:10 totalItems=totalItems itemLabel=itemLabel|default:"items" %}{% endpagination_summary %}
|
|
32
|
+
</div>
|
|
33
|
+
{% endif %}
|
|
34
|
+
{% endif %}
|
|
35
|
+
|
|
36
|
+
{# ── Nav + step options (right slot) ─────────────────── #}
|
|
37
|
+
<div class="usx-pagination__container-end">
|
|
38
|
+
|
|
39
|
+
{% if showStepOptions != False %}
|
|
40
|
+
{% pagination_step_options pageSize=pageSize|default:10 pageSizeOptions=pageSizeOptions stepOptionsLabel=stepOptionsLabel|default:"Items per page" stepOptionsId=stepOptionsId|default:"pagination-step-options" %}{% endpagination_step_options %}
|
|
41
|
+
{% endif %}
|
|
42
|
+
|
|
43
|
+
{% pagination_navigation currentPage=currentPage|default:1 totalPages=totalPages pages=pages unbounded=unbounded arrowsOnly=arrowsOnly prevLabel=prevLabel|default:"Previous" nextLabel=nextLabel|default:"Next" hideLinkText=hideLinkText|default:True ariaLabel=ariaLabel|default:"Pagination" pageUrlPrefix=pageUrlPrefix|default:"?page=" %}{% endpagination_navigation %}
|
|
44
|
+
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|