Files

14 lines
3.8 KiB
JavaScript

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
import{property as h,customElement as u}from"lit/decorators.js";import{LitElement as P,nothing as i,html as t}from"lit";import"@typo3/backend/element/icon-element.js";var n=function(s,e,l,r){var g=arguments.length,a=g<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,l):r,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(s,e,l,r);else for(var d=s.length-1;d>=0;d--)(c=s[d])&&(a=(g<3?c(a):g>3?c(e,l,a):c(e,l))||a);return g>3&&a&&Object.defineProperty(e,l,a),a};let p=class extends P{constructor(){super(...arguments),this.pagination=null,this.loading=!1}createRenderRoot(){return this}render(){return this.loading||this.pagination===null||this.pagination.allPageNumbers.length<=1?i:t`<nav><ul class=pagination><li class=page-item><typo3-backend-live-search-result-page class="page-link ${!this.pagination.previousPageNumber||this.pagination.previousPageNumber<this.pagination.firstPage?"disabled":""}" page=${this.pagination.previousPageNumber} perpage=${this.pagination.itemsPerPage}><typo3-backend-icon identifier=actions-view-paging-previous size=small></typo3-backend-icon></typo3-backend-live-search-result-page></li>${this.pagination.allPageNumbers.includes(this.pagination.firstPage)?i:t`<li class=page-item><typo3-backend-live-search-result-page class=page-link page=${this.pagination.firstPage} perpage=${this.pagination.itemsPerPage}>${this.pagination.firstPage}</typo3-backend-live-search-result-page></li>`} ${this.pagination.hasLessPages?t`<li class="page-item disabled"><span class="page-link disabled">&hellip;</span></li>`:i} ${this.pagination.allPageNumbers.map(e=>t`<li class=page-item><typo3-backend-live-search-result-page page=${e} perpage=${this.pagination.itemsPerPage} class="page-link ${this.pagination.currentPage===e?"active":""}">${e}</typo3-backend-live-search-result-page></li>`)} ${this.pagination.hasMorePages?t`<li class=page-item><span class="page-link disabled">&hellip;</span></li>`:i} ${this.pagination.allPageNumbers.includes(this.pagination.lastPage)?i:t`<li class=page-item><typo3-backend-live-search-result-page class=page-link page=${this.pagination.lastPage} perpage=${this.pagination.itemsPerPage}>${this.pagination.lastPage}</typo3-backend-live-search-result-page></li>`}<li class=page-item><typo3-backend-live-search-result-page class="page-link ${!this.pagination.nextPageNumber||this.pagination.nextPageNumber>this.pagination.lastPage?"disabled":""}" page=${this.pagination.nextPageNumber} perpage=${this.pagination.itemsPerPage}><typo3-backend-icon identifier=actions-view-paging-next size=small></typo3-backend-icon></typo3-backend-live-search-result-page></li></ul></nav>`}};n([h({type:Object})],p.prototype,"pagination",void 0),n([h({type:Boolean,attribute:!1})],p.prototype,"loading",void 0),p=n([u("typo3-backend-live-search-result-pagination")],p);let o=class extends P{connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.dispatchPaginationEvent)}disconnectedCallback(){this.removeEventListener("click",this.dispatchPaginationEvent),super.disconnectedCallback()}createRenderRoot(){return this}render(){return i}dispatchPaginationEvent(){this.closest("typo3-backend-live-search").dispatchEvent(new CustomEvent("livesearch:pagination-selected",{detail:{offset:(this.page-1)*this.perPage}}))}};n([h({type:Number})],o.prototype,"page",void 0),n([h({type:Number})],o.prototype,"perPage",void 0),o=n([u("typo3-backend-live-search-result-page")],o);export{p as ResultPagination,o as ResultPaginationPage};