-
,
+ 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
diff --git a/packages/ui/src/styles/index.css b/packages/ui/src/styles/index.css
index 918ba9e44..d60082d93 100644
--- a/packages/ui/src/styles/index.css
+++ b/packages/ui/src/styles/index.css
@@ -21,7 +21,7 @@
@import "../components/provider-icon.css" layer(components);
@import "../components/icon.css" layer(components);
@import "../components/icon-button.css" layer(components);
-@import "../components/input.css" layer(components);
+@import "../components/text-field.css" layer(components);
@import "../components/list.css" layer(components);
@import "../components/logo.css" layer(components);
@import "../components/markdown.css" layer(components);
--
cgit v1.2.3