{
  "name": "PromptInput",
  "source": "src/components/PromptInput.tsx",
  "propsType": "PromptInputProps",
  "description": "PromptInput — where a person writes to an agent.\n\nWHY IT IS NOT A TEXTAREA AND A BUTTON\n\nEvery composer is assembled that way, and every one re-implements the same\nfour bugs:\n\n  Enter during IME composition sends half a word. Japanese, Chinese and\n  Korean input confirm a candidate with Enter; a handler that does not check\n  `isComposing` sends the message mid-character. That excludes whole\n  languages from the product, silently, and nobody on an English keyboard\n  ever sees it.\n\n  The prompt is lost when sending fails. Clearing on submit is right —\n  waiting for the server makes the composer feel broken — but clearing and\n  never restoring destroys what may have been a long message. Uncontrolled,\n  a rejected `onSubmit` promise puts the text back.\n\n  The stop control lives somewhere else. While a run is going, the send\n  button's place is exactly where the user's pointer and attention already\n  are, so that is where `AgentStop` goes — the same control, the same\n  guarantees, not a second stop button with different ones.\n\n  The keyboard contract is invisible. \"Enter sends, Shift+Enter for a new\n  line\" is announced through `aria-describedby`, because a screen-reader\n  user who presses Enter expecting a newline has just sent a message.\n\nWHAT IT DOES NOT DO\n\nIt does not upload, pick models or render messages. `attachments` and\n`actions` are slots, because what a product attaches and which tools it\noffers are the product's decisions.",
  "import": "import { PromptInput } from 'ionbase-ui';",
  "status": "stable",
  "summary": "Where a person writes to an agent: a growing text field, a send control that becomes the stop control while a run is going, and slots for attachments and tools.",
  "useWhen": [
    "a chat or assistant surface where the user's message starts a run",
    "a command bar that sends free text to an agent"
  ],
  "useInstead": [
    {
      "when": "the text is a form value submitted with other fields",
      "use": "Textarea",
      "why": "Enter-to-send inside a form fights the form's own submit, and a single field of a larger form is not a composer"
    },
    {
      "when": "the input is a single-line search",
      "use": "Input",
      "why": "a search box does not grow, does not stop runs, and Enter means search rather than send"
    },
    {
      "when": "the run needs a stop control and was not started from this composer",
      "use": "AgentStop",
      "why": "the composer's stop belongs to the run it sent; a run started elsewhere keeps its stop beside its own activity"
    }
  ],
  "variants": {
    "submitKey": {
      "enter": {
        "use": "the default — chat. Enter sends, Shift+Enter is a new line"
      },
      "mod-enter": {
        "use": "long messages, where a stray Enter is expensive. Cmd/Ctrl+Enter sends and Enter is a new line"
      }
    }
  },
  "slots": {
    "actions": {
      "accepts": "Button",
      "note": "attach, a model picker, a tool toggle — at the start of the toolbar. Icon-only buttons need their own aria-label"
    },
    "attachments": {
      "accepts": "Badge",
      "note": "what is attached, above the text. Each removable item needs a remove control named for the file"
    }
  },
  "a11y": {
    "requires": [
      "`label` — the accessible name of the field. A placeholder is not one: it disappears on the first keystroke"
    ],
    "guarantees": [
      "the send key is described through aria-describedby, so a screen-reader user knows Enter sends before pressing it",
      "Enter pressed while an IME is composing never sends — Japanese, Chinese and Korean input confirm candidates with Enter",
      "while `isRunning` with `onStop`, the send control is replaced in place by AgentStop, with its guarantees: it keeps its place while stopping and announces once",
      "focus stays in the field after sending, so the next message can be typed straight away"
    ],
    "notes": [
      "the field stays editable while a run is going; only submitting is refused",
      "uncontrolled, the field clears on send and a rejected onSubmit promise restores the text — unless the user has already started typing something new"
    ]
  },
  "antiPatterns": [
    {
      "dont": "<Textarea> beside a <Button> with an onKeyDown that checks for Enter",
      "do": "<PromptInput label=\"Message\" onSubmit={send} />",
      "why": "the hand-built version sends mid-character for IME users and loses the prompt when sending fails"
    },
    {
      "dont": "a separate AgentStop elsewhere on screen as well as `isRunning` with `onStop`",
      "why": "two stop controls for one run raises the question of whether they do different things"
    },
    {
      "dont": "`isRunning` without `onStop`",
      "why": "the send control disables and nothing replaces it — the user can see the agent working and has no way to stop it"
    },
    {
      "dont": "controlled `value` cleared in onSubmit before the request settles",
      "why": "controlled, restoring the text on failure is the caller's job; clearing early and not restoring loses the message"
    }
  ],
  "stylesheet": "src/styles/prompt-input.css",
  "tokens": [
    "--border-default",
    "--border-disabled",
    "--border-focus",
    "--border-strong",
    "--border-width-default",
    "--font-family-sans",
    "--ion-duration-base",
    "--ion-ease-out",
    "--radius-lg",
    "--spacing-32",
    "--spacing-4",
    "--spacing-8",
    "--surface-default",
    "--surface-disabled",
    "--text-default",
    "--text-disabled",
    "--text-tertiary",
    "--type-body",
    "--type-body-line-height"
  ],
  "props": {
    "label": {
      "type": "string",
      "required": true,
      "origin": "own",
      "description": "The accessible name of the text field. Required, and not a placeholder:\nplaceholder text disappears the moment the user types, and is not reliably\nannounced as a name."
    },
    "value": {
      "type": "string | undefined",
      "required": false,
      "origin": "own",
      "description": "Controlled text. Pass `onChange` with it."
    },
    "defaultValue": {
      "type": "string | undefined",
      "required": false,
      "origin": "own",
      "description": "Uncontrolled starting text."
    },
    "onChange": {
      "type": "((value: string) => void) | undefined",
      "required": false,
      "origin": "own"
    },
    "onSubmit": {
      "type": "((value: string) => void | Promise<unknown>) | undefined",
      "required": false,
      "origin": "own",
      "description": "Fires with the text as typed. Uncontrolled, the field clears straight away;\nif the returned promise rejects, the text is put back — a prompt lost to a\nnetwork error is the one thing a composer must never do."
    },
    "submitKey": {
      "type": "PromptInputSubmitKey | undefined",
      "required": false,
      "origin": "own",
      "description": "Which key sends. `enter` sends on Enter with Shift+Enter for a new line —\na chat. `mod-enter` sends on Cmd/Ctrl+Enter and leaves Enter for new lines —\na composer where messages are long and a stray Enter is expensive.",
      "values": [
        "enter",
        "mod-enter"
      ]
    },
    "isRunning": {
      "type": "boolean | undefined",
      "required": false,
      "origin": "own",
      "description": "A run is in progress. The send control becomes an `AgentStop` in the same\nplace, and submitting is refused. The field stays editable, so the user can\ndraft the next message while the agent works."
    },
    "onStop": {
      "type": "(() => void) | undefined",
      "required": false,
      "origin": "own",
      "description": "Called by the stop control while `isRunning`."
    },
    "isStopping": {
      "type": "boolean | undefined",
      "required": false,
      "origin": "own",
      "description": "Passed to the stop control once the stop has been requested."
    },
    "isDisabled": {
      "type": "boolean | undefined",
      "required": false,
      "origin": "own"
    },
    "minRows": {
      "type": "number | undefined",
      "required": false,
      "origin": "own",
      "description": "Rows the field starts at."
    },
    "maxRows": {
      "type": "number | undefined",
      "required": false,
      "origin": "own",
      "description": "Rows the field grows to before it scrolls."
    },
    "actions": {
      "type": "React.ReactNode",
      "required": false,
      "origin": "own",
      "description": "Controls at the start of the toolbar — attach, a model picker, a tool\ntoggle. Icon-only controls here need their own `aria-label`."
    },
    "attachments": {
      "type": "React.ReactNode",
      "required": false,
      "origin": "own",
      "description": "Rendered above the text — attached files, a quoted message."
    },
    "sendLabel": {
      "type": "string | undefined",
      "required": false,
      "origin": "own",
      "description": "Accessible name of the send control."
    },
    "stopLabel": {
      "type": "string | undefined",
      "required": false,
      "origin": "own",
      "description": "The stop control's label while a run is in progress — AgentStop's `label`."
    },
    "stoppingLabel": {
      "type": "string | undefined",
      "required": false,
      "origin": "own",
      "description": "The stop control's label once pressed — AgentStop's `stoppingLabel`."
    },
    "submitHint": {
      "type": "string | undefined",
      "required": false,
      "origin": "own",
      "description": "How to send, read after the field's name — \"Press Enter to send, Shift\nand Enter for a new line.\" in English, or the ⌘/Ctrl+Enter version when\n`submitKey` is `mod-enter`. Pass the translation for your `submitKey`."
    },
    "className": {
      "type": "string | undefined",
      "required": false,
      "origin": "own",
      "description": "Class names for the outer box."
    }
  },
  "propCounts": {
    "own": 19,
    "aria": 0,
    "dom": 284,
    "other": 0
  }
}
