"use client"; /** * Icon Select Field * * Renders selectable cards with icons, images, or logos. * Supports both boxed (icons) and plain (logos/images) display styles. */ import { ANIMATION_CLASSES, getStaggerStyle, STAGGER_PRESETS, } from "../animations"; import { cx } from "../lib/utils"; import { OnboardingCard } from "../primitives/onboarding-card"; import { OnboardingCheckbox } from "../primitives/onboarding-checkbox"; import { OnboardingLabel } from "../primitives/onboarding-label"; import type { IconSelectFieldProps } from "../types/fields"; const iconSizeClasses = { sm: "h-8 w-8 text-xl", md: "h-10 w-10 text-2xl", lg: "h-12 w-12 text-3xl", }; export function IconSelectField({ options, selectedIds, onChange, selectionMode = "multiple", iconStyle = "boxed", iconSize = "md", ariaLabel, disabled = false, }: IconSelectFieldProps) { const handleToggle = (id: string, checked: boolean) => { let newSelected: string[]; if (selectionMode === "single") { newSelected = checked ? [id] : []; } else { newSelected = checked ? [...selectedIds, id] : selectedIds.filter((selectedId) => selectedId !== id); } onChange(newSelected); }; return (
{ariaLabel}
{options.map((option, index) => { const isSelected = selectedIds.includes(option.id); return (
handleToggle(option.id, checked === true) } /> {option.icon && (iconStyle === "boxed" ? (
{option.icon}
) : (
{option.icon}
))}
{option.name} {option.description && (

{option.description}

)}
); })}
); }