{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "file-tree-solid",
  "title": "File Tree (Solid)",
  "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/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-tree-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/file-tree.tsx",
      "content": "import { fileTreePrimitive } from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport type { TreeItemData } from \"@ui-sdk/solid/tree\";\nimport { For, omit, Show } from \"solid-js\";\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\" stroke-width=\"2\" aria-hidden=\"true\">\n    <path d=\"m9 18 6-6-6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n  </svg>\n);\n\nexport type FileTreeProps = Omit<ComponentProps<typeof parts.Root>, \"children\"> & { children?: JSX.Element };\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(props: FileTreeProps) {\n  return (\n    <parts.Root {...omit(props, \"children\")}>\n      {(tree) => (\n        <KindTree\n          controller={tree.controller}\n          items={tree.items}\n          defaultValue={tree.defaultValue}\n          defaultExpanded={tree.defaultExpanded}\n          aria-label={tree[\"aria-label\"]}\n          hiddenUntilFound={tree.hiddenUntilFound}\n        >\n          {props.children ?? <FileTreeRows items={tree.items} />}\n        </KindTree>\n      )}\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 function FileTreeRows(props: FileTreeRowsProps) {\n  return (\n    <For each={props.items} keyed={(item) => item.value}>\n      {(item) => (\n        <KindTreeItem value={item().value}>\n          <KindTreeItemLabel>\n            <KindTreeItemIndicator data-agent-hidden=\"\">\n              <Show when={item().children}>\n                <Chevron />\n              </Show>\n            </KindTreeItemIndicator>\n            <FileTreeItem value={item().value} />\n          </KindTreeItemLabel>\n          <Show when={item().children}>\n            {(children) => (\n              <KindTreeGroup>\n                <FileTreeRows items={children()} />\n              </KindTreeGroup>\n            )}\n          </Show>\n        </KindTreeItem>\n      )}\n    </For>\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(props: FileTreeItemProps) {\n  return (\n    <parts.Item {...omit(props, \"children\")}>\n      {props.children ??\n        ((row) => (\n          <>\n            <span data-file-tree-name=\"\">{row.name}</span> <FileTreeCounts /> <FileTreeBadge />\n          </>\n        ))}\n    </parts.Item>\n  );\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/solid/file-tree.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
