import{nothing,type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraAppearance,LyraSize}from'../../../internal/variants.js'; /** `standard` renders the numbered page list; `compact` collapses it to the page-jump field. */ export type LyraPaginationFormat='standard'|'compact';export interface LyraPaginationChangeDetail{readonly page:number;readonly pageSize:number;}export interface LyraPaginationEventMap{'lr-before-page-change':CustomEvent;'lr-page-change':CustomEvent;'lr-activate':CustomEvent<{value:number;}>;blur:FocusEvent;focus:FocusEvent;} /** * `` — controlled, server-friendly page navigation: a numbered * page list with elided gaps, optional first/last controls, an optional * item-range summary, and a compact layout that swaps the list for an * editable page jump. * * The component never mutates `page`. Button and compact-field activation emits * `lr-page-change`; link-mode anchors navigate without either page-change event. The consumer * applies a button/field request after its own routing or data-fetch decision. Once the `page` property changes, a polite * live region announces the applied page and focus follows the newly current * page control (or the compact page field). * Public `focus()`, `blur()`, and `click()` resolve the primary control for the active format: * the applied page control in standard format, or the page-jump input in compact format. * * `total="-1"` enters indeterminate mode for a server API that never returns a total (limit/offset * and cursor/keyset APIs typically don't) -- it renders previous/next plus a page-number field, no * numbered page list, no item-range summary, and no `page-count`. `format`, `with-summary`, and * `with-edges` are ignored in this mode: there is no total to lay a page list or a "last page" * button against. `hasNext` (default `true`) is the one extra signal the mode needs -- previous * availability stays derivable from `page` alone, but forward availability generally is not for a * caller with no total. Any OTHER negative `total` (e.g. a computed `-50`) still renders the * ordinary empty state, exactly like today: only the exact `-1` sentinel opts in, so a garbage or * miscalculated negative value never silently reclassifies into a different rendering mode. Picked * over a pair of `has-next`/`has-previous` booleans as the sole entry point because `total` is the * one property every consumer already sets, and it mirrors ``'s own established * negative-sentinel `total-items` precedent (see that property's own doc for why the two sentinels * are kept numerically distinct). Event, focus-management, and announcement contracts are * unchanged: `lr-before-page-change`/`lr-page-change`/`lr-activate` fire the same way, and the * applied-page announcement/focus-follow both still run, just against a page-only message with no * total-pages figure. * * @customElement lr-pagination * @event lr-before-page-change - Fired before a valid button or compact-field page request. * `detail: { page, pageSize }`. Cancelable; vetoing it suppresses `lr-page-change`. Link-mode * anchors navigate without emitting. * @event lr-page-change - Fired when a button or compact field requests a valid page. * `detail: { page, pageSize }`. The component remains controlled and never mutates `page` * itself; link-mode anchors navigate without emitting. * @event lr-activate - Fired on every accepted page request, whether or not the page actually * moved. `detail: { value }` carries the requested page number. Bubbling and composed, so a host * outside the shadow tree receives it. Not cancelable: `lr-before-page-change` is this * component's veto point, and a vetoed request emits no activation at all. Re-requesting the * current page is the case `lr-page-change` deliberately stays silent for -- "load that page * again" is a real intent, and it is otherwise unobservable, because the page buttons and the * jump input live in this shadow root, so a retargeted `click` names no page and pressing Enter * on the jump field produces no click. When a request does move the page, * `lr-before-page-change` and `lr-page-change` are emitted first. Link-mode anchors navigate * without emitting. * @slot first-icon - Replacement for the first-page icon. * @slot previous-icon - Replacement for the previous-page icon. * @slot next-icon - Replacement for the next-page icon. * @slot last-icon - Replacement for the last-page icon. * @event {FocusEvent} blur - Re-dispatched from an internal pagination control as one bubbling, * composed native `FocusEvent`, preserving its focus payload. * @event {FocusEvent} focus - Re-dispatched from an internal pagination control as one bubbling, * composed native `FocusEvent`, preserving its focus payload. * @csspart base - Compatibility name for the navigation wrapper; use `pagination`. * @csspart pagination - The navigation wrapper. It is the same node as `base`. * @csspart summary - The item-range summary. * @csspart controls - The previous/pages/next control group. * @csspart pages - The `role="list"` wrapper around the numbered page items. * @csspart page - One numbered page control; a `