// ============================================================================ // Chatbot Main - Message Input // ============================================================================ import type { FormEvent, FunctionComponent, Ref } from 'react'; import { useState } from 'react'; import { ActionGroup, Button, Form, FormProps, TextArea } from '@patternfly/react-core'; export interface MessageInputProps extends FormProps { /** Placeholder for edit input */ editPlaceholder?: string; /** Label for the English word "Update" used in edit mode. */ updateWord?: string; /** Label for the English word "Cancel" used in edit mode. */ cancelWord?: string; /** Callback function for when edit mode update button is clicked */ onEditUpdate?: (event: React.MouseEvent, value: string) => void; /** Callback functionf or when edit cancel update button is clicked */ onEditCancel?: (event: React.MouseEvent) => void; /** Ref applied to editable message input */ inputRef?: Ref; /** Message text */ content?: string; } export const MessageInput: FunctionComponent = ({ editPlaceholder = 'Edit prompt message...', updateWord = 'Update', cancelWord = 'Cancel', onEditUpdate, onEditCancel, inputRef, content, ...props }: MessageInputProps) => { const [messageText, setMessageText] = useState(content ?? ''); const onChange = (_event: FormEvent, value: string) => { setMessageText(value); }; return (