"use client" import type { KeyboardEvent, ReactNode } from "react" import { ChevronLeft, ChevronRight, Minus, Plus } from "lucide-react" import { Button } from "@/components/ui/button" import { cn } from "@/lib/utils" export function handleStepAdjustKeyDown( e: KeyboardEvent, onDecrease: () => void, onIncrease: () => void, ) { if (e.key === "ArrowUp" || e.key === "+" || (e.key === "=" && !e.shiftKey)) { e.preventDefault() onIncrease() } else if (e.key === "ArrowDown" || e.key === "-") { e.preventDefault() onDecrease() } } export function StepAdjustDecreaseButton({ onClick, disabled, label, className, }: { onClick: () => void disabled?: boolean label: string className?: string }) { return ( ) } export function StepAdjustIncreaseButton({ onClick, disabled, label, className, }: { onClick: () => void disabled?: boolean label: string className?: string }) { return ( ) } /** Reculer l'heure — chevron gauche (réservé aux champs horaires). */ export function StepAdjustTimeDecreaseButton({ onClick, disabled, label, className, }: { onClick: () => void disabled?: boolean label: string className?: string }) { return ( ) } /** Avancer l'heure — chevron droit (réservé aux champs horaires). */ export function StepAdjustTimeIncreaseButton({ onClick, disabled, label, className, }: { onClick: () => void disabled?: boolean label: string className?: string }) { return ( ) } export function StepAdjustGroup({ children, className, }: { children: ReactNode className?: string }) { return (
{children}
) } export function FocusableStepValue({ tabIndex, value, ariaLabel, onDecrease, onIncrease, decreaseDisabled, increaseDisabled, decreaseLabel, increaseLabel, className, buttonClassName, valueWrapperClassName, valueClassName, }: { tabIndex?: number value: string ariaLabel: string onDecrease: () => void onIncrease: () => void decreaseDisabled?: boolean increaseDisabled?: boolean decreaseLabel: string increaseLabel: string className?: string buttonClassName?: string valueWrapperClassName?: string valueClassName?: string }) { const valueNode = ( handleStepAdjustKeyDown(e, onDecrease, onIncrease)} className={cn( "cursor-default outline-none focus-visible:rounded-sm focus-visible:ring-2 focus-visible:ring-ring", valueClassName, )} > {value} ) return ( {valueWrapperClassName ? (
{valueNode}
) : ( valueNode )}
) }