moi-computer 0.11.0 → 0.11.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/AGENTS.md +2 -2
- package/client/components/ui/button.tsx +1 -53
- package/client/components/ui/collapsible.tsx +1 -15
- package/client/components/ui/dialog.tsx +1 -58
- package/client/components/ui/dropdown-menu.tsx +1 -254
- package/client/components/ui/hover-card.tsx +1 -44
- package/client/components/ui/input.tsx +1 -21
- package/client/components/ui/popover.tsx +1 -88
- package/client/components/ui/resizable.tsx +1 -40
- package/client/components/ui/skeleton.tsx +1 -13
- package/client/components/ui/slider.tsx +1 -70
- package/client/components/ui/spinner.tsx +1 -18
- package/client/components/ui/switch.tsx +1 -23
- package/client/components/ui/tabs.tsx +1 -0
- package/client/components/ui/textarea.tsx +1 -18
- package/client/components/ui/tooltip.tsx +1 -51
- package/client/features/chat/ChatPanel.tsx +6 -6
- package/client/features/chat/ChatPopup.tsx +3 -4
- package/client/features/chat/TurnView.tsx +5 -4
- package/client/features/chat/api.ts +5 -14
- package/client/features/chat/chat-frames.ts +5 -2
- package/client/features/chat/composer/ChatComposer.tsx +5 -1
- package/client/features/chat/composer/ModelPicker.tsx +4 -3
- package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
- package/client/features/chat/group-turns.ts +11 -0
- package/client/features/chat/session-view.ts +53 -0
- package/client/features/chat/useChat.ts +5 -1
- package/client/features/dev/ChatStatesPage.tsx +3 -1
- package/client/features/dev/DevIndexPage.tsx +5 -0
- package/client/features/dev/DevRoutes.tsx +2 -0
- package/client/features/dev/HarnessDebugPage.tsx +1 -1
- package/client/features/dev/UiComponentPreviews.tsx +834 -0
- package/client/features/dev/UiComponentsPage.tsx +60 -0
- package/client/features/home/WorkspacePreview.tsx +1 -1
- package/client/features/home/workspace-setup/DemoDialog.tsx +3 -2
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +5 -8
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +7 -20
- package/client/features/settings/SettingsLayout.tsx +1 -1
- package/client/features/settings/WorkspaceSettings.tsx +4 -1
- package/client/features/views/ViewManager.tsx +14 -9
- package/client/features/widgets/WidgetFrame.tsx +1 -1
- package/client/features/widgets/Widgets.tsx +1 -3
- package/client/features/workspace/WorkspaceScreen.tsx +5 -1
- package/client/features/workspace/WorkspaceSplitLayout.tsx +6 -1
- package/client/features/workspace/api.ts +2 -4
- package/client/index.css +22 -29
- package/dist/{chunk-tny85yt2.js → chunk-4s15axjs.js} +2 -2
- package/dist/{chunk-c9pjqx9m.js → chunk-53a7pxcz.js} +1 -1
- package/dist/chunk-6664vxpk.css +1 -0
- package/dist/{chunk-104m57qw.js → chunk-87thzbtw.js} +2 -2
- package/dist/chunk-a6jad1a6.js +1 -0
- package/dist/chunk-dghwstd2.js +9 -0
- package/dist/chunk-eg120aca.js +1 -0
- package/dist/{chunk-v7wr1df4.js → chunk-j3wvxjr7.js} +1 -1
- package/dist/chunk-vwjeezeb.js +1 -0
- package/dist/chunk-w482ew2c.js +546 -0
- package/dist/chunk-yc471zah.js +70 -0
- package/dist/index.html +1 -1
- package/lib/format.ts +49 -1
- package/lib/themes.ts +6 -6
- package/lib/types.ts +5 -7
- package/package.json +17 -7
- package/registry.json +643 -0
- package/server/AGENTS.md +1 -0
- package/server/agent.ts +1 -1
- package/server/api.ts +25 -29
- package/server/applets.ts +30 -29
- package/server/bundler/applet-css.ts +6 -1
- package/server/bundler/build-applet.ts +5 -1
- package/server/bundler/build-worker.ts +178 -0
- package/server/cli-ui-components.ts +28 -33
- package/server/cli.ts +6 -11
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +13 -9
- package/server/harness/acp/NOTES.md +426 -0
- package/server/harness/acp/discovery.ts +27 -30
- package/server/harness/acp/model-state.ts +57 -0
- package/server/harness/acp/session.ts +18 -6
- package/server/harness/claude-code/NOTES.md +47 -12
- package/server/harness/claude-code/cli.ts +40 -0
- package/server/harness/claude-code/index.ts +11 -5
- package/server/harness/claude-code/models.ts +72 -19
- package/server/harness/claude-code/session.ts +408 -299
- package/server/harness/hermes/NOTES.md +18 -0
- package/server/harness/hermes/discovery.ts +20 -0
- package/server/harness/hermes/index.ts +9 -0
- package/server/harness/hermes/models.ts +28 -8
- package/server/harness/types.ts +4 -2
- package/server/moi-scaffold.ts +1 -1
- package/server/preview.ts +3 -1
- package/server/registry.ts +63 -41
- package/server/scratchpad-executor.ts +79 -56
- package/server/scratchpad-shape-defaults.ts +82 -0
- package/server/tldraw-package.d.ts +4 -0
- package/server/ui-components.ts +101 -434
- package/server/view-builders.ts +2 -1
- package/server/web.ts +9 -5
- package/server/workspace-env.ts +3 -2
- package/tsconfig.json +0 -1
- package/ui-components/accordion.tsx +71 -0
- package/ui-components/alert-dialog.tsx +165 -0
- package/ui-components/alert.tsx +68 -0
- package/ui-components/attachment.tsx +195 -0
- package/ui-components/avatar.tsx +90 -0
- package/ui-components/badge.tsx +49 -0
- package/ui-components/button-group.tsx +78 -0
- package/ui-components/button.tsx +55 -0
- package/ui-components/calendar.tsx +180 -0
- package/ui-components/card.tsx +84 -0
- package/ui-components/carousel.tsx +235 -0
- package/ui-components/chart.tsx +338 -0
- package/ui-components/checkbox.tsx +27 -0
- package/ui-components/collapsible.tsx +15 -0
- package/ui-components/combobox.tsx +265 -0
- package/ui-components/context-menu.tsx +244 -0
- package/ui-components/dialog.tsx +138 -0
- package/ui-components/docs/accordion.md +463 -0
- package/ui-components/docs/alert-dialog.md +481 -0
- package/ui-components/docs/alert.md +301 -0
- package/ui-components/docs/attachment.md +689 -0
- package/ui-components/docs/avatar.md +495 -0
- package/ui-components/docs/badge.md +258 -0
- package/ui-components/docs/button-group.md +879 -0
- package/ui-components/docs/button.md +26 -0
- package/ui-components/docs/calendar.md +862 -0
- package/ui-components/docs/card.md +265 -0
- package/ui-components/docs/carousel.md +627 -0
- package/ui-components/docs/chart.md +1256 -0
- package/ui-components/docs/checkbox.md +477 -0
- package/ui-components/docs/collapsible.md +446 -0
- package/ui-components/docs/combobox.md +1003 -0
- package/ui-components/docs/context-menu.md +860 -0
- package/ui-components/docs/data-table.md +1580 -0
- package/ui-components/docs/date-picker.md +614 -0
- package/ui-components/docs/dialog.md +414 -0
- package/ui-components/docs/drawer.md +51 -0
- package/ui-components/docs/dropdown-menu.md +1000 -0
- package/ui-components/docs/field.md +1192 -0
- package/ui-components/docs/hover-card.md +275 -0
- package/ui-components/docs/input-group.md +866 -0
- package/ui-components/docs/input.md +456 -0
- package/ui-components/docs/label.md +295 -0
- package/ui-components/docs/pagination.md +416 -0
- package/ui-components/docs/popover.md +348 -0
- package/ui-components/docs/progress.md +214 -0
- package/ui-components/docs/radio-group.md +389 -0
- package/ui-components/docs/resizable.md +265 -0
- package/ui-components/docs/select.md +616 -0
- package/ui-components/docs/separator.md +216 -0
- package/ui-components/docs/skeleton.md +205 -0
- package/ui-components/docs/slider.md +226 -0
- package/ui-components/docs/spinner.md +332 -0
- package/ui-components/docs/switch.md +236 -0
- package/ui-components/docs/table.md +551 -0
- package/ui-components/docs/tabs.md +379 -0
- package/ui-components/docs/textarea.md +187 -0
- package/ui-components/docs/toggle-group.md +370 -0
- package/ui-components/docs/toggle.md +91 -0
- package/ui-components/docs/tooltip.md +290 -0
- package/ui-components/drawer.tsx +213 -0
- package/ui-components/dropdown-menu.tsx +263 -0
- package/ui-components/field.tsx +224 -0
- package/ui-components/hover-card.tsx +46 -0
- package/ui-components/input-group.tsx +146 -0
- package/ui-components/input.tsx +20 -0
- package/ui-components/label.tsx +17 -0
- package/ui-components/pagination.tsx +124 -0
- package/ui-components/popover.tsx +81 -0
- package/ui-components/progress.tsx +63 -0
- package/ui-components/radio-group.tsx +37 -0
- package/ui-components/resizable.tsx +40 -0
- package/ui-components/scoped-portal.tsx +31 -0
- package/ui-components/select.tsx +195 -0
- package/ui-components/separator.tsx +18 -0
- package/ui-components/skeleton.tsx +15 -0
- package/ui-components/slider.tsx +75 -0
- package/ui-components/spinner.tsx +20 -0
- package/ui-components/switch.tsx +26 -0
- package/ui-components/table.tsx +86 -0
- package/ui-components/tabs.tsx +75 -0
- package/ui-components/textarea.tsx +17 -0
- package/ui-components/toggle-group.tsx +85 -0
- package/ui-components/toggle.tsx +42 -0
- package/ui-components/tooltip.tsx +61 -0
- package/ui-components/utils.ts +8 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +11 -20
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +4 -3
- package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +67 -203
- package/dist/chunk-59zf0m6n.js +0 -1
- package/dist/chunk-bj3akjs2.js +0 -1
- package/dist/chunk-j2w2vak4.js +0 -546
- package/dist/chunk-k2r9c95m.js +0 -10
- package/dist/chunk-kmbxhgwv.js +0 -1
- package/dist/chunk-p1yqa71k.js +0 -83
- package/dist/chunk-r5xrenjy.css +0 -1
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Collapsible
|
|
3
|
+
description: An interactive component which expands/collapses a panel.
|
|
4
|
+
base: base
|
|
5
|
+
component: true
|
|
6
|
+
featured: true
|
|
7
|
+
links:
|
|
8
|
+
doc: https://base-ui.com/react/components/collapsible
|
|
9
|
+
api: https://base-ui.com/react/components/collapsible#api-reference
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
'use client'
|
|
14
|
+
|
|
15
|
+
import * as React from 'react'
|
|
16
|
+
import { IconSelector } from '@tabler/icons-react'
|
|
17
|
+
|
|
18
|
+
import { Button } from '@/components/ui/button'
|
|
19
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
|
|
20
|
+
|
|
21
|
+
export function CollapsibleDemo() {
|
|
22
|
+
const [isOpen, setIsOpen] = React.useState(false)
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Collapsible open={isOpen} onOpenChange={setIsOpen} className="flex w-[350px] flex-col gap-2">
|
|
26
|
+
<div className="flex items-center justify-between gap-4 px-4">
|
|
27
|
+
<h4 className="text-sm font-semibold">Order #4189</h4>
|
|
28
|
+
<CollapsibleTrigger render={<Button variant="ghost" size="icon" className="size-8" />}>
|
|
29
|
+
<IconSelector stroke={1.5} />
|
|
30
|
+
<span className="sr-only">Toggle details</span>
|
|
31
|
+
</CollapsibleTrigger>
|
|
32
|
+
</div>
|
|
33
|
+
<div className="flex items-center justify-between rounded-md border px-4 py-2 text-sm">
|
|
34
|
+
<span className="text-muted-foreground">Status</span>
|
|
35
|
+
<span className="font-medium">Shipped</span>
|
|
36
|
+
</div>
|
|
37
|
+
<CollapsibleContent className="flex flex-col gap-2">
|
|
38
|
+
<div className="rounded-md border px-4 py-2 text-sm">
|
|
39
|
+
<p className="font-medium">Shipping address</p>
|
|
40
|
+
<p className="text-muted-foreground">100 Market St, San Francisco</p>
|
|
41
|
+
</div>
|
|
42
|
+
<div className="rounded-md border px-4 py-2 text-sm">
|
|
43
|
+
<p className="font-medium">Items</p>
|
|
44
|
+
<p className="text-muted-foreground">2x Studio Headphones</p>
|
|
45
|
+
</div>
|
|
46
|
+
</CollapsibleContent>
|
|
47
|
+
</Collapsible>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
<CodeTabs>
|
|
55
|
+
|
|
56
|
+
<TabsList>
|
|
57
|
+
<TabsTrigger value="cli">Command</TabsTrigger>
|
|
58
|
+
<TabsTrigger value="manual">Manual</TabsTrigger>
|
|
59
|
+
</TabsList>
|
|
60
|
+
<TabsContent value="cli">
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
moi ui-components add collapsible
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
</TabsContent>
|
|
67
|
+
|
|
68
|
+
<TabsContent value="manual">
|
|
69
|
+
|
|
70
|
+
<Steps className="mb-0 pt-2">
|
|
71
|
+
|
|
72
|
+
<Step>Install the following dependencies:</Step>
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm install @base-ui/react
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
<Step>Copy and paste the following code into your project.</Step>
|
|
79
|
+
|
|
80
|
+
<ComponentSource
|
|
81
|
+
name="collapsible"
|
|
82
|
+
title="components/ui/collapsible.tsx"
|
|
83
|
+
styleName="base-nova"
|
|
84
|
+
/>
|
|
85
|
+
|
|
86
|
+
<Step>Update the import paths to match your project setup.</Step>
|
|
87
|
+
|
|
88
|
+
</Steps>
|
|
89
|
+
|
|
90
|
+
</TabsContent>
|
|
91
|
+
|
|
92
|
+
</CodeTabs>
|
|
93
|
+
|
|
94
|
+
## Usage
|
|
95
|
+
|
|
96
|
+
```tsx showLineNumbers
|
|
97
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```tsx showLineNumbers
|
|
101
|
+
<Collapsible>
|
|
102
|
+
<CollapsibleTrigger>Can I use this in my project?</CollapsibleTrigger>
|
|
103
|
+
<CollapsibleContent>
|
|
104
|
+
Yes. Free to use for personal and commercial projects. No attribution required.
|
|
105
|
+
</CollapsibleContent>
|
|
106
|
+
</Collapsible>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Composition
|
|
110
|
+
|
|
111
|
+
Use the following composition to build a `Collapsible`:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
Collapsible
|
|
115
|
+
├── CollapsibleTrigger
|
|
116
|
+
└── CollapsibleContent
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Controlled State
|
|
120
|
+
|
|
121
|
+
Use the `open` and `onOpenChange` props to control the state.
|
|
122
|
+
|
|
123
|
+
```tsx showLineNumbers
|
|
124
|
+
import * as React from 'react'
|
|
125
|
+
|
|
126
|
+
export function Example() {
|
|
127
|
+
const [open, setOpen] = React.useState(false)
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<Collapsible open={open} onOpenChange={setOpen}>
|
|
131
|
+
<CollapsibleTrigger>Toggle</CollapsibleTrigger>
|
|
132
|
+
<CollapsibleContent>Content</CollapsibleContent>
|
|
133
|
+
</Collapsible>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Basic
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { IconChevronDown } from '@tabler/icons-react'
|
|
142
|
+
import { Button } from '@/components/ui/button'
|
|
143
|
+
import { Card, CardContent } from '@/components/ui/card'
|
|
144
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
|
|
145
|
+
|
|
146
|
+
export function CollapsibleBasic() {
|
|
147
|
+
return (
|
|
148
|
+
<Card className="mx-auto w-full max-w-sm">
|
|
149
|
+
<CardContent>
|
|
150
|
+
<Collapsible className="rounded-md data-open:bg-muted">
|
|
151
|
+
<CollapsibleTrigger render={<Button variant="ghost" className="w-full" />}>
|
|
152
|
+
Product details
|
|
153
|
+
<IconChevronDown
|
|
154
|
+
stroke={1.5}
|
|
155
|
+
className="ml-auto group-data-panel-open/button:rotate-180"
|
|
156
|
+
/>
|
|
157
|
+
</CollapsibleTrigger>
|
|
158
|
+
<CollapsibleContent className="flex flex-col items-start gap-2 p-2.5 pt-0 text-sm">
|
|
159
|
+
<div>This panel can be expanded or collapsed to reveal additional content.</div>
|
|
160
|
+
<Button size="xs">Learn More</Button>
|
|
161
|
+
</CollapsibleContent>
|
|
162
|
+
</Collapsible>
|
|
163
|
+
</CardContent>
|
|
164
|
+
</Card>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Settings Panel
|
|
170
|
+
|
|
171
|
+
Use a trigger button to reveal additional settings.
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
'use client'
|
|
175
|
+
|
|
176
|
+
import * as React from 'react'
|
|
177
|
+
import { IconMaximize, IconMinimize } from '@tabler/icons-react'
|
|
178
|
+
|
|
179
|
+
import { Button } from '@/components/ui/button'
|
|
180
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
|
181
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
|
|
182
|
+
import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'
|
|
183
|
+
import { Input } from '@/components/ui/input'
|
|
184
|
+
|
|
185
|
+
export function CollapsibleSettings() {
|
|
186
|
+
const [isOpen, setIsOpen] = React.useState(false)
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<Card className="mx-auto w-full max-w-xs" size="sm">
|
|
190
|
+
<CardHeader>
|
|
191
|
+
<CardTitle>Radius</CardTitle>
|
|
192
|
+
<CardDescription>Set the corner radius of the element.</CardDescription>
|
|
193
|
+
</CardHeader>
|
|
194
|
+
<CardContent>
|
|
195
|
+
<Collapsible open={isOpen} onOpenChange={setIsOpen} className="flex items-start gap-2">
|
|
196
|
+
<FieldGroup className="grid w-full grid-cols-2 gap-2">
|
|
197
|
+
<Field>
|
|
198
|
+
<FieldLabel htmlFor="radius-x" className="sr-only">
|
|
199
|
+
Radius X
|
|
200
|
+
</FieldLabel>
|
|
201
|
+
<Input id="radius" placeholder="0" defaultValue={0} />
|
|
202
|
+
</Field>
|
|
203
|
+
<Field>
|
|
204
|
+
<FieldLabel htmlFor="radius-y" className="sr-only">
|
|
205
|
+
Radius Y
|
|
206
|
+
</FieldLabel>
|
|
207
|
+
<Input id="radius" placeholder="0" defaultValue={0} />
|
|
208
|
+
</Field>
|
|
209
|
+
<CollapsibleContent className="col-span-full grid grid-cols-subgrid gap-2">
|
|
210
|
+
<Field>
|
|
211
|
+
<FieldLabel htmlFor="radius-x" className="sr-only">
|
|
212
|
+
Radius X
|
|
213
|
+
</FieldLabel>
|
|
214
|
+
<Input id="radius" placeholder="0" defaultValue={0} />
|
|
215
|
+
</Field>
|
|
216
|
+
<Field>
|
|
217
|
+
<FieldLabel htmlFor="radius-y" className="sr-only">
|
|
218
|
+
Radius Y
|
|
219
|
+
</FieldLabel>
|
|
220
|
+
<Input id="radius" placeholder="0" defaultValue={0} />
|
|
221
|
+
</Field>
|
|
222
|
+
</CollapsibleContent>
|
|
223
|
+
</FieldGroup>
|
|
224
|
+
<CollapsibleTrigger render={<Button variant="outline" size="icon" />}>
|
|
225
|
+
{isOpen ? <IconMinimize stroke={1.5} /> : <IconMaximize stroke={1.5} />}
|
|
226
|
+
</CollapsibleTrigger>
|
|
227
|
+
</Collapsible>
|
|
228
|
+
</CardContent>
|
|
229
|
+
</Card>
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## File Tree
|
|
235
|
+
|
|
236
|
+
Use nested collapsibles to build a file tree.
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
import { IconChevronRight, IconFile, IconFolder } from '@tabler/icons-react'
|
|
240
|
+
|
|
241
|
+
import { Button } from '@/components/ui/button'
|
|
242
|
+
import { Card, CardContent, CardHeader } from '@/components/ui/card'
|
|
243
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
|
|
244
|
+
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
|
245
|
+
|
|
246
|
+
type FileTreeItem = { name: string } | { name: string; items: FileTreeItem[] }
|
|
247
|
+
|
|
248
|
+
export function CollapsibleFileTree() {
|
|
249
|
+
const fileTree: FileTreeItem[] = [
|
|
250
|
+
{
|
|
251
|
+
name: 'components',
|
|
252
|
+
items: [
|
|
253
|
+
{
|
|
254
|
+
name: 'ui',
|
|
255
|
+
items: [
|
|
256
|
+
{ name: 'button.tsx' },
|
|
257
|
+
{ name: 'card.tsx' },
|
|
258
|
+
{ name: 'dialog.tsx' },
|
|
259
|
+
{ name: 'input.tsx' },
|
|
260
|
+
{ name: 'select.tsx' },
|
|
261
|
+
{ name: 'table.tsx' }
|
|
262
|
+
]
|
|
263
|
+
},
|
|
264
|
+
{ name: 'login-form.tsx' },
|
|
265
|
+
{ name: 'register-form.tsx' }
|
|
266
|
+
]
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: 'lib',
|
|
270
|
+
items: [{ name: 'utils.ts' }, { name: 'cn.ts' }, { name: 'api.ts' }]
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: 'hooks',
|
|
274
|
+
items: [
|
|
275
|
+
{ name: 'use-media-query.ts' },
|
|
276
|
+
{ name: 'use-debounce.ts' },
|
|
277
|
+
{ name: 'use-local-storage.ts' }
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: 'types',
|
|
282
|
+
items: [{ name: 'index.d.ts' }, { name: 'api.d.ts' }]
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: 'public',
|
|
286
|
+
items: [{ name: 'favicon.ico' }, { name: 'logo.svg' }, { name: 'images' }]
|
|
287
|
+
},
|
|
288
|
+
{ name: 'app.tsx' },
|
|
289
|
+
{ name: 'layout.tsx' },
|
|
290
|
+
{ name: 'globals.css' },
|
|
291
|
+
{ name: 'package.json' },
|
|
292
|
+
{ name: 'tsconfig.json' },
|
|
293
|
+
{ name: 'README.md' },
|
|
294
|
+
{ name: '.gitignore' }
|
|
295
|
+
]
|
|
296
|
+
|
|
297
|
+
const renderItem = (fileItem: FileTreeItem) => {
|
|
298
|
+
if ('items' in fileItem) {
|
|
299
|
+
return (
|
|
300
|
+
<Collapsible key={fileItem.name}>
|
|
301
|
+
<CollapsibleTrigger
|
|
302
|
+
render={
|
|
303
|
+
<Button
|
|
304
|
+
variant="ghost"
|
|
305
|
+
size="sm"
|
|
306
|
+
className="group w-full justify-start transition-none hover:bg-accent hover:text-accent-foreground"
|
|
307
|
+
/>
|
|
308
|
+
}
|
|
309
|
+
>
|
|
310
|
+
<IconChevronRight
|
|
311
|
+
stroke={1.75}
|
|
312
|
+
className="transition-transform group-data-[state=open]:rotate-90"
|
|
313
|
+
/>
|
|
314
|
+
<IconFolder stroke={1.75} />
|
|
315
|
+
{fileItem.name}
|
|
316
|
+
</CollapsibleTrigger>
|
|
317
|
+
<CollapsibleContent className="mt-1 ml-5 style-lyra:ml-4">
|
|
318
|
+
<div className="flex flex-col gap-1">
|
|
319
|
+
{fileItem.items.map(child => renderItem(child))}
|
|
320
|
+
</div>
|
|
321
|
+
</CollapsibleContent>
|
|
322
|
+
</Collapsible>
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
return (
|
|
326
|
+
<Button
|
|
327
|
+
key={fileItem.name}
|
|
328
|
+
variant="link"
|
|
329
|
+
size="sm"
|
|
330
|
+
className="w-full justify-start gap-2 text-foreground"
|
|
331
|
+
>
|
|
332
|
+
<IconFile stroke={1.75} />
|
|
333
|
+
<span>{fileItem.name}</span>
|
|
334
|
+
</Button>
|
|
335
|
+
)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return (
|
|
339
|
+
<Card className="mx-auto w-full max-w-[16rem] gap-2" size="sm">
|
|
340
|
+
<CardHeader>
|
|
341
|
+
<Tabs defaultValue="explorer">
|
|
342
|
+
<TabsList className="w-full">
|
|
343
|
+
<TabsTrigger value="explorer">Explorer</TabsTrigger>
|
|
344
|
+
<TabsTrigger value="settings">Outline</TabsTrigger>
|
|
345
|
+
</TabsList>
|
|
346
|
+
</Tabs>
|
|
347
|
+
</CardHeader>
|
|
348
|
+
<CardContent>
|
|
349
|
+
<div className="flex flex-col gap-1">{fileTree.map(item => renderItem(item))}</div>
|
|
350
|
+
</CardContent>
|
|
351
|
+
</Card>
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## RTL
|
|
357
|
+
|
|
358
|
+
```tsx
|
|
359
|
+
'use client'
|
|
360
|
+
|
|
361
|
+
import * as React from 'react'
|
|
362
|
+
import { IconSelector } from '@tabler/icons-react'
|
|
363
|
+
|
|
364
|
+
import { useTranslation, type Translations } from '@/components/language-selector'
|
|
365
|
+
import { Button } from '@/components/ui/button'
|
|
366
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
|
|
367
|
+
|
|
368
|
+
const translations: Translations = {
|
|
369
|
+
en: {
|
|
370
|
+
dir: 'ltr',
|
|
371
|
+
values: {
|
|
372
|
+
orderNumber: 'Order #4189',
|
|
373
|
+
status: 'Status',
|
|
374
|
+
shipped: 'Shipped',
|
|
375
|
+
shippingAddress: 'Shipping address',
|
|
376
|
+
address: '100 Market St, San Francisco',
|
|
377
|
+
items: 'Items',
|
|
378
|
+
itemsDescription: '2x Studio Headphones'
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
ar: {
|
|
382
|
+
dir: 'rtl',
|
|
383
|
+
values: {
|
|
384
|
+
orderNumber: 'الطلب #4189',
|
|
385
|
+
status: 'الحالة',
|
|
386
|
+
shipped: 'تم الشحن',
|
|
387
|
+
shippingAddress: 'عنوان الشحن',
|
|
388
|
+
address: '100 Market St, San Francisco',
|
|
389
|
+
items: 'العناصر',
|
|
390
|
+
itemsDescription: '2x سماعات الاستوديو'
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
he: {
|
|
394
|
+
dir: 'rtl',
|
|
395
|
+
values: {
|
|
396
|
+
orderNumber: 'הזמנה #4189',
|
|
397
|
+
status: 'סטטוס',
|
|
398
|
+
shipped: 'נשלח',
|
|
399
|
+
shippingAddress: 'כתובת משלוח',
|
|
400
|
+
address: '100 Market St, San Francisco',
|
|
401
|
+
items: 'פריטים',
|
|
402
|
+
itemsDescription: '2x אוזניות סטודיו'
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export function CollapsibleRtl() {
|
|
408
|
+
const { dir, t } = useTranslation(translations, 'ar')
|
|
409
|
+
const [isOpen, setIsOpen] = React.useState(false)
|
|
410
|
+
|
|
411
|
+
return (
|
|
412
|
+
<Collapsible
|
|
413
|
+
open={isOpen}
|
|
414
|
+
onOpenChange={setIsOpen}
|
|
415
|
+
className="flex w-[350px] flex-col gap-2"
|
|
416
|
+
dir={dir}
|
|
417
|
+
>
|
|
418
|
+
<div className="flex items-center justify-between gap-4 px-4">
|
|
419
|
+
<h4 className="text-sm font-semibold">{t.orderNumber}</h4>
|
|
420
|
+
<CollapsibleTrigger render={<Button variant="ghost" size="icon" className="size-8" />}>
|
|
421
|
+
<IconSelector stroke={1.5} />
|
|
422
|
+
<span className="sr-only">Toggle details</span>
|
|
423
|
+
</CollapsibleTrigger>
|
|
424
|
+
</div>
|
|
425
|
+
<div className="flex items-center justify-between rounded-md border px-4 py-2 text-sm">
|
|
426
|
+
<span className="text-muted-foreground">{t.status}</span>
|
|
427
|
+
<span className="font-medium">{t.shipped}</span>
|
|
428
|
+
</div>
|
|
429
|
+
<CollapsibleContent className="flex flex-col gap-2">
|
|
430
|
+
<div className="rounded-md border px-4 py-2 text-sm">
|
|
431
|
+
<p className="font-medium">{t.shippingAddress}</p>
|
|
432
|
+
<p className="text-muted-foreground">{t.address}</p>
|
|
433
|
+
</div>
|
|
434
|
+
<div className="rounded-md border px-4 py-2 text-sm">
|
|
435
|
+
<p className="font-medium">{t.items}</p>
|
|
436
|
+
<p className="text-muted-foreground">{t.itemsDescription}</p>
|
|
437
|
+
</div>
|
|
438
|
+
</CollapsibleContent>
|
|
439
|
+
</Collapsible>
|
|
440
|
+
)
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
## API Reference
|
|
445
|
+
|
|
446
|
+
See the [Base UI](https://base-ui.com/react/components/collapsible#api-reference) documentation for more information.
|