12 lines
282 B
TypeScript
12 lines
282 B
TypeScript
export function submitComposer<Event extends { preventDefault(): void }>(
|
|
event: Event,
|
|
input: string,
|
|
busy: boolean,
|
|
submit: (event: Event) => void,
|
|
focus: () => void,
|
|
): void {
|
|
event.preventDefault();
|
|
if (busy || !input.trim()) return;
|
|
submit(event);
|
|
focus();
|
|
}
|