/** * PaginationMechanismCard Component * * Card component for displaying pagination mechanism detection results. * Shows pagination type and type-specific selectors for different pagination patterns. * * Supports: * - NUMBERED_PAGES: Page links with optional active page indicator * - NEXT_PREV: Next and previous navigation buttons * - LOAD_MORE: Load more button for incremental loading * - INFINITE_SCROLL: Infinite scroll with container and loading indicator * * @layer Presentation */ import * as React from 'react'; import { List } from 'lucide-react'; import { PaginationMechanism, PaginationType } from '@archer/domain'; import { Badge } from '@/components/ui/badge'; import { formatPaginationType } from '@/lib/pattern-format-utils'; export interface PaginationMechanismCardProps { mechanism: PaginationMechanism; className?: string; } export const PaginationMechanismCard = React.forwardRef( ({ mechanism, className }, ref) => { return (
{/* Header with icon and type badge */}

Pagination Mechanism

{formatPaginationType(mechanism.type)}
{/* Selectors section - conditional based on type */}
{/* NUMBERED_PAGES */} {mechanism.type === PaginationType.NUMBERED_PAGES && ( <> {mechanism.pageNumberSelector && (
Page Links: {mechanism.pageNumberSelector}
)} {mechanism.containerSelector && (
Container: {mechanism.containerSelector}
)} {mechanism.urlPattern && (
URL Pattern: {mechanism.urlPattern}
)} )} {/* NEXT_PREV */} {mechanism.type === PaginationType.NEXT_PREV && ( <> {mechanism.nextSelector && (
Next Button: {mechanism.nextSelector}
)} {mechanism.prevSelector && (
Previous Button: {mechanism.prevSelector}
)} {mechanism.containerSelector && (
Container: {mechanism.containerSelector}
)} )} {/* LOAD_MORE */} {mechanism.type === PaginationType.LOAD_MORE && ( <> {mechanism.buttonSelector && (
Load More Button: {mechanism.buttonSelector}
)} {mechanism.containerSelector && (
Container: {mechanism.containerSelector}
)} )} {/* INFINITE_SCROLL */} {mechanism.type === PaginationType.INFINITE_SCROLL && ( <> {mechanism.containerSelector && (
Scroll Container: {mechanism.containerSelector}
)} {/* Note: loadingIndicatorSelector not in interface, but we check for common alternative fields */} {mechanism.nextSelector && (
Loading Trigger: {mechanism.nextSelector}
)} )} {/* Fallback if no selectors available */} {!hasAnySelectors(mechanism) && (
No selector details available
)}
); } ); PaginationMechanismCard.displayName = 'PaginationMechanismCard'; /** * Checks if pagination mechanism has any selector fields defined * * @param mechanism - PaginationMechanism to check * @returns true if any selector field is defined */ function hasAnySelectors(mechanism: PaginationMechanism): boolean { return !!( mechanism.containerSelector || mechanism.nextSelector || mechanism.prevSelector || mechanism.pageNumberSelector || mechanism.buttonSelector || mechanism.urlPattern ); }