@synergy-design-system/components
Version:
105 lines (104 loc) • 5.14 kB
TypeScript
import { type CSSResultGroup, type PropertyValues } from 'lit';
import SynergyElement from '../../internal/synergy-element.js';
import SynDivider from '../divider/divider.component.js';
import SynIconButton from '../icon-button/icon-button.component.js';
import SynInput from '../input/input.component.js';
import SynOption from '../option/option.component.js';
import SynSelect from '../select/select.component.js';
/**
* @summary <syn-pagination /> provides page navigation, direct page input, and page-size selection for large data sets.
*
* @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-pagination--docs
* @status stable
* @since 3.12.0
*
* @event syn-pagination-page-changed - Emitted when the current page changes
* @event syn-pagination-page-size-changed - Emitted when the page size changes
*
* @csspart base - The component's base wrapper.
* @csspart divider - The divider element displayed at the top of the pagination component.
* @csspart page-size-select-wrapper - The wrapper element containing the page size select and page item summary.
* @csspart page-size-select - The page size select element.
* @csspart page-item-summary - The text element displaying the current page item range and total items.
* @csspart page-input-section - The section containing the page number input and total pages display.
* @csspart page-input - The page number input element.
* @csspart navigation - The pagination navigation element.
* @csspart navigation-action - The individual navigation action buttons (first, previous, next, last).
*
* @accessibility
* The entire component is wrapped in a semantic `<nav>` landmark with an `aria-label` for screen reader accessibility.
* Use the `aria-label` attribute to provide a unique, descriptive label when multiple pagination controls exist on the page.
* Example: `<syn-pagination aria-label="Search results pagination"></syn-pagination>`
*/
export default class SynPagination extends SynergyElement {
private static readonly DEFAULT_PAGE_SIZE;
private static readonly DEFAULT_CURRENT_PAGE;
private static readonly DEFAULT_TOTAL_ITEMS;
private readonly baseRef;
private readonly localize;
static styles: CSSResultGroup;
static dependencies: {
'syn-divider': typeof SynDivider;
'syn-icon-button': typeof SynIconButton;
'syn-input': typeof SynInput;
'syn-option': typeof SynOption;
'syn-select': typeof SynSelect;
};
/**
* When true, a divider is displayed at the top of the pagination component.
*/
divider: boolean;
/**
* When true, the pagination controls are disabled and non-interactive.
*/
disabled: boolean;
/**
* The size of the pagination controls.
*/
size: 'small' | 'medium' | 'large';
/**
* The current page number. The default value is 1.
* The component will emit a `syn-pagination-page-changed` event whenever the page changes, allowing you to respond to page changes in your application.
*/
currentPage: number;
/**
* The number of items to display per page. The default value is 25.
* The component will emit a `syn-pagination-page-size-changed` event whenever the page size changes, allowing you to respond to page size changes in your application.
*/
pageSize: number;
/**
* An array of numbers representing the available options for the number of items to display per page. The default value is [10, 25, 50, 100].
* The component will use this array to populate the rows-per-page selector, allowing users to choose from the specified options.
*/
pageSizeOptions: number[];
/**
* Total amount of items. The component will use this value to calculate the total number of pages based on the selected rows per page.
*/
totalItems: number;
/**
* The pagination variant to use. The "full" variant includes comprehensive controls for navigating between pages and adjusting the number of displayed rows,
* while the "compact" variant offers a streamlined interface with essential navigation controls.
* The default value is "full".
*/
variant: 'full' | 'compact';
/**
* An accessible label for the navigation landmark. Customize for multiple paginations on a page.
*/
ariaLabel: string;
private pageChangedViaUserInput;
private navigationClicked;
private sanitizeInvalidPropertyValues;
/**
* Updates the current page number and emits a "syn-pagination-page-changed" event with the new and previous page numbers.
* This method is called when the page number is changed via the page input or the navigation buttons.
*/
private updateCurrentPage;
/**
* Called when the page size is changed via the page size select.
* Emits a `syn-pagination-page-size-changed` event with the new and previous page sizes.
*/
private pageSizeChanged;
protected willUpdate(changed: PropertyValues<this>): void;
protected updated(changed: PropertyValues<this>): void;
render(): import("lit").TemplateResult<1>;
}