UNPKG

@porsche-design-system/components-react

Version:

Porsche Design System is a component library designed to help developers create the best experience for software or services distributed by Dr. Ing. h.c. F. Porsche AG.

38 lines (34 loc) 1.6 kB
"use client"; 'use strict'; var jsxRuntime = require('react/jsx-runtime'); var react = require('react'); var hooks = require('../../hooks.cjs'); var utils = require('../../utils.cjs'); var pagination = require('../dsr-components/pagination.cjs'); const PPagination = /*#__PURE__*/ react.forwardRef(({ activePage = 1, intl = { root: 'Pagination', prev: 'Previous page', next: 'Next page', page: 'Page', }, itemsPerPage = 1, onUpdate, showLastPage = true, totalItemsCount = 1, className, ...rest }, ref) => { const elementRef = react.useRef(undefined); hooks.useEventCallback(elementRef, 'update', onUpdate); const WebComponentTag = hooks.usePrefix('p-pagination'); const propsToSync = [activePage, intl, itemsPerPage, showLastPage, totalItemsCount]; hooks.useBrowserLayoutEffect(() => { const { current } = elementRef; ['activePage', 'intl', 'itemsPerPage', 'showLastPage', 'totalItemsCount'].forEach((propName, i) => (current[propName] = propsToSync[i])); }, propsToSync); const props = { ...rest, // @ts-ignore ...(!process.browser ? { children: (jsxRuntime.jsx(pagination.DSRPagination, { activePage, intl, itemsPerPage, showLastPage, totalItemsCount })), } : { suppressHydrationWarning: true, }), 'data-ssr': '', class: hooks.useMergedClass(elementRef, className), ref: utils.syncRef(elementRef, ref) }; // @ts-ignore return jsxRuntime.jsx(WebComponentTag, { ...props }); }); exports.PPagination = PPagination;