import { composeEventHandlers } from "@kobalte/utils"; import { type Component, type JSX, type ValidComponent, splitProps, } from "solid-js"; import * as Button from "../button"; import type { ElementOf, PolymorphicProps } from "../polymorphic"; import { usePaginationContext } from "./pagination-context"; export interface PaginationNextOptions {} export interface PaginationNextCommonProps< T extends HTMLElement = HTMLElement, > { onClick: JSX.EventHandlerUnion; } export interface PaginationNextRenderProps extends PaginationNextCommonProps, Button.ButtonRootRenderProps {} export type PaginationNextProps< T extends ValidComponent | HTMLElement = HTMLElement, > = PaginationNextOptions & Partial>>; export function PaginationNext( props: PolymorphicProps>, ) { const context = usePaginationContext(); const [local, others] = splitProps(props as PaginationNextProps, ["onClick"]); const onClick: JSX.EventHandlerUnion = () => { context.setPage(context.page() + 1); }; const isDisabled = () => context.page() === context.count(); return (
  • > > tabIndex={ isDisabled() || context.page() === context.count() ? -1 : undefined } disabled={isDisabled()} aria-disabled={isDisabled() || undefined} data-disabled={isDisabled() ? "" : undefined} onClick={composeEventHandlers([local.onClick, onClick])} {...others} />
  • ); }