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,616 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Select
|
|
3
|
+
description: Displays a list of options for the user to pick from—triggered by a button.
|
|
4
|
+
base: base
|
|
5
|
+
component: true
|
|
6
|
+
featured: true
|
|
7
|
+
links:
|
|
8
|
+
doc: https://base-ui.com/react/components/select
|
|
9
|
+
api: https://base-ui.com/react/components/select#api-reference
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import {
|
|
14
|
+
Select,
|
|
15
|
+
SelectContent,
|
|
16
|
+
SelectGroup,
|
|
17
|
+
SelectItem,
|
|
18
|
+
SelectLabel,
|
|
19
|
+
SelectTrigger,
|
|
20
|
+
SelectValue
|
|
21
|
+
} from '@/components/ui/select'
|
|
22
|
+
|
|
23
|
+
const items = [
|
|
24
|
+
{ label: 'Select a fruit', value: null },
|
|
25
|
+
{ label: 'Apple', value: 'apple' },
|
|
26
|
+
{ label: 'Banana', value: 'banana' },
|
|
27
|
+
{ label: 'Blueberry', value: 'blueberry' },
|
|
28
|
+
{ label: 'Grapes', value: 'grapes' },
|
|
29
|
+
{ label: 'Pineapple', value: 'pineapple' }
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
export function SelectDemo() {
|
|
33
|
+
return (
|
|
34
|
+
<Select items={items}>
|
|
35
|
+
<SelectTrigger className="w-full max-w-48">
|
|
36
|
+
<SelectValue />
|
|
37
|
+
</SelectTrigger>
|
|
38
|
+
<SelectContent>
|
|
39
|
+
<SelectGroup>
|
|
40
|
+
<SelectLabel>Fruits</SelectLabel>
|
|
41
|
+
{items.map(item => (
|
|
42
|
+
<SelectItem key={item.value} value={item.value}>
|
|
43
|
+
{item.label}
|
|
44
|
+
</SelectItem>
|
|
45
|
+
))}
|
|
46
|
+
</SelectGroup>
|
|
47
|
+
</SelectContent>
|
|
48
|
+
</Select>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
<CodeTabs>
|
|
56
|
+
|
|
57
|
+
<TabsList>
|
|
58
|
+
<TabsTrigger value="cli">Command</TabsTrigger>
|
|
59
|
+
<TabsTrigger value="manual">Manual</TabsTrigger>
|
|
60
|
+
</TabsList>
|
|
61
|
+
<TabsContent value="cli">
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
moi ui-components add select
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
</TabsContent>
|
|
68
|
+
|
|
69
|
+
<TabsContent value="manual">
|
|
70
|
+
|
|
71
|
+
<Steps className="mb-0 pt-2">
|
|
72
|
+
|
|
73
|
+
<Step>Install the following dependencies:</Step>
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm install @base-ui/react
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
<Step>Copy and paste the following code into your project.</Step>
|
|
80
|
+
|
|
81
|
+
<ComponentSource
|
|
82
|
+
name="select"
|
|
83
|
+
title="components/ui/select.tsx"
|
|
84
|
+
styleName="base-nova"
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<Step>Update the import paths to match your project setup.</Step>
|
|
88
|
+
|
|
89
|
+
</Steps>
|
|
90
|
+
|
|
91
|
+
</TabsContent>
|
|
92
|
+
|
|
93
|
+
</CodeTabs>
|
|
94
|
+
|
|
95
|
+
## Usage
|
|
96
|
+
|
|
97
|
+
```tsx showLineNumbers
|
|
98
|
+
import {
|
|
99
|
+
Select,
|
|
100
|
+
SelectContent,
|
|
101
|
+
SelectGroup,
|
|
102
|
+
SelectItem,
|
|
103
|
+
SelectTrigger,
|
|
104
|
+
SelectValue
|
|
105
|
+
} from '@/components/ui/select'
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```tsx showLineNumbers
|
|
109
|
+
const items = [
|
|
110
|
+
{ label: "Light", value: "light" },
|
|
111
|
+
{ label: "Dark", value: "dark" },
|
|
112
|
+
{ label: "System", value: "system" },
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
<Select items={items}>
|
|
116
|
+
<SelectTrigger className="w-[180px]">
|
|
117
|
+
<SelectValue placeholder="Theme" />
|
|
118
|
+
</SelectTrigger>
|
|
119
|
+
<SelectContent>
|
|
120
|
+
<SelectGroup>
|
|
121
|
+
{items.map((item) => (
|
|
122
|
+
<SelectItem key={item.value} value={item.value}>
|
|
123
|
+
{item.label}
|
|
124
|
+
</SelectItem>
|
|
125
|
+
))}
|
|
126
|
+
</SelectGroup>
|
|
127
|
+
</SelectContent>
|
|
128
|
+
</Select>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Composition
|
|
132
|
+
|
|
133
|
+
Use the following composition to build a `Select`:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
Select
|
|
137
|
+
├── SelectTrigger
|
|
138
|
+
│ └── SelectValue
|
|
139
|
+
└── SelectContent
|
|
140
|
+
├── SelectGroup
|
|
141
|
+
│ ├── SelectLabel
|
|
142
|
+
│ ├── SelectItem
|
|
143
|
+
│ └── SelectItem
|
|
144
|
+
├── SelectSeparator
|
|
145
|
+
└── SelectGroup
|
|
146
|
+
├── SelectLabel
|
|
147
|
+
├── SelectItem
|
|
148
|
+
└── SelectItem
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Align Item With Trigger
|
|
152
|
+
|
|
153
|
+
Use `alignItemWithTrigger` on `SelectContent` to control whether the selected item aligns with the trigger. When `true` (default), the popup positions so the selected item appears over the trigger. When `false`, the popup aligns to the trigger edge.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
'use client'
|
|
157
|
+
|
|
158
|
+
import * as React from 'react'
|
|
159
|
+
|
|
160
|
+
import {
|
|
161
|
+
Field,
|
|
162
|
+
FieldContent,
|
|
163
|
+
FieldDescription,
|
|
164
|
+
FieldGroup,
|
|
165
|
+
FieldLabel
|
|
166
|
+
} from '@/components/ui/field'
|
|
167
|
+
import { Label } from '@/components/ui/label'
|
|
168
|
+
import {
|
|
169
|
+
Select,
|
|
170
|
+
SelectContent,
|
|
171
|
+
SelectGroup,
|
|
172
|
+
SelectItem,
|
|
173
|
+
SelectTrigger,
|
|
174
|
+
SelectValue
|
|
175
|
+
} from '@/components/ui/select'
|
|
176
|
+
import { Switch } from '@/components/ui/switch'
|
|
177
|
+
|
|
178
|
+
const items = [
|
|
179
|
+
{ label: 'Select a fruit', value: null },
|
|
180
|
+
{ label: 'Apple', value: 'apple' },
|
|
181
|
+
{ label: 'Banana', value: 'banana' },
|
|
182
|
+
{ label: 'Blueberry', value: 'blueberry' },
|
|
183
|
+
{ label: 'Grapes', value: 'grapes' },
|
|
184
|
+
{ label: 'Pineapple', value: 'pineapple' }
|
|
185
|
+
]
|
|
186
|
+
|
|
187
|
+
export function SelectAlignItem() {
|
|
188
|
+
const [alignItemWithTrigger, setAlignItemWithTrigger] = React.useState(true)
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<FieldGroup className="w-full max-w-xs">
|
|
192
|
+
<Field orientation="horizontal">
|
|
193
|
+
<FieldContent>
|
|
194
|
+
<FieldLabel htmlFor="align-item">Align Item</FieldLabel>
|
|
195
|
+
<FieldDescription>Toggle to align the item with the trigger.</FieldDescription>
|
|
196
|
+
</FieldContent>
|
|
197
|
+
<Switch
|
|
198
|
+
id="align-item"
|
|
199
|
+
checked={alignItemWithTrigger}
|
|
200
|
+
onCheckedChange={setAlignItemWithTrigger}
|
|
201
|
+
/>
|
|
202
|
+
</Field>
|
|
203
|
+
<Field>
|
|
204
|
+
<Select items={items} defaultValue="banana">
|
|
205
|
+
<SelectTrigger>
|
|
206
|
+
<SelectValue />
|
|
207
|
+
</SelectTrigger>
|
|
208
|
+
<SelectContent alignItemWithTrigger={alignItemWithTrigger}>
|
|
209
|
+
<SelectGroup>
|
|
210
|
+
{items.map(item => (
|
|
211
|
+
<SelectItem key={item.value} value={item.value}>
|
|
212
|
+
{item.label}
|
|
213
|
+
</SelectItem>
|
|
214
|
+
))}
|
|
215
|
+
</SelectGroup>
|
|
216
|
+
</SelectContent>
|
|
217
|
+
</Select>
|
|
218
|
+
</Field>
|
|
219
|
+
</FieldGroup>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Groups
|
|
225
|
+
|
|
226
|
+
Use `SelectGroup`, `SelectLabel`, and `SelectSeparator` to organize items.
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
import {
|
|
230
|
+
Select,
|
|
231
|
+
SelectContent,
|
|
232
|
+
SelectGroup,
|
|
233
|
+
SelectItem,
|
|
234
|
+
SelectLabel,
|
|
235
|
+
SelectSeparator,
|
|
236
|
+
SelectTrigger,
|
|
237
|
+
SelectValue
|
|
238
|
+
} from '@/components/ui/select'
|
|
239
|
+
|
|
240
|
+
export function SelectGroups() {
|
|
241
|
+
const fruits = [
|
|
242
|
+
{ label: 'Apple', value: 'apple' },
|
|
243
|
+
{ label: 'Banana', value: 'banana' },
|
|
244
|
+
{ label: 'Blueberry', value: 'blueberry' }
|
|
245
|
+
]
|
|
246
|
+
const vegetables = [
|
|
247
|
+
{ label: 'Carrot', value: 'carrot' },
|
|
248
|
+
{ label: 'Broccoli', value: 'broccoli' },
|
|
249
|
+
{ label: 'Spinach', value: 'spinach' }
|
|
250
|
+
]
|
|
251
|
+
const allItems = [{ label: 'Select a fruit', value: null }, ...fruits, ...vegetables]
|
|
252
|
+
return (
|
|
253
|
+
<Select items={allItems}>
|
|
254
|
+
<SelectTrigger className="w-full max-w-48">
|
|
255
|
+
<SelectValue />
|
|
256
|
+
</SelectTrigger>
|
|
257
|
+
<SelectContent>
|
|
258
|
+
<SelectGroup>
|
|
259
|
+
<SelectLabel>Fruits</SelectLabel>
|
|
260
|
+
{fruits.map(item => (
|
|
261
|
+
<SelectItem key={item.value} value={item.value}>
|
|
262
|
+
{item.label}
|
|
263
|
+
</SelectItem>
|
|
264
|
+
))}
|
|
265
|
+
</SelectGroup>
|
|
266
|
+
<SelectSeparator />
|
|
267
|
+
<SelectGroup>
|
|
268
|
+
<SelectLabel>Vegetables</SelectLabel>
|
|
269
|
+
{vegetables.map(item => (
|
|
270
|
+
<SelectItem key={item.value} value={item.value}>
|
|
271
|
+
{item.label}
|
|
272
|
+
</SelectItem>
|
|
273
|
+
))}
|
|
274
|
+
</SelectGroup>
|
|
275
|
+
</SelectContent>
|
|
276
|
+
</Select>
|
|
277
|
+
)
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Scrollable
|
|
282
|
+
|
|
283
|
+
A select with many items that scrolls.
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import {
|
|
287
|
+
Select,
|
|
288
|
+
SelectContent,
|
|
289
|
+
SelectGroup,
|
|
290
|
+
SelectItem,
|
|
291
|
+
SelectLabel,
|
|
292
|
+
SelectTrigger,
|
|
293
|
+
SelectValue
|
|
294
|
+
} from '@/components/ui/select'
|
|
295
|
+
|
|
296
|
+
const northAmerica = [
|
|
297
|
+
{ label: 'Eastern Standard Time', value: 'est' },
|
|
298
|
+
{ label: 'Central Standard Time', value: 'cst' },
|
|
299
|
+
{ label: 'Mountain Standard Time', value: 'mst' },
|
|
300
|
+
{ label: 'Pacific Standard Time', value: 'pst' },
|
|
301
|
+
{ label: 'Alaska Standard Time', value: 'akst' },
|
|
302
|
+
{ label: 'Hawaii Standard Time', value: 'hst' }
|
|
303
|
+
]
|
|
304
|
+
|
|
305
|
+
const europeAfrica = [
|
|
306
|
+
{ label: 'Greenwich Mean Time', value: 'gmt' },
|
|
307
|
+
{ label: 'Central European Time', value: 'cet' },
|
|
308
|
+
{ label: 'Eastern European Time', value: 'eet' },
|
|
309
|
+
{ label: 'Western European Summer Time', value: 'west' },
|
|
310
|
+
{ label: 'Central Africa Time', value: 'cat' },
|
|
311
|
+
{ label: 'East Africa Time', value: 'eat' }
|
|
312
|
+
]
|
|
313
|
+
|
|
314
|
+
const asia = [
|
|
315
|
+
{ label: 'Moscow Time', value: 'msk' },
|
|
316
|
+
{ label: 'India Standard Time', value: 'ist' },
|
|
317
|
+
{ label: 'China Standard Time', value: 'cst_china' },
|
|
318
|
+
{ label: 'Japan Standard Time', value: 'jst' },
|
|
319
|
+
{ label: 'Korea Standard Time', value: 'kst' },
|
|
320
|
+
{ label: 'Indonesia Central Standard Time', value: 'ist_indonesia' }
|
|
321
|
+
]
|
|
322
|
+
|
|
323
|
+
const australiaPacific = [
|
|
324
|
+
{ label: 'Australian Western Standard Time', value: 'awst' },
|
|
325
|
+
{ label: 'Australian Central Standard Time', value: 'acst' },
|
|
326
|
+
{ label: 'Australian Eastern Standard Time', value: 'aest' },
|
|
327
|
+
{ label: 'New Zealand Standard Time', value: 'nzst' },
|
|
328
|
+
{ label: 'Fiji Time', value: 'fjt' }
|
|
329
|
+
]
|
|
330
|
+
|
|
331
|
+
const southAmerica = [
|
|
332
|
+
{ label: 'Argentina Time', value: 'art' },
|
|
333
|
+
{ label: 'Bolivia Time', value: 'bot' },
|
|
334
|
+
{ label: 'Brasilia Time', value: 'brt' },
|
|
335
|
+
{ label: 'Chile Standard Time', value: 'clt' }
|
|
336
|
+
]
|
|
337
|
+
|
|
338
|
+
const items = [
|
|
339
|
+
{ label: 'Select a timezone', value: null },
|
|
340
|
+
...northAmerica,
|
|
341
|
+
...europeAfrica,
|
|
342
|
+
...asia,
|
|
343
|
+
...australiaPacific,
|
|
344
|
+
...southAmerica
|
|
345
|
+
]
|
|
346
|
+
|
|
347
|
+
export function SelectScrollable() {
|
|
348
|
+
return (
|
|
349
|
+
<Select items={items}>
|
|
350
|
+
<SelectTrigger className="w-full max-w-64">
|
|
351
|
+
<SelectValue />
|
|
352
|
+
</SelectTrigger>
|
|
353
|
+
<SelectContent>
|
|
354
|
+
<SelectGroup>
|
|
355
|
+
<SelectLabel>North America</SelectLabel>
|
|
356
|
+
{northAmerica.map(item => (
|
|
357
|
+
<SelectItem key={item.value} value={item.value}>
|
|
358
|
+
{item.label}
|
|
359
|
+
</SelectItem>
|
|
360
|
+
))}
|
|
361
|
+
</SelectGroup>
|
|
362
|
+
<SelectGroup>
|
|
363
|
+
<SelectLabel>Europe & Africa</SelectLabel>
|
|
364
|
+
{europeAfrica.map(item => (
|
|
365
|
+
<SelectItem key={item.value} value={item.value}>
|
|
366
|
+
{item.label}
|
|
367
|
+
</SelectItem>
|
|
368
|
+
))}
|
|
369
|
+
</SelectGroup>
|
|
370
|
+
<SelectGroup>
|
|
371
|
+
<SelectLabel>Asia</SelectLabel>
|
|
372
|
+
{asia.map(item => (
|
|
373
|
+
<SelectItem key={item.value} value={item.value}>
|
|
374
|
+
{item.label}
|
|
375
|
+
</SelectItem>
|
|
376
|
+
))}
|
|
377
|
+
</SelectGroup>
|
|
378
|
+
<SelectGroup>
|
|
379
|
+
<SelectLabel>Australia & Pacific</SelectLabel>
|
|
380
|
+
{australiaPacific.map(item => (
|
|
381
|
+
<SelectItem key={item.value} value={item.value}>
|
|
382
|
+
{item.label}
|
|
383
|
+
</SelectItem>
|
|
384
|
+
))}
|
|
385
|
+
</SelectGroup>
|
|
386
|
+
<SelectGroup>
|
|
387
|
+
<SelectLabel>South America</SelectLabel>
|
|
388
|
+
{southAmerica.map(item => (
|
|
389
|
+
<SelectItem key={item.value} value={item.value}>
|
|
390
|
+
{item.label}
|
|
391
|
+
</SelectItem>
|
|
392
|
+
))}
|
|
393
|
+
</SelectGroup>
|
|
394
|
+
</SelectContent>
|
|
395
|
+
</Select>
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## Disabled
|
|
401
|
+
|
|
402
|
+
```tsx
|
|
403
|
+
import {
|
|
404
|
+
Select,
|
|
405
|
+
SelectContent,
|
|
406
|
+
SelectGroup,
|
|
407
|
+
SelectItem,
|
|
408
|
+
SelectTrigger,
|
|
409
|
+
SelectValue
|
|
410
|
+
} from '@/components/ui/select'
|
|
411
|
+
|
|
412
|
+
export function SelectDisabled() {
|
|
413
|
+
const items = [
|
|
414
|
+
{ label: 'Select a fruit', value: null },
|
|
415
|
+
{ label: 'Apple', value: 'apple' },
|
|
416
|
+
{ label: 'Banana', value: 'banana' },
|
|
417
|
+
{ label: 'Blueberry', value: 'blueberry' },
|
|
418
|
+
{ label: 'Grapes', value: 'grapes', disabled: true },
|
|
419
|
+
{ label: 'Pineapple', value: 'pineapple' }
|
|
420
|
+
]
|
|
421
|
+
return (
|
|
422
|
+
<Select items={items} disabled>
|
|
423
|
+
<SelectTrigger className="w-full max-w-48">
|
|
424
|
+
<SelectValue />
|
|
425
|
+
</SelectTrigger>
|
|
426
|
+
<SelectContent>
|
|
427
|
+
<SelectGroup>
|
|
428
|
+
{items.map(item => (
|
|
429
|
+
<SelectItem key={item.value} value={item.value} disabled={item.disabled}>
|
|
430
|
+
{item.label}
|
|
431
|
+
</SelectItem>
|
|
432
|
+
))}
|
|
433
|
+
</SelectGroup>
|
|
434
|
+
</SelectContent>
|
|
435
|
+
</Select>
|
|
436
|
+
)
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## Invalid
|
|
441
|
+
|
|
442
|
+
Add the `data-invalid` attribute to the `Field` component and the `aria-invalid` attribute to the `SelectTrigger` component to show an error state.
|
|
443
|
+
|
|
444
|
+
```tsx showLineNumbers /data-invalid/ /aria-invalid/
|
|
445
|
+
<Field data-invalid>
|
|
446
|
+
<FieldLabel>Fruit</FieldLabel>
|
|
447
|
+
<SelectTrigger aria-invalid>
|
|
448
|
+
<SelectValue />
|
|
449
|
+
</SelectTrigger>
|
|
450
|
+
</Field>
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
```tsx
|
|
454
|
+
import { Field, FieldError, FieldLabel } from '@/components/ui/field'
|
|
455
|
+
import {
|
|
456
|
+
Select,
|
|
457
|
+
SelectContent,
|
|
458
|
+
SelectGroup,
|
|
459
|
+
SelectItem,
|
|
460
|
+
SelectTrigger,
|
|
461
|
+
SelectValue
|
|
462
|
+
} from '@/components/ui/select'
|
|
463
|
+
|
|
464
|
+
const items = [
|
|
465
|
+
{ label: 'Select a fruit', value: null },
|
|
466
|
+
{ label: 'Apple', value: 'apple' },
|
|
467
|
+
{ label: 'Banana', value: 'banana' },
|
|
468
|
+
{ label: 'Blueberry', value: 'blueberry' }
|
|
469
|
+
]
|
|
470
|
+
|
|
471
|
+
export function SelectInvalid() {
|
|
472
|
+
return (
|
|
473
|
+
<Field data-invalid className="w-full max-w-48">
|
|
474
|
+
<FieldLabel>Fruit</FieldLabel>
|
|
475
|
+
<Select items={items}>
|
|
476
|
+
<SelectTrigger aria-invalid>
|
|
477
|
+
<SelectValue />
|
|
478
|
+
</SelectTrigger>
|
|
479
|
+
<SelectContent>
|
|
480
|
+
<SelectGroup>
|
|
481
|
+
{items.map(item => (
|
|
482
|
+
<SelectItem key={item.value} value={item.value}>
|
|
483
|
+
{item.label}
|
|
484
|
+
</SelectItem>
|
|
485
|
+
))}
|
|
486
|
+
</SelectGroup>
|
|
487
|
+
</SelectContent>
|
|
488
|
+
</Select>
|
|
489
|
+
<FieldError>Please select a fruit.</FieldError>
|
|
490
|
+
</Field>
|
|
491
|
+
)
|
|
492
|
+
}
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
## RTL
|
|
496
|
+
|
|
497
|
+
```tsx
|
|
498
|
+
'use client'
|
|
499
|
+
|
|
500
|
+
import * as React from 'react'
|
|
501
|
+
|
|
502
|
+
import { useTranslation, type Language, type Translations } from '@/components/language-selector'
|
|
503
|
+
import {
|
|
504
|
+
Select,
|
|
505
|
+
SelectContent,
|
|
506
|
+
SelectGroup,
|
|
507
|
+
SelectItem,
|
|
508
|
+
SelectLabel,
|
|
509
|
+
SelectSeparator,
|
|
510
|
+
SelectTrigger,
|
|
511
|
+
SelectValue
|
|
512
|
+
} from '@/components/ui/select'
|
|
513
|
+
|
|
514
|
+
const translations: Translations = {
|
|
515
|
+
en: {
|
|
516
|
+
dir: 'ltr',
|
|
517
|
+
values: {
|
|
518
|
+
selectFruit: 'Select a fruit',
|
|
519
|
+
fruits: 'Fruits',
|
|
520
|
+
apple: 'Apple',
|
|
521
|
+
banana: 'Banana',
|
|
522
|
+
blueberry: 'Blueberry',
|
|
523
|
+
grapes: 'Grapes',
|
|
524
|
+
pineapple: 'Pineapple',
|
|
525
|
+
vegetables: 'Vegetables',
|
|
526
|
+
carrot: 'Carrot',
|
|
527
|
+
broccoli: 'Broccoli',
|
|
528
|
+
spinach: 'Spinach'
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
ar: {
|
|
532
|
+
dir: 'rtl',
|
|
533
|
+
values: {
|
|
534
|
+
selectFruit: 'اختر فاكهة',
|
|
535
|
+
fruits: 'الفواكه',
|
|
536
|
+
apple: 'تفاح',
|
|
537
|
+
banana: 'موز',
|
|
538
|
+
blueberry: 'توت أزرق',
|
|
539
|
+
grapes: 'عنب',
|
|
540
|
+
pineapple: 'أناناس',
|
|
541
|
+
vegetables: 'الخضروات',
|
|
542
|
+
carrot: 'جزر',
|
|
543
|
+
broccoli: 'بروكلي',
|
|
544
|
+
spinach: 'سبانخ'
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
he: {
|
|
548
|
+
dir: 'rtl',
|
|
549
|
+
values: {
|
|
550
|
+
selectFruit: 'בחר פרי',
|
|
551
|
+
fruits: 'פירות',
|
|
552
|
+
apple: 'תפוח',
|
|
553
|
+
banana: 'בננה',
|
|
554
|
+
blueberry: 'אוכמניה',
|
|
555
|
+
grapes: 'ענבים',
|
|
556
|
+
pineapple: 'אננס',
|
|
557
|
+
vegetables: 'ירקות',
|
|
558
|
+
carrot: 'גזר',
|
|
559
|
+
broccoli: 'ברוקולי',
|
|
560
|
+
spinach: 'תרד'
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export function SelectRtl() {
|
|
566
|
+
const { dir, t, language } = useTranslation(translations, 'ar')
|
|
567
|
+
const [selectedFruit, setSelectedFruit] = React.useState<string | null>(null)
|
|
568
|
+
|
|
569
|
+
const fruits = [
|
|
570
|
+
{ label: t.apple, value: 'apple' },
|
|
571
|
+
{ label: t.banana, value: 'banana' },
|
|
572
|
+
{ label: t.blueberry, value: 'blueberry' },
|
|
573
|
+
{ label: t.grapes, value: 'grapes' },
|
|
574
|
+
{ label: t.pineapple, value: 'pineapple' }
|
|
575
|
+
]
|
|
576
|
+
|
|
577
|
+
const vegetables = [
|
|
578
|
+
{ label: t.carrot, value: 'carrot' },
|
|
579
|
+
{ label: t.broccoli, value: 'broccoli' },
|
|
580
|
+
{ label: t.spinach, value: 'spinach' }
|
|
581
|
+
]
|
|
582
|
+
|
|
583
|
+
const allItems = [{ label: t.selectFruit, value: null }, ...fruits, ...vegetables]
|
|
584
|
+
|
|
585
|
+
return (
|
|
586
|
+
<Select items={allItems} value={selectedFruit} onValueChange={setSelectedFruit}>
|
|
587
|
+
<SelectTrigger className="w-32" dir={dir}>
|
|
588
|
+
<SelectValue />
|
|
589
|
+
</SelectTrigger>
|
|
590
|
+
<SelectContent dir={dir} data-lang={dir === 'rtl' ? language : undefined}>
|
|
591
|
+
<SelectGroup>
|
|
592
|
+
<SelectLabel>{t.fruits}</SelectLabel>
|
|
593
|
+
{fruits.map(item => (
|
|
594
|
+
<SelectItem key={item.value} value={item.value}>
|
|
595
|
+
{item.label}
|
|
596
|
+
</SelectItem>
|
|
597
|
+
))}
|
|
598
|
+
</SelectGroup>
|
|
599
|
+
<SelectSeparator />
|
|
600
|
+
<SelectGroup>
|
|
601
|
+
<SelectLabel>{t.vegetables}</SelectLabel>
|
|
602
|
+
{vegetables.map(item => (
|
|
603
|
+
<SelectItem key={item.value} value={item.value}>
|
|
604
|
+
{item.label}
|
|
605
|
+
</SelectItem>
|
|
606
|
+
))}
|
|
607
|
+
</SelectGroup>
|
|
608
|
+
</SelectContent>
|
|
609
|
+
</Select>
|
|
610
|
+
)
|
|
611
|
+
}
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
## API Reference
|
|
615
|
+
|
|
616
|
+
See the [Base UI Select](https://base-ui.com/react/components/select#api-reference) documentation.
|