This commit is contained in:
Qing
2023-12-13 22:56:09 +08:00
parent 354a1280a4
commit 142aa64cc6
19 changed files with 360 additions and 181 deletions

View File

@@ -1,7 +1,8 @@
import React, { FormEvent } from "react"
import React, { FormEvent, useRef } from "react"
import { Button } from "./ui/button"
import { Input } from "./ui/input"
import { useStore } from "@/lib/states"
import { useClickAway } from "react-use"
const PromptInput = () => {
const [isProcessing, prompt, updateSettings, runInpainting] = useStore(
@@ -12,6 +13,14 @@ const PromptInput = () => {
state.runInpainting,
]
)
const ref = useRef(null)
useClickAway<MouseEvent>(ref, () => {
if (ref?.current) {
const input = ref.current as HTMLInputElement
input.blur()
}
})
const handleOnInput = (evt: FormEvent<HTMLInputElement>) => {
evt.preventDefault()
@@ -43,6 +52,7 @@ const PromptInput = () => {
return (
<div className="flex gap-4 items-center">
<Input
ref={ref}
className="min-w-[500px]"
value={prompt}
onInput={handleOnInput}