{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "file-tree-vue",
  "title": "File Tree (Vue)",
  "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/vue@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-tree-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/file-tree.ts",
      "content": "import { type FileTreeRow, type FileTreeTreeState, fileTreePrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport type { TreeItemData } from \"@ui-sdk/vue/tree\";\nimport { type Component, defineComponent, h, type PropType, type Slots } from \"vue\";\nimport {\n  KindTree,\n  KindTreeGroup,\n  KindTreeItem,\n  KindTreeItemIndicator,\n  KindTreeItemLabel,\n} from \"./internal/tree\";\n\n// `@ui-sdk/vue`'s `createParts` hands the primitive an emitter for every callback, whether or not anything listens, so\n// `onSelect`, whose presence offers selection, is declared a function prop instead, which `@select` binds.\nconst primitive = Object.defineProperty(\n  Object.assign((options: never) => fileTreePrimitive(options), fileTreePrimitive, {\n    options: { ...fileTreePrimitive.options, onSelect: \"action\" },\n  }),\n  \"name\",\n  { value: fileTreePrimitive.name },\n) as typeof fileTreePrimitive;\n\nconst parts = createParts(primitive, {\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  h(\n    \"svg\",\n    {\n      viewBox: \"0 0 24 24\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"2\",\n      \"aria-hidden\": \"true\",\n    },\n    [h(\"path\", { d: \"m9 18 6-6-6-6\", \"stroke-linecap\": \"round\", \"stroke-linejoin\": \"round\" })],\n  );\n\n// A part whose default slot falls back to `fallback` when the caller fills none.\nfunction withDefault<C extends Component>(part: C, name: string, fallback: (scope: never) => unknown): C {\n  const Part = defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () => h(part, attrs, { ...slots, default: slots.default ?? fallback } as Slots);\n    },\n  });\n  return Part as unknown as C;\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.\n/** A Tree row for each item, with a `FileTreeItem` in its label, and its children in a group. */\nexport const FileTreeRows: Component<{ items: TreeItemData[] }> = defineComponent({\n  name: \"FileTreeRows\",\n  props: { items: { type: Array as PropType<TreeItemData[]>, required: true } },\n  setup(props) {\n    return () =>\n      props.items.map(({ value, children }) =>\n        h(KindTreeItem, { key: value, value }, () => [\n          h(KindTreeItemLabel, null, () => [\n            h(KindTreeItemIndicator, { \"data-agent-hidden\": \"\" }, children ? chevron : undefined),\n            h(FileTreeItem, { value }),\n          ]),\n          children ? h(KindTreeGroup, null, () => h(FileTreeRows, { items: children })) : null,\n        ]),\n      );\n  },\n});\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. A default slot replaces the rows inside the Tree; `FileTreeRows` draws them.\n */\nexport const FileTree = defineComponent({\n  name: \"FileTree\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Root, attrs, {\n        ...slots,\n        default: ({ state }: { state: FileTreeTreeState }) =>\n          // The slot's state is a proxy that lists no keys, so the Tree's props are read one by one.\n          h(\n            KindTree,\n            {\n              controller: state.controller,\n              items: state.items,\n              defaultValue: state.defaultValue,\n              defaultExpanded: state.defaultExpanded,\n              \"aria-label\": state[\"aria-label\"],\n              hiddenUntilFound: state.hiddenUntilFound,\n            },\n            () => slots.default?.() ?? h(FileTreeRows, { items: state.items }),\n          ),\n      });\n  },\n}) as unknown as typeof parts.Root;\n\n/** A file's added and removed lines, shown as `+N −N` and read as words. */\nexport const FileTreeCounts = parts.Counts;\n\n/** A file's change, shown as a letter like `M` and read as the word, like \"modified\". */\nexport const FileTreeBadge = parts.Badge;\n\n/**\n * A row's icon, name, line counts and badge, unless you fill its slot. Its `value` is the row's path. Spaces between\n * the parts keep their words apart in the row's accessible name.\n */\nexport const FileTreeItem = withDefault(parts.Item, \"FileTreeItem\", ({ state }: { state: FileTreeRow }) => [\n  h(\"span\", { \"data-file-tree-name\": \"\" }, state.name),\n  \" \",\n  h(FileTreeCounts),\n  \" \",\n  h(FileTreeBadge),\n]);\n",
      "type": "registry:ui",
      "target": "@ui/vue/file-tree.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
