Обзор
Компоненты
- Accordion
- Alert
- Alert Dialog
- Autocomplete
- Auth Surface
- Avatar
- Badge
- Browse Catalog Dialog
- Button
- Card
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Connector Setup Dialog
- Cookie Banner
- Dialog
- Directory Card
- Directory Detail
- Directory Skeleton
- DrawerНовое
- Token Parts Input
- Empty
- Field
- Fieldset
- File Preview Modal
- File Preview Skeleton
- Form
- Frame
- Group
- Icon
- Input
- Input Group
- Kbd
- Label
- Legal Shell
- Menu
- Mermaid Diagram
- Mind Map Diagram
- Not Found Screen
- Onboarding Frame
- Popover
- PDF Thumbnail
- Personalization Landing
- Preview Card
- Pricing Page
- Progress
- Radio Group
- Ring Spinner
- Scroll Area
- Select
- Separator
- Settings Page
- Settings Skills
- Settings Connectors
- Settings Capabilities
- Settings Usage
- Settings Account
- Settings Billing
- Sheet
- Sidebar
- Skeleton
- Skill Create Dialog
- Slider
- Spinner
- Stat
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Tooltip
AI-компоненты
- Компоненты AI
- Chat Conversation
- Chat Message
- Chat Response
- Chat Suggestion
- Chat Prompt Input
- Slash Highlighted Textarea
- Chat Search Dialog
- Chat Skill Doc
- Chat Connector Detail
- Chat Attachments
- Chat File Card
- Chat Token Chip
- Chat Code Block
- Chat Image
- Chat Inline Citation
- Chat Sources
- Chat Web Search
- Chat Research
- Chat Source
- Chat Actions
- Chat Context
- Chat Loader
- Chat Compaction
- Chat Timeline
- Chat Snippet
- Chat Terminal
- Chat Stack Trace
- Chat Test Results
- Chat File Tree
- Chat Environment Variables
- Chat Audio Player
- Chat Transcription
- Chat Speech Input
- Chat Mic Selector
- Chat Voice Selector
- Chat Agent
- Chat Persona
- Chat Connection
- Chat Connector Suggestion
- Chat Queue
- Chat Checkpoint
- Chat Confirmation
- Chat Artifact
- Chat JSX Preview
- Chat Schema Display
- Chat Package Info
- Chat Commit
- Chat Plan
- Chat Open In Chat
- Chat Sandbox
- Chat Model Selector
- Chat Canvas
- Chat Node
- Chat Edge
Ресурсы
Chat File Tree
Рекурсивное дерево файлов/папок с выбором и индентацией.
Выбрано: apps/ui/registry/default/ui/chat-message.tsx
"use client";
import { useState } from "react";
import {
ChatFileTree,
ChatFileTreeFile,
ChatFileTreeFolder,
} from "@/components/ui/chat-file-tree";
export default function Particle() {
const [selected, setSelected] = useState<string>(
"apps/ui/registry/default/ui/chat-message.tsx",
);
return (
<div className="flex w-full max-w-md flex-col gap-3 p-4">
<ChatFileTree
onSelect={(node) => setSelected(node.id)}
selectedId={selected}
>
<ChatFileTreeFolder name="apps">
<ChatFileTreeFolder name="ui" level={1}>
<ChatFileTreeFolder name="registry" level={2}>
<ChatFileTreeFolder name="default" level={3}>
<ChatFileTreeFolder name="ui" level={4}>
<ChatFileTreeFile
badge="M"
id="apps/ui/registry/default/ui/chat-message.tsx"
level={5}
name="chat-message.tsx"
/>
<ChatFileTreeFile
id="apps/ui/registry/default/ui/chat-prompt-input.tsx"
level={5}
name="chat-prompt-input.tsx"
/>
<ChatFileTreeFile
badge="A"
id="apps/ui/registry/default/ui/chat-snippet.tsx"
level={5}
name="chat-snippet.tsx"
/>
</ChatFileTreeFolder>
</ChatFileTreeFolder>
</ChatFileTreeFolder>
</ChatFileTreeFolder>
</ChatFileTreeFolder>
</ChatFileTree>
<p className="text-muted-foreground text-sm">
Выбрано:{" "}
<span className="font-mono text-foreground text-xs">{selected}</span>
</p>
</div>
);
}
Установка
pnpm dlx shadcn@latest add @oracul/chat-file-tree
Использование
Композиция вручную
import {
ChatFileTree,
ChatFileTreeFile,
ChatFileTreeFolder,
} from "@/components/ui/chat-file-tree";
<ChatFileTree onSelect={(node) => openFile(node.id)}>
<ChatFileTreeFolder name="app" defaultOpen>
<ChatFileTreeFile id="app/page.tsx" name="page.tsx" level={1} />
<ChatFileTreeFolder name="components" level={1}>
<ChatFileTreeFile id="app/components/button.tsx" name="button.tsx" level={2} />
</ChatFileTreeFolder>
</ChatFileTreeFolder>
</ChatFileTree>Из массива данных
import { ChatFileTree, ChatFileTreeFolder, type ChatFileTreeNode } from "@/components/ui/chat-file-tree";
const tree: ChatFileTreeNode[] = [
{
id: "app",
name: "app",
children: [
{ id: "app/page.tsx", name: "page.tsx" },
{
id: "app/components",
name: "components",
children: [{ id: "app/components/button.tsx", name: "button.tsx" }],
},
],
},
];
<ChatFileTree onSelect={(n) => openFile(n.id)}>
<ChatFileTreeFolder data={tree[0].children!} name={tree[0].name} />
</ChatFileTree>Выбор
selectedId/defaultSelectedIdдля controlled / uncontrolled выбора.onSelect(node)— срабатывает только при клике на файл (не на папку).- Выбранный файл получает
data-state="selected"и подсветку фона.
На этой странице