moi-computer 0.11.1-next.0 → 0.11.1-next.2
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 +9 -7
- package/client/features/chat/chat-send.ts +13 -2
- package/client/features/chat/chat-store.ts +1 -3
- package/client/features/chat/composer/ChatComposer.tsx +5 -1
- package/client/features/chat/composer/ModelPicker.tsx +44 -44
- package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
- package/client/features/chat/composer/model-order.ts +15 -0
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
- package/client/features/chat/group-turns.ts +12 -0
- package/client/features/chat/interleave-notices.ts +7 -11
- package/client/features/chat/session-view.ts +53 -0
- package/client/features/chat/tool-group/ToolCallGroup.tsx +1 -4
- package/client/features/chat/tool-group/format/codex.ts +4 -1
- package/client/features/chat/useChat.ts +10 -9
- 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-245wt82v.css +1 -0
- package/dist/{chunk-tny85yt2.js → chunk-4s15axjs.js} +2 -2
- package/dist/{chunk-c9pjqx9m.js → chunk-53a7pxcz.js} +1 -1
- 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-j7hh2ab4.js +70 -0
- package/dist/chunk-w482ew2c.js +546 -0
- package/dist/chunk-y8eyahwx.js +1 -0
- package/dist/index.html +1 -1
- package/lib/format.ts +55 -6
- package/lib/themes.ts +6 -6
- package/lib/types.ts +10 -9
- package/package.json +12 -5
- package/registry.json +643 -0
- package/server/agent.ts +1 -1
- package/server/api.ts +26 -30
- package/server/applets.ts +30 -29
- package/server/bundler/applet-css.ts +7 -107
- 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 +41 -48
- 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/codex/NOTES.md +222 -350
- package/server/harness/codex/adapter.ts +94 -45
- package/server/harness/codex/auth.ts +1 -3
- package/server/harness/codex/client.ts +169 -249
- package/server/harness/codex/discovery.ts +9 -17
- package/server/harness/codex/index.ts +2 -1
- package/server/harness/codex/pagination.ts +24 -0
- package/server/harness/codex/permissions.ts +31 -7
- package/server/harness/codex/probe.ts +10 -13
- package/server/harness/codex/session.ts +549 -136
- package/server/harness/codex/transport.ts +184 -0
- package/server/harness/debug.ts +1 -1
- 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/tldraw-package.d.ts +4 -0
- package/server/ui-components.ts +101 -434
- package/server/view-builders.ts +2 -1
- package/server/web.ts +12 -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 +28 -0
- package/ui-components/collapsible.tsx +15 -0
- package/ui-components/combobox.tsx +267 -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 +38 -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 +27 -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,290 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Tooltip
|
|
3
|
+
description: A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.
|
|
4
|
+
base: base
|
|
5
|
+
component: true
|
|
6
|
+
links:
|
|
7
|
+
doc: https://base-ui.com/react/components/tooltip
|
|
8
|
+
api: https://base-ui.com/react/components/tooltip#api-reference
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Button } from '@/components/ui/button'
|
|
13
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
|
14
|
+
|
|
15
|
+
export function TooltipDemo() {
|
|
16
|
+
return (
|
|
17
|
+
<Tooltip>
|
|
18
|
+
<TooltipTrigger render={<Button variant="outline" />}>Hover</TooltipTrigger>
|
|
19
|
+
<TooltipContent>
|
|
20
|
+
<p>Add to library</p>
|
|
21
|
+
</TooltipContent>
|
|
22
|
+
</Tooltip>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
<CodeTabs>
|
|
30
|
+
|
|
31
|
+
<TabsList>
|
|
32
|
+
<TabsTrigger value="cli">Command</TabsTrigger>
|
|
33
|
+
<TabsTrigger value="manual">Manual</TabsTrigger>
|
|
34
|
+
</TabsList>
|
|
35
|
+
<TabsContent value="cli">
|
|
36
|
+
|
|
37
|
+
<Steps className="mb-0 pt-2">
|
|
38
|
+
|
|
39
|
+
<Step>Run the following command:</Step>
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
moi ui-components add tooltip
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
<Step>Add the `TooltipProvider` to the root of your app.</Step>
|
|
46
|
+
|
|
47
|
+
```tsx title="app/layout.tsx" showLineNumbers {1,7}
|
|
48
|
+
import { TooltipProvider } from '@/components/ui/tooltip'
|
|
49
|
+
|
|
50
|
+
export default function RootLayout({ children }) {
|
|
51
|
+
return (
|
|
52
|
+
<html lang="en">
|
|
53
|
+
<body>
|
|
54
|
+
<TooltipProvider>{children}</TooltipProvider>
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
</Steps>
|
|
62
|
+
|
|
63
|
+
</TabsContent>
|
|
64
|
+
|
|
65
|
+
<TabsContent value="manual">
|
|
66
|
+
|
|
67
|
+
<Steps className="mb-0 pt-2">
|
|
68
|
+
|
|
69
|
+
<Step>Install the following dependencies:</Step>
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install @base-ui/react
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
<Step>Copy and paste the following code into your project.</Step>
|
|
76
|
+
|
|
77
|
+
<ComponentSource
|
|
78
|
+
name="tooltip"
|
|
79
|
+
title="components/ui/tooltip.tsx"
|
|
80
|
+
styleName="base-nova"
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
<Step>Update the import paths to match your project setup.</Step>
|
|
84
|
+
|
|
85
|
+
<Step>Add the `TooltipProvider` to the root of your app.</Step>
|
|
86
|
+
|
|
87
|
+
```tsx title="app/layout.tsx" showLineNumbers {1,7}
|
|
88
|
+
import { TooltipProvider } from '@/components/ui/tooltip'
|
|
89
|
+
|
|
90
|
+
export default function RootLayout({ children }) {
|
|
91
|
+
return (
|
|
92
|
+
<html lang="en">
|
|
93
|
+
<body>
|
|
94
|
+
<TooltipProvider>{children}</TooltipProvider>
|
|
95
|
+
</body>
|
|
96
|
+
</html>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
</Steps>
|
|
102
|
+
|
|
103
|
+
</TabsContent>
|
|
104
|
+
|
|
105
|
+
</CodeTabs>
|
|
106
|
+
|
|
107
|
+
## Usage
|
|
108
|
+
|
|
109
|
+
```tsx showLineNumbers
|
|
110
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```tsx showLineNumbers
|
|
114
|
+
<Tooltip>
|
|
115
|
+
<TooltipTrigger>Hover</TooltipTrigger>
|
|
116
|
+
<TooltipContent>
|
|
117
|
+
<p>Add to library</p>
|
|
118
|
+
</TooltipContent>
|
|
119
|
+
</Tooltip>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Composition
|
|
123
|
+
|
|
124
|
+
Use the following composition to build a `Tooltip`:
|
|
125
|
+
|
|
126
|
+
```text
|
|
127
|
+
Tooltip
|
|
128
|
+
├── TooltipTrigger
|
|
129
|
+
└── TooltipContent
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Side
|
|
133
|
+
|
|
134
|
+
Use the `side` prop to change the position of the tooltip.
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
import { Button } from '@/components/ui/button'
|
|
138
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
|
139
|
+
|
|
140
|
+
export function TooltipSides() {
|
|
141
|
+
return (
|
|
142
|
+
<div className="flex flex-wrap gap-2">
|
|
143
|
+
{(['left', 'top', 'bottom', 'right'] as const).map(side => (
|
|
144
|
+
<Tooltip key={side}>
|
|
145
|
+
<TooltipTrigger render={<Button variant="outline" className="w-fit capitalize" />}>
|
|
146
|
+
{side}
|
|
147
|
+
</TooltipTrigger>
|
|
148
|
+
<TooltipContent side={side}>
|
|
149
|
+
<p>Add to library</p>
|
|
150
|
+
</TooltipContent>
|
|
151
|
+
</Tooltip>
|
|
152
|
+
))}
|
|
153
|
+
</div>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## With Keyboard Shortcut
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import { IconDeviceFloppy } from '@tabler/icons-react'
|
|
162
|
+
|
|
163
|
+
import { Button } from '@/components/ui/button'
|
|
164
|
+
import { Kbd } from '@/components/ui/kbd'
|
|
165
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
|
166
|
+
|
|
167
|
+
export function TooltipKeyboard() {
|
|
168
|
+
return (
|
|
169
|
+
<Tooltip>
|
|
170
|
+
<TooltipTrigger render={<Button variant="outline" size="icon-sm" />}>
|
|
171
|
+
<IconDeviceFloppy stroke={1.75} />
|
|
172
|
+
</TooltipTrigger>
|
|
173
|
+
<TooltipContent>
|
|
174
|
+
Save Changes <Kbd>S</Kbd>
|
|
175
|
+
</TooltipContent>
|
|
176
|
+
</Tooltip>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Disabled Button
|
|
182
|
+
|
|
183
|
+
Show a tooltip on a disabled button by wrapping it with a span.
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
import { Button } from '@/components/ui/button'
|
|
187
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
|
188
|
+
|
|
189
|
+
export function TooltipDisabled() {
|
|
190
|
+
return (
|
|
191
|
+
<>
|
|
192
|
+
<Tooltip>
|
|
193
|
+
<TooltipTrigger render={<span className="inline-block w-fit" />}>
|
|
194
|
+
<Button variant="outline" disabled>
|
|
195
|
+
Disabled
|
|
196
|
+
</Button>
|
|
197
|
+
</TooltipTrigger>
|
|
198
|
+
<TooltipContent>
|
|
199
|
+
<p>This feature is currently unavailable</p>
|
|
200
|
+
</TooltipContent>
|
|
201
|
+
</Tooltip>
|
|
202
|
+
</>
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## RTL
|
|
208
|
+
|
|
209
|
+
```tsx
|
|
210
|
+
'use client'
|
|
211
|
+
|
|
212
|
+
import { useTranslation, type Translations } from '@/components/language-selector'
|
|
213
|
+
import { Button } from '@/components/ui/button'
|
|
214
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
|
215
|
+
|
|
216
|
+
const translations: Translations = {
|
|
217
|
+
en: {
|
|
218
|
+
dir: 'ltr',
|
|
219
|
+
values: {
|
|
220
|
+
content: 'Add to library',
|
|
221
|
+
'inline-start': 'Inline Start',
|
|
222
|
+
left: 'Left',
|
|
223
|
+
top: 'Top',
|
|
224
|
+
bottom: 'Bottom',
|
|
225
|
+
right: 'Right',
|
|
226
|
+
'inline-end': 'Inline End'
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
ar: {
|
|
230
|
+
dir: 'rtl',
|
|
231
|
+
values: {
|
|
232
|
+
content: 'إضافة إلى المكتبة',
|
|
233
|
+
'inline-start': 'بداية السطر',
|
|
234
|
+
left: 'يسار',
|
|
235
|
+
top: 'أعلى',
|
|
236
|
+
bottom: 'أسفل',
|
|
237
|
+
right: 'يمين',
|
|
238
|
+
'inline-end': 'نهاية السطر'
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
he: {
|
|
242
|
+
dir: 'rtl',
|
|
243
|
+
values: {
|
|
244
|
+
content: 'הוסף לספרייה',
|
|
245
|
+
'inline-start': 'תחילת השורה',
|
|
246
|
+
left: 'שמאל',
|
|
247
|
+
top: 'למעלה',
|
|
248
|
+
bottom: 'למטה',
|
|
249
|
+
right: 'ימין',
|
|
250
|
+
'inline-end': 'סוף השורה'
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const physicalSides = ['left', 'top', 'bottom', 'right'] as const
|
|
256
|
+
const logicalSides = ['inline-start', 'inline-end'] as const
|
|
257
|
+
|
|
258
|
+
export function TooltipRtl() {
|
|
259
|
+
const { dir, t } = useTranslation(translations, 'ar')
|
|
260
|
+
|
|
261
|
+
return (
|
|
262
|
+
<div className="grid gap-4">
|
|
263
|
+
<div className="flex flex-wrap justify-center gap-2">
|
|
264
|
+
{physicalSides.map(side => (
|
|
265
|
+
<Tooltip key={side}>
|
|
266
|
+
<TooltipTrigger render={<Button variant="outline" />}>{t[side]}</TooltipTrigger>
|
|
267
|
+
<TooltipContent side={side} dir={dir}>
|
|
268
|
+
{t.content}
|
|
269
|
+
</TooltipContent>
|
|
270
|
+
</Tooltip>
|
|
271
|
+
))}
|
|
272
|
+
</div>
|
|
273
|
+
<div className="flex flex-wrap justify-center gap-2">
|
|
274
|
+
{logicalSides.map(side => (
|
|
275
|
+
<Tooltip key={side}>
|
|
276
|
+
<TooltipTrigger render={<Button variant="outline" />}>{t[side]}</TooltipTrigger>
|
|
277
|
+
<TooltipContent side={side} dir={dir}>
|
|
278
|
+
{t.content}
|
|
279
|
+
</TooltipContent>
|
|
280
|
+
</Tooltip>
|
|
281
|
+
))}
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## API Reference
|
|
289
|
+
|
|
290
|
+
See the [Base UI Tooltip](https://base-ui.com/react/components/tooltip#api-reference) documentation.
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer'
|
|
5
|
+
import { IconX } from '@tabler/icons-react'
|
|
6
|
+
|
|
7
|
+
import { Button } from './button'
|
|
8
|
+
import { cn } from './utils'
|
|
9
|
+
|
|
10
|
+
type DrawerContextProps = {
|
|
11
|
+
hasSnapPoints: boolean
|
|
12
|
+
modal: DrawerPrimitive.Root.Props['modal']
|
|
13
|
+
swipeDirection: NonNullable<DrawerPrimitive.Root.Props['swipeDirection']>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const DrawerContext = React.createContext<DrawerContextProps | null>(null)
|
|
17
|
+
|
|
18
|
+
function useDrawer() {
|
|
19
|
+
const context = React.useContext(DrawerContext)
|
|
20
|
+
|
|
21
|
+
if (!context) {
|
|
22
|
+
throw new Error('useDrawer must be used within a Drawer.')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return context
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function Drawer({
|
|
29
|
+
modal = 'trap-focus',
|
|
30
|
+
snapPoints,
|
|
31
|
+
swipeDirection = 'right',
|
|
32
|
+
...props
|
|
33
|
+
}: DrawerPrimitive.Root.Props) {
|
|
34
|
+
const hasSnapPoints = snapPoints != null && snapPoints.length > 0
|
|
35
|
+
const contextValue = React.useMemo(
|
|
36
|
+
() => ({ hasSnapPoints, modal, swipeDirection }),
|
|
37
|
+
[hasSnapPoints, modal, swipeDirection]
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<DrawerContext.Provider value={contextValue}>
|
|
42
|
+
<DrawerPrimitive.Root
|
|
43
|
+
data-slot="drawer"
|
|
44
|
+
modal={modal}
|
|
45
|
+
snapPoints={snapPoints}
|
|
46
|
+
swipeDirection={swipeDirection}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
</DrawerContext.Provider>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function DrawerTrigger({ ...props }: DrawerPrimitive.Trigger.Props) {
|
|
54
|
+
return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function DrawerClose({ ...props }: DrawerPrimitive.Close.Props) {
|
|
58
|
+
return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type DrawerContentProps = DrawerPrimitive.Popup.Props & {
|
|
62
|
+
showCloseButton?: boolean
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function DrawerContent({
|
|
66
|
+
className,
|
|
67
|
+
children,
|
|
68
|
+
showCloseButton = true,
|
|
69
|
+
...props
|
|
70
|
+
}: DrawerContentProps) {
|
|
71
|
+
const { hasSnapPoints, modal, swipeDirection } = useDrawer()
|
|
72
|
+
const [container, setContainer] = React.useState<HTMLElement | null>(null)
|
|
73
|
+
const markerRef = React.useCallback((node: HTMLElement | null) => {
|
|
74
|
+
if (node) setContainer(node.closest<HTMLElement>('[data-applet]'))
|
|
75
|
+
}, [])
|
|
76
|
+
const swipeAxis = swipeDirection === 'down' || swipeDirection === 'up' ? 'y' : 'x'
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
<span hidden ref={markerRef} />
|
|
81
|
+
<DrawerPrimitive.Portal data-slot="drawer-portal" container={container}>
|
|
82
|
+
{modal === true && (
|
|
83
|
+
<DrawerPrimitive.Backdrop
|
|
84
|
+
data-slot="drawer-overlay"
|
|
85
|
+
data-snap-points={hasSnapPoints ? '' : undefined}
|
|
86
|
+
className="absolute inset-0 z-50 min-h-full bg-black/10 opacity-[max(var(--drawer-overlay-min-opacity,0),calc(1-var(--drawer-swipe-progress)))] transition-opacity duration-450 ease-[cubic-bezier(0.32,0.72,0,1)] select-none data-ending-style:pointer-events-none data-ending-style:opacity-0 data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-snap-points:[--drawer-overlay-min-opacity:0.5] data-starting-style:opacity-0 data-swiping:duration-0"
|
|
87
|
+
/>
|
|
88
|
+
)}
|
|
89
|
+
<DrawerPrimitive.Viewport
|
|
90
|
+
data-slot="drawer-viewport"
|
|
91
|
+
data-modal={modal}
|
|
92
|
+
className="pointer-events-none absolute inset-0 z-50 select-none data-[modal=true]:pointer-events-auto"
|
|
93
|
+
>
|
|
94
|
+
<DrawerPrimitive.Popup
|
|
95
|
+
data-slot="drawer-popup"
|
|
96
|
+
data-swipe-axis={swipeAxis}
|
|
97
|
+
data-snap-points={hasSnapPoints ? '' : undefined}
|
|
98
|
+
className={cn(
|
|
99
|
+
// Base.
|
|
100
|
+
'group/drawer-popup pointer-events-auto absolute z-50 m-(--drawer-inset,0.5rem) flex h-(--drawer-content-height) max-h-(--drawer-content-max-height,none) min-h-0 w-(--drawer-content-width,auto) transform-[translate3d(var(--translate-x,0px),var(--translate-y,0px),0)_scale(var(--stack-scale))] flex-col rounded-lg bg-popover text-sm text-popover-foreground shadow-xl transition-[transform,height,opacity,filter] duration-450 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform outline-none select-none [interpolate-size:allow-keywords]',
|
|
101
|
+
// Nested.
|
|
102
|
+
'data-nested-drawer-open:overflow-hidden data-nested-drawer-open:brightness-95',
|
|
103
|
+
// Sizing.
|
|
104
|
+
'[--drawer-content-height:var(--drawer-height,auto)] data-[swipe-axis=x]:[--drawer-content-width:75%] data-[swipe-axis=y]:[--drawer-content-max-height:calc(100%-6rem)] data-[swipe-axis=y]:data-snap-points:[--drawer-content-height:100%] data-[swipe-axis=x]:sm:[--drawer-content-width:24rem]',
|
|
105
|
+
// Stack.
|
|
106
|
+
'[--peek:1rem] [--stack-height:var(--drawer-frontmost-height,var(--drawer-height,0px))] [--stack-peek-offset:max(0px,calc((var(--nested-drawers)-var(--stack-progress))*var(--peek)))] [--stack-progress:clamp(0,var(--drawer-swipe-progress),1)] [--stack-scale-base:max(0,calc(1-(var(--nested-drawers)*var(--stack-step))))] [--stack-scale:clamp(0,calc(var(--stack-scale-base)+(var(--stack-step)*var(--stack-progress))),1)] [--stack-shrink:calc(1-var(--stack-scale))] [--stack-step:0.05]',
|
|
107
|
+
// Transitions.
|
|
108
|
+
'data-ending-style:transform-(--closed-transform) data-ending-style:opacity-[0.9999] data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-nested-drawer-swiping:duration-0 data-ending-style:data-nested-drawer-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-starting-style:transform-(--closed-transform) data-swiping:duration-0 data-ending-style:data-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)]',
|
|
109
|
+
// Axis: y.
|
|
110
|
+
'data-[swipe-axis=y]:inset-x-0 data-[swipe-axis=y]:data-nested-drawer-open:h-(--stack-height)',
|
|
111
|
+
// Axis: x.
|
|
112
|
+
'data-[swipe-axis=x]:inset-y-0 data-[swipe-axis=x]:flex-row',
|
|
113
|
+
// Direction: down.
|
|
114
|
+
'data-[swipe-direction=down]:bottom-0 data-[swipe-direction=down]:origin-bottom data-[swipe-direction=down]:[--closed-transform:translate3d(0,calc(100%+var(--drawer-inset,0.5rem)+2px),0)] data-[swipe-direction=down]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)-var(--stack-peek-offset)-(var(--stack-shrink)*var(--stack-height)))]',
|
|
115
|
+
// Direction: up.
|
|
116
|
+
'data-[swipe-direction=up]:top-0 data-[swipe-direction=up]:origin-top data-[swipe-direction=up]:[--closed-transform:translate3d(0,calc(-100%-var(--drawer-inset,0.5rem)-2px),0)] data-[swipe-direction=up]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)+var(--stack-peek-offset)+(var(--stack-shrink)*var(--stack-height)))]',
|
|
117
|
+
// Direction: left.
|
|
118
|
+
'data-[swipe-direction=left]:left-0 data-[swipe-direction=left]:origin-left data-[swipe-direction=left]:[--closed-transform:translate3d(calc(-100%-var(--drawer-inset,0.5rem)-2px),0,0)] data-[swipe-direction=left]:[--translate-x:calc(var(--drawer-swipe-movement-x)+var(--stack-peek-offset)+(var(--stack-shrink)*100%))]',
|
|
119
|
+
// Direction: right.
|
|
120
|
+
'data-[swipe-direction=right]:right-0 data-[swipe-direction=right]:origin-right data-[swipe-direction=right]:[--closed-transform:translate3d(calc(100%+var(--drawer-inset,0.5rem)+2px),0,0)] data-[swipe-direction=right]:[--translate-x:calc(var(--drawer-swipe-movement-x)-var(--stack-peek-offset)-(var(--stack-shrink)*100%))]',
|
|
121
|
+
className
|
|
122
|
+
)}
|
|
123
|
+
{...props}
|
|
124
|
+
>
|
|
125
|
+
<DrawerPrimitive.Content
|
|
126
|
+
data-slot="drawer-content"
|
|
127
|
+
className={cn(
|
|
128
|
+
'flex min-h-0 flex-1 flex-col overflow-hidden overscroll-contain rounded-[inherit] transition-opacity duration-300 ease-[cubic-bezier(0.45,1.005,0,1.005)] select-text group-data-nested-drawer-open/drawer-popup:opacity-0 group-data-nested-drawer-swiping/drawer-popup:opacity-100 group-data-swiping/drawer-popup:select-none'
|
|
129
|
+
)}
|
|
130
|
+
>
|
|
131
|
+
{children}
|
|
132
|
+
{showCloseButton && (
|
|
133
|
+
<DrawerClose
|
|
134
|
+
render={
|
|
135
|
+
<Button variant="ghost" size="icon-sm" className="absolute top-3 right-3" />
|
|
136
|
+
}
|
|
137
|
+
>
|
|
138
|
+
<IconX stroke={1.75} />
|
|
139
|
+
<span className="sr-only">Close</span>
|
|
140
|
+
</DrawerClose>
|
|
141
|
+
)}
|
|
142
|
+
</DrawerPrimitive.Content>
|
|
143
|
+
</DrawerPrimitive.Popup>
|
|
144
|
+
</DrawerPrimitive.Viewport>
|
|
145
|
+
</DrawerPrimitive.Portal>
|
|
146
|
+
</>
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function DrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
151
|
+
return (
|
|
152
|
+
<div
|
|
153
|
+
data-slot="drawer-header"
|
|
154
|
+
className={cn(
|
|
155
|
+
'flex shrink-0 flex-col gap-0.5 p-4 pr-12 pb-0 group-data-[swipe-axis=y]/drawer-popup:text-center md:gap-0.5 md:text-left',
|
|
156
|
+
className
|
|
157
|
+
)}
|
|
158
|
+
{...props}
|
|
159
|
+
/>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function DrawerBody({ className, ...props }: React.ComponentProps<'div'>) {
|
|
164
|
+
return (
|
|
165
|
+
<div
|
|
166
|
+
data-slot="drawer-body"
|
|
167
|
+
className={cn('min-h-0 flex-1 overflow-y-auto overscroll-contain p-4', className)}
|
|
168
|
+
{...props}
|
|
169
|
+
/>
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function DrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
|
174
|
+
return (
|
|
175
|
+
<div
|
|
176
|
+
data-slot="drawer-footer"
|
|
177
|
+
className={cn('mt-auto flex shrink-0 flex-col gap-2 p-4 pt-0', className)}
|
|
178
|
+
{...props}
|
|
179
|
+
/>
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function DrawerTitle({ className, ...props }: DrawerPrimitive.Title.Props) {
|
|
184
|
+
return (
|
|
185
|
+
<DrawerPrimitive.Title
|
|
186
|
+
data-slot="drawer-title"
|
|
187
|
+
className={cn('text-base font-medium', className)}
|
|
188
|
+
{...props}
|
|
189
|
+
/>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function DrawerDescription({ className, ...props }: DrawerPrimitive.Description.Props) {
|
|
194
|
+
return (
|
|
195
|
+
<DrawerPrimitive.Description
|
|
196
|
+
data-slot="drawer-description"
|
|
197
|
+
className={cn('text-sm text-muted-foreground', className)}
|
|
198
|
+
{...props}
|
|
199
|
+
/>
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export {
|
|
204
|
+
Drawer,
|
|
205
|
+
DrawerBody,
|
|
206
|
+
DrawerClose,
|
|
207
|
+
DrawerContent,
|
|
208
|
+
DrawerDescription,
|
|
209
|
+
DrawerFooter,
|
|
210
|
+
DrawerHeader,
|
|
211
|
+
DrawerTitle,
|
|
212
|
+
DrawerTrigger
|
|
213
|
+
}
|