import React, { useMemo, useState } from 'react'; import * as LucideIcons from 'lucide-react'; import Button from './Button'; export default function IconSelector({ isOpen, onClose, onSelect, selectedIcon = '', }) { const [searchTerm, setSearchTerm] = useState(''); const excludedKeys = new Set([ 'Icon', 'DynamicIcon', 'createLucideIcon', 'default', 'icons', ]); const allIcons = Object.keys(LucideIcons).filter((key) => { // Exclure les utilitaires if (excludedKeys.has(key)) return false; return true; }); const filteredIcons = useMemo(() => { if (!searchTerm) return allIcons; return allIcons.filter((iconName) => iconName.toLowerCase().includes(searchTerm.toLowerCase()) ); }, [searchTerm, allIcons]); if (!isOpen) return null; const selectIcon = (iconName) => { onSelect(iconName); onClose(); }; return (

Choisir une icône ({filteredIcons.length} / {allIcons.length}{' '} icônes)

{/* Barre de recherche */}
setSearchTerm(e.target.value)} className="w-full px-4 py-3 pl-10 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" /> {searchTerm && ( )}
{filteredIcons.map((iconName) => { try { const IconComponent = LucideIcons[iconName]; return ( ); } catch (error) { // En cas d'erreur avec une icône spécifique, ne pas la rendre return null; } })}

{searchTerm ? ( <> {filteredIcons.length} icône(s) trouvée(s) sur {allIcons.length}{' '} disponibles ) : ( <>Total : {allIcons.length} icônes disponibles )}

); }