import React, { useState } from 'react'; import { IconButton, Icon, Button, TextInput, css, Label, useId, spacing, useFormattedDate, } from '@mongodb-js/compass-components'; import { Query } from '../query/query'; import type { QueryAttributes } from '../query/query'; type RecentModel = { _lastExecuted: Date; getAttributes: (arg0: { props: true }) => QueryAttributes; }; type SaveFormProps = { saveFavorite: (name: string) => void; onCancel: () => void; }; const formStyles = css({ display: 'flex', }); const labelStyles = css({ display: 'none', }); const textInputStyles = css({ flex: 1, }); const submitButtonStyles = css({ marginLeft: '6px', // spacing[1] makes the shadows overlap, spacing[2] is too much marginRight: spacing[1], }); function SaveForm({ saveFavorite, onCancel }: SaveFormProps) { const [name, setName] = useState(''); const labelId = useId(); const controlId = useId(); return (
{ event.preventDefault(); saveFavorite(name); }} >