MCPcopy Create free account
hub / github.com/arctic-cli/interface / TextField

Function TextField

packages/ui/src/components/text-field.tsx:31–98  ·  view source on GitHub ↗
(props: TextFieldProps)

Source from the content-addressed store, hash-verified

29}
30
31export function TextField(props: TextFieldProps) {
32 const [local, others] = splitProps(props, [
33 "name",
34 "defaultValue",
35 "value",
36 "onChange",
37 "onKeyDown",
38 "validationState",
39 "required",
40 "disabled",
41 "readOnly",
42 "class",
43 "label",
44 "hideLabel",
45 "description",
46 "error",
47 "variant",
48 "copyable",
49 ])
50 const [copied, setCopied] = createSignal(false)
51
52 async function handleCopy() {
53 const value = local.value ?? local.defaultValue ?? ""
54 await navigator.clipboard.writeText(value)
55 setCopied(true)
56 setTimeout(() => setCopied(false), 2000)
57 }
58
59 return (
60 <Kobalte
61 data-component="input"
62 data-variant={local.variant || "normal"}
63 name={local.name}
64 defaultValue={local.defaultValue}
65 value={local.value}
66 onChange={local.onChange}
67 onKeyDown={local.onKeyDown}
68 required={local.required}
69 disabled={local.disabled}
70 readOnly={local.readOnly}
71 validationState={local.validationState}
72 >
73 <Show when={local.label}>
74 <Kobalte.Label data-slot="input-label" classList={{ "sr-only": local.hideLabel }}>
75 {local.label}
76 </Kobalte.Label>
77 </Show>
78 <div data-slot="input-wrapper">
79 <Kobalte.Input {...others} data-slot="input-input" class={local.class} />
80 <Show when={local.copyable}>
81 <Tooltip value={copied() ? "Copied" : "Copy to clipboard"} placement="top" gutter={8}>
82 <IconButton
83 type="button"
84 icon={copied() ? "check" : "copy"}
85 variant="ghost"
86 onClick={handleCopy}
87 data-slot="input-copy-button"
88 />

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected