The best way to control Claude Code, Codex and more from any computer or phone

main
tsx 41 lines 1.02 KB
Raw
1 import { useGT } from "gt-react";
2
3 import { DraftInput, type DraftInputProps } from "../ui/draft-input";
4 import { Input, type InputProps } from "../ui/input";
5
6 type SecretInputProps = Omit<InputProps, "type" | "autoComplete" | "defaultValue" | "value"> & {
7 /** Pass only the replacement draft as `value`. */
8 readonly configured?: boolean;
9 readonly value: string;
10 readonly onCommit?: DraftInputProps["onCommit"];
11 };
12
13 export function SecretInput({
14 configured = false,
15 placeholder,
16 onCommit,
17 ...props
18 }: SecretInputProps) {
19 const gt = useGT();
20 const shared = {
21 ...props,
22 type: "password" as const,
23 autoComplete: "off",
24 spellCheck: false,
25 placeholder: configured
26 ? gt("Stored secret, enter a new value to replace")
27 : (placeholder ?? gt("Not set")),
28 };
29 if (onCommit) {
30 return (
31 <DraftInput
32 {...shared}
33 onCommit={(next) => {
34 if (configured && next === "") return;
35 onCommit(next);
36 }}
37 />
38 );
39 }
40 return <Input {...shared} />;
41 }