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