UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

79 lines (78 loc) 2.5 kB
/** * DevExtreme (esm/__internal/pagination/pagination.js) * Version: 25.2.5 * Build date: Fri Feb 20 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { createComponentVNode } from "inferno"; import { createReRenderEffect, InfernoWrapperComponent } from "../core/r1/runtime/inferno/index"; import { combineClasses } from "../core/r1/utils/render_utils"; import { PaginationDefaultProps } from "./common/pagination_props"; import { PaginationContent } from "./content"; import { ResizableContainer } from "./resizable_container"; import { isGridCompatibilityMode } from "./utils/compatibility_utils"; export class Pagination extends InfernoWrapperComponent { constructor(props) { super(props); this.__getterCache = {}; this.pageIndexChangedInternal = this.pageIndexChangedInternal.bind(this); this.pageSizeChangedInternal = this.pageSizeChangedInternal.bind(this) } createEffects() { return [createReRenderEffect()] } pageIndexChangedInternal(newPageIndex) { const newValue = newPageIndex + 1; this.setState((() => ({ pageIndex: newValue }))); this.props.pageIndexChangedInternal(newValue) } getPageIndex() { return this.props.pageIndex - 1 } pageSizeChangedInternal(newPageSize) { this.setState((() => ({ pageSize: newPageSize }))); this.props.pageSizeChangedInternal(newPageSize) } getClassName() { return combineClasses({ "dx-datagrid-pager": isGridCompatibilityMode(this.context), [`${this.props.className}`]: !!this.props.className }) } getPaginationProps() { return Object.assign({}, this.props, { className: this.getClassName(), pageIndex: this.getPageIndex(), pageIndexChangedInternal: pageIndex => this.pageIndexChangedInternal(pageIndex), pageSizeChangedInternal: pageSize => this.pageSizeChangedInternal(pageSize) }) } render() { return createComponentVNode(2, ResizableContainer, { contentTemplate: PaginationContent, paginationProps: this.getPaginationProps() }) } } Pagination.defaultProps = PaginationDefaultProps;