/** @jsx h */ import { h, render } from 'preact'; import { cx } from '@algolia/ui-components-shared'; import type { PaginationComponentCSSClasses, PaginationComponentTemplates, } from '../../components/Pagination/Pagination'; import Pagination from '../../components/Pagination/Pagination'; import type { PaginationConnectorParams, PaginationRenderState, PaginationWidgetDescription, } from '../../connectors/pagination/connectPagination'; import connectPagination from '../../connectors/pagination/connectPagination'; import { getContainerNode, createDocumentationMessageGenerator, } from '../../lib/utils'; import { component } from '../../lib/suit'; import type { Renderer, WidgetFactory } from '../../types'; const suit = component('Pagination'); const withUsage = createDocumentationMessageGenerator({ name: 'pagination' }); const defaultTemplates: PaginationComponentTemplates = { previous: '‹', next: '›', first: '«', last: '»', }; const renderer = ({ containerNode, cssClasses, templates, showFirst, showLast, showPrevious, showNext, scrollToNode, }: { containerNode: HTMLElement; cssClasses: PaginationComponentCSSClasses; templates: PaginationComponentTemplates; showFirst: boolean; showLast: boolean; showPrevious: boolean; showNext: boolean; scrollToNode: HTMLElement | false; }): Renderer> => ( { createURL, currentRefinement, nbPages, pages, isFirstPage, isLastPage, refine, }, isFirstRendering ) => { if (isFirstRendering) return; const setCurrentPage = (pageNumber: number) => { refine(pageNumber); if (scrollToNode !== false) { scrollToNode.scrollIntoView(); } }; render( , containerNode ); }; export type PaginationCSSClasses = Partial<{ /** * CSS classes added to the root element of the widget. */ root: string | string[]; /** * CSS class to add to the root element of the widget if there are no refinements. */ noRefinementRoot: string | string[]; /** * CSS classes added to the wrapping `