{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-field",
  "title": "Text field",
  "description": "A labelled text input in a cut frame, with a hint, an error and an optional icon.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5",
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/text-field.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Field, FieldDescription, FieldError, FieldLabel } from \"@ui-sdk/react/field\"\nimport { Input, InputClear, InputGroup } from \"@ui-sdk/react/input\"\nimport { X } from \"lucide-react\"\nimport \"@/registry/cyber/ui/cyber/text-field.css\"\n\n// One line of text in the kit's field box: a label, the framed input, and a\n// hint or an error under it. A tick on the box's leading edge lights in the\n// signal color while the field holds anything.\n//\n// - `hint` describes the field; `error` marks it invalid and replaces the\n//   browser's own message. Without `error`, native constraints (`required`,\n//   `pattern`, `type=\"email\"`) still report under the field after a submit.\n// - `icon` and `prefix` sit before the text, `suffix` after it. They're\n//   display only: pressing them focuses the input.\n// - `clearable` adds a key that empties the field while it has text.\n//\n// Everything else goes to the input, so `value`, `onValueChange`, `name` and\n// a `controller` work as they do on the SDK's own.\nfunction Group({ clearable, label, children }: { clearable?: boolean; label: string; children: React.ReactNode }) {\n  const frame = { \"data-kit\": \"control\", \"data-frame\": \"br\", \"data-frame-focus\": \"within\" }\n  if (!clearable) return <div {...frame}>{children}</div>\n  return (\n    <InputGroup {...frame} role=\"group\" aria-label={`${label} field`}>\n      {children}\n    </InputGroup>\n  )\n}\n\nfunction TextField({\n  label,\n  hint,\n  error,\n  icon,\n  prefix,\n  suffix,\n  clearable,\n  disabled,\n  required,\n  ...props\n}: Omit<React.ComponentProps<typeof Input>, \"prefix\"> & {\n  label: string\n  hint?: React.ReactNode\n  error?: string\n  icon?: React.ReactNode\n  prefix?: string\n  suffix?: string\n  clearable?: boolean\n}) {\n  return (\n    <Field data-kit=\"field\" disabled={disabled} invalid={error ? true : undefined}>\n      <div data-kit=\"text-field-head\">\n        <FieldLabel data-kit=\"label\">{label}</FieldLabel>\n        {required && (\n          <span data-kit=\"text-field-tag\" aria-hidden>\n            REQ\n          </span>\n        )}\n      </div>\n      {/* The group part exists for the clear key. It registers with the agent\n          bridge as a component of its own, so it's only used when there is a\n          clear key for it to offer, and then it's named. */}\n      <Group clearable={clearable} label={label}>\n        <span data-kit=\"text-field-tick\" aria-hidden />\n        {icon && (\n          <span data-kit=\"control-icon\" aria-hidden>\n            {icon}\n          </span>\n        )}\n        {prefix && <span data-kit=\"control-icon\">{prefix}</span>}\n        <Input data-kit=\"text-field\" spellCheck={false} required={required} {...props} />\n        {suffix && <span data-kit=\"control-icon\">{suffix}</span>}\n        {clearable && (\n          <InputClear data-kit=\"text-field-clear\" data-frame=\"br\" data-press-flash=\"\" aria-label={`Clear ${label}`}>\n            <X aria-hidden />\n          </InputClear>\n        )}\n      </Group>\n      {hint && <FieldDescription data-kit=\"hint\">{hint}</FieldDescription>}\n      {error ? (\n        <FieldError data-kit=\"field-error\" match>\n          {error}\n        </FieldError>\n      ) : (\n        <FieldError data-kit=\"field-error\" />\n      )}\n    </Field>\n  )\n}\n\nexport { TextField }\n",
      "type": "registry:ui",
      "target": "@ui/text-field.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/text-field.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n/* A text field is the shared field box (field.css) and three things of its\n   own: the row its label sits in, the tick on the box's leading edge, and\n   the clear key. */\n@layer cyber.ui {\n  /* The label, with room at the far end for a tag. */\n  [data-skin=\"cyber\"] [data-kit=\"text-field-head\"] {\n    display: flex;\n    align-items: baseline;\n    justify-content: space-between;\n    gap: 12px;\n    min-width: 0;\n\n    &:has([data-disabled]) [data-kit=\"label\"] {\n      color: var(--cy-ink-mute);\n    }\n  }\n\n  /* REQ: printed, so \"required\" doesn't rest on an asterisk's color. */\n  [data-skin=\"cyber\"] [data-kit=\"text-field-tag\"] {\n    flex: none;\n    font-family: var(--cy-mono);\n    font-size: 9px;\n    letter-spacing: 0.08em;\n    line-height: 1;\n    color: var(--cy-ink-mute);\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"text-field\"] {\n    letter-spacing: 0.01em;\n\n    /* The box shows focus for the input (data-frame-focus=\"within\"), so the\n       input's own ring is cut off rather than drawn twice. */\n    clip-path: inset(0);\n\n    /* The browser's own clear glyph would double the kit's. */\n    &::-webkit-search-cancel-button {\n      display: none;\n    }\n  }\n\n  /* A segment of the leading edge. Dark while the field is empty, the\n     signal color once it holds something, the flag color when what it holds\n     is wrong. It only changes color, so it survives every FX level. */\n  [data-skin=\"cyber\"] [data-kit=\"text-field-tick\"] {\n    position: absolute;\n    inset-block: 9px;\n    inset-inline-start: -1px;\n    width: 3px;\n    background: transparent;\n    pointer-events: none;\n    transition: background-color var(--cy-t) var(--cy-ease-snap);\n\n    [data-filled] > & {\n      background: var(--cy-signal);\n    }\n    [data-kit=\"control\"]:has([aria-invalid=\"true\"]) > & {\n      background: var(--cy-flag);\n    }\n    [data-disabled] > & {\n      background: transparent;\n    }\n  }\n\n  /* The clear key: a small cut key set inside the box, three pixels clear\n     of its edge so its own focus ring never runs into the box's. It has no\n     edge until the pointer finds it. Under a finger the gap closes and the\n     key takes the box's full height. */\n  [data-skin=\"cyber\"] [data-kit=\"text-field-clear\"] {\n    --frame-cut: 4px;\n    --frame-line: transparent;\n    --frame-fill: transparent;\n    --frame-image: none;\n    --inset: 3px;\n\n    flex: none;\n    display: grid;\n    place-items: center;\n    width: calc(var(--cy-h) - 2px - var(--inset) * 2);\n    height: calc(var(--cy-h) - 2px - var(--inset) * 2);\n    margin-inline-end: calc(var(--inset) - 10px);\n    padding: 0;\n    color: var(--cy-ink-mute);\n    cursor: pointer;\n    transition:\n      background-color var(--cy-t-fast) linear,\n      border-color var(--cy-t-fast) linear,\n      color var(--cy-t-fast) linear;\n\n    @media (pointer: coarse) {\n      --inset: 0px;\n    }\n\n    & svg {\n      width: 14px;\n      height: 14px;\n    }\n\n    @media (hover: hover) {\n      &:hover {\n        --frame-line: var(--cy-line-hot);\n        --frame-fill: var(--cy-fill-hover);\n        color: var(--cy-ink);\n      }\n    }\n\n    &:active {\n      --frame-line: var(--cy-line-hot);\n      --frame-fill: var(--cy-fill-active);\n      color: var(--cy-ink-hi);\n    }\n\n    &:focus-visible {\n      color: var(--cy-signal);\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/text-field.css"
    }
  ],
  "type": "registry:ui"
}
