{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "file-tree",
  "title": "File Tree",
  "description": "Changed files as a folder tree, each with its change and the lines it added and removed.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-tree"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/file-tree.tsx",
      "content": "\"use client\";\n\nimport { fileTreePrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/react/primitive\";\nimport type { TreeItemData } from \"@ui-sdk/react/tree\";\nimport { type ComponentProps, memo, type ReactNode } from \"react\";\nimport {\n  KindTree,\n  KindTreeGroup,\n  KindTreeItem,\n  KindTreeItemIndicator,\n  KindTreeItemLabel,\n} from \"./internal/tree\";\n\nconst parts = createParts(fileTreePrimitive, {\n  root: \"div\",\n  item: \"span\",\n  counts: \"span\",\n  badge: \"span\",\n});\n\n// Lucide \"chevron-right\", see THIRD_PARTY_NOTICES.md.\nconst CHEVRON = (\n  <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" aria-hidden=\"true\">\n    <path d=\"m9 18 6-6-6-6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n  </svg>\n);\n\nexport type FileTreeProps = Omit<ComponentProps<typeof parts.Root>, \"children\"> & { children?: ReactNode };\n\n/**\n * Changed files as a folder tree: each file shows its change as a badge and its added and removed lines; a folder\n * shows the most significant change inside it as a dot. The arrow keys, Home and End, and typing a name move\n * between rows, as in UI SDK's Tree. Any `children` replace the rows inside the Tree; `FileTreeRows` draws them.\n */\nexport function FileTree({ children, ...props }: FileTreeProps) {\n  return (\n    <parts.Root {...props}>\n      {(tree) => <KindTree {...tree}>{children ?? <FileTreeRows items={tree.items} />}</KindTree>}\n    </parts.Root>\n  );\n}\n\n// Every row has an indicator, a file's an empty spacer that lines its name up with a folder's. It's hidden from agents,\n// which hides UI SDK's Tree from them (a component with a part under `data-agent-hidden` is off limits) while the rows\n// stay the File Tree's.\nexport type FileTreeRowsProps = { items: TreeItemData[] };\n\n/** A Tree row for each item, with a `FileTreeItem` in its label, and its children in a group. */\nexport const FileTreeRows = memo(function FileTreeRows({ items }: FileTreeRowsProps) {\n  return items.map((item) => (\n    <KindTreeItem key={item.value} value={item.value}>\n      <KindTreeItemLabel>\n        <KindTreeItemIndicator data-agent-hidden=\"\">{item.children ? CHEVRON : null}</KindTreeItemIndicator>\n        <FileTreeItem value={item.value} />\n      </KindTreeItemLabel>\n      {item.children ? (\n        <KindTreeGroup>\n          <FileTreeRows items={item.children} />\n        </KindTreeGroup>\n      ) : null}\n    </KindTreeItem>\n  ));\n});\n\nexport type FileTreeItemProps = ComponentProps<typeof parts.Item>;\n\n/**\n * A row's icon, name, line counts and badge, unless you pass children. Its `value` is the row's path. Spaces between\n * the parts keep their words apart in the row's accessible name.\n */\nexport function FileTreeItem({\n  children = ({ name }) => (\n    <>\n      <span data-file-tree-name=\"\">{name}</span> <FileTreeCounts /> <FileTreeBadge />\n    </>\n  ),\n  ...props\n}: FileTreeItemProps) {\n  return <parts.Item {...props}>{children}</parts.Item>;\n}\n\nexport type FileTreeCountsProps = ComponentProps<typeof parts.Counts>;\n\n/** A file's added and removed lines, shown as `+N −N` and read as words. */\nexport function FileTreeCounts(props: FileTreeCountsProps) {\n  return <parts.Counts {...props} />;\n}\n\nexport type FileTreeBadgeProps = ComponentProps<typeof parts.Badge>;\n\n/** A file's change, shown as a letter like `M` and read as the word, like \"modified\". */\nexport function FileTreeBadge(props: FileTreeBadgeProps) {\n  return <parts.Badge {...props} />;\n}\n",
      "type": "registry:ui",
      "target": "@ui/file-tree.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
