@adamosuiteservices/ui 1.2.4 → 1.3.5
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/README.md +4 -0
- package/dist/accordion-rounded.cjs +1 -1
- package/dist/accordion-rounded.js +1 -1
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +1 -1
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +1 -1
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/breadcrumb.cjs +1 -0
- package/dist/breadcrumb.js +105 -0
- package/dist/{button-C1n6snOY.js → button-2GdKenQI.js} +1 -1
- package/dist/{button-BV-_FVKZ.cjs → button-DEQVHMrX.cjs} +1 -1
- package/dist/button-group.cjs +1 -1
- package/dist/button-group.js +2 -2
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.js +1 -1
- package/dist/{checkbox-BrmXPKTn.js → checkbox-Dr487kAg.js} +3 -3
- package/dist/{checkbox-Lq-HvSgc.cjs → checkbox-YWAnswaW.cjs} +1 -1
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/collapsible.cjs +1 -1
- package/dist/collapsible.js +1 -1
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.js +6 -6
- package/dist/components/ui/breadcrumb/breadcrumb.d.ts +11 -0
- package/dist/components/ui/breadcrumb/breadcrumb.stories.d.ts +26 -0
- package/dist/components/ui/breadcrumb/index.d.ts +1 -0
- package/dist/components/ui/dialog/dialog.d.ts +2 -1
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.js +2 -2
- package/dist/custom-layered-styles.css +1 -1
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +33 -19
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.js +3 -3
- package/dist/ellipsis-CryjZKZn.js +15 -0
- package/dist/ellipsis-Ct9VTDOG.cjs +6 -0
- package/dist/field.cjs +1 -1
- package/dist/field.js +2 -2
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.js +6 -6
- package/dist/{index-CAOY367Y.js → index-B0M7VOwp.js} +2 -2
- package/dist/{index-B-ZRqW0J.js → index-BBoIAjAs.js} +3 -3
- package/dist/{index-gO_QEiaK.cjs → index-BDs8lUfq.cjs} +1 -1
- package/dist/index-BFyr34mw.cjs +5 -0
- package/dist/index-BMWt1NBG.js +79 -0
- package/dist/{index-yR-v1A4G.js → index-BX9hz-JD.js} +1 -1
- package/dist/{index-BGiGvaq8.cjs → index-BcGMAmWE.cjs} +1 -1
- package/dist/{index-IKJMQref.cjs → index-Bd0gQB0k.cjs} +1 -1
- package/dist/{index-VIUqZjyP.cjs → index-BeWgla7c.cjs} +1 -1
- package/dist/{index-EUea2gfp.js → index-BpWB3aFK.js} +1 -1
- package/dist/index-BvLQnI56.js +59 -0
- package/dist/{index-CwUFT-GQ.js → index-C0YiLSjW.js} +4 -4
- package/dist/{index-o0sNTcKe.js → index-CBjZooac.js} +2 -2
- package/dist/{index-DnS_sBBe.cjs → index-COuvjZLM.cjs} +1 -1
- package/dist/index-CTjlbbt9.cjs +1 -0
- package/dist/index-CUWMxxKG.js +97 -0
- package/dist/{index-C329e3yQ.js → index-CZZ3llmi.js} +2 -2
- package/dist/index-CjyiloO7.cjs +1 -0
- package/dist/{index-D3wSWKST.cjs → index-Cmx9M9cZ.cjs} +1 -1
- package/dist/index-CocSS1YK.cjs +1 -0
- package/dist/index-CzRiuk60.cjs +1 -0
- package/dist/index-DFPDUUq7.js +658 -0
- package/dist/{index-D3S7dBDI.cjs → index-DIwmXz1u.cjs} +1 -1
- package/dist/index-DLcqcWxM.js +29 -0
- package/dist/index-DMLQL2aG.js +286 -0
- package/dist/{index-DXQ-7kNJ.cjs → index-DMs8RL3E.cjs} +1 -1
- package/dist/{index-Ce3QBKyj.cjs → index-Dbj9vHNq.cjs} +1 -1
- package/dist/{index-BRLtxFFr.cjs → index-DmGzwG2z.cjs} +1 -1
- package/dist/{index-P1sVIHE3.js → index-PYkEXTqJ.js} +1 -1
- package/dist/{index-DulPG3F9.js → index-Se4vRnIO.js} +3 -3
- package/dist/index-_XxjJPRD.cjs +1 -0
- package/dist/{index-B-cHTKrs.js → index-yWvyIlmA.js} +4 -4
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +1 -1
- package/dist/{label-Cne2J57f.cjs → label-BjXORCBM.cjs} +1 -1
- package/dist/{label-Ky8qBEC3.js → label-CmwGvhy1.js} +1 -1
- package/dist/label.cjs +1 -1
- package/dist/label.js +1 -1
- package/dist/pagination.cjs +1 -6
- package/dist/pagination.js +58 -69
- package/dist/popover-3rIoNCXs.js +306 -0
- package/dist/popover-FCKBtFo-.cjs +1 -0
- package/dist/popover.cjs +1 -1
- package/dist/popover.js +1 -1
- package/dist/progress.cjs +1 -1
- package/dist/progress.js +1 -1
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +5 -5
- package/dist/select.cjs +2 -2
- package/dist/select.js +585 -542
- package/dist/{separator-CGnu_jIu.cjs → separator-BaZqZZ9R.cjs} +1 -1
- package/dist/{separator-BH73A90k.js → separator-DR7lQjv9.js} +1 -1
- package/dist/separator.cjs +1 -1
- package/dist/separator.js +1 -1
- package/dist/{sheet-CcxnJ6LH.cjs → sheet-CU-sFSaJ.cjs} +1 -1
- package/dist/{sheet-_DVpQIVF.js → sheet-UZWAbdXr.js} +1 -1
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.js +1 -1
- package/dist/sidebar.cjs +1 -1
- package/dist/sidebar.js +4 -4
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +3 -3
- package/dist/styles.css +1 -1
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +2 -2
- package/dist/tabs-underline.cjs +1 -1
- package/dist/tabs-underline.js +1 -1
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/toaster.cjs +1 -1
- package/dist/toaster.js +1 -1
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +1 -1
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.js +114 -108
- package/dist/typography.cjs +1 -1
- package/dist/typography.js +16 -16
- package/docs/AI-GUIDE.md +321 -0
- package/docs/components/layout/sidebar.md +330 -0
- package/docs/components/layout/toaster.md +436 -0
- package/docs/components/ui/accordion-rounded.md +583 -0
- package/docs/components/ui/accordion.md +267 -0
- package/docs/components/ui/alert.md +671 -0
- package/docs/components/ui/avatar.md +588 -0
- package/docs/components/ui/badge.md +1024 -0
- package/docs/components/ui/breadcrumb.md +614 -0
- package/docs/components/ui/button-group.md +1002 -0
- package/docs/components/ui/button.md +1078 -0
- package/docs/components/ui/calendar.md +1159 -0
- package/docs/components/ui/card.md +1265 -0
- package/docs/components/ui/checkbox.md +292 -0
- package/docs/components/ui/collapsible.md +320 -0
- package/docs/components/ui/combobox.md +328 -0
- package/docs/components/ui/command.md +454 -0
- package/docs/components/ui/context-menu.md +540 -0
- package/docs/components/ui/dialog.md +628 -0
- package/docs/components/ui/dropdown-menu.md +731 -0
- package/docs/components/ui/field.md +706 -0
- package/docs/components/ui/hover-card.md +446 -0
- package/docs/components/ui/input-group.md +509 -0
- package/docs/components/ui/input.md +362 -0
- package/docs/components/ui/kbd.md +434 -0
- package/docs/components/ui/label.md +359 -0
- package/docs/components/ui/pagination.md +650 -0
- package/docs/components/ui/popover.md +536 -0
- package/docs/components/ui/progress.md +182 -0
- package/docs/components/ui/radio-group.md +311 -0
- package/docs/components/ui/select.md +352 -0
- package/docs/components/ui/separator.md +214 -0
- package/docs/components/ui/sheet.md +142 -0
- package/docs/components/ui/skeleton.md +140 -0
- package/docs/components/ui/slider.md +341 -0
- package/docs/components/ui/spinner.md +170 -0
- package/docs/components/ui/switch.md +402 -0
- package/docs/components/ui/table.md +183 -0
- package/docs/components/ui/tabs-underline.md +106 -0
- package/docs/components/ui/tabs.md +122 -0
- package/docs/components/ui/textarea.md +243 -0
- package/docs/components/ui/toggle.md +243 -0
- package/docs/components/ui/tooltip.md +320 -0
- package/docs/components/ui/typography.md +191 -0
- package/package.json +11 -5
- package/dist/index-6oTEokEx.js +0 -82
- package/dist/index-B-NyefE0.js +0 -243
- package/dist/index-BKbK2GzY.cjs +0 -1
- package/dist/index-BMitW9UR.cjs +0 -1
- package/dist/index-BpvjJ_T6.cjs +0 -5
- package/dist/index-C5wjudc-.js +0 -36
- package/dist/index-CezwiPd_.js +0 -615
- package/dist/index-D02K8KOB.js +0 -54
- package/dist/index-D7hQvndv.cjs +0 -1
- package/dist/index-DQvx1rG_.cjs +0 -1
- package/dist/popover-BjdTqaB8.cjs +0 -1
- package/dist/popover-EnVfE0YA.js +0 -263
package/dist/typography.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import { j as r } from "./jsx-runtime-BzflLqGi.js";
|
|
2
|
-
import { c as
|
|
2
|
+
import { c as p } from "./index-CRiPKpXj.js";
|
|
3
3
|
import { c as e } from "./index-BqtVL8d-.js";
|
|
4
|
-
import { S as
|
|
4
|
+
import { S as x } from "./index-BvLQnI56.js";
|
|
5
5
|
const n = e("adm:text-neutrals-700", {
|
|
6
6
|
variants: {
|
|
7
7
|
variant: {
|
|
8
|
-
lg: "adm:text-lg
|
|
9
|
-
md: "adm:text-base
|
|
10
|
-
sm: "adm:text-sm
|
|
11
|
-
xs: "adm:text-xs
|
|
12
|
-
caption: "adm:text-[11px]
|
|
8
|
+
lg: "adm:text-lg",
|
|
9
|
+
md: "adm:text-base",
|
|
10
|
+
sm: "adm:text-sm",
|
|
11
|
+
xs: "adm:text-xs",
|
|
12
|
+
caption: "adm:text-[11px]"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
function
|
|
17
|
-
className:
|
|
18
|
-
variant:
|
|
19
|
-
asChild:
|
|
20
|
-
...
|
|
16
|
+
function f({
|
|
17
|
+
className: t,
|
|
18
|
+
variant: a,
|
|
19
|
+
asChild: s = !1,
|
|
20
|
+
...m
|
|
21
21
|
}) {
|
|
22
|
-
const o =
|
|
22
|
+
const o = s ? x : "p";
|
|
23
23
|
return /* @__PURE__ */ r.jsx(
|
|
24
24
|
o,
|
|
25
25
|
{
|
|
26
26
|
"data-slot": "typography",
|
|
27
|
-
className:
|
|
28
|
-
...
|
|
27
|
+
className: p(n({ variant: a, className: t })),
|
|
28
|
+
...m
|
|
29
29
|
}
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
export {
|
|
33
|
-
|
|
33
|
+
f as Typography
|
|
34
34
|
};
|
package/docs/AI-GUIDE.md
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# Guía para IA: Cómo usar la documentación de Adamo UI
|
|
2
|
+
|
|
3
|
+
## Propósito de esta Documentación
|
|
4
|
+
|
|
5
|
+
Esta documentación está diseñada para ayudar a una IA a entender y utilizar correctamente todos los componentes de la biblioteca Adamo UI. Cada componente tiene su propia documentación detallada con ejemplos de código y explicaciones.
|
|
6
|
+
|
|
7
|
+
## Estructura de la Documentación
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
docs/
|
|
11
|
+
├── AI-GUIDE.md # Esta guía (para IA)
|
|
12
|
+
└── components/
|
|
13
|
+
├── ui/ # Componentes de interfaz
|
|
14
|
+
│ ├── accordion.md
|
|
15
|
+
│ ├── button.md
|
|
16
|
+
│ ├── input.md
|
|
17
|
+
└── layout/ # Componentes de layout
|
|
18
|
+
├── sidebar.md
|
|
19
|
+
└── toaster.md
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Convenciones Importantes
|
|
23
|
+
|
|
24
|
+
### 1. Estilos Incorporados
|
|
25
|
+
|
|
26
|
+
**IMPORTANTE**: Los componentes vienen con todos los estilos necesarios incorporados. El prefijo `` es INTERNO de la biblioteca y los usuarios NO deben usarlo.
|
|
27
|
+
|
|
28
|
+
✅ **Correcto** (uso normal):
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
<Button className="custom-class">Click</Button>
|
|
32
|
+
<div className="flex gap-4">
|
|
33
|
+
<Button variant="outline">Cancel</Button>
|
|
34
|
+
<Button>Submit</Button>
|
|
35
|
+
</div>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Nota Técnica**: Internamente la biblioteca usa el prefijo `` en Tailwind para evitar conflictos con los estilos de las aplicaciones que la consumen, pero esto es transparente para el usuario final.
|
|
39
|
+
|
|
40
|
+
### 2. Importaciones
|
|
41
|
+
|
|
42
|
+
Los componentes se importan desde rutas específicas:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// ✅ Correcto
|
|
46
|
+
import { Button } from "@adamosuiteservices/ui/button";
|
|
47
|
+
import { Input } from "@adamosuiteservices/ui/input";
|
|
48
|
+
|
|
49
|
+
// ❌ Incorrecto
|
|
50
|
+
import { Button, Input } from "@adamosuiteservices/ui";
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. Estilos CSS
|
|
54
|
+
|
|
55
|
+
Importar los estilos en el punto de entrada de la aplicación:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import "@adamosuiteservices/ui/styles.css";
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Patrones Comunes
|
|
62
|
+
|
|
63
|
+
### Componentes con Variantes
|
|
64
|
+
|
|
65
|
+
Muchos componentes soportan la prop `variant`:
|
|
66
|
+
|
|
67
|
+
- `default` - Estilo primario
|
|
68
|
+
- `secondary` - Estilo secundario
|
|
69
|
+
- `success` - Verde para acciones exitosas
|
|
70
|
+
- `warning` - Naranja para advertencias
|
|
71
|
+
- `destructive` - Rojo para acciones peligrosas
|
|
72
|
+
- `outline` - Borde sin relleno
|
|
73
|
+
- `ghost` - Mínimo, aparece en hover
|
|
74
|
+
|
|
75
|
+
Variantes `-medium` están disponibles para estilos más suaves.
|
|
76
|
+
|
|
77
|
+
### Componentes Compuestos
|
|
78
|
+
|
|
79
|
+
Muchos componentes tienen sub-componentes que deben usarse juntos:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
// Accordion
|
|
83
|
+
<Accordion>
|
|
84
|
+
<AccordionItem>
|
|
85
|
+
<AccordionTrigger>...</AccordionTrigger>
|
|
86
|
+
<AccordionContent>...</AccordionContent>
|
|
87
|
+
</AccordionItem>
|
|
88
|
+
</Accordion>
|
|
89
|
+
|
|
90
|
+
// Dialog
|
|
91
|
+
<Dialog>
|
|
92
|
+
<DialogTrigger>...</DialogTrigger>
|
|
93
|
+
<DialogContent>
|
|
94
|
+
<DialogHeader>
|
|
95
|
+
<DialogTitle>...</DialogTitle>
|
|
96
|
+
<DialogDescription>...</DialogDescription>
|
|
97
|
+
</DialogHeader>
|
|
98
|
+
</DialogContent>
|
|
99
|
+
</Dialog>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Componentes Controlados vs No Controlados
|
|
103
|
+
|
|
104
|
+
La mayoría de los componentes soportan ambos modos:
|
|
105
|
+
|
|
106
|
+
**No Controlado:**
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
<Input defaultValue="Hello" />
|
|
110
|
+
<Select defaultValue="option1">...</Select>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Controlado:**
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
const [value, setValue] = useState("");
|
|
117
|
+
<Input value={value} onChange={(e) => setValue(e.target.value)} />;
|
|
118
|
+
|
|
119
|
+
const [selected, setSelected] = useState("");
|
|
120
|
+
<Select value={selected} onValueChange={setSelected}>
|
|
121
|
+
...
|
|
122
|
+
</Select>;
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Casos de Uso Frecuentes
|
|
126
|
+
|
|
127
|
+
### Formularios
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<div className="space-y-4">
|
|
131
|
+
<Field label="Email" error={emailError}>
|
|
132
|
+
<Input
|
|
133
|
+
type="email"
|
|
134
|
+
value={email}
|
|
135
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
136
|
+
aria-invalid={!!emailError}
|
|
137
|
+
/>
|
|
138
|
+
</Field>
|
|
139
|
+
|
|
140
|
+
<Field label="Password">
|
|
141
|
+
<Input type="password" />
|
|
142
|
+
</Field>
|
|
143
|
+
|
|
144
|
+
<Button type="submit">Submit</Button>
|
|
145
|
+
</div>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Modales/Diálogos
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
<Dialog>
|
|
152
|
+
<DialogTrigger asChild>
|
|
153
|
+
<Button>Open</Button>
|
|
154
|
+
</DialogTrigger>
|
|
155
|
+
<DialogContent>
|
|
156
|
+
<DialogHeader>
|
|
157
|
+
<DialogTitle>Title</DialogTitle>
|
|
158
|
+
<DialogDescription>Description</DialogDescription>
|
|
159
|
+
</DialogHeader>
|
|
160
|
+
{/* Contenido */}
|
|
161
|
+
<DialogFooter>
|
|
162
|
+
<DialogClose asChild>
|
|
163
|
+
<Button variant="outline">Cancel</Button>
|
|
164
|
+
</DialogClose>
|
|
165
|
+
<Button>Confirm</Button>
|
|
166
|
+
</DialogFooter>
|
|
167
|
+
</DialogContent>
|
|
168
|
+
</Dialog>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Navegación
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
<Tabs defaultValue="tab1">
|
|
175
|
+
<TabsList>
|
|
176
|
+
<TabsTrigger value="tab1">Tab 1</TabsTrigger>
|
|
177
|
+
<TabsTrigger value="tab2">Tab 2</TabsTrigger>
|
|
178
|
+
</TabsList>
|
|
179
|
+
<TabsContent value="tab1">Content 1</TabsContent>
|
|
180
|
+
<TabsContent value="tab2">Content 2</TabsContent>
|
|
181
|
+
</Tabs>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Feedback al Usuario
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
// Toasts
|
|
188
|
+
const { toast } = useToast();
|
|
189
|
+
|
|
190
|
+
toast({
|
|
191
|
+
title: "Success",
|
|
192
|
+
description: "Operation completed",
|
|
193
|
+
variant: "success",
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Alertas
|
|
197
|
+
<Alert variant="destructive">
|
|
198
|
+
<AlertCircleIcon />
|
|
199
|
+
<AlertTitle>Error</AlertTitle>
|
|
200
|
+
<AlertDescription>Something went wrong</AlertDescription>
|
|
201
|
+
</Alert>;
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Accesibilidad
|
|
205
|
+
|
|
206
|
+
### Labels
|
|
207
|
+
|
|
208
|
+
Siempre asocia labels con inputs:
|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
<Label htmlFor="email">Email</Label>
|
|
212
|
+
<Input id="email" type="email" />
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### ARIA Attributes
|
|
216
|
+
|
|
217
|
+
Usa atributos ARIA apropiados:
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
<Input aria-invalid={hasError} aria-describedby="error-message" />;
|
|
221
|
+
{
|
|
222
|
+
hasError && <p id="error-message">{errorMessage}</p>;
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Botones de Solo Icono
|
|
227
|
+
|
|
228
|
+
Siempre incluye `aria-label`:
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
<Button size="icon" aria-label="Settings">
|
|
232
|
+
<SettingsIcon />
|
|
233
|
+
</Button>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Responsive Design
|
|
237
|
+
|
|
238
|
+
Usa los breakpoints estándar de Tailwind con el prefijo ``:
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
|
|
242
|
+
{/* Contenido responsive */}
|
|
243
|
+
</div>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Errores Comunes a Evitar
|
|
247
|
+
|
|
248
|
+
### 1. Olvidar el prefijo
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
// ❌ Incorrecto
|
|
252
|
+
<Button className="px-4 py-2">Click</Button>
|
|
253
|
+
|
|
254
|
+
// ✅ Correcto
|
|
255
|
+
<Button className="px-4 py-2">Click</Button>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### 2. No usar asChild para elementos personalizados
|
|
259
|
+
|
|
260
|
+
```tsx
|
|
261
|
+
// ❌ Incorrecto
|
|
262
|
+
<Button>
|
|
263
|
+
<a href="#">Link</a>
|
|
264
|
+
</Button>
|
|
265
|
+
|
|
266
|
+
// ✅ Correcto
|
|
267
|
+
<Button asChild>
|
|
268
|
+
<a href="#">Link</a>
|
|
269
|
+
</Button>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### 3. No cerrar componentes compuestos
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
// ❌ Incorrecto
|
|
276
|
+
<Dialog>
|
|
277
|
+
<DialogTrigger>Open</DialogTrigger>
|
|
278
|
+
{/* Falta DialogContent */}
|
|
279
|
+
</Dialog>
|
|
280
|
+
|
|
281
|
+
// ✅ Correcto
|
|
282
|
+
<Dialog>
|
|
283
|
+
<DialogTrigger>Open</DialogTrigger>
|
|
284
|
+
<DialogContent>...</DialogContent>
|
|
285
|
+
</Dialog>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Recursos Adicionales
|
|
289
|
+
|
|
290
|
+
### Para cada componente, consulta
|
|
291
|
+
|
|
292
|
+
1. **Descripción**: Qué hace el componente y cuándo usarlo
|
|
293
|
+
2. **Importación**: Cómo importar correctamente
|
|
294
|
+
3. **Uso Básico**: Ejemplo mínimo funcional
|
|
295
|
+
4. **Props**: Tabla completa de propiedades
|
|
296
|
+
5. **Casos de Uso**: Ejemplos prácticos reales
|
|
297
|
+
6. **Referencias**: Enlaces a shadcn/ui y Radix UI
|
|
298
|
+
|
|
299
|
+
### Documentación de Referencia Externa
|
|
300
|
+
|
|
301
|
+
- shadcn/ui: [https://ui.shadcn.com](https://ui.shadcn.com)
|
|
302
|
+
- Radix UI: [https://www.radix-ui.com/primitives](https://www.radix-ui.com/primitives)
|
|
303
|
+
- Tailwind CSS: [https://tailwindcss.com](https://tailwindcss.com)
|
|
304
|
+
|
|
305
|
+
## Flujo de Trabajo Recomendado
|
|
306
|
+
|
|
307
|
+
1. **Identificar el componente necesario** → Consultar /docs/components
|
|
308
|
+
2. **Leer la documentación específica** → Archivo .md del componente
|
|
309
|
+
3. **Copiar el ejemplo básico** → Modificar según necesidad
|
|
310
|
+
4. **Verificar props disponibles** → Tabla de props
|
|
311
|
+
5. **Validar accesibilidad** → Labels, ARIA attributes, etc.
|
|
312
|
+
6. **Probar responsive** → Diferentes tamaños de pantalla
|
|
313
|
+
|
|
314
|
+
## Soporte y Preguntas
|
|
315
|
+
|
|
316
|
+
Si un componente no tiene documentación o necesitas más información:
|
|
317
|
+
|
|
318
|
+
1. Revisa los archivos `.stories.tsx` en `src/components/ui/[componente]/`
|
|
319
|
+
2. Consulta el código fuente en `src/components/ui/[componente]/[componente].tsx`
|
|
320
|
+
3. Revisa la documentación de shadcn/ui para el componente equivalente
|
|
321
|
+
4. Consulta Radix UI Primitives para comportamiento bajo nivel
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# Sidebar Component
|
|
2
|
+
|
|
3
|
+
## Descripción
|
|
4
|
+
|
|
5
|
+
El componente `Sidebar` es un layout component que proporciona navegación lateral responsive. En desktop muestra un sidebar fijo lateral, mientras que en mobile se convierte automáticamente en un menú Sheet desplegable con icono hamburguesa.
|
|
6
|
+
|
|
7
|
+
## Importación
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import {
|
|
11
|
+
Sidebar,
|
|
12
|
+
SidebarContent,
|
|
13
|
+
SidebarInset,
|
|
14
|
+
SidebarHeader,
|
|
15
|
+
SidebarFooter,
|
|
16
|
+
SidebarMenu,
|
|
17
|
+
SidebarMenuItem,
|
|
18
|
+
} from "@adamosuiteservices/ui/sidebar";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Nota**: Si usas `SidebarMenuItem` con `asChild`, también puedes importar componentes de navegación:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Link } from "react-router-dom"; // o Next.js Link
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Uso Básico
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
<Sidebar>
|
|
31
|
+
<SidebarContent>
|
|
32
|
+
<SidebarHeader>
|
|
33
|
+
{/* Logo o título */}
|
|
34
|
+
</SidebarHeader>
|
|
35
|
+
|
|
36
|
+
<SidebarMenu>
|
|
37
|
+
<SidebarMenuItem>
|
|
38
|
+
<HomeIcon />
|
|
39
|
+
Dashboard
|
|
40
|
+
</SidebarMenuItem>
|
|
41
|
+
<SidebarMenuItem>
|
|
42
|
+
<SettingsIcon />
|
|
43
|
+
Settings
|
|
44
|
+
</SidebarMenuItem>
|
|
45
|
+
</SidebarMenu>
|
|
46
|
+
|
|
47
|
+
<SidebarFooter>
|
|
48
|
+
{/* Usuario o acciones */}
|
|
49
|
+
</SidebarFooter>
|
|
50
|
+
</SidebarContent>
|
|
51
|
+
</Sidebar>
|
|
52
|
+
|
|
53
|
+
<SidebarInset>
|
|
54
|
+
{/* Contenido principal */}
|
|
55
|
+
</SidebarInset>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Componentes
|
|
59
|
+
|
|
60
|
+
### Sidebar (Root)
|
|
61
|
+
|
|
62
|
+
Contenedor principal con context provider.
|
|
63
|
+
|
|
64
|
+
### SidebarContent
|
|
65
|
+
|
|
66
|
+
Contenido del sidebar con Portal para posicionamiento fijo.
|
|
67
|
+
|
|
68
|
+
### SidebarInset
|
|
69
|
+
|
|
70
|
+
Contenedor para el contenido principal que se ajusta al sidebar.
|
|
71
|
+
|
|
72
|
+
### SidebarHeader
|
|
73
|
+
|
|
74
|
+
Sección superior del sidebar.
|
|
75
|
+
|
|
76
|
+
### SidebarFooter
|
|
77
|
+
|
|
78
|
+
Sección inferior del sidebar.
|
|
79
|
+
|
|
80
|
+
### SidebarMenu
|
|
81
|
+
|
|
82
|
+
Contenedor para items de menú con scroll.
|
|
83
|
+
|
|
84
|
+
### SidebarMenuItem
|
|
85
|
+
|
|
86
|
+
Item individual del menú con hover effects.
|
|
87
|
+
|
|
88
|
+
## Responsive
|
|
89
|
+
|
|
90
|
+
- **Desktop (xl+)**: Sidebar fijo lateral (256px de ancho)
|
|
91
|
+
- **Mobile**: Sidebar en Sheet (modal lateral)
|
|
92
|
+
- Incluye icono hamburguesa automático en mobile
|
|
93
|
+
|
|
94
|
+
## Props
|
|
95
|
+
|
|
96
|
+
### Sidebar
|
|
97
|
+
|
|
98
|
+
| Prop | Tipo | Descripción |
|
|
99
|
+
| -------- | ----------- | --------------------------------------------------- |
|
|
100
|
+
| children | `ReactNode` | Contenido del sidebar (debe incluir SidebarContent) |
|
|
101
|
+
|
|
102
|
+
### SidebarContent
|
|
103
|
+
|
|
104
|
+
| Prop | Tipo | Descripción |
|
|
105
|
+
| --------- | ----------------------- | ------------------------------------- |
|
|
106
|
+
| className | `string` | Clases adicionales para el contenedor |
|
|
107
|
+
| children | `ReactNode` | Contenido del sidebar |
|
|
108
|
+
| ...props | `ComponentProps<"div">` | Props nativas de div |
|
|
109
|
+
|
|
110
|
+
### SidebarInset
|
|
111
|
+
|
|
112
|
+
| Prop | Tipo | Descripción |
|
|
113
|
+
| --------- | ----------------------- | ------------------------------------ |
|
|
114
|
+
| className | `string` | Clases adicionales |
|
|
115
|
+
| children | `ReactNode` | Contenido principal de la aplicación |
|
|
116
|
+
| ...props | `ComponentProps<"div">` | Props nativas de div |
|
|
117
|
+
|
|
118
|
+
### SidebarHeader
|
|
119
|
+
|
|
120
|
+
| Prop | Tipo | Descripción |
|
|
121
|
+
| --------- | -------------------------- | ----------------------------------- |
|
|
122
|
+
| className | `string` | Clases adicionales |
|
|
123
|
+
| children | `ReactNode` | Contenido del header (logo, título) |
|
|
124
|
+
| ...props | `ComponentProps<"header">` | Props nativas de header |
|
|
125
|
+
|
|
126
|
+
### SidebarFooter
|
|
127
|
+
|
|
128
|
+
| Prop | Tipo | Descripción |
|
|
129
|
+
| --------- | -------------------------- | -------------------------------------- |
|
|
130
|
+
| className | `string` | Clases adicionales |
|
|
131
|
+
| children | `ReactNode` | Contenido del footer (usuario, logout) |
|
|
132
|
+
| ...props | `ComponentProps<"footer">` | Props nativas de footer |
|
|
133
|
+
|
|
134
|
+
### SidebarMenu
|
|
135
|
+
|
|
136
|
+
| Prop | Tipo | Descripción |
|
|
137
|
+
| --------- | ----------------------- | -------------------------------- |
|
|
138
|
+
| className | `string` | Clases adicionales |
|
|
139
|
+
| children | `ReactNode` | Items del menú (SidebarMenuItem) |
|
|
140
|
+
| ...props | `ComponentProps<"div">` | Props nativas de div |
|
|
141
|
+
|
|
142
|
+
### SidebarMenuItem
|
|
143
|
+
|
|
144
|
+
| Prop | Tipo | Default | Descripción |
|
|
145
|
+
| --------- | -------------------------- | ------- | ----------------------------------------------------------- |
|
|
146
|
+
| asChild | `boolean` | `false` | Si es true, renderiza el hijo directo en lugar de un button |
|
|
147
|
+
| className | `string` | - | Clases adicionales |
|
|
148
|
+
| ...props | `ComponentProps<"button">` | - | Props nativas de button |
|
|
149
|
+
|
|
150
|
+
## Características Principales
|
|
151
|
+
|
|
152
|
+
- **Responsive automático**: Desktop muestra sidebar fijo, mobile usa Sheet con hamburger
|
|
153
|
+
- **Auto-manejo del height**: Previene layout shifts al calcular altura automáticamente
|
|
154
|
+
- **Breakpoint xl (1280px)**: Usa `useMediaQuery` para detectar el cambio
|
|
155
|
+
- **Portal rendering**: Usa Radix Portal para z-index correcto
|
|
156
|
+
- **Sheet integration**: Integración nativa con componente Sheet para mobile
|
|
157
|
+
- **Accesibilidad**: Incluye VisuallyHidden para screen readers
|
|
158
|
+
- **Sticky positioning**: Sidebar fijo en desktop con scroll independiente del contenido
|
|
159
|
+
|
|
160
|
+
## Ejemplo Completo
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
<Sidebar>
|
|
164
|
+
<SidebarContent>
|
|
165
|
+
<SidebarHeader>
|
|
166
|
+
<div className="p-4">
|
|
167
|
+
<h2 className="text-lg font-bold">My App</h2>
|
|
168
|
+
</div>
|
|
169
|
+
</SidebarHeader>
|
|
170
|
+
|
|
171
|
+
<SidebarMenu>
|
|
172
|
+
<SidebarMenuItem asChild>
|
|
173
|
+
<a href="/dashboard">
|
|
174
|
+
<HomeIcon />
|
|
175
|
+
Dashboard
|
|
176
|
+
</a>
|
|
177
|
+
</SidebarMenuItem>
|
|
178
|
+
<SidebarMenuItem asChild>
|
|
179
|
+
<a href="/projects">
|
|
180
|
+
<FolderIcon />
|
|
181
|
+
Projects
|
|
182
|
+
</a>
|
|
183
|
+
</SidebarMenuItem>
|
|
184
|
+
<SidebarMenuItem asChild>
|
|
185
|
+
<a href="/settings">
|
|
186
|
+
<SettingsIcon />
|
|
187
|
+
Settings
|
|
188
|
+
</a>
|
|
189
|
+
</SidebarMenuItem>
|
|
190
|
+
</SidebarMenu>
|
|
191
|
+
|
|
192
|
+
<SidebarFooter>
|
|
193
|
+
<div className="p-4">
|
|
194
|
+
<Button variant="outline" className="w-full">
|
|
195
|
+
<UserIcon />
|
|
196
|
+
Profile
|
|
197
|
+
</Button>
|
|
198
|
+
</div>
|
|
199
|
+
</SidebarFooter>
|
|
200
|
+
</SidebarContent>
|
|
201
|
+
</Sidebar>
|
|
202
|
+
|
|
203
|
+
<SidebarInset>
|
|
204
|
+
<main className="p-6">
|
|
205
|
+
{/* Tu contenido aquí */}
|
|
206
|
+
</main>
|
|
207
|
+
</SidebarInset>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Hook Personalizado
|
|
211
|
+
|
|
212
|
+
### useSidebarContext()
|
|
213
|
+
|
|
214
|
+
Hook para acceder al contexto del Sidebar desde componentes hijos.
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
import { useSidebarContext } from "@adamosuiteservices/ui/sidebar";
|
|
218
|
+
|
|
219
|
+
function CustomSidebarComponent() {
|
|
220
|
+
const { isXl, sidebarHeight, setSidebarHeight } = useSidebarContext();
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<div>
|
|
224
|
+
{isXl ? "Desktop" : "Mobile"}
|
|
225
|
+
<span>Height: {sidebarHeight}</span>
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Retorna**:
|
|
232
|
+
| Propiedad | Tipo | Descripción |
|
|
233
|
+
|-----------|------|-------------|
|
|
234
|
+
| isXl | `boolean` | True si el viewport es >= 1280px |
|
|
235
|
+
| sidebarHeight | `string` | Altura calculada del sidebar ("auto" en desktop, px en mobile) |
|
|
236
|
+
| setSidebarHeight | `Dispatch<SetStateAction<string>>` | Setter para actualizar la altura |
|
|
237
|
+
|
|
238
|
+
**Nota**: Este hook debe usarse dentro de un componente que sea hijo de `<Sidebar>`.
|
|
239
|
+
|
|
240
|
+
## Ejemplos Adicionales
|
|
241
|
+
|
|
242
|
+
### Con React Router
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
import { Link } from "react-router-dom";
|
|
246
|
+
|
|
247
|
+
<SidebarMenu>
|
|
248
|
+
<SidebarMenuItem asChild>
|
|
249
|
+
<Link to="/dashboard">
|
|
250
|
+
<HomeIcon />
|
|
251
|
+
Dashboard
|
|
252
|
+
</Link>
|
|
253
|
+
</SidebarMenuItem>
|
|
254
|
+
<SidebarMenuItem asChild>
|
|
255
|
+
<Link to="/settings">
|
|
256
|
+
<SettingsIcon />
|
|
257
|
+
Settings
|
|
258
|
+
</Link>
|
|
259
|
+
</SidebarMenuItem>
|
|
260
|
+
</SidebarMenu>;
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Con Next.js
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
import Link from "next/link";
|
|
267
|
+
|
|
268
|
+
<SidebarMenu>
|
|
269
|
+
<SidebarMenuItem asChild>
|
|
270
|
+
<Link href="/dashboard">
|
|
271
|
+
<HomeIcon />
|
|
272
|
+
Dashboard
|
|
273
|
+
</Link>
|
|
274
|
+
</SidebarMenuItem>
|
|
275
|
+
</SidebarMenu>;
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Sidebar con Estados Activos
|
|
279
|
+
|
|
280
|
+
```tsx
|
|
281
|
+
const pathname = usePathname(); // Next.js o similar
|
|
282
|
+
|
|
283
|
+
<SidebarMenu>
|
|
284
|
+
<SidebarMenuItem
|
|
285
|
+
asChild
|
|
286
|
+
className={pathname === "/dashboard" ? "bg-white/20" : ""}
|
|
287
|
+
>
|
|
288
|
+
<Link href="/dashboard">
|
|
289
|
+
<HomeIcon />
|
|
290
|
+
Dashboard
|
|
291
|
+
</Link>
|
|
292
|
+
</SidebarMenuItem>
|
|
293
|
+
</SidebarMenu>;
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Personalización de Colores
|
|
297
|
+
|
|
298
|
+
El sidebar usa variables CSS de tema. Puedes personalizarlas:
|
|
299
|
+
|
|
300
|
+
```css
|
|
301
|
+
:root {
|
|
302
|
+
--sidebar-primary: 220 13% 18%;
|
|
303
|
+
--sidebar-primary-foreground: 210 20% 98%;
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Notas de Implementación
|
|
308
|
+
|
|
309
|
+
- El componente usa internamente las clases con prefijo `adm:` para evitar conflictos de estilos
|
|
310
|
+
- `SidebarContent` usa Portal de Radix para renderizar en el top level del DOM
|
|
311
|
+
- El cambio responsive ocurre automáticamente en el breakpoint xl (1280px)
|
|
312
|
+
- En mobile, el Sheet se abre desde la izquierda
|
|
313
|
+
- `SidebarMenuItem` tiene hover effects y padding predefinidos
|
|
314
|
+
- `SidebarMenu` incluye scroll automático si el contenido excede la altura
|
|
315
|
+
- Los componentes usan `data-slot` attributes para debugging y testing
|
|
316
|
+
|
|
317
|
+
## Accesibilidad
|
|
318
|
+
|
|
319
|
+
- ✅ El Sheet en mobile incluye SheetTitle y SheetDescription (ocultos visualmente)
|
|
320
|
+
- ✅ Navegación por teclado soportada en todos los items
|
|
321
|
+
- ✅ Focus visible en items del menú
|
|
322
|
+
- ✅ Semántica HTML correcta (nav, header, footer)
|
|
323
|
+
- ✅ ARIA labels automáticos en el Sheet trigger
|
|
324
|
+
|
|
325
|
+
## Referencias
|
|
326
|
+
|
|
327
|
+
- Similar a shadcn/ui Sidebar pattern
|
|
328
|
+
- Usa Radix UI Portal para rendering
|
|
329
|
+
- Usa Radix UI Sheet para modal mobile
|
|
330
|
+
- Implementa useMediaQuery de @uidotdev/usehooks
|