import React, { ElementType, forwardRef, HTMLAttributes } from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import { CLink } from '../link/CLink'
import { PolymorphicRefForwardingComponent } from '../../helpers'
export interface CPaginationItemProps extends HTMLAttributes {
/**
* Toggle the active state for the component.
*/
active?: boolean
/**
* Component used for the root node. Either a string to use a HTML element or a component.
*/
as?: string | ElementType
/**
* Toggle the disabled state for the component.
*/
disabled?: boolean
}
export const CPaginationItem: PolymorphicRefForwardingComponent<'a', CPaginationItemProps> =
forwardRef(
({ children, as, className, ...rest }, ref) => {
const Component = as ?? (rest.active ? 'span' : 'a')
return (
{Component === 'a' ? (
{children}
) : (
{children}
)}
)
}
)
CPaginationItem.propTypes = {
as: PropTypes.elementType,
children: PropTypes.node,
className: PropTypes.string,
}
CPaginationItem.displayName = 'CPaginationItem'