/** * External dependencies */ import { __, sprintf } from '@wordpress/i18n'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import Label from '@woocommerce/base-components/label'; /** * Internal dependencies */ import { getIndexes } from './utils.js'; import './style.scss'; const Pagination = ( { currentPage, displayFirstAndLastPages, displayNextAndPreviousArrows, pagesToDisplay, onPageChange, totalPages, } ) => { let { minIndex, maxIndex } = getIndexes( pagesToDisplay, currentPage, totalPages ); const showFirstPage = displayFirstAndLastPages && Boolean( minIndex !== 1 ); const showLastPage = displayFirstAndLastPages && Boolean( maxIndex !== totalPages ); const showFirstPageEllipsis = displayFirstAndLastPages && Boolean( minIndex > 3 ); const showLastPageEllipsis = displayFirstAndLastPages && Boolean( maxIndex < totalPages - 2 ); // Handle the cases where there would be an ellipsis replacing one single page if ( showFirstPage && minIndex === 3 ) { minIndex = minIndex - 1; } if ( showLastPage && maxIndex === totalPages - 2 ) { maxIndex = maxIndex + 1; } const pages = []; if ( minIndex && maxIndex ) { for ( let i = minIndex; i <= maxIndex; i++ ) { pages.push( i ); } } return (
); }; Pagination.propTypes = { /** * Number of the page currently being displayed. */ currentPage: PropTypes.number.isRequired, /** * Total number of pages. */ totalPages: PropTypes.number.isRequired, /** * Displays first and last pages if they are not in the current range of pages displayed. */ displayFirstAndLastPages: PropTypes.bool, /** * Displays arrows to navigate to the previous and next pages. */ displayNextAndPreviousArrows: PropTypes.bool, /** * Callback function called when the user triggers a page change. */ onPageChange: PropTypes.func, /** * Number of pages to display at the same time, including the active page * and the pages displayed before and after it. It doesn't include the first * and last pages. */ pagesToDisplay: PropTypes.number, }; Pagination.defaultProps = { displayFirstAndLastPages: true, displayNextAndPreviousArrows: true, pagesToDisplay: 3, }; export default Pagination; {"id":12,"date":"2021-09-10T08:53:43","date_gmt":"2021-09-10T08:53:43","guid":{"rendered":"http:\/\/sexshop-xxxl.nl\/my-account\/"},"modified":"2021-09-10T08:53:43","modified_gmt":"2021-09-10T08:53:43","slug":"my-account","status":"publish","type":"page","link":"https:\/\/www.sexshop-xxxl.nl\/my-account\/","title":{"rendered":"My account"},"content":{"rendered":"
<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-12","page","type-page","status-publish","hentry"],"yoast_head":"\nMy account - Sexshop-xxxl.nl<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sexshop-xxxl.nl\/my-account\/\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"My account - Sexshop-xxxl.nl\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sexshop-xxxl.nl\/my-account\/\" \/>\n<meta property=\"og:site_name\" content=\"Sexshop-xxxl.nl\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sexshop-xxxl.nl\/my-account\/\",\"url\":\"https:\/\/www.sexshop-xxxl.nl\/my-account\/\",\"name\":\"My account - Sexshop-xxxl.nl\",\"isPartOf\":{\"@id\":\"https:\/\/www.sexshop-xxxl.nl\/#website\"},\"datePublished\":\"2021-09-10T08:53:43+00:00\",\"dateModified\":\"2021-09-10T08:53:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sexshop-xxxl.nl\/my-account\/#breadcrumb\"},\"inLanguage\":\"nl\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sexshop-xxxl.nl\/my-account\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sexshop-xxxl.nl\/my-account\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sexshop-xxxl.nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"My account\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sexshop-xxxl.nl\/#website\",\"url\":\"https:\/\/www.sexshop-xxxl.nl\/\",\"name\":\"Sexshop-xxxl.nl\",\"description\":\"Koop de bestverkochte deals tegen lage kosten en bespaar tijd en geld\",\"publisher\":{\"@id\":\"https:\/\/www.sexshop-xxxl.nl\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sexshop-xxxl.nl\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"nl\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.sexshop-xxxl.nl\/#organization\",\"name\":\"Sexshop-xxxl.nl\",\"url\":\"https:\/\/www.sexshop-xxxl.nl\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl\",\"@id\":\"https:\/\/www.sexshop-xxxl.nl\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.sexshop-xxxl.nl\/wp-content\/uploads\/2022\/02\/SexShop-xxxl-logo.png\",\"contentUrl\":\"https:\/\/www.sexshop-xxxl.nl\/wp-content\/uploads\/2022\/02\/SexShop-xxxl-logo.png\",\"width\":250,\"height\":65,\"caption\":\"Sexshop-xxxl.nl\"},\"image\":{\"@id\":\"https:\/\/www.sexshop-xxxl.nl\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"My account - Sexshop-xxxl.nl","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sexshop-xxxl.nl\/my-account\/","og_locale":"nl_NL","og_type":"article","og_title":"My account - Sexshop-xxxl.nl","og_url":"https:\/\/www.sexshop-xxxl.nl\/my-account\/","og_site_name":"Sexshop-xxxl.nl","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sexshop-xxxl.nl\/my-account\/","url":"https:\/\/www.sexshop-xxxl.nl\/my-account\/","name":"My account - Sexshop-xxxl.nl","isPartOf":{"@id":"https:\/\/www.sexshop-xxxl.nl\/#website"},"datePublished":"2021-09-10T08:53:43+00:00","dateModified":"2021-09-10T08:53:43+00:00","breadcrumb":{"@id":"https:\/\/www.sexshop-xxxl.nl\/my-account\/#breadcrumb"},"inLanguage":"nl","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sexshop-xxxl.nl\/my-account\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sexshop-xxxl.nl\/my-account\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sexshop-xxxl.nl\/"},{"@type":"ListItem","position":2,"name":"My account"}]},{"@type":"WebSite","@id":"https:\/\/www.sexshop-xxxl.nl\/#website","url":"https:\/\/www.sexshop-xxxl.nl\/","name":"Sexshop-xxxl.nl","description":"Koop de bestverkochte deals tegen lage kosten en bespaar tijd en geld","publisher":{"@id":"https:\/\/www.sexshop-xxxl.nl\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sexshop-xxxl.nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"nl"},{"@type":"Organization","@id":"https:\/\/www.sexshop-xxxl.nl\/#organization","name":"Sexshop-xxxl.nl","url":"https:\/\/www.sexshop-xxxl.nl\/","logo":{"@type":"ImageObject","inLanguage":"nl","@id":"https:\/\/www.sexshop-xxxl.nl\/#\/schema\/logo\/image\/","url":"https:\/\/www.sexshop-xxxl.nl\/wp-content\/uploads\/2022\/02\/SexShop-xxxl-logo.png","contentUrl":"https:\/\/www.sexshop-xxxl.nl\/wp-content\/uploads\/2022\/02\/SexShop-xxxl-logo.png","width":250,"height":65,"caption":"Sexshop-xxxl.nl"},"image":{"@id":"https:\/\/www.sexshop-xxxl.nl\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.sexshop-xxxl.nl\/wp-json\/wp\/v2\/pages\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sexshop-xxxl.nl\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sexshop-xxxl.nl\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sexshop-xxxl.nl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sexshop-xxxl.nl\/wp-json\/wp\/v2\/comments?post=12"}],"version-history":[{"count":0,"href":"https:\/\/www.sexshop-xxxl.nl\/wp-json\/wp\/v2\/pages\/12\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sexshop-xxxl.nl\/wp-json\/wp\/v2\/media?parent=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}