{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "terminal-solid",
  "title": "Terminal (Solid)",
  "description": "A command and its output in ANSI colors, following the end as it streams, with its approval, exit code and duration.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/confirmation-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/terminal.tsx",
      "content": "import { type AnsiSpan, terminalPrimitive } from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, omit } from \"solid-js\";\nimport { Confirmation } from \"./confirmation\";\n\nconst parts = createParts(terminalPrimitive, {\n  root: \"div\",\n  trigger: \"button\",\n  icon: \"span\",\n  title: \"span\",\n  exit: \"span\",\n  meta: \"span\",\n  approval: \"div\",\n  content: \"div\",\n  command: \"div\",\n  copy: \"button\",\n  viewport: \"div\",\n  output: \"div\",\n  line: \"div\",\n  jump: \"button\",\n});\n\nexport type TerminalProps = ComponentProps<typeof parts.Root>;\n\n/**\n * A command and its output as a step: the command, its exit code and duration, its approval while it has one, then\n * the output with its ANSI colors, following its end while it streams. Any `children` replace the default parts.\n */\nexport function Terminal(props: TerminalProps) {\n  return (\n    <parts.Root {...omit(props, \"children\")}>\n      {props.children ?? (\n        <>\n          <TerminalTrigger>\n            <TerminalIcon />\n            <TerminalTitle />\n            <TerminalExit />\n            <TerminalMeta />\n          </TerminalTrigger>\n          <TerminalApproval />\n          <TerminalContent>\n            <div data-terminal-screen=\"\" data-kind-code=\"\">\n              <div data-terminal-header=\"\">\n                <TerminalCommand />\n                <TerminalCopy />\n              </div>\n              <TerminalViewport>\n                <TerminalOutput />\n              </TerminalViewport>\n              <TerminalJump />\n            </div>\n          </TerminalContent>\n        </>\n      )}\n    </parts.Root>\n  );\n}\n\nexport const TerminalTrigger = parts.Trigger;\nexport const TerminalIcon = parts.Icon;\nexport const TerminalContent = parts.Content;\nexport const TerminalCopy = parts.Copy;\n/** Scrolls the output and follows its end. Holds a `TerminalOutput`. */\nexport const TerminalViewport = parts.Viewport;\n\nexport type TerminalTitleProps = ComponentProps<typeof parts.Title>;\n\n/** The command, or the `label`, or \"Run <command>?\" while the approval waits, unless you pass children. */\nexport function TerminalTitle(props: TerminalTitleProps) {\n  return (\n    <parts.Title {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => state.spans.map((piece, index) => (index % 2 ? <code>{piece}</code> : piece)))}\n    </parts.Title>\n  );\n}\n\nexport type TerminalExitProps = ComponentProps<typeof parts.Exit>;\n\n/** \"Exit N\" once there's an exit code other than 0, unless you pass children. */\nexport function TerminalExit(props: TerminalExitProps) {\n  return <parts.Exit {...omit(props, \"children\")}>{props.children ?? ((state) => state.text)}</parts.Exit>;\n}\n\nexport type TerminalMetaProps = ComponentProps<typeof parts.Meta>;\n\n/** \"Waiting for approval\" while the approval waits, else the duration as \"6 sec\", unless you pass children. */\nexport function TerminalMeta(props: TerminalMetaProps) {\n  return <parts.Meta {...omit(props, \"children\")}>{props.children ?? ((state) => state.text)}</parts.Meta>;\n}\n\nexport type TerminalApprovalProps = ComponentProps<typeof parts.Approval>;\n\n/**\n * A Confirmation for the command's approval while it has one: the choices whose callbacks are set while the request\n * waits, then what was decided. Pass children to render it yourself.\n */\nexport function TerminalApproval(props: TerminalApprovalProps) {\n  return (\n    <parts.Approval {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <Confirmation\n            approval={state.approval}\n            label={state.label}\n            onApprove={state.onApprove}\n            onDeny={state.onDeny}\n            onAlwaysAllow={state.onAlwaysAllow}\n            reason={state.reason}\n            approveLabel={state.approveLabel}\n            alwaysLabel={state.alwaysLabel}\n            alwaysTarget={state.alwaysTarget}\n            alwaysScope={state.alwaysScope}\n            alwaysDetail={state.alwaysDetail}\n            risk={state.risk}\n            riskText={state.riskText}\n            focusFallback={state.focusFallback}\n            motion={state.motion}\n          />\n        ))}\n    </parts.Approval>\n  );\n}\n\nexport type TerminalCommandProps = ComponentProps<typeof parts.Command>;\n\n/**\n * The command after its prompt, which the stylesheet draws, unless you pass children. Present only while a `label`\n * replaces the command as the title.\n */\nexport function TerminalCommand(props: TerminalCommandProps) {\n  return (\n    <parts.Command {...omit(props, \"children\")}>{props.children ?? ((state) => state.command)}</parts.Command>\n  );\n}\n\nexport type TerminalOutputProps = ComponentProps<typeof parts.Output>;\n\n/** A `TerminalLine` for each line in view, keyed by its index, unless you pass children. */\nexport function TerminalOutput(props: TerminalOutputProps) {\n  return (\n    <parts.Output {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <For each={state.rows} keyed={(row) => row.index}>\n            {(row) => <TerminalLine index={row().index} />}\n          </For>\n        ))}\n    </parts.Output>\n  );\n}\n\nconst spanStyle = (span: AnsiSpan): JSX.CSSProperties | undefined =>\n  span.fg || span.bg ? { color: span.fg, \"background-color\": span.bg } : undefined;\n\nexport type TerminalLineProps = ComponentProps<typeof parts.Line>;\n\n/** One line of output, its `index`th, as styled spans, unless you pass children. */\nexport function TerminalLine(props: TerminalLineProps) {\n  return (\n    <parts.Line value={props.value ?? String(props.index)} {...omit(props, \"children\", \"value\")}>\n      {props.children ??\n        ((state) => (\n          <For each={state.spans} keyed={false}>\n            {(span) => (\n              <span\n                style={spanStyle(span())}\n                data-bold={span().bold ? \"\" : undefined}\n                data-dim={span().dim ? \"\" : undefined}\n                data-italic={span().italic ? \"\" : undefined}\n                data-underline={span().underline ? \"\" : undefined}\n                data-strike={span().strike ? \"\" : undefined}\n              >\n                {span().text}\n              </span>\n            )}\n          </For>\n        ))}\n    </parts.Line>\n  );\n}\n\nexport type TerminalJumpProps = ComponentProps<typeof parts.Jump>;\n\n/** Shown while the reader has scrolled away from the end. \"Jump to latest\", unless you pass children. */\nexport function TerminalJump(props: TerminalJumpProps) {\n  return <parts.Jump {...omit(props, \"children\")}>{props.children ?? \"Jump to latest\"}</parts.Jump>;\n}\n",
      "type": "registry:ui",
      "target": "@ui/solid/terminal.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
