@adamosuiteservices/ui 2.11.21 → 2.12.0
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/dist/{button-BzVY7053.js → button-CMWUcYpz.js} +54 -54
- package/dist/button-CmLeuaI0.cjs +75 -0
- package/dist/button-group.cjs +6 -6
- package/dist/button-group.js +20 -20
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/{calendar-IAVS_7up.cjs → calendar-DUvRetFW.cjs} +1 -1
- package/dist/{calendar-BIttOd3g.js → calendar-yJWQTCer.js} +1 -1
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.js +1 -1
- package/dist/combobox-BhDOduAb.cjs +40 -0
- package/dist/{combobox-DI-WK3Ng.js → combobox-CYOGlfQe.js} +91 -88
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.js +1 -1
- package/dist/components/ui/button/button.d.ts +1 -1
- package/dist/components/ui/input-otp/index.d.ts +1 -0
- package/dist/components/ui/input-otp/input-otp.d.ts +11 -0
- package/dist/components/ui/input-otp.d.ts +11 -0
- package/dist/context-menu.cjs +38 -36
- package/dist/context-menu.js +54 -52
- package/dist/date-picker-selector.cjs +1 -1
- package/dist/date-picker-selector.js +4 -4
- package/dist/dropdown-menu.cjs +48 -52
- package/dist/dropdown-menu.js +164 -168
- package/dist/{input-DFvZLcgm.js → input-BCiOr4Fy.js} +7 -6
- package/dist/{input-CWDpI1Ua.cjs → input-Bz5k4w94.cjs} +7 -6
- package/dist/input-group.cjs +5 -5
- package/dist/input-group.js +10 -10
- package/dist/input-otp.cjs +68 -0
- package/dist/input-otp.js +384 -0
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/pagination.cjs +2 -2
- package/dist/pagination.js +4 -3
- package/dist/select.cjs +22 -20
- package/dist/select.js +112 -111
- package/dist/sidebar.cjs +1 -1
- package/dist/sidebar.js +1 -1
- package/dist/styles.css +1 -1
- package/docs/components/ui/button-group.md +986 -984
- package/docs/components/ui/button.md +1156 -1137
- package/docs/components/ui/combobox.md +33 -2
- package/docs/components/ui/command.md +484 -454
- package/docs/components/ui/context-menu.md +574 -540
- package/docs/components/ui/dropdown-menu.md +743 -709
- package/docs/components/ui/input.md +362 -362
- package/docs/components/ui/select.md +357 -352
- package/package.json +8 -3
- package/dist/button-B_VHdPPV.cjs +0 -76
- package/dist/combobox-DplJzBX6.cjs +0 -37
|
@@ -1,352 +1,357 @@
|
|
|
1
|
-
# Select
|
|
2
|
-
|
|
3
|
-
Dropdown de selección con búsqueda y scroll. Basado en Radix UI con 10 subcomponentes.
|
|
4
|
-
|
|
5
|
-
## Descripción
|
|
6
|
-
|
|
7
|
-
El componente `Select` muestra una lista de opciones en las que el usuario puede seleccionar una opción de la lista.
|
|
8
|
-
|
|
9
|
-
## Importación
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import {
|
|
13
|
-
Select,
|
|
14
|
-
SelectContent,
|
|
15
|
-
SelectGroup,
|
|
16
|
-
SelectItem,
|
|
17
|
-
SelectLabel,
|
|
18
|
-
SelectTrigger,
|
|
19
|
-
SelectValue,
|
|
20
|
-
} from "@adamosuiteservices/ui/select";
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Anatomía
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
<Select>
|
|
27
|
-
<SelectTrigger className="w-[180px]">
|
|
28
|
-
<SelectValue placeholder="Select option" />
|
|
29
|
-
</SelectTrigger>
|
|
30
|
-
<SelectContent>
|
|
31
|
-
<SelectItem value="option1">Option 1</SelectItem>
|
|
32
|
-
<SelectItem value="option2">Option 2</SelectItem>
|
|
33
|
-
</SelectContent>
|
|
34
|
-
</Select>
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
**Componentes**: 10 (Select, SelectTrigger, SelectValue, SelectContent, SelectItem, SelectGroup, SelectLabel, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton)
|
|
38
|
-
|
|
39
|
-
## Props
|
|
40
|
-
|
|
41
|
-
### Select (Root)
|
|
42
|
-
|
|
43
|
-
| Prop | Tipo | Descripción |
|
|
44
|
-
| --------------- | ------------------------- | ---------------------------- |
|
|
45
|
-
| `defaultValue` | `string` | Valor inicial (uncontrolled) |
|
|
46
|
-
| `value` | `string` | Valor controlado |
|
|
47
|
-
| `onValueChange` | `(value: string) => void` | Callback al cambiar valor |
|
|
48
|
-
| `disabled` | `boolean` | Deshabilita el select |
|
|
49
|
-
| `required` | `boolean` | Campo requerido |
|
|
50
|
-
| `name` | `string` | Nombre (formularios) |
|
|
51
|
-
|
|
52
|
-
### SelectTrigger
|
|
53
|
-
|
|
54
|
-
| Prop | Tipo | Descripción |
|
|
55
|
-
| ----------- | ------------------- | ---------------------- |
|
|
56
|
-
| `size` | `"sm" \| "default"` | Tamaño del trigger |
|
|
57
|
-
| `className` | `string` | Clases CSS adicionales |
|
|
58
|
-
|
|
59
|
-
**Nota**: `size="sm"` = h-
|
|
60
|
-
|
|
61
|
-
### SelectValue
|
|
62
|
-
|
|
63
|
-
| Prop | Tipo | Descripción |
|
|
64
|
-
| ------------- | -------- | ----------------------------- |
|
|
65
|
-
| `placeholder` | `string` | Texto cuando no hay selección |
|
|
66
|
-
|
|
67
|
-
### SelectContent
|
|
68
|
-
|
|
69
|
-
| Prop | Tipo | Descripción |
|
|
70
|
-
| ----------- | ------------------------------ | ---------------------- |
|
|
71
|
-
| `position` | `"popper" \| "item-aligned"` | Posición del dropdown |
|
|
72
|
-
| `align` | `"start" \| "center" \| "end"` | Alineación horizontal |
|
|
73
|
-
| `className` | `string` | Clases CSS adicionales |
|
|
74
|
-
|
|
75
|
-
### SelectItem
|
|
76
|
-
|
|
77
|
-
| Prop | Tipo | Descripción |
|
|
78
|
-
| ----------- | --------- | ---------------------- |
|
|
79
|
-
| `value` | `string` | Valor único del item |
|
|
80
|
-
| `disabled` | `boolean` | Deshabilita este item |
|
|
81
|
-
| `className` | `string` | Clases CSS adicionales |
|
|
82
|
-
|
|
83
|
-
### SelectLabel
|
|
84
|
-
|
|
85
|
-
| Prop | Tipo | Descripción |
|
|
86
|
-
| ----------- | -------- | ---------------------------------- |
|
|
87
|
-
| `className` | `string` | Clases CSS para el label del grupo |
|
|
88
|
-
|
|
89
|
-
## Patrones de Uso
|
|
90
|
-
|
|
91
|
-
### Básico
|
|
92
|
-
|
|
93
|
-
```tsx
|
|
94
|
-
import {
|
|
95
|
-
Select,
|
|
96
|
-
SelectContent,
|
|
97
|
-
SelectItem,
|
|
98
|
-
SelectTrigger,
|
|
99
|
-
SelectValue,
|
|
100
|
-
} from "@adamosuiteservices/ui/select";
|
|
101
|
-
|
|
102
|
-
<Select>
|
|
103
|
-
<SelectTrigger className="w-[180px]">
|
|
104
|
-
<SelectValue placeholder="Select a theme" />
|
|
105
|
-
</SelectTrigger>
|
|
106
|
-
<SelectContent>
|
|
107
|
-
<SelectItem value="light">Light</SelectItem>
|
|
108
|
-
<SelectItem value="dark">Dark</SelectItem>
|
|
109
|
-
<SelectItem value="system">System</SelectItem>
|
|
110
|
-
</SelectContent>
|
|
111
|
-
</Select>;
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Controlado
|
|
115
|
-
|
|
116
|
-
```tsx
|
|
117
|
-
import { useState } from "react";
|
|
118
|
-
|
|
119
|
-
function App() {
|
|
120
|
-
const [value, setValue] = useState("");
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<Select value={value} onValueChange={setValue}>
|
|
124
|
-
<SelectTrigger className="w-[180px]">
|
|
125
|
-
<SelectValue placeholder="Select a language" />
|
|
126
|
-
</SelectTrigger>
|
|
127
|
-
<SelectContent>
|
|
128
|
-
<SelectItem value="javascript">JavaScript</SelectItem>
|
|
129
|
-
<SelectItem value="typescript">TypeScript</SelectItem>
|
|
130
|
-
<SelectItem value="python">Python</SelectItem>
|
|
131
|
-
</SelectContent>
|
|
132
|
-
</Select>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Con Label
|
|
138
|
-
|
|
139
|
-
```tsx
|
|
140
|
-
import { Label } from "@adamosuiteservices/ui/label";
|
|
141
|
-
|
|
142
|
-
<div className="grid w-full max-w-sm items-center gap-2">
|
|
143
|
-
<Label htmlFor="email-provider">Email provider</Label>
|
|
144
|
-
<Select>
|
|
145
|
-
<SelectTrigger id="email-provider">
|
|
146
|
-
<SelectValue placeholder="Select a provider" />
|
|
147
|
-
</SelectTrigger>
|
|
148
|
-
<SelectContent>
|
|
149
|
-
<SelectItem value="gmail">Gmail</SelectItem>
|
|
150
|
-
<SelectItem value="outlook">Outlook</SelectItem>
|
|
151
|
-
<SelectItem value="yahoo">Yahoo</SelectItem>
|
|
152
|
-
</SelectContent>
|
|
153
|
-
</Select>
|
|
154
|
-
</div>;
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Con Grupos
|
|
158
|
-
|
|
159
|
-
```tsx
|
|
160
|
-
import { SelectGroup, SelectLabel } from "@adamosuiteservices/ui/select";
|
|
161
|
-
|
|
162
|
-
<Select>
|
|
163
|
-
<SelectTrigger className="w-[200px]">
|
|
164
|
-
<SelectValue placeholder="Select a fruit" />
|
|
165
|
-
</SelectTrigger>
|
|
166
|
-
<SelectContent>
|
|
167
|
-
<SelectGroup>
|
|
168
|
-
<SelectLabel>Fruits</SelectLabel>
|
|
169
|
-
<SelectItem value="apple">Apple</SelectItem>
|
|
170
|
-
<SelectItem value="banana">Banana</SelectItem>
|
|
171
|
-
<SelectItem value="blueberry">Blueberry</SelectItem>
|
|
172
|
-
</SelectGroup>
|
|
173
|
-
</SelectContent>
|
|
174
|
-
</Select>;
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### Con Iconos
|
|
178
|
-
|
|
179
|
-
```tsx
|
|
180
|
-
import { Icon } from "@adamosuiteservices/ui/icon";
|
|
181
|
-
|
|
182
|
-
<Select>
|
|
183
|
-
<SelectTrigger className="w-[200px]">
|
|
184
|
-
<SelectValue placeholder="Select a fruit" />
|
|
185
|
-
</SelectTrigger>
|
|
186
|
-
<SelectContent>
|
|
187
|
-
<SelectItem value="apple">
|
|
188
|
-
<Icon symbol="nutrition" className="mr-2 text-lg" />
|
|
189
|
-
Apple
|
|
190
|
-
</SelectItem>
|
|
191
|
-
<SelectItem value="banana">
|
|
192
|
-
<Icon symbol="nutrition" className="mr-2 text-lg" />
|
|
193
|
-
Banana
|
|
194
|
-
</SelectItem>
|
|
195
|
-
<SelectItem value="cherry">
|
|
196
|
-
<Icon symbol="nutrition" className="mr-2 text-lg" />
|
|
197
|
-
Cherry
|
|
198
|
-
</SelectItem>
|
|
199
|
-
</SelectContent>
|
|
200
|
-
</Select>;
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### Tamaño Pequeño
|
|
204
|
-
|
|
205
|
-
```tsx
|
|
206
|
-
<Select>
|
|
207
|
-
<SelectTrigger size="sm" className="w-[160px]">
|
|
208
|
-
<SelectValue placeholder="Small select" />
|
|
209
|
-
</SelectTrigger>
|
|
210
|
-
<SelectContent>
|
|
211
|
-
<SelectItem value="xs">Extra Small</SelectItem>
|
|
212
|
-
<SelectItem value="sm">Small</SelectItem>
|
|
213
|
-
<SelectItem value="md">Medium</SelectItem>
|
|
214
|
-
</SelectContent>
|
|
215
|
-
</Select>
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
### Scrollable
|
|
219
|
-
|
|
220
|
-
```tsx
|
|
221
|
-
<Select>
|
|
222
|
-
<SelectTrigger className="w-[280px]">
|
|
223
|
-
<SelectValue placeholder="Select a timezone" />
|
|
224
|
-
</SelectTrigger>
|
|
225
|
-
<SelectContent>
|
|
226
|
-
<SelectGroup>
|
|
227
|
-
<SelectLabel>North America</SelectLabel>
|
|
228
|
-
<SelectItem value="est">Eastern Standard Time (EST)</SelectItem>
|
|
229
|
-
<SelectItem value="cst">Central Standard Time (CST)</SelectItem>
|
|
230
|
-
<SelectItem value="mst">Mountain Standard Time (MST)</SelectItem>
|
|
231
|
-
<SelectItem value="pst">Pacific Standard Time (PST)</SelectItem>
|
|
232
|
-
</SelectGroup>
|
|
233
|
-
<SelectGroup>
|
|
234
|
-
<SelectLabel>Europe & Africa</SelectLabel>
|
|
235
|
-
<SelectItem value="gmt">Greenwich Mean Time (GMT)</SelectItem>
|
|
236
|
-
<SelectItem value="cet">Central European Time (CET)</SelectItem>
|
|
237
|
-
<SelectItem value="eet">Eastern European Time (EET)</SelectItem>
|
|
238
|
-
</SelectGroup>
|
|
239
|
-
</SelectContent>
|
|
240
|
-
</Select>
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### Con Validación
|
|
244
|
-
|
|
245
|
-
```tsx
|
|
246
|
-
import { Button } from "@adamosuiteservices/ui/button";
|
|
247
|
-
|
|
248
|
-
function App() {
|
|
249
|
-
const [value, setValue] = useState("");
|
|
250
|
-
const [error, setError] = useState("");
|
|
251
|
-
|
|
252
|
-
const handleValidate = () => {
|
|
253
|
-
if (!value) {
|
|
254
|
-
setError("Please select a priority level");
|
|
255
|
-
} else {
|
|
256
|
-
setError("");
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
return (
|
|
261
|
-
<div className="space-y-4">
|
|
262
|
-
<div className="grid w-full max-w-sm items-center gap-2">
|
|
263
|
-
<Label htmlFor="priority">
|
|
264
|
-
Priority level <span className="text-destructive">*</span>
|
|
265
|
-
</Label>
|
|
266
|
-
<Select value={value} onValueChange={setValue}>
|
|
267
|
-
<SelectTrigger
|
|
268
|
-
id="priority"
|
|
269
|
-
className={error ? "border-destructive" : ""}
|
|
270
|
-
>
|
|
271
|
-
<SelectValue placeholder="Select priority" />
|
|
272
|
-
</SelectTrigger>
|
|
273
|
-
<SelectContent>
|
|
274
|
-
<SelectItem value="low">Low</SelectItem>
|
|
275
|
-
<SelectItem value="medium">Medium</SelectItem>
|
|
276
|
-
<SelectItem value="high">High</SelectItem>
|
|
277
|
-
</SelectContent>
|
|
278
|
-
</Select>
|
|
279
|
-
{error && <p className="text-destructive text-sm">{error}</p>}
|
|
280
|
-
</div>
|
|
281
|
-
<Button onClick={handleValidate} variant="outline">
|
|
282
|
-
Validate Selection
|
|
283
|
-
</Button>
|
|
284
|
-
</div>
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
### Deshabilitado
|
|
290
|
-
|
|
291
|
-
```tsx
|
|
292
|
-
<Select disabled>
|
|
293
|
-
<SelectTrigger className="w-[180px]">
|
|
294
|
-
<SelectValue placeholder="Select a theme" />
|
|
295
|
-
</SelectTrigger>
|
|
296
|
-
<SelectContent>
|
|
297
|
-
<SelectItem value="light">Light</SelectItem>
|
|
298
|
-
<SelectItem value="dark">Dark</SelectItem>
|
|
299
|
-
</SelectContent>
|
|
300
|
-
</Select>
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
## Casos de Uso### Configuración
|
|
304
|
-
|
|
305
|
-
```tsx## Casos de Uso
|
|
306
|
-
|
|
307
|
-
**Selección simple**: Elegir una opción de lista larga
|
|
308
|
-
**Formularios**: País, estado, categoría, idioma
|
|
309
|
-
**Filtros**: Ordenar por, filtrar por tipo
|
|
310
|
-
**Settings**: Theme, tamaño de texto, timezone
|
|
311
|
-
**Navegación**: Cambio rápido entre secciones/vistas
|
|
312
|
-
|
|
313
|
-
## Estilos Base
|
|
314
|
-
|
|
315
|
-
- **Trigger height**: `h-
|
|
316
|
-
- **
|
|
317
|
-
- **
|
|
318
|
-
- **
|
|
319
|
-
- **
|
|
320
|
-
- **
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
-
|
|
325
|
-
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
- **
|
|
333
|
-
- **
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
- **
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
**
|
|
342
|
-
**
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
**
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
1
|
+
# Select
|
|
2
|
+
|
|
3
|
+
Dropdown de selección con búsqueda y scroll. Basado en Radix UI con 10 subcomponentes.
|
|
4
|
+
|
|
5
|
+
## Descripción
|
|
6
|
+
|
|
7
|
+
El componente `Select` muestra una lista de opciones en las que el usuario puede seleccionar una opción de la lista.
|
|
8
|
+
|
|
9
|
+
## Importación
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import {
|
|
13
|
+
Select,
|
|
14
|
+
SelectContent,
|
|
15
|
+
SelectGroup,
|
|
16
|
+
SelectItem,
|
|
17
|
+
SelectLabel,
|
|
18
|
+
SelectTrigger,
|
|
19
|
+
SelectValue,
|
|
20
|
+
} from "@adamosuiteservices/ui/select";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Anatomía
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
<Select>
|
|
27
|
+
<SelectTrigger className="w-[180px]">
|
|
28
|
+
<SelectValue placeholder="Select option" />
|
|
29
|
+
</SelectTrigger>
|
|
30
|
+
<SelectContent>
|
|
31
|
+
<SelectItem value="option1">Option 1</SelectItem>
|
|
32
|
+
<SelectItem value="option2">Option 2</SelectItem>
|
|
33
|
+
</SelectContent>
|
|
34
|
+
</Select>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Componentes**: 10 (Select, SelectTrigger, SelectValue, SelectContent, SelectItem, SelectGroup, SelectLabel, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton)
|
|
38
|
+
|
|
39
|
+
## Props
|
|
40
|
+
|
|
41
|
+
### Select (Root)
|
|
42
|
+
|
|
43
|
+
| Prop | Tipo | Descripción |
|
|
44
|
+
| --------------- | ------------------------- | ---------------------------- |
|
|
45
|
+
| `defaultValue` | `string` | Valor inicial (uncontrolled) |
|
|
46
|
+
| `value` | `string` | Valor controlado |
|
|
47
|
+
| `onValueChange` | `(value: string) => void` | Callback al cambiar valor |
|
|
48
|
+
| `disabled` | `boolean` | Deshabilita el select |
|
|
49
|
+
| `required` | `boolean` | Campo requerido |
|
|
50
|
+
| `name` | `string` | Nombre (formularios) |
|
|
51
|
+
|
|
52
|
+
### SelectTrigger
|
|
53
|
+
|
|
54
|
+
| Prop | Tipo | Descripción |
|
|
55
|
+
| ----------- | ------------------- | ---------------------- |
|
|
56
|
+
| `size` | `"sm" \| "default"` | Tamaño del trigger |
|
|
57
|
+
| `className` | `string` | Clases CSS adicionales |
|
|
58
|
+
|
|
59
|
+
**Nota**: `size="sm"` = h-9, `size="default"` = h-10
|
|
60
|
+
|
|
61
|
+
### SelectValue
|
|
62
|
+
|
|
63
|
+
| Prop | Tipo | Descripción |
|
|
64
|
+
| ------------- | -------- | ----------------------------- |
|
|
65
|
+
| `placeholder` | `string` | Texto cuando no hay selección |
|
|
66
|
+
|
|
67
|
+
### SelectContent
|
|
68
|
+
|
|
69
|
+
| Prop | Tipo | Descripción |
|
|
70
|
+
| ----------- | ------------------------------ | ---------------------- |
|
|
71
|
+
| `position` | `"popper" \| "item-aligned"` | Posición del dropdown |
|
|
72
|
+
| `align` | `"start" \| "center" \| "end"` | Alineación horizontal |
|
|
73
|
+
| `className` | `string` | Clases CSS adicionales |
|
|
74
|
+
|
|
75
|
+
### SelectItem
|
|
76
|
+
|
|
77
|
+
| Prop | Tipo | Descripción |
|
|
78
|
+
| ----------- | --------- | ---------------------- |
|
|
79
|
+
| `value` | `string` | Valor único del item |
|
|
80
|
+
| `disabled` | `boolean` | Deshabilita este item |
|
|
81
|
+
| `className` | `string` | Clases CSS adicionales |
|
|
82
|
+
|
|
83
|
+
### SelectLabel
|
|
84
|
+
|
|
85
|
+
| Prop | Tipo | Descripción |
|
|
86
|
+
| ----------- | -------- | ---------------------------------- |
|
|
87
|
+
| `className` | `string` | Clases CSS para el label del grupo |
|
|
88
|
+
|
|
89
|
+
## Patrones de Uso
|
|
90
|
+
|
|
91
|
+
### Básico
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import {
|
|
95
|
+
Select,
|
|
96
|
+
SelectContent,
|
|
97
|
+
SelectItem,
|
|
98
|
+
SelectTrigger,
|
|
99
|
+
SelectValue,
|
|
100
|
+
} from "@adamosuiteservices/ui/select";
|
|
101
|
+
|
|
102
|
+
<Select>
|
|
103
|
+
<SelectTrigger className="w-[180px]">
|
|
104
|
+
<SelectValue placeholder="Select a theme" />
|
|
105
|
+
</SelectTrigger>
|
|
106
|
+
<SelectContent>
|
|
107
|
+
<SelectItem value="light">Light</SelectItem>
|
|
108
|
+
<SelectItem value="dark">Dark</SelectItem>
|
|
109
|
+
<SelectItem value="system">System</SelectItem>
|
|
110
|
+
</SelectContent>
|
|
111
|
+
</Select>;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Controlado
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { useState } from "react";
|
|
118
|
+
|
|
119
|
+
function App() {
|
|
120
|
+
const [value, setValue] = useState("");
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<Select value={value} onValueChange={setValue}>
|
|
124
|
+
<SelectTrigger className="w-[180px]">
|
|
125
|
+
<SelectValue placeholder="Select a language" />
|
|
126
|
+
</SelectTrigger>
|
|
127
|
+
<SelectContent>
|
|
128
|
+
<SelectItem value="javascript">JavaScript</SelectItem>
|
|
129
|
+
<SelectItem value="typescript">TypeScript</SelectItem>
|
|
130
|
+
<SelectItem value="python">Python</SelectItem>
|
|
131
|
+
</SelectContent>
|
|
132
|
+
</Select>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Con Label
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import { Label } from "@adamosuiteservices/ui/label";
|
|
141
|
+
|
|
142
|
+
<div className="grid w-full max-w-sm items-center gap-2">
|
|
143
|
+
<Label htmlFor="email-provider">Email provider</Label>
|
|
144
|
+
<Select>
|
|
145
|
+
<SelectTrigger id="email-provider">
|
|
146
|
+
<SelectValue placeholder="Select a provider" />
|
|
147
|
+
</SelectTrigger>
|
|
148
|
+
<SelectContent>
|
|
149
|
+
<SelectItem value="gmail">Gmail</SelectItem>
|
|
150
|
+
<SelectItem value="outlook">Outlook</SelectItem>
|
|
151
|
+
<SelectItem value="yahoo">Yahoo</SelectItem>
|
|
152
|
+
</SelectContent>
|
|
153
|
+
</Select>
|
|
154
|
+
</div>;
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Con Grupos
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
import { SelectGroup, SelectLabel } from "@adamosuiteservices/ui/select";
|
|
161
|
+
|
|
162
|
+
<Select>
|
|
163
|
+
<SelectTrigger className="w-[200px]">
|
|
164
|
+
<SelectValue placeholder="Select a fruit" />
|
|
165
|
+
</SelectTrigger>
|
|
166
|
+
<SelectContent>
|
|
167
|
+
<SelectGroup>
|
|
168
|
+
<SelectLabel>Fruits</SelectLabel>
|
|
169
|
+
<SelectItem value="apple">Apple</SelectItem>
|
|
170
|
+
<SelectItem value="banana">Banana</SelectItem>
|
|
171
|
+
<SelectItem value="blueberry">Blueberry</SelectItem>
|
|
172
|
+
</SelectGroup>
|
|
173
|
+
</SelectContent>
|
|
174
|
+
</Select>;
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Con Iconos
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
import { Icon } from "@adamosuiteservices/ui/icon";
|
|
181
|
+
|
|
182
|
+
<Select>
|
|
183
|
+
<SelectTrigger className="w-[200px]">
|
|
184
|
+
<SelectValue placeholder="Select a fruit" />
|
|
185
|
+
</SelectTrigger>
|
|
186
|
+
<SelectContent>
|
|
187
|
+
<SelectItem value="apple">
|
|
188
|
+
<Icon symbol="nutrition" className="mr-2 text-lg" />
|
|
189
|
+
Apple
|
|
190
|
+
</SelectItem>
|
|
191
|
+
<SelectItem value="banana">
|
|
192
|
+
<Icon symbol="nutrition" className="mr-2 text-lg" />
|
|
193
|
+
Banana
|
|
194
|
+
</SelectItem>
|
|
195
|
+
<SelectItem value="cherry">
|
|
196
|
+
<Icon symbol="nutrition" className="mr-2 text-lg" />
|
|
197
|
+
Cherry
|
|
198
|
+
</SelectItem>
|
|
199
|
+
</SelectContent>
|
|
200
|
+
</Select>;
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Tamaño Pequeño
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
<Select>
|
|
207
|
+
<SelectTrigger size="sm" className="w-[160px]">
|
|
208
|
+
<SelectValue placeholder="Small select" />
|
|
209
|
+
</SelectTrigger>
|
|
210
|
+
<SelectContent>
|
|
211
|
+
<SelectItem value="xs">Extra Small</SelectItem>
|
|
212
|
+
<SelectItem value="sm">Small</SelectItem>
|
|
213
|
+
<SelectItem value="md">Medium</SelectItem>
|
|
214
|
+
</SelectContent>
|
|
215
|
+
</Select>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Scrollable
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
<Select>
|
|
222
|
+
<SelectTrigger className="w-[280px]">
|
|
223
|
+
<SelectValue placeholder="Select a timezone" />
|
|
224
|
+
</SelectTrigger>
|
|
225
|
+
<SelectContent>
|
|
226
|
+
<SelectGroup>
|
|
227
|
+
<SelectLabel>North America</SelectLabel>
|
|
228
|
+
<SelectItem value="est">Eastern Standard Time (EST)</SelectItem>
|
|
229
|
+
<SelectItem value="cst">Central Standard Time (CST)</SelectItem>
|
|
230
|
+
<SelectItem value="mst">Mountain Standard Time (MST)</SelectItem>
|
|
231
|
+
<SelectItem value="pst">Pacific Standard Time (PST)</SelectItem>
|
|
232
|
+
</SelectGroup>
|
|
233
|
+
<SelectGroup>
|
|
234
|
+
<SelectLabel>Europe & Africa</SelectLabel>
|
|
235
|
+
<SelectItem value="gmt">Greenwich Mean Time (GMT)</SelectItem>
|
|
236
|
+
<SelectItem value="cet">Central European Time (CET)</SelectItem>
|
|
237
|
+
<SelectItem value="eet">Eastern European Time (EET)</SelectItem>
|
|
238
|
+
</SelectGroup>
|
|
239
|
+
</SelectContent>
|
|
240
|
+
</Select>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Con Validación
|
|
244
|
+
|
|
245
|
+
```tsx
|
|
246
|
+
import { Button } from "@adamosuiteservices/ui/button";
|
|
247
|
+
|
|
248
|
+
function App() {
|
|
249
|
+
const [value, setValue] = useState("");
|
|
250
|
+
const [error, setError] = useState("");
|
|
251
|
+
|
|
252
|
+
const handleValidate = () => {
|
|
253
|
+
if (!value) {
|
|
254
|
+
setError("Please select a priority level");
|
|
255
|
+
} else {
|
|
256
|
+
setError("");
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<div className="space-y-4">
|
|
262
|
+
<div className="grid w-full max-w-sm items-center gap-2">
|
|
263
|
+
<Label htmlFor="priority">
|
|
264
|
+
Priority level <span className="text-destructive">*</span>
|
|
265
|
+
</Label>
|
|
266
|
+
<Select value={value} onValueChange={setValue}>
|
|
267
|
+
<SelectTrigger
|
|
268
|
+
id="priority"
|
|
269
|
+
className={error ? "border-destructive" : ""}
|
|
270
|
+
>
|
|
271
|
+
<SelectValue placeholder="Select priority" />
|
|
272
|
+
</SelectTrigger>
|
|
273
|
+
<SelectContent>
|
|
274
|
+
<SelectItem value="low">Low</SelectItem>
|
|
275
|
+
<SelectItem value="medium">Medium</SelectItem>
|
|
276
|
+
<SelectItem value="high">High</SelectItem>
|
|
277
|
+
</SelectContent>
|
|
278
|
+
</Select>
|
|
279
|
+
{error && <p className="text-destructive text-sm">{error}</p>}
|
|
280
|
+
</div>
|
|
281
|
+
<Button onClick={handleValidate} variant="outline">
|
|
282
|
+
Validate Selection
|
|
283
|
+
</Button>
|
|
284
|
+
</div>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Deshabilitado
|
|
290
|
+
|
|
291
|
+
```tsx
|
|
292
|
+
<Select disabled>
|
|
293
|
+
<SelectTrigger className="w-[180px]">
|
|
294
|
+
<SelectValue placeholder="Select a theme" />
|
|
295
|
+
</SelectTrigger>
|
|
296
|
+
<SelectContent>
|
|
297
|
+
<SelectItem value="light">Light</SelectItem>
|
|
298
|
+
<SelectItem value="dark">Dark</SelectItem>
|
|
299
|
+
</SelectContent>
|
|
300
|
+
</Select>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Casos de Uso### Configuración
|
|
304
|
+
|
|
305
|
+
```tsx## Casos de Uso
|
|
306
|
+
|
|
307
|
+
**Selección simple**: Elegir una opción de lista larga
|
|
308
|
+
**Formularios**: País, estado, categoría, idioma
|
|
309
|
+
**Filtros**: Ordenar por, filtrar por tipo
|
|
310
|
+
**Settings**: Theme, tamaño de texto, timezone
|
|
311
|
+
**Navegación**: Cambio rápido entre secciones/vistas
|
|
312
|
+
|
|
313
|
+
## Estilos Base
|
|
314
|
+
|
|
315
|
+
- **Trigger height**: `h-10` (default, 40px), `h-9` (sm, 36px)
|
|
316
|
+
- **Item height**: `h-10` (40px) - consistent with trigger default
|
|
317
|
+
- **Padding**: Trigger uses `px-3` (no vertical padding, height defines size)
|
|
318
|
+
- **Item padding**: `px-3` horizontal, `pr-10` when with check icon
|
|
319
|
+
- **Separators**: Border-bottom between items, removed on last item
|
|
320
|
+
- **Border radius**: Items have rounded corners on first (top) and last (bottom) to match container
|
|
321
|
+
- **Border**: `border-input` con `shadow-xs`
|
|
322
|
+
- **Focus**: `ring-ring/50` con `ring-[3px]`
|
|
323
|
+
- **Content**: `bg-popover` con `shadow-md` y `border`
|
|
324
|
+
- **Item hover**: `bg-accent text-accent-foreground`
|
|
325
|
+
- **Check icon**: Icon `check` con `text-lg` en item seleccionado
|
|
326
|
+
|
|
327
|
+
## Accesibilidad
|
|
328
|
+
|
|
329
|
+
- ✅ **Role**: `role="combobox"` en trigger, `role="option"` en items
|
|
330
|
+
- ✅ **ARIA**: `aria-expanded`, `aria-controls`, `aria-selected`
|
|
331
|
+
- ✅ **Keyboard**: Arrow keys, Enter, Escape, Type-ahead search
|
|
332
|
+
- ✅ **Focus**: Focus trap en content abierto
|
|
333
|
+
- ✅ **Label**: Asociar con `id` en SelectTrigger
|
|
334
|
+
|
|
335
|
+
## Notas de Implementación
|
|
336
|
+
|
|
337
|
+
- **Radix UI**: Basado en `@radix-ui/react-select`
|
|
338
|
+
- **Portal**: SelectContent se renderiza en portal
|
|
339
|
+
- **Iconos**: Icon `expand_more` en trigger, Icon `check` en items seleccionados, Icon `expand_less`/`expand_more` en scroll buttons
|
|
340
|
+
- **Scroll buttons**: Auto-mostrados cuando content es scrollable
|
|
341
|
+
- **Position**: `popper` (default) para absolute positioning
|
|
342
|
+
- **Type-ahead**: Buscar items escribiendo
|
|
343
|
+
|
|
344
|
+
## Troubleshooting
|
|
345
|
+
|
|
346
|
+
**Dropdown no abre**: Verifica que SelectContent esté dentro de Select
|
|
347
|
+
**No muestra valor**: Asegura que `value` del item seleccionado coincida con `value` del Select
|
|
348
|
+
**Portal issues**: SelectContent usa Portal, puede afectar z-index
|
|
349
|
+
**Width mismatch**: SelectTrigger necesita `className="w-[Xpx]"` explícito
|
|
350
|
+
**Scroll no funciona**: Scroll automático cuando items exceden max-height
|
|
351
|
+
**Placeholder no desaparece**: SelectValue.placeholder solo visible cuando no hay valor
|
|
352
|
+
|
|
353
|
+
## Referencias
|
|
354
|
+
|
|
355
|
+
- **Radix UI Select**: <https://www.radix-ui.com/primitives/docs/components/select>
|
|
356
|
+
- **shadcn/ui Select**: <https://ui.shadcn.com/docs/components/select>
|
|
357
|
+
```
|