UNPKG

carbon-components-angular

Version:
985 lines (827 loc) 40.3 kB
<!doctype html> <html class="no-js" lang=""> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>carbon-components-angular documentation</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="../images/favicon.ico"> <link rel="stylesheet" href="../styles/style.css"> <link rel="stylesheet" href="../styles/dark.css"> <style> footer.carbon { position: absolute; bottom: 0; width: 100%; z-index: 9999; } #root > div { /* * Subtracting the height of the footer to prevent * overlaying the footer ontop of content */ height: calc(100vh - 48px); } </style> </head> <body> <script> // Blocking script to avoid flickering dark mode // Dark mode toggle button var useDark = window.matchMedia('(prefers-color-scheme: dark)'); var darkModeState = useDark.matches; var $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input'); var $darkModeToggles = document.querySelectorAll('.dark-mode-switch'); var darkModeStateLocal = localStorage.getItem('compodoc_darkmode-state'); function checkToggle(check) { for (var i = 0; i < $darkModeToggleSwitchers.length; i++) { $darkModeToggleSwitchers[i].checked = check; } } function toggleDarkMode(state) { if (window.localStorage) { localStorage.setItem('compodoc_darkmode-state', state); } checkToggle(state); const hasClass = document.body.classList.contains('dark'); if (state) { for (var i = 0; i < $darkModeToggles.length; i++) { $darkModeToggles[i].classList.add('dark'); } if (!hasClass) { document.body.classList.add('dark'); } } else { for (var i = 0; i < $darkModeToggles.length; i++) { $darkModeToggles[i].classList.remove('dark'); } if (hasClass) { document.body.classList.remove('dark'); } } } useDark.addEventListener('change', function (evt) { toggleDarkMode(evt.matches); }); if (darkModeStateLocal) { darkModeState = darkModeStateLocal === 'true'; } toggleDarkMode(darkModeState); </script> <div class="navbar navbar-default navbar-fixed-top d-md-none p-0"> <div class="d-flex"> <a href="../" class="navbar-brand">carbon-components-angular documentation</a> <button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button> </div> </div> <div class="xs-menu menu" id="mobile-menu"> <div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu> </div> <div class="container-fluid main"> <div class="row main"> <div class="d-none d-md-block menu"> <compodoc-menu mode="normal"></compodoc-menu> </div> <!-- START CONTENT --> <div class="content interface"> <div class="content-data"> <ol class="breadcrumb"> <li class="breadcrumb-item">Interfaces</li> <li class="breadcrumb-item" > PaginationTranslations</li> </ol> <ul class="nav nav-tabs" role="tablist"> <li class="nav-item"> <a href="#info" class="nav-link" class="nav-link active" role="tab" id="info-tab" data-bs-toggle="tab" data-link="info">Info</a> </li> <li class="nav-item"> <a href="#source" class="nav-link" role="tab" id="source-tab" data-bs-toggle="tab" data-link="source">Source</a> </li> </ul> <div class="tab-content"> <div class="tab-pane fade active in" id="info"> <p class="comment"> <h3>File</h3> </p> <p class="comment"> <code>src/pagination/pagination.component.ts</code> </p> <section data-compodoc="block-index"> <h3 id="index">Index</h3> <table class="table table-sm table-bordered index-table"> <tbody> <tr> <td class="col-md-4"> <h6><b>Properties</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <a href="#BACKWARD" > BACKWARD </a> </li> <li> <a href="#FORWARD" > FORWARD </a> </li> <li> <a href="#ITEMS_PER_PAGE" > ITEMS_PER_PAGE </a> </li> <li> <a href="#OF_LAST_PAGE" > OF_LAST_PAGE </a> </li> <li> <a href="#OF_LAST_PAGES" > OF_LAST_PAGES </a> </li> <li> <a href="#OPEN_LIST_OF_OPTIONS" > OPEN_LIST_OF_OPTIONS </a> </li> <li> <a href="#TOTAL_ITEM" > TOTAL_ITEM </a> </li> <li> <a href="#TOTAL_ITEMS" > TOTAL_ITEMS </a> </li> <li> <a href="#TOTAL_ITEMS_UNKNOWN" > TOTAL_ITEMS_UNKNOWN </a> </li> </ul> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-properties"> <h3 id="inputs">Properties</h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="BACKWARD"></a> <span class="name "><b>BACKWARD</b> <a href="#BACKWARD"> <span class="icon ion-ios-link"></span> </a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>BACKWARD: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </code> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="FORWARD"></a> <span class="name "><b>FORWARD</b> <a href="#FORWARD"> <span class="icon ion-ios-link"></span> </a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>FORWARD: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </code> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="ITEMS_PER_PAGE"></a> <span class="name "><b>ITEMS_PER_PAGE</b> <a href="#ITEMS_PER_PAGE"> <span class="icon ion-ios-link"></span> </a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>ITEMS_PER_PAGE: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </code> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="OF_LAST_PAGE"></a> <span class="name "><b>OF_LAST_PAGE</b> <a href="#OF_LAST_PAGE"> <span class="icon ion-ios-link"></span> </a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>OF_LAST_PAGE: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </code> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="OF_LAST_PAGES"></a> <span class="name "><b>OF_LAST_PAGES</b> <a href="#OF_LAST_PAGES"> <span class="icon ion-ios-link"></span> </a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>OF_LAST_PAGES: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </code> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="OPEN_LIST_OF_OPTIONS"></a> <span class="name "><b>OPEN_LIST_OF_OPTIONS</b> <a href="#OPEN_LIST_OF_OPTIONS"> <span class="icon ion-ios-link"></span> </a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>OPEN_LIST_OF_OPTIONS: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </code> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="TOTAL_ITEM"></a> <span class="name "><b>TOTAL_ITEM</b> <a href="#TOTAL_ITEM"> <span class="icon ion-ios-link"></span> </a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>TOTAL_ITEM: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </code> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="TOTAL_ITEMS"></a> <span class="name "><b>TOTAL_ITEMS</b> <a href="#TOTAL_ITEMS"> <span class="icon ion-ios-link"></span> </a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>TOTAL_ITEMS: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </code> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="TOTAL_ITEMS_UNKNOWN"></a> <span class="name "><b>TOTAL_ITEMS_UNKNOWN</b> <a href="#TOTAL_ITEMS_UNKNOWN"> <span class="icon ion-ios-link"></span> </a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>TOTAL_ITEMS_UNKNOWN: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </code> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> </tbody> </table> </section> </div> <div class="tab-pane fade tab-source-code" id="source"> <pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { PaginationModel } from &quot;./pagination-model.class&quot;; import { Component, Input, Output, EventEmitter } from &quot;@angular/core&quot;; import { I18n, Overridable } from &quot;carbon-components-angular/i18n&quot;; import { ExperimentalService } from &quot;carbon-components-angular/experimental&quot;; import { merge } from &quot;carbon-components-angular/utils&quot;; export interface PaginationTranslations { ITEMS_PER_PAGE: string; OPEN_LIST_OF_OPTIONS: string; BACKWARD: string; FORWARD: string; TOTAL_ITEMS_UNKNOWN: string; TOTAL_ITEMS: string; TOTAL_ITEM: string; OF_LAST_PAGES: string; OF_LAST_PAGE: string; } /** * Use pagination when you have multiple pages of data to handle. Get started with importing the module: * * &#x60;&#x60;&#x60;typescript * import { PaginationModule } from &#x27;carbon-components-angular&#x27;; * &#x60;&#x60;&#x60; * * &#x60;&#x60;&#x60;html * &lt;cds-pagination [model]&#x3D;&quot;model&quot; (selectPage)&#x3D;&quot;selectPage($event)&quot;&gt;&lt;/cds-pagination&gt; * &#x60;&#x60;&#x60; * * In your &#x60;selectPage()&#x60; method set the &#x60;model.currentPage&#x60; to selected page, _after_ * you load the page. * * &#x60;&#x60;&#x60;typescript * selectPage(page) { * // ... your code to load the page goes here * * this.model.currentPage &#x3D; page; * * // ... anything you want to do after page selection changes goes here * } * &#x60;&#x60;&#x60; * * [See demo](../../?path&#x3D;/story/components-pagination--basic) */ @Component({ selector: &quot;cds-pagination, ibm-pagination&quot;, template: &#x60; &lt;div class&#x3D;&quot;cds--pagination&quot; [ngClass]&#x3D;&quot;{ &#x27;cds--skeleton&#x27;: skeleton }&quot;&gt; &lt;!-- left skeleton div --&gt; &lt;div *ngIf&#x3D;&quot;skeleton&quot; class&#x3D;&quot;cds--pagination__left&quot;&gt; &lt;p class&#x3D;&quot;cds--skeleton__text&quot; style&#x3D;&quot;width: 70px&quot;&gt;&lt;/p&gt; &lt;p class&#x3D;&quot;cds--skeleton__text&quot; style&#x3D;&quot;width: 35px&quot;&gt;&lt;/p&gt; &lt;p class&#x3D;&quot;cds--skeleton__text&quot; style&#x3D;&quot;width: 105px&quot;&gt;&lt;/p&gt; &lt;/div&gt; &lt;div *ngIf&#x3D;&quot;!skeleton&quot; class&#x3D;&quot;cds--pagination__left&quot;&gt; &lt;ng-container *ngIf&#x3D;&quot;showPageInput&quot;&gt; &lt;label class&#x3D;&quot;cds--pagination__text&quot; [for]&#x3D;&quot;itemsPerPageSelectId&quot;&gt; {{itemsPerPageText.subject | async}} &lt;/label&gt; &lt;div class&#x3D;&quot;cds--select cds--select--inline cds--select__item-count&quot; [class.cds--select--disabled]&#x3D;&quot;pageInputDisabled&quot;&gt; &lt;select [id]&#x3D;&quot;itemsPerPageSelectId&quot; [(ngModel)]&#x3D;&quot;itemsPerPage&quot; [disabled]&#x3D;&quot;pageInputDisabled&quot; class&#x3D;&quot;cds--select-input&quot;&gt; &lt;option class&#x3D;&quot;cds--select-option&quot; *ngFor&#x3D;&quot;let option of itemsPerPageOptions&quot; [value]&#x3D;&quot;option&quot;&gt; {{ option }} &lt;/option&gt; &lt;/select&gt; &lt;svg cdsIcon&#x3D;&quot;chevron--down&quot; size&#x3D;&quot;16&quot; style&#x3D;&quot;display: inherit&quot; class&#x3D;&quot;cds--select__arrow&quot; aria-hidden&#x3D;&quot;true&quot; [attr.ariaLabel]&#x3D;&quot;optionsListText.subject | async&quot;&gt; &lt;/svg&gt; &lt;/div&gt; &lt;/ng-container&gt; &lt;span *ngIf&#x3D;&quot;!pagesUnknown &amp;&amp; totalDataLength &lt;&#x3D; 1&quot; class&#x3D;&quot;cds--pagination__text cds--pagination__items-count&quot; [ngStyle]&#x3D;&quot;{&#x27;margin-left&#x27;: showPageInput ? null : 0}&quot;&gt; {{totalItemText.subject | i18nReplace:{start: startItemIndex, end: endItemIndex, total: totalDataLength } | async}} &lt;/span&gt; &lt;span *ngIf&#x3D;&quot;!pagesUnknown &amp;&amp; totalDataLength &gt; 1&quot; class&#x3D;&quot;cds--pagination__text cds--pagination__items-count&quot; [ngStyle]&#x3D;&quot;{&#x27;margin-left&#x27;: showPageInput ? null : 0}&quot;&gt; {{totalItemsText.subject | i18nReplace:{start: startItemIndex, end: endItemIndex, total: totalDataLength } | async}} &lt;/span&gt; &lt;span *ngIf&#x3D;&quot;pagesUnknown&quot; class&#x3D;&quot;cds--pagination__text cds--pagination__items-count&quot; [ngStyle]&#x3D;&quot;{&#x27;margin-left&#x27;: showPageInput ? null : 0}&quot;&gt; {{totalItemsUnknownText.subject | i18nReplace:{start: startItemIndex, end: endItemIndex } | async}} &lt;/span&gt; &lt;/div&gt; &lt;!-- right skeleton div --&gt; &lt;div *ngIf&#x3D;&quot;skeleton&quot; class&#x3D;&quot;cds--pagination__right&quot;&gt; &lt;p class&#x3D;&quot;cds--skeleton__text&quot; style&#x3D;&quot;width: 70px&quot;&gt;&lt;/p&gt; &lt;/div&gt; &lt;div *ngIf&#x3D;&quot;!skeleton&quot; class&#x3D;&quot;cds--pagination__right&quot;&gt; &lt;span *ngIf&#x3D;&quot;pagesUnknown&quot; class&#x3D;&quot;cds--pagination__text cds--pagination__page-text&quot;&gt; &lt;ng-container *ngIf&#x3D;&quot;!showPageInput&quot;&gt;{{currentPage}}&lt;/ng-container&gt; {{pageText.subject | async}} &lt;/span&gt; &lt;ng-container *ngIf&#x3D;&quot;showPageInput&quot;&gt; &lt;div class&#x3D;&quot;cds--select cds--select--inline cds--select__page-number&quot; [class.cds--select--disabled]&#x3D;&quot;pageInputDisabled&quot;&gt; &lt;label [for]&#x3D;&quot;currentPageSelectId&quot; class&#x3D;&quot;cds--label cds--visually-hidden&quot;&gt;{{pageText.subject | async}}&lt;/label&gt; &lt;input *ngIf&#x3D;&quot;pageOptions.length &gt; pageSelectThreshold&quot; style&#x3D;&quot;padding-right: 1rem; margin-right: 1rem;&quot; [id]&#x3D;&quot;currentPageSelectId&quot; type&#x3D;&quot;number&quot; min&#x3D;&quot;1&quot; [max]&#x3D;&quot;pageOptions.length&quot; class&#x3D;&quot;cds--select-input&quot; [(ngModel)]&#x3D;&quot;currentPage&quot;&gt; &lt;select *ngIf&#x3D;&quot;pageOptions.length &lt;&#x3D; pageSelectThreshold&quot; [id]&#x3D;&quot;currentPageSelectId&quot; class&#x3D;&quot;cds--select-input&quot; [disabled]&#x3D;&quot;pageInputDisabled&quot; [(ngModel)]&#x3D;&quot;currentPage&quot;&gt; &lt;option *ngFor&#x3D;&quot;let page of pageOptions; let i &#x3D; index;&quot; class&#x3D;&quot;cds--select-option&quot; [value]&#x3D;&quot;i + 1&quot;&gt;{{i + 1}}&lt;/option&gt; &lt;/select&gt; &lt;svg *ngIf&#x3D;&quot;pageOptions.length &lt;&#x3D; pageSelectThreshold&quot; cdsIcon&#x3D;&quot;chevron--down&quot; size&#x3D;&quot;16&quot; style&#x3D;&quot;display: inherit;&quot; class&#x3D;&quot;cds--select__arrow&quot; [attr.ariaLabel]&#x3D;&quot;optionsListText.subject | async&quot;&gt; &lt;/svg&gt; &lt;/div&gt; &lt;/ng-container&gt; &lt;span *ngIf&#x3D;&quot;!pagesUnknown &amp;&amp; lastPage &lt;&#x3D; 1&quot; class&#x3D;&quot;cds--pagination__text&quot;&gt; &lt;ng-container *ngIf&#x3D;&quot;!showPageInput&quot;&gt;{{currentPage}}&lt;/ng-container&gt; {{ofLastPageText.subject | i18nReplace: {last: lastPage} | async}} &lt;/span&gt; &lt;span *ngIf&#x3D;&quot;!pagesUnknown &amp;&amp; lastPage &gt; 1&quot; class&#x3D;&quot;cds--pagination__text&quot;&gt; &lt;ng-container *ngIf&#x3D;&quot;!showPageInput&quot;&gt;{{currentPage}}&lt;/ng-container&gt; {{ofLastPagesText.subject | i18nReplace: {last: lastPage} | async}} &lt;/span&gt; &lt;div class&#x3D;&quot;cds--pagination__control-buttons&quot;&gt; &lt;button cdsButton&#x3D;&quot;ghost&quot; iconOnly&#x3D;&quot;true&quot; class&#x3D;&quot;cds--pagination__button cds--pagination__button--backward&quot; [ngClass]&#x3D;&quot;{ &#x27;cds--pagination__button--no-index&#x27;: currentPage &lt;&#x3D; 1 || disabled }&quot; tabindex&#x3D;&quot;0&quot; [attr.aria-label]&#x3D;&quot;backwardText.subject | async&quot; (click)&#x3D;&quot;selectPage.emit(previousPage)&quot; [disabled]&#x3D;&quot;(currentPage &lt;&#x3D; 1 || disabled ? true : null)&quot;&gt; &lt;svg cdsIcon&#x3D;&quot;caret--left&quot; size&#x3D;&quot;16&quot; class&#x3D;&quot;cds--btn__icon&quot;&gt;&lt;/svg&gt; &lt;/button&gt; &lt;button cdsButton&#x3D;&quot;ghost&quot; iconOnly&#x3D;&quot;true&quot; class&#x3D;&quot; cds--pagination__button cds--pagination__button--forward&quot; [ngClass]&#x3D;&quot;{ &#x27;cds--pagination__button--no-index&#x27;: currentPage &gt;&#x3D; lastPage || disabled }&quot; tabindex&#x3D;&quot;0&quot; [attr.aria-label]&#x3D;&quot;forwardText.subject | async&quot; (click)&#x3D;&quot;selectPage.emit(nextPage)&quot; [disabled]&#x3D;&quot;(currentPage &gt;&#x3D; lastPage || disabled ? true : null)&quot;&gt; &lt;svg cdsIcon&#x3D;&quot;caret--right&quot; size&#x3D;&quot;16&quot; class&#x3D;&quot;cds--btn__icon&quot;&gt;&lt;/svg&gt; &lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &#x60; }) export class Pagination { static paginationCounter &#x3D; 0; /** * Set to &#x60;true&#x60; for a loading pagination component. */ @Input() skeleton &#x3D; false; /** * &#x60;PaginationModel&#x60; with the information about pages you&#x27;re controlling. */ @Input() model: PaginationModel; /** * Set to &#x60;true&#x60; to disable the backward/forward buttons. */ @Input() disabled &#x3D; false; /** * Set to &#x60;true&#x60; to disable the select box that changes the page. */ @Input() pageInputDisabled &#x3D; false; /** * Controls wether or not to show the page selects */ @Input() showPageInput &#x3D; true; /** * Set to &#x60;true&#x60; if the total number of items is unknown. */ @Input() pagesUnknown &#x3D; false; @Input() pageSelectThreshold &#x3D; 1000; /** * Expects an object that contains some or all of: * &#x60;&#x60;&#x60; * { * &quot;ITEMS_PER_PAGE&quot;: &quot;Items per page:&quot;, * &quot;OPEN_LIST_OF_OPTIONS&quot;: &quot;Open list of options&quot;, * &quot;BACKWARD&quot;: &quot;Backward&quot;, * &quot;FORWARD&quot;: &quot;Forward&quot;, * &quot;TOTAL_ITEMS_UNKNOWN&quot;: &quot;{{start}}-{{end}} items&quot;, * &quot;TOTAL_ITEMS&quot;: &quot;{{start}}-{{end}} of {{total}} items&quot;, * &quot;TOTAL_ITEM&quot;: &quot;{{start}}-{{end}} of {{total}} item&quot;, * &quot;OF_LAST_PAGES&quot;: &quot;of {{last}} pages&quot;, * &quot;OF_LAST_PAGE&quot;: &quot;of {{last}} page&quot; * } * &#x60;&#x60;&#x60; */ @Input() set translations (value: PaginationTranslations) { const valueWithDefaults &#x3D; merge(this.i18n.getMultiple(&quot;PAGINATION&quot;), value); this.itemsPerPageText.override(valueWithDefaults.ITEMS_PER_PAGE); this.optionsListText.override(valueWithDefaults.OPEN_LIST_OF_OPTIONS); this.backwardText.override(valueWithDefaults.BACKWARD); this.forwardText.override(valueWithDefaults.FORWARD); this.totalItemsText.override(valueWithDefaults.TOTAL_ITEMS); this.totalItemText.override(valueWithDefaults.TOTAL_ITEM); this.totalItemsUnknownText.override(valueWithDefaults.TOTAL_ITEMS_UNKNOWN); this.pageText.override(valueWithDefaults.PAGE); this.ofLastPagesText.override(valueWithDefaults.OF_LAST_PAGES); this.ofLastPageText.override(valueWithDefaults.OF_LAST_PAGE); } /** * Options for items per page select * * A default array of options will be defined: [10, 20, 30, 40, 50] */ @Input() itemsPerPageOptions: number[] &#x3D; [10, 20, 30, 40, 50]; /** * Emits the new page number. * * You should tie into this and update &#x60;model.currentPage&#x60; once the fresh * data is finally loaded. */ @Output() selectPage &#x3D; new EventEmitter&lt;number&gt;(); get itemsPerPage() { return this.model.pageLength; } set itemsPerPage(value) { this.model.pageLength &#x3D; Number(value); this.currentPage &#x3D; 1; // reset page } get currentPage() { return this.model.currentPage; } set currentPage(value) { value &#x3D; Number(value); // emits the value to allow the user to update current page // in the model once the page is loaded this.selectPage.emit(value); } get totalDataLength() { return this.model.totalDataLength; } /** * The last page number to display in the pagination view. */ get lastPage(): number { const last &#x3D; Math.ceil(this.totalDataLength / this.itemsPerPage); return last &gt; 0 ? last : 1; } get startItemIndex() { return this.endItemIndex &gt; 0 ? (this.currentPage - 1) * this.itemsPerPage + 1 : 0; } get endItemIndex() { const projectedEndItemIndex &#x3D; this.currentPage * this.itemsPerPage; return projectedEndItemIndex &lt; this.totalDataLength ? projectedEndItemIndex : this.totalDataLength; } /** * The previous page number to navigate to, from the current page. */ get previousPage(): number { return this.currentPage &lt;&#x3D; 1 ? 1 : this.currentPage - 1; } /** * The next page number to navigate to, from the current page. */ get nextPage(): number { const lastPage &#x3D; this.lastPage; return this.currentPage &gt;&#x3D; lastPage ? lastPage : this.currentPage + 1; } get pageOptions() { /** * Calculate number of pages based on totalDataLength and itemsPerPage. * Even if totalDataLength is 0, numberOfPages should be always at least 1. * New array will be constructed only if number of pages changes. */ const numberOfPages &#x3D; Math.max(Math.ceil(this.totalDataLength / this.itemsPerPage), 1); if (this._pageOptions.length !&#x3D;&#x3D; numberOfPages) { this._pageOptions &#x3D; Array(numberOfPages); } return this._pageOptions; } itemsPerPageSelectId &#x3D; &#x60;pagination-select-items-per-page-${Pagination.paginationCounter}&#x60;; currentPageSelectId &#x3D; &#x60;pagination-select-current-page-${Pagination.paginationCounter}&#x60;; itemsPerPageText &#x3D; this.i18n.getOverridable(&quot;PAGINATION.ITEMS_PER_PAGE&quot;); optionsListText &#x3D; this.i18n.getOverridable(&quot;PAGINATION.OPEN_LIST_OF_OPTIONS&quot;); backwardText &#x3D; this.i18n.getOverridable(&quot;PAGINATION.BACKWARD&quot;); forwardText &#x3D; this.i18n.getOverridable(&quot;PAGINATION.FORWARD&quot;); totalItemsText &#x3D; this.i18n.getOverridable(&quot;PAGINATION.TOTAL_ITEMS&quot;); totalItemText &#x3D; this.i18n.getOverridable(&quot;PAGINATION.TOTAL_ITEM&quot;); totalItemsUnknownText &#x3D; this.i18n.getOverridable(&quot;PAGINATION.TOTAL_ITEMS_UNKNOWN&quot;); pageText &#x3D; this.i18n.getOverridable(&quot;PAGINATION.PAGE&quot;); ofLastPagesText &#x3D; this.i18n.getOverridable(&quot;PAGINATION.OF_LAST_PAGES&quot;); ofLastPageText &#x3D; this.i18n.getOverridable(&quot;PAGINATION.OF_LAST_PAGE&quot;); protected _pageOptions &#x3D; []; constructor(protected i18n: I18n, protected experimental: ExperimentalService) { Pagination.paginationCounter++; } } </code></pre> </div> </div> </div><div class="search-results"> <div class="has-results"> <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1> <ul class="search-results-list"></ul> </div> <div class="no-results"> <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1> </div> </div> </div> <!-- END CONTENT --> </div> </div> <label class="dark-mode-switch"> <input type="checkbox"> <span class="slider"> <svg class="slider-icon" viewBox="0 0 24 24" fill="none" height="20" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" width="20" xmlns="http://www.w3.org/2000/svg"> <path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"></path> </svg> </span> </label> <script> var COMPODOC_CURRENT_PAGE_DEPTH = 1; var COMPODOC_CURRENT_PAGE_CONTEXT = 'interface'; var COMPODOC_CURRENT_PAGE_URL = 'PaginationTranslations.html'; var MAX_SEARCH_RESULTS = 15; </script> <script> $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input'); checkToggle(darkModeState); if ($darkModeToggleSwitchers.length > 0) { for (var i = 0; i < $darkModeToggleSwitchers.length; i++) { $darkModeToggleSwitchers[i].addEventListener('change', function (event) { darkModeState = !darkModeState; toggleDarkMode(darkModeState); }); } } </script> <script src="../js/libs/custom-elements.min.js"></script> <script src="../js/libs/lit-html.js"></script> <script src="../js/menu-wc.js" defer></script> <script nomodule src="../js/menu-wc_es5.js" defer></script> <script src="../js/libs/bootstrap-native.js"></script> <script src="../js/libs/es6-shim.min.js"></script> <script src="../js/libs/EventDispatcher.js"></script> <script src="../js/libs/promise.min.js"></script> <script src="../js/libs/zepto.min.js"></script> <script src="../js/compodoc.js"></script> <script src="../js/tabs.js"></script> <script src="../js/menu.js"></script> <script src="../js/libs/clipboard.min.js"></script> <script src="../js/libs/prism.js"></script> <script src="../js/sourceCode.js"></script> <script src="../js/search/search.js"></script> <script src="../js/search/lunr.min.js"></script> <script src="../js/search/search-lunr.js"></script> <script src="../js/search/search_index.js"></script> <script src="../js/lazy-load-graphs.js"></script> <footer class="carbon"> <dds-footer-container key="footer" disable-locale-button="true" size="micro" /> </footer> <script key="8" type="module" src="https://1.www.s81c.com/common/carbon-for-ibm-dotcom/tag/v1/latest/footer.min.js"> </script> <!-- Storybook override --> <script> document.title = "Carbon Components Angular"; </script> <script src="//1.www.s81c.com/common/stats/ibm-common.js" type="text/javascript" async="async"> </script> </body> </html>