2025-12-25 11:25:07 +00:00
|
|
|
import { Info } from 'lucide-react';
|
|
|
|
|
import { Tooltip } from './tooltip';
|
|
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
/**
|
|
|
|
|
* HelpTextProps - Propriétés du composant HelpText
|
|
|
|
|
*
|
|
|
|
|
* @interface HelpTextProps
|
|
|
|
|
*/
|
2025-12-25 11:25:07 +00:00
|
|
|
interface HelpTextProps {
|
2026-01-07 09:31:02 +00:00
|
|
|
/**
|
|
|
|
|
* Texte d'aide à afficher dans le tooltip
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* ```tsx
|
|
|
|
|
* <HelpText text="Ce champ est optionnel" />
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
2025-12-25 11:25:07 +00:00
|
|
|
text: string;
|
2026-01-07 09:31:02 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Classes CSS personnalisées
|
|
|
|
|
*/
|
2025-12-25 11:25:07 +00:00
|
|
|
className?: string;
|
2026-01-07 09:31:02 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Position du tooltip par rapport à l'icône
|
|
|
|
|
*
|
|
|
|
|
* - `top`: Au-dessus
|
|
|
|
|
* - `bottom`: En-dessous
|
|
|
|
|
* - `left`: À gauche
|
|
|
|
|
* - `right`: À droite
|
|
|
|
|
*
|
|
|
|
|
* @default 'top'
|
|
|
|
|
*/
|
2025-12-25 11:25:07 +00:00
|
|
|
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-07 09:31:02 +00:00
|
|
|
* HelpText - Composant de texte d'aide avec tooltip
|
|
|
|
|
*
|
|
|
|
|
* Composant affichant une icône d'information avec un tooltip au survol.
|
|
|
|
|
* Utilisé pour fournir des informations contextuelles aux utilisateurs.
|
|
|
|
|
*
|
2025-12-25 11:25:07 +00:00
|
|
|
* FE-COMP-024: Help text component with tooltip
|
2026-01-07 09:31:02 +00:00
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* ```tsx
|
|
|
|
|
* // Texte d'aide simple
|
|
|
|
|
* <HelpText text="Ce champ est optionnel" />
|
|
|
|
|
*
|
|
|
|
|
* // Avec position personnalisée
|
|
|
|
|
* <HelpText
|
|
|
|
|
* text="Minimum 8 caractères"
|
|
|
|
|
* position="right"
|
|
|
|
|
* />
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* @component
|
|
|
|
|
* @param {HelpTextProps} props - Propriétés du composant
|
|
|
|
|
* @returns {JSX.Element} Élément span avec icône Info et tooltip
|
2025-12-25 11:25:07 +00:00
|
|
|
*/
|
|
|
|
|
export function HelpText({
|
|
|
|
|
text,
|
|
|
|
|
className,
|
|
|
|
|
position = 'top',
|
|
|
|
|
}: HelpTextProps) {
|
|
|
|
|
return (
|
|
|
|
|
<Tooltip content={text} position={position}>
|
|
|
|
|
<span
|
|
|
|
|
className={cn(
|
|
|
|
|
'inline-flex items-center text-muted-foreground cursor-help',
|
|
|
|
|
className,
|
|
|
|
|
)}
|
|
|
|
|
aria-label={`Aide: ${text}`}
|
|
|
|
|
>
|
|
|
|
|
<Info className="h-3 w-3" aria-hidden="true" />
|
|
|
|
|
</span>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|