import { useAppForm, Form } from '@/components/form'; import type { DialogProps } from '@/components/elements/dialog'; import { Dialog } from '@/components/elements/dialog'; import { join } from 'pathe'; type Props = DialogProps & { /** The directory the new file is written to. */ directory: string; onFileNamed: (name: string) => void; }; /** Names a new file before the editor first writes it. */ export default function FileNameModal({ directory, onFileNamed, onClose, ...props }: Props) { const form = useAppForm({ defaultValues: { fileName: '' }, onSubmit: async ({ value }) => { onFileNamed(join(directory, value.fileName)); }, }); return ( { form.reset(); onClose(); }} {...props} >
(value.length >= 1 ? undefined : 'Required') }} > {(field) => ( )}
Create File
); }