import { useId } from "react"; import { choosePath } from "@/platform/choosePath"; import { useTx } from "@/platform/i18n"; import { IconButton, Input } from "@/ui"; import { Row } from "../components/Form"; import { useSetting } from "../components/context"; import styles from "./Sdk.module.css"; interface PathFieldProps { k: string; placeholder: string; title: string; id?: string; "aria-label"?: string; /** Browse for a file instead of a directory. */ file?: boolean; } export function PathField({ k, placeholder, title, id, file, ...aria }: PathFieldProps) { const [value, set] = useSetting(k); const tx = useTx(); return ( set(e.target.value.trim())} aria-label={aria["aria-label"]} /> { const p = await choosePath({ directory: !file, title: tx(title), defaultPath: value || undefined }); if (p) set(p); }} /> ); } export function PathInput({ label, hint, ...field }: Omit & { label: string; hint?: string }) { const id = useId(); return ( ); }