MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / ValueField

Function ValueField

packages/react/src/plugins/secret-form.tsx:246–289  ·  view source on GitHub ↗
(props: { revealable?: boolean; placeholder?: string; autoFocus?: boolean })

Source from the content-addressed store, hash-verified

244}
245
246function ValueField(props: { revealable?: boolean; placeholder?: string; autoFocus?: boolean }) {
247 const { state, actions } = useSecretForm();
248 const inputId = useId();
249 const revealable = props.revealable ?? false;
250 const revealed = revealable && state.revealed;
251 const errored = state.status.kind === "error";
252
253 return (
254 <Field>
255 <FieldLabel htmlFor={inputId}>Value</FieldLabel>
256 <div className="relative" data-ph-block>
257 <Input
258 id={inputId}
259 type={secretValueInputType({ revealable, revealed })}
260 value={state.value}
261 onChange={(e) => actions.setValue((e.target as HTMLInputElement).value)}
262 placeholder={props.placeholder ?? "ghp_xxxxxxxxxxxxxxxxxxxx"}
263 autoFocus={props.autoFocus}
264 autoComplete="new-password"
265 className={revealable ? "pr-9 font-mono" : "font-mono"}
266 style={
267 revealable && !revealed ? ({ WebkitTextSecurity: "disc" } as CSSProperties) : undefined
268 }
269 data-ph-block
270 />
271 {revealable && (
272 <Button
273 type="button"
274 variant="ghost"
275 size="icon-xs"
276 className="absolute right-1 top-1/2 size-7 -translate-y-1/2 text-muted-foreground hover:text-foreground"
277 onClick={actions.toggleReveal}
278 aria-label={state.revealed ? "Hide value" : "Reveal value"}
279 >
280 <SecretVisibilityIcon revealed={state.revealed} />
281 </Button>
282 )}
283 </div>
284 {errored && (
285 <FieldError>{state.status.kind === "error" ? state.status.message : ""}</FieldError>
286 )}
287 </Field>
288 );
289}
290
291function ErrorBanner() {
292 const { state } = useSecretForm();

Callers

nothing calls this directly

Calls 2

secretValueInputTypeFunction · 0.90
useSecretFormFunction · 0.85

Tested by

no test coverage detected