11import React from 'react'
2- import Box from '../Box'
32import { buildComponentData , buildPaginationModel , type PageDataProps } from './model'
43import type { ResponsiveValue } from '../hooks/useResponsiveValue'
54import { viewportRanges } from '../hooks/useResponsiveValue'
65import { clsx } from 'clsx'
76import classes from './Pagination.module.css'
8- import { BoxWithFallback } from '../internal/components/BoxWithFallback'
97
108const getViewportRangesToHidePages = ( showPages : PaginationProps [ 'showPages' ] ) => {
119 if ( showPages && typeof showPages !== 'boolean' ) {
@@ -33,7 +31,6 @@ export type PageProps = {
3331} & Omit < PageDataProps [ 'props' ] , 'as' | 'role' >
3432
3533type UsePaginationPagesParameters = {
36- theme ?: Record < string , unknown > // set to theme type once /src/theme.js is converted
3734 pageCount : number
3835 currentPage : number
3936 onPageChange : ( e : React . MouseEvent , n : number ) => void
@@ -45,7 +42,6 @@ type UsePaginationPagesParameters = {
4542}
4643
4744function usePaginationPages ( {
48- theme,
4945 pageCount,
5046 currentPage,
5147 onPageChange,
@@ -67,22 +63,22 @@ function usePaginationPages({
6763 if ( renderPage && props . as !== 'span' ) {
6864 return renderPage ( { key, children : content , number : page . num , className : classes . Page , ...props } )
6965 }
66+ const Component = props . as || 'a'
7067
7168 return (
7269 // @ts -ignore giving me grief about children and "as" props
73- < BoxWithFallback as = "a" key = { key } theme = { theme } className = { clsx ( classes . Page ) } { ...props } >
70+ < Component key = { key } className = { clsx ( classes . Page ) } { ...props } >
7471 { content }
75- </ BoxWithFallback >
72+ </ Component >
7673 )
7774 } )
78- } , [ model , hrefBuilder , pageChange , renderPage , theme ] )
75+ } , [ model , hrefBuilder , pageChange , renderPage ] )
7976
8077 return children
8178}
8279
8380export type PaginationProps = {
8481 className ?: string
85- theme ?: Record < string , unknown >
8682 pageCount : number
8783 currentPage : number
8884 onPageChange ?: ( e : React . MouseEvent , n : number ) => void
@@ -95,7 +91,6 @@ export type PaginationProps = {
9591
9692function Pagination ( {
9793 className,
98- theme : _theme ,
9994 pageCount,
10095 currentPage,
10196 onPageChange = noop ,
@@ -107,7 +102,6 @@ function Pagination({
107102 ...rest
108103} : PaginationProps ) {
109104 const pageElements = usePaginationPages ( {
110- theme : _theme ,
111105 pageCount,
112106 currentPage,
113107 onPageChange,
@@ -119,20 +113,14 @@ function Pagination({
119113 } )
120114
121115 return (
122- < BoxWithFallback
123- as = "nav"
124- className = { clsx ( classes . PaginationContainer , className ) }
125- aria-label = "Pagination"
126- { ...rest }
127- >
128- < Box
129- display = "inline-block"
116+ < nav className = { clsx ( classes . PaginationContainer , className ) } aria-label = "Pagination" { ...rest } >
117+ < div
130118 className = { classes . TablePaginationSteps }
131119 data-hidden-viewport-ranges = { getViewportRangesToHidePages ( showPages ) . join ( ' ' ) }
132120 >
133121 { pageElements }
134- </ Box >
135- </ BoxWithFallback >
122+ </ div >
123+ </ nav >
136124 )
137125}
138126
0 commit comments