@adamosuiteservices/ui 1.3.5 → 1.4.6

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.
@@ -11,6 +11,8 @@ import {
11
11
  Sidebar,
12
12
  SidebarContent,
13
13
  SidebarInset,
14
+ SidebarTopBar,
15
+ SidebarTrigger,
14
16
  SidebarHeader,
15
17
  SidebarFooter,
16
18
  SidebarMenu,
@@ -29,30 +31,37 @@ import { Link } from "react-router-dom"; // o Next.js Link
29
31
  ```tsx
30
32
  <Sidebar>
31
33
  <SidebarContent>
32
- <SidebarHeader>
34
+ <SidebarHeader className="adm:items-center">
33
35
  {/* Logo o título */}
34
36
  </SidebarHeader>
35
37
 
36
38
  <SidebarMenu>
37
39
  <SidebarMenuItem>
38
- <HomeIcon />
39
- Dashboard
40
+ <HomeIcon /> Dashboard
40
41
  </SidebarMenuItem>
41
42
  <SidebarMenuItem>
42
- <SettingsIcon />
43
- Settings
43
+ <FolderIcon /> Projects
44
+ </SidebarMenuItem>
45
+ <SidebarMenuItem>
46
+ <SettingsIcon /> Settings
44
47
  </SidebarMenuItem>
45
48
  </SidebarMenu>
46
49
 
47
50
  <SidebarFooter>
48
- {/* Usuario o acciones */}
51
+ <SidebarMenuItem>
52
+ <CircleUserRoundIcon /> Profile
53
+ </SidebarMenuItem>
49
54
  </SidebarFooter>
50
55
  </SidebarContent>
51
- </Sidebar>
52
56
 
53
- <SidebarInset>
54
- {/* Contenido principal */}
55
- </SidebarInset>
57
+ <SidebarInset>
58
+ <SidebarTopBar>
59
+ <h1 className="adm:text-lg adm:font-semibold">Dashboard</h1>
60
+ <SidebarTrigger />
61
+ </SidebarTopBar>
62
+ {/* Contenido principal */}
63
+ </SidebarInset>
64
+ </Sidebar>
56
65
  ```
57
66
 
58
67
  ## Componentes
@@ -69,6 +78,14 @@ Contenido del sidebar con Portal para posicionamiento fijo.
69
78
 
70
79
  Contenedor para el contenido principal que se ajusta al sidebar.
71
80
 
81
+ ### SidebarTopBar
82
+
83
+ Barra superior sticky para el contenido principal, ideal para incluir el trigger del sidebar y el título de la página.
84
+
85
+ ### SidebarTrigger
86
+
87
+ Botón hamburguesa que abre/cierra el sidebar en mobile. Automáticamente oculto en desktop (xl+).
88
+
72
89
  ### SidebarHeader
73
90
 
74
91
  Sección superior del sidebar.
@@ -115,6 +132,25 @@ Item individual del menú con hover effects.
115
132
  | children | `ReactNode` | Contenido principal de la aplicación |
116
133
  | ...props | `ComponentProps<"div">` | Props nativas de div |
117
134
 
135
+ ### SidebarTopBar
136
+
137
+ | Prop | Tipo | Descripción |
138
+ | --------- | ----------------------- | ------------------------------------------------- |
139
+ | className | `string` | Clases adicionales |
140
+ | children | `ReactNode` | Contenido de la barra (trigger, título, acciones) |
141
+ | ...props | `ComponentProps<"div">` | Props nativas de div |
142
+
143
+ **Estilos por defecto**: sticky, top-0, flex, gap-2, items-center, justify-between, bg-background, p-4, border-b
144
+
145
+ ### SidebarTrigger
146
+
147
+ | Prop | Tipo | Descripción |
148
+ | --------- | -------------------------- | ----------------------- |
149
+ | className | `string` | Clases adicionales |
150
+ | ...props | `ComponentProps<"button">` | Props nativas de button |
151
+
152
+ **Comportamiento**: Oculto automáticamente en desktop (xl:hidden). Incluye icono MenuIcon de lucide-react.
153
+
118
154
  ### SidebarHeader
119
155
 
120
156
  | Prop | Tipo | Descripción |
@@ -160,51 +196,61 @@ Item individual del menú con hover effects.
160
196
  ## Ejemplo Completo
161
197
 
162
198
  ```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>
199
+ import {
200
+ Sidebar,
201
+ SidebarContent,
202
+ SidebarFooter,
203
+ SidebarHeader,
204
+ SidebarInset,
205
+ SidebarMenu,
206
+ SidebarMenuItem,
207
+ SidebarTopBar,
208
+ SidebarTrigger,
209
+ } from "@adamosuiteservices/ui/sidebar";
210
+ import {
211
+ CircleUserRoundIcon,
212
+ HomeIcon,
213
+ SettingsIcon,
214
+ FolderIcon,
215
+ } from "lucide-react";
202
216
 
203
- <SidebarInset>
204
- <main className="p-6">
205
- {/* Tu contenido aquí */}
206
- </main>
207
- </SidebarInset>
217
+ export default function AppLayout() {
218
+ return (
219
+ <Sidebar>
220
+ <SidebarContent>
221
+ <SidebarHeader className="adm:items-center">
222
+ <Logo />
223
+ </SidebarHeader>
224
+
225
+ <SidebarMenu>
226
+ <SidebarMenuItem>
227
+ <HomeIcon /> Dashboard
228
+ </SidebarMenuItem>
229
+ <SidebarMenuItem>
230
+ <FolderIcon /> Projects
231
+ </SidebarMenuItem>
232
+ <SidebarMenuItem>
233
+ <SettingsIcon /> Settings
234
+ </SidebarMenuItem>
235
+ </SidebarMenu>
236
+
237
+ <SidebarFooter>
238
+ <SidebarMenuItem>
239
+ <CircleUserRoundIcon /> Profile
240
+ </SidebarMenuItem>
241
+ </SidebarFooter>
242
+ </SidebarContent>
243
+
244
+ <SidebarInset>
245
+ <SidebarTopBar>
246
+ <h1 className="adm:text-lg adm:font-semibold">Dashboard</h1>
247
+ <SidebarTrigger />
248
+ </SidebarTopBar>
249
+ <main className="adm:p-6">{/* Tu contenido aquí */}</main>
250
+ </SidebarInset>
251
+ </Sidebar>
252
+ );
253
+ }
208
254
  ```
209
255
 
210
256
  ## Hook Personalizado
@@ -217,12 +263,13 @@ Hook para acceder al contexto del Sidebar desde componentes hijos.
217
263
  import { useSidebarContext } from "@adamosuiteservices/ui/sidebar";
218
264
 
219
265
  function CustomSidebarComponent() {
220
- const { isXl, sidebarHeight, setSidebarHeight } = useSidebarContext();
266
+ const { isXl, sidebarHeight, sheetOpen, setSheetOpen } = useSidebarContext();
221
267
 
222
268
  return (
223
269
  <div>
224
270
  {isXl ? "Desktop" : "Mobile"}
225
271
  <span>Height: {sidebarHeight}</span>
272
+ <button onClick={() => setSheetOpen(!sheetOpen)}>Toggle Sidebar</button>
226
273
  </div>
227
274
  );
228
275
  }
@@ -234,12 +281,32 @@ function CustomSidebarComponent() {
234
281
  | isXl | `boolean` | True si el viewport es >= 1280px |
235
282
  | sidebarHeight | `string` | Altura calculada del sidebar ("auto" en desktop, px en mobile) |
236
283
  | setSidebarHeight | `Dispatch<SetStateAction<string>>` | Setter para actualizar la altura |
284
+ | sheetOpen | `boolean` | Estado del Sheet en mobile (abierto/cerrado) |
285
+ | setSheetOpen | `Dispatch<SetStateAction<boolean>>` | Setter para controlar el estado del Sheet |
237
286
 
238
287
  **Nota**: Este hook debe usarse dentro de un componente que sea hijo de `<Sidebar>`.
239
288
 
240
289
  ## Ejemplos Adicionales
241
290
 
242
- ### Con React Router
291
+ ### Items Básicos con Iconos
292
+
293
+ El ejemplo principal muestra el uso más simple - items como buttons con iconos:
294
+
295
+ ```tsx
296
+ <SidebarMenu>
297
+ <SidebarMenuItem>
298
+ <HomeIcon /> Dashboard
299
+ </SidebarMenuItem>
300
+ <SidebarMenuItem>
301
+ <FolderIcon /> Projects
302
+ </SidebarMenuItem>
303
+ <SidebarMenuItem>
304
+ <SettingsIcon /> Settings
305
+ </SidebarMenuItem>
306
+ </SidebarMenu>
307
+ ```
308
+
309
+ ### Con React Router (usando asChild)
243
310
 
244
311
  ```tsx
245
312
  import { Link } from "react-router-dom";
@@ -247,20 +314,18 @@ import { Link } from "react-router-dom";
247
314
  <SidebarMenu>
248
315
  <SidebarMenuItem asChild>
249
316
  <Link to="/dashboard">
250
- <HomeIcon />
251
- Dashboard
317
+ <HomeIcon /> Dashboard
252
318
  </Link>
253
319
  </SidebarMenuItem>
254
320
  <SidebarMenuItem asChild>
255
321
  <Link to="/settings">
256
- <SettingsIcon />
257
- Settings
322
+ <SettingsIcon /> Settings
258
323
  </Link>
259
324
  </SidebarMenuItem>
260
325
  </SidebarMenu>;
261
326
  ```
262
327
 
263
- ### Con Next.js
328
+ ### Con Next.js (usando asChild)
264
329
 
265
330
  ```tsx
266
331
  import Link from "next/link";
@@ -268,27 +333,27 @@ import Link from "next/link";
268
333
  <SidebarMenu>
269
334
  <SidebarMenuItem asChild>
270
335
  <Link href="/dashboard">
271
- <HomeIcon />
272
- Dashboard
336
+ <HomeIcon /> Dashboard
273
337
  </Link>
274
338
  </SidebarMenuItem>
275
339
  </SidebarMenu>;
276
340
  ```
277
341
 
278
- ### Sidebar con Estados Activos
342
+ ### Estados Activos
279
343
 
280
344
  ```tsx
281
345
  const pathname = usePathname(); // Next.js o similar
282
346
 
283
347
  <SidebarMenu>
284
348
  <SidebarMenuItem
285
- asChild
286
- className={pathname === "/dashboard" ? "bg-white/20" : ""}
349
+ className={pathname === "/dashboard" ? "adm:bg-white/20" : ""}
287
350
  >
288
- <Link href="/dashboard">
289
- <HomeIcon />
290
- Dashboard
291
- </Link>
351
+ <HomeIcon /> Dashboard
352
+ </SidebarMenuItem>
353
+ <SidebarMenuItem
354
+ className={pathname === "/settings" ? "adm:bg-white/20" : ""}
355
+ >
356
+ <SettingsIcon /> Settings
292
357
  </SidebarMenuItem>
293
358
  </SidebarMenu>;
294
359
  ```
@@ -312,7 +377,16 @@ El sidebar usa variables CSS de tema. Puedes personalizarlas:
312
377
  - En mobile, el Sheet se abre desde la izquierda
313
378
  - `SidebarMenuItem` tiene hover effects y padding predefinidos
314
379
  - `SidebarMenu` incluye scroll automático si el contenido excede la altura
315
- - Los componentes usan `data-slot` attributes para debugging y testing
380
+ - Los componentes usan `data-slot` attributes para debugging y testing:
381
+ - `sidebar` - Contenedor root
382
+ - `sidebar-content` - Contenido principal del sidebar
383
+ - `sidebar-trigger` - Botón hamburguesa para mobile
384
+ - `sidebar-inset` - Contenedor del contenido principal
385
+ - `sidebar-top-bar` - Barra superior (si se usa)
386
+ - `sidebar-header` - Header del sidebar
387
+ - `sidebar-footer` - Footer del sidebar
388
+ - `sidebar-menu` - Contenedor de items del menú
389
+ - `sidebar-menu-item` - Item individual del menú
316
390
 
317
391
  ## Accesibilidad
318
392
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamosuiteservices/ui",
3
- "version": "1.3.5",
3
+ "version": "1.4.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",