import { useState } from 'react' import { t } from '../i18n' import { useMedia } from '../store' import type { CustomList } from '../types' /** * Champ « Nouvelle liste » (onglet Listes, fiche d'un titre, sélection multiple). * Dans son propre fichier : l'importer n'embarque pas tout l'onglet Listes (chargé à la demande). */ export function NewListForm({ onCreated, autoFocus }: { onCreated?: (list: CustomList) => void; autoFocus?: boolean }) { const { createList } = useMedia() const [name, setName] = useState('') // Pas de
ici : ce champ peut vivre à l'intérieur du formulaire d'une fiche const submit = () => { if (!name.trim()) return onCreated?.(createList(name)) setName('') } return (
setName(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault() submit() } }} placeholder={t('lists.newListPh')} autoFocus={autoFocus} enterKeyHint="done" />
) }