-
,
+ Partial<
+ Pick<
+ ComponentProps
,
+ | "name"
+ | "defaultValue"
+ | "value"
+ | "onChange"
+ | "onKeyDown"
+ | "validationState"
+ | "required"
+ | "disabled"
+ | "readOnly"
+ >
+ > {
+ label?: string
+ hideLabel?: boolean
+ description?: string
+ error?: string
+ variant?: "normal" | "ghost"
+ copyable?: boolean
+}
+
+export function TextField(props: TextFieldProps) {
+ const [local, others] = splitProps(props, [
+ "name",
+ "defaultValue",
+ "value",
+ "onChange",
+ "onKeyDown",
+ "validationState",
+ "required",
+ "disabled",
+ "readOnly",
+ "class",
+ "label",
+ "hideLabel",
+ "description",
+ "error",
+ "variant",
+ "copyable",
+ ])
+ const [copied, setCopied] = createSignal(false)
+
+ async function handleCopy() {
+ const value = local.value ?? local.defaultValue ?? ""
+ await navigator.clipboard.writeText(value)
+ setCopied(true)
+ setTimeout(() => setCopied(false), 2000)
+ }
+
+ return (
+
+
+
+ {local.label}
+
+
+
+
+
+
+
+
+
+
+
+ {local.description}
+
+ {local.error}
+
+ )
+}
+
+/** @deprecated Use TextField instead */
+export const Input = TextField
+/** @deprecated Use TextFieldProps instead */
+export type InputProps = TextFieldProps
--
cgit v1.2.3