({
input,
handleInputChange,
isLoading,
status,
stop,
}: InputProps)
| 10 | } |
| 11 | |
| 12 | export const Input = ({ |
| 13 | input, |
| 14 | handleInputChange, |
| 15 | isLoading, |
| 16 | status, |
| 17 | stop, |
| 18 | }: InputProps) => { |
| 19 | return ( |
| 20 | <div className="relative w-full"> |
| 21 | <ShadcnInput |
| 22 | className="bg-secondary py-6 w-full rounded-xl pr-12" |
| 23 | value={input} |
| 24 | autoFocus |
| 25 | placeholder={"Say something..."} |
| 26 | onChange={handleInputChange} |
| 27 | /> |
| 28 | {status === "streaming" || status === "submitted" ? ( |
| 29 | <button |
| 30 | type="button" |
| 31 | onClick={stop} |
| 32 | className="cursor-pointer absolute right-2 top-1/2 -translate-y-1/2 rounded-full p-2 bg-black hover:bg-zinc-800 disabled:bg-zinc-300 disabled:cursor-not-allowed transition-colors" |
| 33 | > |
| 34 | <div className="animate-spin h-4 w-4"> |
| 35 | <svg className="h-4 w-4 text-white" viewBox="0 0 24 24"> |
| 36 | <circle |
| 37 | className="opacity-25" |
| 38 | cx="12" |
| 39 | cy="12" |
| 40 | r="10" |
| 41 | stroke="currentColor" |
| 42 | strokeWidth="4" |
| 43 | fill="none" |
| 44 | /> |
| 45 | <path |
| 46 | className="opacity-75" |
| 47 | fill="currentColor" |
| 48 | d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" |
| 49 | /> |
| 50 | </svg> |
| 51 | </div> |
| 52 | </button> |
| 53 | ) : ( |
| 54 | <button |
| 55 | type="submit" |
| 56 | disabled={isLoading || !input.trim()} |
| 57 | className="absolute right-2 top-1/2 -translate-y-1/2 rounded-full p-2 bg-black hover:bg-zinc-800 disabled:bg-zinc-300 disabled:cursor-not-allowed transition-colors" |
| 58 | > |
| 59 | <ArrowUp className="h-4 w-4 text-white" /> |
| 60 | </button> |
| 61 | )} |
| 62 | </div> |
| 63 | ); |
| 64 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected