{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "diff-solid",
  "title": "Diff (Solid)",
  "description": "One file's changes or a run's, with Keep and Undo for each file and change, and Keep all and Undo all.",
  "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"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/diff.tsx",
      "content": "import { codeSpans, type DiffLineView, type DiffPiece, diffPrimitive } from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, Match, omit, Show, Switch } from \"solid-js\";\n\nconst parts = createParts(diffPrimitive, {\n  root: \"div\",\n  summary: \"div\",\n  \"summary-title\": \"div\",\n  \"summary-counts\": \"span\",\n  \"summary-mark\": \"span\",\n  \"summary-progress\": \"div\",\n  \"summary-outcome\": \"div\",\n  \"summary-actions\": \"div\",\n  \"undo-all\": \"button\",\n  \"keep-all\": \"button\",\n  \"undo-all-question\": \"span\",\n  \"undo-all-cancel\": \"button\",\n  \"undo-all-confirm\": \"button\",\n  \"summary-error\": \"div\",\n  list: \"div\",\n  file: \"div\",\n  \"file-trigger\": \"button\",\n  \"file-path\": \"span\",\n  \"file-old-path\": \"span\",\n  \"file-status\": \"span\",\n  \"file-counts\": \"span\",\n  \"file-mark\": \"span\",\n  \"file-actions\": \"div\",\n  \"file-undo\": \"button\",\n  \"file-keep\": \"button\",\n  \"file-outcome\": \"span\",\n  \"file-error\": \"span\",\n  \"file-content\": \"div\",\n  \"file-note\": \"div\",\n  viewport: \"div\",\n  table: \"div\",\n  head: \"div\",\n  column: \"span\",\n  change: \"div\",\n  \"change-title\": \"div\",\n  \"change-undo\": \"button\",\n  \"change-keep\": \"button\",\n  \"change-outcome\": \"span\",\n  \"change-error\": \"span\",\n  line: \"div\",\n  \"old-number\": \"span\",\n  \"new-number\": \"span\",\n  sign: \"span\",\n  code: \"span\",\n  collapsed: \"button\",\n  \"collapsed-text\": \"span\",\n  \"show-all\": \"button\",\n});\n\n// Text with its backticks as `code`.\nconst withCode = (text: string) =>\n  codeSpans(text).map((piece, index) => (index % 2 ? <code>{piece}</code> : piece));\n\nexport type DiffProps = ComponentProps<typeof parts.Root>;\n\n/**\n * One file's changes, or a run's: a summary with Keep all and Undo all, then each file's row with its own Keep and\n * Undo, opening to its lines. Any `children` replace the default parts.\n */\nexport function Diff(props: DiffProps) {\n  return <parts.Root {...omit(props, \"children\")}>{props.children ?? <DefaultParts />}</parts.Root>;\n}\n\n/** The title, counts, progress and Keep all and Undo all, above several files. */\nexport const DiffSummary = parts.Summary;\n/** The running mark while a patch streams. */\nexport const DiffSummaryMark = parts.SummaryMark;\n/** Holds Undo all and Keep all, or Undo all's question. */\nexport const DiffSummaryActions = parts.SummaryActions;\n/** Holds a file's Keep, Undo, outcome and error, at one width. */\nexport const DiffFileActions = parts.FileActions;\n/** The running mark in place of a file's counts while its patch streams. */\nexport const DiffFileMark = parts.FileMark;\n/** A file's lines, opened by its row. */\nexport const DiffFileContent = parts.FileContent;\n/** Scrolls a file's lines. Holds a `DiffTable`. */\nexport const DiffViewport = parts.Viewport;\n/** The screen-reader column headers. */\nexport const DiffHead = parts.Head;\n\nexport type DiffSummaryTitleProps = ComponentProps<typeof parts.SummaryTitle>;\n\n/** \"4 files changed\", \"Editing 2 files\" or \"All changes reviewed\", unless you pass children. */\nexport function DiffSummaryTitle(props: DiffSummaryTitleProps) {\n  return (\n    <parts.SummaryTitle {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.SummaryTitle>\n  );\n}\n\nconst counts = (state: { added: string; removed: string; name: string }): JSX.Element => (\n  <>\n    <span aria-hidden=\"true\">\n      <Show when={state.added}>\n        <span data-diff-added=\"\">{state.added}</span>\n      </Show>\n      <Show when={state.added && state.removed}> </Show>\n      <Show when={state.removed}>\n        <span data-diff-removed=\"\">{state.removed}</span>\n      </Show>\n    </span>\n    <span data-diff-hidden=\"\">{state.name}</span>\n  </>\n);\n\nexport type DiffSummaryCountsProps = ComponentProps<typeof parts.SummaryCounts>;\n\n/** \"+120 −8\", read as \"120 additions, 8 deletions\", unless you pass children. */\nexport function DiffSummaryCounts(props: DiffSummaryCountsProps) {\n  return <parts.SummaryCounts {...omit(props, \"children\")}>{props.children ?? counts}</parts.SummaryCounts>;\n}\n\nexport type DiffSummaryProgressProps = ComponentProps<typeof parts.SummaryProgress>;\n\n/** \"2 of 4 reviewed\", then \"3 kept, 1 undone\", unless you pass children. */\nexport function DiffSummaryProgress(props: DiffSummaryProgressProps) {\n  return (\n    <parts.SummaryProgress {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.SummaryProgress>\n  );\n}\n\nexport type DiffSummaryOutcomeProps = ComponentProps<typeof parts.SummaryOutcome>;\n\n/** \"3 kept, 1 undone\" once every change is reviewed, unless you pass children. */\nexport function DiffSummaryOutcome(props: DiffSummaryOutcomeProps) {\n  return (\n    <parts.SummaryOutcome {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.SummaryOutcome>\n  );\n}\n\nexport type DiffUndoAllProps = ComponentProps<typeof parts.UndoAll>;\n\n/** Asks before undoing every undecided file. \"Undo all\", unless you pass children. */\nexport function DiffUndoAll(props: DiffUndoAllProps) {\n  return (\n    <parts.UndoAll {...omit(props, \"children\")}>{props.children ?? ((state) => state.text)}</parts.UndoAll>\n  );\n}\n\nconst Running = () => <span data-status-mark=\"\" data-status=\"running\" aria-hidden=\"true\" />;\nconst Pending = () => (\n  <span data-kind-pending-mark=\"\" data-status-mark=\"\" data-status=\"running\" aria-hidden=\"true\" />\n);\n\nexport type DiffKeepAllProps = ComponentProps<typeof parts.KeepAll>;\n\n/** \"Keep all\", unless you pass children. */\nexport function DiffKeepAll(props: DiffKeepAllProps) {\n  return (\n    <parts.KeepAll {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <>\n            <Pending />\n            {state.text}\n          </>\n        ))}\n    </parts.KeepAll>\n  );\n}\n\nexport type DiffUndoAllQuestionProps = ComponentProps<typeof parts.UndoAllQuestion>;\n\n/** \"Undo all 4 files? This can't be undone.\", unless you pass children. */\nexport function DiffUndoAllQuestion(props: DiffUndoAllQuestionProps) {\n  return (\n    <parts.UndoAllQuestion {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <>\n            {state.text} <span data-diff-warning=\"\">{state.warning}</span>\n          </>\n        ))}\n    </parts.UndoAllQuestion>\n  );\n}\n\nexport type DiffUndoAllCancelProps = ComponentProps<typeof parts.UndoAllCancel>;\n\n/** \"Cancel\", unless you pass children. */\nexport function DiffUndoAllCancel(props: DiffUndoAllCancelProps) {\n  return (\n    <parts.UndoAllCancel {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.UndoAllCancel>\n  );\n}\n\nexport type DiffUndoAllConfirmProps = ComponentProps<typeof parts.UndoAllConfirm>;\n\n/** Undoes every undecided file. \"Undo all\", unless you pass children. */\nexport function DiffUndoAllConfirm(props: DiffUndoAllConfirmProps) {\n  return (\n    <parts.UndoAllConfirm {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <>\n            <Pending />\n            {state.text}\n          </>\n        ))}\n    </parts.UndoAllConfirm>\n  );\n}\n\nexport type DiffSummaryErrorProps = ComponentProps<typeof parts.SummaryError>;\n\n/** \"Couldn't undo all changes\", unless you pass children. */\nexport function DiffSummaryError(props: DiffSummaryErrorProps) {\n  return (\n    <parts.SummaryError {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.SummaryError>\n  );\n}\n\nexport type DiffListProps = ComponentProps<typeof parts.List>;\n\n/** A `DiffFile` for each file, keyed by its path, unless you pass children. */\nexport function DiffList(props: DiffListProps) {\n  return (\n    <parts.List {...omit(props, \"children\")}>\n      {props.children ?? ((state) => <For each={state.paths}>{(path) => <DiffFile value={path} />}</For>)}\n    </parts.List>\n  );\n}\n\nexport type DiffFileProps = ComponentProps<typeof parts.File>;\n\n/** The file whose path is `value`: its row and its lines, unless you pass children. */\nexport function DiffFile(props: DiffFileProps) {\n  return <parts.File {...omit(props, \"children\")}>{props.children ?? <FileParts />}</parts.File>;\n}\n\n/** Opens and closes the file's lines. Holds its path, status and counts. */\nexport const DiffFileTrigger = parts.FileTrigger;\n\nexport type DiffFilePathProps = ComponentProps<typeof parts.FilePath>;\n\n/** The path, cut at its start when it's long so the file name stays, unless you pass children. */\nexport function DiffFilePath(props: DiffFilePathProps) {\n  return (\n    <parts.FilePath {...omit(props, \"children\")}>\n      {props.children ?? ((state) => <bdi>{state.text}</bdi>)}\n    </parts.FilePath>\n  );\n}\n\nexport type DiffFileOldPathProps = ComponentProps<typeof parts.FileOldPath>;\n\n/** \"from old/path.ts\" for a rename, unless you pass children. */\nexport function DiffFileOldPath(props: DiffFileOldPathProps) {\n  return (\n    <parts.FileOldPath {...omit(props, \"children\")}>\n      {props.children ?? ((state) => <bdi>{state.text}</bdi>)}\n    </parts.FileOldPath>\n  );\n}\n\nexport type DiffFileStatusProps = ComponentProps<typeof parts.FileStatus>;\n\n/** \"Added\", \"Deleted\" or \"Renamed\", unless you pass children. Absent for a modified file. */\nexport function DiffFileStatus(props: DiffFileStatusProps) {\n  return (\n    <parts.FileStatus {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.FileStatus>\n  );\n}\n\nexport type DiffFileCountsProps = ComponentProps<typeof parts.FileCounts>;\n\n/** \"+4 −2\", read as \"4 additions, 2 deletions\", unless you pass children. */\nexport function DiffFileCounts(props: DiffFileCountsProps) {\n  return <parts.FileCounts {...omit(props, \"children\")}>{props.children ?? counts}</parts.FileCounts>;\n}\n\nexport type DiffFileUndoProps = ComponentProps<typeof parts.FileUndo>;\n\n/** \"Undo\", named with the path, unless you pass children. */\nexport function DiffFileUndo(props: DiffFileUndoProps) {\n  return (\n    <parts.FileUndo {...omit(props, \"children\")}>{props.children ?? ((state) => state.text)}</parts.FileUndo>\n  );\n}\n\nexport type DiffFileKeepProps = ComponentProps<typeof parts.FileKeep>;\n\n/** \"Keep\", named with the path, unless you pass children. */\nexport function DiffFileKeep(props: DiffFileKeepProps) {\n  return (\n    <parts.FileKeep {...omit(props, \"children\")}>{props.children ?? ((state) => state.text)}</parts.FileKeep>\n  );\n}\n\nconst outcome = (state: { text: string; working: boolean }): JSX.Element => (\n  <>\n    <Show when={state.working}>\n      <Running />\n    </Show>\n    {state.text}\n  </>\n);\n\nexport type DiffFileOutcomeProps = ComponentProps<typeof parts.FileOutcome>;\n\n/** \"Kept\", \"Undone\", \"Keeping…\" or \"Undoing…\" in the buttons' place, unless you pass children. */\nexport function DiffFileOutcome(props: DiffFileOutcomeProps) {\n  return <parts.FileOutcome {...omit(props, \"children\")}>{props.children ?? outcome}</parts.FileOutcome>;\n}\n\nexport type DiffFileErrorProps = ComponentProps<typeof parts.FileError>;\n\n/** \"Couldn't undo `auth.ts`\", unless you pass children. */\nexport function DiffFileError(props: DiffFileErrorProps) {\n  return (\n    <parts.FileError {...omit(props, \"children\")}>\n      {props.children ?? ((state) => <>{withCode(state.text)}</>)}\n    </parts.FileError>\n  );\n}\n\nexport type DiffFileNoteProps = ComponentProps<typeof parts.FileNote>;\n\n/** \"Binary file, not shown\" or \"Renamed, no changes\" in place of lines, unless you pass children. */\nexport function DiffFileNote(props: DiffFileNoteProps) {\n  return (\n    <parts.FileNote {...omit(props, \"children\")}>{props.children ?? ((state) => state.text)}</parts.FileNote>\n  );\n}\n\nexport type DiffColumnProps = ComponentProps<typeof parts.Column>;\n\n/** A column's name for screen readers, unless you pass children. */\nexport function DiffColumn(props: DiffColumnProps) {\n  return (\n    <parts.Column {...omit(props, \"children\")}>{props.children ?? ((state) => state.text)}</parts.Column>\n  );\n}\n\nexport type DiffTableProps = ComponentProps<typeof parts.Table>;\n\n/** The column headers, then a `DiffChange` or `DiffLine` for each row, keyed by its key, unless you pass children. */\nexport function DiffTable(props: DiffTableProps) {\n  return (\n    <parts.Table {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <>\n            <DiffHead>\n              <For each={state.columns}>{(column) => <DiffColumn value={column} />}</For>\n            </DiffHead>\n            <For each={state.rows} keyed={(row) => row.key}>\n              {(row) => (\n                <Show when={row().change} fallback={<DiffLine value={row().key} />}>\n                  <DiffChange value={row().key} />\n                </Show>\n              )}\n            </For>\n          </>\n        ))}\n    </parts.Table>\n  );\n}\n\nexport type DiffChangeProps = ComponentProps<typeof parts.Change>;\n\n/** A change's header row, \"Change 1 of 2 · line 19\" with its Keep and Undo, unless you pass children. */\nexport function DiffChange(props: DiffChangeProps) {\n  return <parts.Change {...omit(props, \"children\")}>{props.children ?? <DiffChangeTitle />}</parts.Change>;\n}\n\nexport type DiffChangeTitleProps = ComponentProps<typeof parts.ChangeTitle>;\n\n/** The change's words, then its error, Undo, Keep and outcome, unless you pass children. */\nexport function DiffChangeTitle(props: DiffChangeTitleProps) {\n  return (\n    <parts.ChangeTitle {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <>\n            <span data-diff-change-text=\"\">{state.text}</span>\n            <DiffChangeError />\n            <DiffChangeUndo />\n            <DiffChangeKeep />\n            <DiffChangeOutcome />\n          </>\n        ))}\n    </parts.ChangeTitle>\n  );\n}\n\nexport type DiffChangeUndoProps = ComponentProps<typeof parts.ChangeUndo>;\n\nexport function DiffChangeUndo(props: DiffChangeUndoProps) {\n  return (\n    <parts.ChangeUndo {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.ChangeUndo>\n  );\n}\n\nexport type DiffChangeKeepProps = ComponentProps<typeof parts.ChangeKeep>;\n\nexport function DiffChangeKeep(props: DiffChangeKeepProps) {\n  return (\n    <parts.ChangeKeep {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.ChangeKeep>\n  );\n}\n\nexport type DiffChangeOutcomeProps = ComponentProps<typeof parts.ChangeOutcome>;\n\nexport function DiffChangeOutcome(props: DiffChangeOutcomeProps) {\n  return <parts.ChangeOutcome {...omit(props, \"children\")}>{props.children ?? outcome}</parts.ChangeOutcome>;\n}\n\nexport type DiffChangeErrorProps = ComponentProps<typeof parts.ChangeError>;\n\nexport function DiffChangeError(props: DiffChangeErrorProps) {\n  return (\n    <parts.ChangeError {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.ChangeError>\n  );\n}\n\nexport type DiffLineProps = ComponentProps<typeof parts.Line>;\n\n/** A line: its numbers, its sign and its code, unless you pass children. */\nexport function DiffLine(props: DiffLineProps) {\n  return <parts.Line {...omit(props, \"children\")}>{props.children ?? <LineCells />}</parts.Line>;\n}\n\n/** The line's number in the old file, drawn from `data-line`, so a copy holds only code. */\nexport const DiffOldNumber = parts.OldNumber;\n/** The line's number in the new file, drawn from `data-line`. */\nexport const DiffNewNumber = parts.NewNumber;\n/** `+` or `−`, drawn from `data-sign`. */\nexport const DiffSign = parts.Sign;\n\nconst Pieces = (props: { pieces: readonly DiffPiece[] }) => (\n  <For each={props.pieces} keyed={false}>\n    {(piece) => (\n      <span\n        style={piece().color ? { color: piece().color } : undefined}\n        data-diff-changed={piece().changed ? \"\" : undefined}\n        data-italic={piece().fontStyle === \"italic\" ? \"\" : undefined}\n        data-bold={piece().fontStyle === \"bold\" ? \"\" : undefined}\n      >\n        {piece().text}\n      </span>\n    )}\n  </For>\n);\n\nconst Code = (props: { line: DiffLineView }) => (\n  <Show\n    when={props.line.kind !== \"collapsed\"}\n    fallback={\n      <>\n        <DiffCollapsed />\n        <DiffCollapsedText />\n      </>\n    }\n  >\n    <Show when={props.line.prefix}>\n      <span data-diff-hidden=\"\">{props.line.prefix} </span>\n    </Show>\n    <Switch fallback={<Pieces pieces={props.line.pieces} />}>\n      <Match when={props.line.kind === \"add\"}>\n        <ins>\n          <Pieces pieces={props.line.pieces} />\n        </ins>\n      </Match>\n      <Match when={props.line.kind === \"remove\"}>\n        <del>\n          <Pieces pieces={props.line.pieces} />\n        </del>\n      </Match>\n    </Switch>\n  </Show>\n);\n\nexport type DiffCodeProps = ComponentProps<typeof parts.Code>;\n\n/**\n * The line's code, in `ins` or `del` with its changed words marked and hidden words for screen readers, or a\n * collapsed run's `DiffCollapsed` and `DiffCollapsedText`, unless you pass children.\n */\nexport function DiffCode(props: DiffCodeProps) {\n  return (\n    <parts.Code {...omit(props, \"children\")}>\n      {props.children ?? ((state) => <Show when={state.line}>{(line) => <Code line={line()} />}</Show>)}\n    </parts.Code>\n  );\n}\n\nexport type DiffCollapsedProps = ComponentProps<typeof parts.Collapsed>;\n\n/** \"Show 12 lines\", unless you pass children. Its name says where they are. */\nexport function DiffCollapsed(props: DiffCollapsedProps) {\n  return (\n    <parts.Collapsed {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.Collapsed>\n  );\n}\n\nexport type DiffCollapsedTextProps = ComponentProps<typeof parts.CollapsedText>;\n\n/** The collapsed lines, hidden until find in page matches one, unless you pass children. */\nexport function DiffCollapsedText(props: DiffCollapsedTextProps) {\n  return (\n    <parts.CollapsedText {...omit(props, \"children\")}>\n      {props.children ?? ((state) => state.text)}\n    </parts.CollapsedText>\n  );\n}\n\nexport type DiffShowAllProps = ComponentProps<typeof parts.ShowAll>;\n\n/** \"Show full diff (6,400 lines)\" for a file cut off at 2,000 rows, unless you pass children. */\nexport function DiffShowAll(props: DiffShowAllProps) {\n  return (\n    <parts.ShowAll {...omit(props, \"children\")}>{props.children ?? ((state) => state.text)}</parts.ShowAll>\n  );\n}\n\nfunction LineCells() {\n  return (\n    <>\n      <DiffOldNumber />\n      <DiffNewNumber />\n      <DiffSign />\n      <DiffCode />\n    </>\n  );\n}\n\nfunction FileParts() {\n  return (\n    <>\n      <DiffFileTrigger>\n        <span data-diff-name=\"\">\n          <DiffFilePath />\n          <DiffFileOldPath />\n        </span>\n        <DiffFileStatus />\n        <DiffFileCounts />\n        <DiffFileMark />\n      </DiffFileTrigger>\n      <DiffFileActions>\n        <DiffFileError />\n        <DiffFileUndo />\n        <DiffFileKeep />\n        <DiffFileOutcome />\n      </DiffFileActions>\n      <DiffFileContent>\n        <DiffFileNote />\n        <DiffViewport>\n          <DiffTable />\n          <DiffShowAll />\n        </DiffViewport>\n      </DiffFileContent>\n    </>\n  );\n}\n\nfunction DefaultParts() {\n  return (\n    <>\n      <DiffSummary>\n        <div data-diff-heading=\"\">\n          <DiffSummaryTitle />\n          <DiffSummaryCounts />\n          <DiffSummaryProgress />\n          <DiffSummaryOutcome />\n        </div>\n        <DiffSummaryMark />\n        <DiffSummaryActions>\n          <DiffUndoAllQuestion />\n          <DiffUndoAll />\n          <DiffKeepAll />\n          <DiffUndoAllCancel />\n          <DiffUndoAllConfirm />\n        </DiffSummaryActions>\n        <DiffSummaryError />\n      </DiffSummary>\n      <DiffList />\n    </>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/solid/diff.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
