xertica-ui 2.0.2 → 2.0.4

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/bin/cli.ts +2 -1
  4. package/components/assistant/markdown-message/markdown-message.mdx +1 -1
  5. package/components/brand/language-selector/language-selector.mdx +1 -1
  6. package/components/brand/theme-toggle/theme-toggle.mdx +1 -1
  7. package/components/brand/xertica-logo/xertica-logo.mdx +1 -1
  8. package/components/brand/xertica-provider/xertica-provider.mdx +1 -1
  9. package/components/brand/xertica-xlogo/xertica-xlogo.mdx +1 -1
  10. package/components/index.ts +6 -0
  11. package/components/layout/header/header.mdx +1 -1
  12. package/components/layout/sidebar/sidebar.mdx +2 -1
  13. package/components/media/floating-media-wrapper.mdx +2 -2
  14. package/components/pages/forgot-password-page/ForgotPasswordPage.tsx +2 -4
  15. package/components/pages/home-content/HomeContent.tsx +1 -1
  16. package/components/pages/home-content/home-content.mdx +1 -1
  17. package/components/pages/home-page/HomePage.stories.tsx +39 -0
  18. package/components/pages/home-page/HomePage.tsx +2 -3
  19. package/components/pages/home-page/home-page.mdx +56 -0
  20. package/components/pages/login-page/LoginPage.tsx +2 -5
  21. package/components/pages/reset-password-page/reset-password-page.mdx +6 -2
  22. package/components/pages/template-page/TemplatePage.stories.tsx +39 -0
  23. package/components/pages/template-page/TemplatePage.tsx +3 -1
  24. package/components/pages/template-page/template-page.mdx +54 -0
  25. package/components/pages/verify-email-page/VerifyEmailPage.tsx +2 -4
  26. package/components/ui/accordion/accordion.stories.tsx +27 -1
  27. package/components/ui/alert-dialog/alert-dialog.stories.tsx +30 -0
  28. package/components/ui/button/button.stories.tsx +23 -0
  29. package/components/ui/checkbox/checkbox.stories.tsx +20 -1
  30. package/components/ui/dialog/dialog.stories.tsx +30 -0
  31. package/components/ui/google-maps-loader/google-maps-loader.mdx +1 -1
  32. package/components/ui/input/input.stories.tsx +24 -0
  33. package/components/ui/switch/switch.stories.tsx +20 -1
  34. package/components/ui/tabs/tabs.stories.tsx +26 -1
  35. package/components.json +1507 -530
  36. package/dist/cli.js +3 -2
  37. package/dist/components/index.d.ts +6 -0
  38. package/dist/index.cjs.js +1233 -484
  39. package/dist/index.es.js +778 -28
  40. package/dist/ui.cjs.js +178 -178
  41. package/dist/ui.es.js +1 -1
  42. package/dist/use-mobile-CaENcqm-.js +4508 -0
  43. package/dist/use-mobile-DMOvImGQ.cjs +4542 -0
  44. package/dist/xertica-ui.css +1 -1
  45. package/docs/decision-tree.md +287 -0
  46. package/guidelines/Guidelines.md +250 -657
  47. package/llms-compact.txt +327 -0
  48. package/llms.txt +160 -71
  49. package/package.json +193 -192
  50. package/templates/CLAUDE.md +160 -0
  51. package/templates/guidelines/Guidelines.md +245 -99
  52. package/templates/package.json +3 -3
@@ -1,657 +1,250 @@
1
- # Xertica UI - Project Guidelines
2
-
3
- ## 📋 Visão Geral do Projeto
4
-
5
- O **Xertica UI** é um Design System completo construído com React e Tailwind CSS v4.0, seguindo uma arquitetura **CLI-first** (modelo shadcn/ui). O sistema está 100% pronto para publicação no NPM e todos os componentes são portáveis, independentes e reutilizáveis.
6
-
7
- ---
8
-
9
- ## 🎨 Design System - Princípios Fundamentais
10
-
11
- ### Variáveis CSS Semânticas
12
-
13
- **REGRA CRÍTICA**: Todos os componentes e páginas DEVEM usar exclusivamente as variáveis CSS definidas em `/styles/xertica/tokens.css`.
14
-
15
- #### Cores
16
- ```css
17
- /* Sempre use as variáveis semânticas */
18
- var(--background)
19
- var(--foreground)
20
- var(--card)
21
- var(--card-foreground)
22
- var(--primary)
23
- var(--primary-foreground)
24
- var(--secondary)
25
- var(--secondary-foreground)
26
- var(--muted)
27
- var(--muted-foreground)
28
- var(--accent)
29
- var(--accent-foreground)
30
- var(--destructive)
31
- var(--destructive-foreground)
32
- var(--border)
33
- var(--input)
34
- var(--ring)
35
- var(--chart-1) até var(--chart-5)
36
- ```
37
-
38
- #### Espaçamentos
39
- ```css
40
- /* Use os tokens de spacing */
41
- var(--spacing-xs) /* 4px */
42
- var(--spacing-sm) /* 8px */
43
- var(--spacing-md) /* 16px */
44
- var(--spacing-lg) /* 24px */
45
- var(--spacing-xl) /* 32px */
46
- var(--spacing-2xl) /* 48px */
47
- var(--spacing-3xl) /* 64px */
48
- ```
49
-
50
- #### Bordas e Raios
51
- ```css
52
- var(--radius) /* Border radius padrão */
53
- var(--radius-sm) /* Border radius pequeno */
54
- var(--radius-lg) /* Border radius grande */
55
- var(--radius-full) /* Border radius circular */
56
- ```
57
-
58
- #### Tipografia
59
-
60
- **REGRA CRÍTICA**: Apenas a fonte **Roboto** pode ser utilizada (definida em `/styles/globals.css`).
61
-
62
- ```css
63
- /* Importado no globals.css */
64
- @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600;700;800&display=swap');
65
-
66
- /* Font weights disponíveis */
67
- font-weight: 400; /* Regular */
68
- font-weight: 500; /* Medium */
69
- font-weight: 600; /* Semibold */
70
- font-weight: 700; /* Bold */
71
- font-weight: 800; /* Extra Bold */
72
- ```
73
-
74
- **NÃO use** classes Tailwind para font-size, font-weight ou line-height, **A MENOS** que o usuário solicite explicitamente.
75
-
76
- ---
77
-
78
- ## 🧩 Componentes do Design System
79
-
80
- ### Localização
81
- Todos os componentes do Design System estão em `/components/ui/` (156 componentes disponíveis).
82
-
83
- ### Regra de Ouro: REUTILIZE, NÃO RECRIE
84
-
85
- **SEMPRE**:
86
- 1. Use componentes existentes em `/components/ui/`
87
- 2. ✅ Consulte os componentes disponíveis antes de criar novos
88
- 3. Combine componentes existentes para criar funcionalidades complexas
89
- 4. ✅ Estenda componentes existentes com props adicionais se necessário
90
-
91
- **NUNCA**:
92
- 1. Crie versões personalizadas de componentes que existem
93
- 2. ❌ Crie componentes inline que duplicam funcionalidades existentes
94
- 3. ❌ Ignore os componentes do design system
95
-
96
- ### Componentes Principais Disponíveis
97
-
98
- #### Layout & Estrutura
99
- - `Card`, `CardHeader`, `CardTitle`, `CardContent`, `CardFooter`
100
- - `Separator`
101
- - `ScrollArea`
102
- - `Sheet`
103
- - `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent`
104
- - `Accordion`, `AccordionItem`, `AccordionTrigger`, `AccordionContent`
105
- - `Collapsible`
106
- - `Resizable`, `ResizablePanel`, `ResizablePanelGroup`, `ResizableHandle`
107
-
108
- #### Navegação
109
- - `Breadcrumb`
110
- - `NavigationMenu`
111
- - `Menubar`
112
- - `Sidebar` (componente especializado do Xertica)
113
- - `PageHeader` (componente especializado do Xertica)
114
-
115
- #### Formulários
116
- - `Input`
117
- - `Textarea`
118
- - `Select`, `SelectTrigger`, `SelectValue`, `SelectContent`, `SelectItem`
119
- - `Checkbox`
120
- - `RadioGroup`, `RadioGroupItem`
121
- - `Switch`
122
- - `Slider`
123
- - `Calendar`
124
- - `Form`, `FormField`, `FormItem`, `FormLabel`, `FormControl`, `FormMessage`
125
- - `Label`
126
- - `InputOTP`
127
- - `FileUpload`
128
- - `Search`
129
-
130
- #### Botões & Ações
131
- - `Button` (variants: default, destructive, outline, secondary, ghost, link)
132
- - `Toggle`, `ToggleGroup`
133
- - `DropdownMenu`
134
- - `ContextMenu`
135
-
136
- #### Feedback
137
- - `Alert`, `AlertTitle`, `AlertDescription`
138
- - `AlertDialog`
139
- - `Dialog`, `DialogTrigger`, `DialogContent`, `DialogHeader`, `DialogTitle`, `DialogDescription`, `DialogFooter`
140
- - `Drawer`
141
- - `toast` (Sonner)
142
- - `Progress`
143
- - `Skeleton`
144
- - `Badge`
145
- - `NotificationBadge`
146
-
147
- #### Dados & Visualização
148
- - `Table`, `TableHeader`, `TableBody`, `TableRow`, `TableCell`
149
- - `Chart` (Recharts integration)
150
- - `StatsCard`
151
- - `Avatar`, `AvatarImage`, `AvatarFallback`
152
- - `Empty`
153
- - `Rating`
154
- - `Timeline`
155
- - `TreeView`
156
-
157
- #### Navegação & Tour
158
- - `Stepper`, `StepperItem`
159
- - `Pagination`
160
- - `Command`, `CommandInput`, `CommandList`, `CommandItem`, `CommandGroup`
161
-
162
- #### Overlays
163
- - `Tooltip`, `TooltipTrigger`, `TooltipContent`, `TooltipProvider`
164
- - `Popover`, `PopoverTrigger`, `PopoverContent`
165
- - `HoverCard`, `HoverCardTrigger`, `HoverCardContent`
166
-
167
- #### Especialidades Xertica
168
- - `Map`, `SimpleMap`, `RouteMap` (Google Maps integration)
169
- - `XerticaAssistant` (Assistente IA integrado)
170
-
171
- ---
172
-
173
- ## 🎯 Ícones
174
-
175
- **REGRA CRÍTICA**: Apenas ícones do **lucide-react** podem ser utilizados.
176
-
177
- ```tsx
178
- import { Home, User, Settings, FileText, ChevronRight, Menu } from 'lucide-react';
179
-
180
- // Uso
181
- <Home className="w-5 h-5" />
182
- <Settings className="w-6 h-6 text-primary" />
183
- ```
184
-
185
- **NÃO use**:
186
- - Font Awesome
187
- - Material Icons
188
- - SVGs customizados (a menos que absolutamente necessário)
189
- - ❌ Qualquer outra biblioteca de ícones
190
-
191
- ---
192
-
193
- ## 📄 Estrutura de Páginas
194
-
195
- ### Anatomia de uma Página Padrão
196
-
197
- Todas as páginas devem seguir esta estrutura:
198
-
199
- ```tsx
200
- import React from 'react';
201
- import { Card, CardContent, CardHeader, CardTitle } from './ui/card';
202
- import { Button } from './ui/button';
203
- import { ScrollArea } from './ui/scroll-area';
204
- import { ChevronRight, Menu, IconName } from 'lucide-react';
205
- import { useLocation, useNavigate } from 'react-router-dom';
206
- import { getRouteByPath } from '../routes';
207
- import { ThemeToggle } from './ThemeToggle';
208
- import { LanguageSelector } from './LanguageSelector';
209
- import { PageHeader } from './ui/page-header';
210
-
211
- interface PageContentProps {
212
- sidebarExpanded: boolean;
213
- assistenteExpanded?: boolean;
214
- onToggleSidebar?: () => void;
215
- onToggleAssistente?: () => void;
216
- }
217
-
218
- export function PageContent({
219
- sidebarExpanded,
220
- assistenteExpanded = false,
221
- onToggleSidebar,
222
- onToggleAssistente
223
- }: PageContentProps) {
224
- const location = useLocation();
225
- const navigate = useNavigate();
226
-
227
- const currentRoute = getRouteByPath(location.pathname);
228
- const breadcrumbLabel = currentRoute?.label || 'Página';
229
-
230
- return (
231
- <div
232
- className={`flex-1 flex flex-col overflow-hidden transition-all duration-300 ${
233
- sidebarExpanded ? 'md:pl-64' : 'md:pl-20'
234
- } ${
235
- assistenteExpanded ? 'md:pr-[420px]' : 'md:pr-20'
236
- }`}
237
- >
238
- {/* Header fixo */}
239
- <header className="bg-card shadow-sm border-b border-border px-[24px] py-[14px] flex-shrink-0">
240
- <div className="flex items-center justify-between p-[0px]">
241
- <div className="flex items-center gap-2 text-muted-foreground">
242
- <Button
243
- variant="ghost"
244
- size="sm"
245
- onClick={onToggleSidebar}
246
- className="md:hidden mr-2 p-2"
247
- >
248
- <Menu className="w-5 h-5" />
249
- </Button>
250
- <span className="text-primary font-medium">Xertica.ai</span>
251
- <ChevronRight className="w-4 h-4" />
252
- <span className="text-foreground font-medium">{breadcrumbLabel}</span>
253
- </div>
254
-
255
- <div className="flex items-center gap-3">
256
- <LanguageSelector variant="minimal" showIcon={false} className="hidden sm:flex" />
257
- <ThemeToggle className="hover:bg-accent" />
258
- </div>
259
- </div>
260
- </header>
261
-
262
- {/* Área de conteúdo */}
263
- <main className="flex-1 overflow-hidden bg-muted">
264
- <ScrollArea className="h-full">
265
- <div className="p-2 sm:p-4 md:p-6">
266
- <div className="max-w-6xl mx-auto space-y-8">
267
- {/* Cabeçalho da página */}
268
- <PageHeader
269
- title="Título da Página"
270
- subtitle="Descrição da página"
271
- />
272
-
273
- {/* Conteúdo principal */}
274
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
275
- {/* Cards e conteúdo aqui */}
276
- </div>
277
- </div>
278
- </div>
279
- </ScrollArea>
280
- </main>
281
- </div>
282
- );
283
- }
284
- ```
285
-
286
- ### Componentes Obrigatórios de uma Página
287
-
288
- 1. **Header** com breadcrumb
289
- 2. **Menu toggle** para mobile
290
- 3. **ThemeToggle** e **LanguageSelector**
291
- 4. **ScrollArea** para conteúdo scrollável
292
- 5. **Responsividade** para sidebar e assistente
293
- 6. **Espaçamento padronizado** (`p-2 sm:p-4 md:p-6`)
294
- 7. **Container centralizado** (`max-w-6xl mx-auto`)
295
-
296
- ---
297
-
298
- ## 🗂️ Hierarquia e Navegação
299
-
300
- ### Páginas Primárias (Top-Level)
301
-
302
- Quando criar uma **nova página primária**:
303
-
304
- #### 1. Criar o arquivo da página
305
- ```
306
- /components/MinhaNovaPage.tsx
307
- /components/MinhaNovaContent.tsx
308
- ```
309
-
310
- #### 2. Adicionar rota em `/routes.tsx`
311
- ```tsx
312
- import { MinhaIcon } from 'lucide-react';
313
-
314
- export const routes: RouteConfig[] = [
315
- {
316
- path: '/home',
317
- label: 'Home',
318
- icon: Home,
319
- },
320
- {
321
- path: '/minha-nova-pagina',
322
- label: 'Minha Nova Página',
323
- icon: MinhaIcon,
324
- },
325
- // ... outras rotas
326
- ];
327
- ```
328
-
329
- #### 3. Adicionar ao Sidebar (`/components/Sidebar.tsx`)
330
- O Sidebar lê automaticamente de `routes.tsx`, mas verifique se está sendo renderizado corretamente.
331
-
332
- #### 4. Adicionar card na Home (`/components/HomeContent.tsx`)
333
- ```tsx
334
- <Card className="hover:shadow-xl transition-shadow duration-200 flex flex-col h-full">
335
- <CardHeader>
336
- <div className="flex items-center gap-3">
337
- <div className="p-2 bg-[var(--chart-2)]/20 rounded-[var(--radius)]">
338
- <MinhaIcon className="w-6 h-6 text-[var(--chart-2)]" />
339
- </div>
340
- <CardTitle className="text-sm">Minha Nova Página</CardTitle>
341
- </div>
342
- </CardHeader>
343
- <CardContent className="flex-1">
344
- <p className="text-muted-foreground">
345
- Descrição da funcionalidade
346
- </p>
347
- </CardContent>
348
- <CardFooter>
349
- <Button
350
- variant="outline"
351
- className="w-full"
352
- onClick={() => navigate('/minha-nova-pagina')}
353
- >
354
- Acessar
355
- </Button>
356
- </CardFooter>
357
- </Card>
358
- ```
359
-
360
- #### 5. Adicionar roteamento em `/App.tsx`
361
- ```tsx
362
- import { MinhaNovaPage } from './components/MinhaNovaPage';
363
-
364
- // No componente App
365
- {location.pathname === '/minha-nova-pagina' && (
366
- <MinhaNovaPage
367
- sidebarExpanded={sidebarExpanded}
368
- assistenteExpanded={assistenteExpanded}
369
- onToggleSidebar={toggleSidebar}
370
- onToggleAssistente={toggleAssistente}
371
- />
372
- )}
373
- ```
374
-
375
- ### Sub-Páginas (Nested Routes)
376
-
377
- Quando criar uma **sub-página**:
378
-
379
- #### 1. Estrutura de arquivos
380
- ```
381
- /components/PaginaPrincipal.tsx
382
- /components/PaginaPrincipalContent.tsx
383
- /components/SubPagina.tsx (se necessário página separada)
384
- ```
385
-
386
- #### 2. Adicionar ao routes.tsx com hierarquia
387
- ```tsx
388
- export const routes: RouteConfig[] = [
389
- {
390
- path: '/pagina-principal',
391
- label: 'Página Principal',
392
- icon: MainIcon,
393
- children: [
394
- {
395
- path: '/pagina-principal/sub-pagina',
396
- label: 'Sub Página',
397
- icon: SubIcon,
398
- }
399
- ]
400
- },
401
- ];
402
- ```
403
-
404
- #### 3. Renderizar sub-navegação na página pai
405
- ```tsx
406
- // Na PaginaPrincipalContent.tsx
407
- <Tabs defaultValue="overview">
408
- <TabsList>
409
- <TabsTrigger value="overview">Visão Geral</TabsTrigger>
410
- <TabsTrigger value="sub-pagina">Sub Página</TabsTrigger>
411
- </TabsList>
412
-
413
- <TabsContent value="overview">
414
- {/* Conteúdo principal */}
415
- </TabsContent>
416
-
417
- <TabsContent value="sub-pagina">
418
- {/* Conteúdo da sub-página */}
419
- </TabsContent>
420
- </Tabs>
421
- ```
422
-
423
- #### 4. Ou usar navegação tradicional
424
- ```tsx
425
- <Button onClick={() => navigate('/pagina-principal/sub-pagina')}>
426
- Ir para Sub Página
427
- </Button>
428
- ```
429
-
430
- ---
431
-
432
- ## 🎨 Tailwind CSS v4.0
433
-
434
- ### Uso Correto
435
-
436
- **SEMPRE**:
437
- - ✅ Use classes utilitárias do Tailwind
438
- - ✅ Use arbitrary values quando necessário: `bg-[var(--primary)]`
439
- - ✅ Use variáveis CSS: `text-[var(--foreground)]`
440
- - ✅ Use classes responsivas: `md:grid-cols-2 lg:grid-cols-3`
441
-
442
- **NUNCA**:
443
- - ❌ Crie classes CSS customizadas (exceto em casos extremos)
444
- - ❌ Use inline styles (use classes Tailwind)
445
- - ❌ Modifique `/styles/xertica/tokens.css` sem aprovação
446
- - ❌ Crie `tailwind.config.js` (estamos usando v4.0)
447
-
448
- ### Classes Proibidas (a menos que solicitado)
449
- ```css
450
- /* NÃO use sem solicitação explícita */
451
- text-xl, text-2xl, text-3xl /* Font sizes */
452
- font-bold, font-semibold /* Font weights */
453
- leading-tight, leading-relaxed /* Line heights */
454
- ```
455
-
456
- ---
457
-
458
- ## 📦 Bibliotecas e Imports
459
-
460
- ### Bibliotecas Aprovadas
461
-
462
- #### Ícones (OBRIGATÓRIO)
463
- ```tsx
464
- import { IconName } from 'lucide-react';
465
- ```
466
-
467
- #### Gráficos
468
- ```tsx
469
- import { ... } from 'recharts';
470
- ```
471
-
472
- #### Animações
473
- ```tsx
474
- import { motion } from 'motion/react'; // Nome atualizado (não Framer Motion)
475
- ```
476
-
477
- #### Carrosséis
478
- ```tsx
479
- import { ... } from 'react-slick';
480
- ```
481
-
482
- #### Drag & Drop
483
- ```tsx
484
- import { ... } from 'react-dnd';
485
- ```
486
-
487
- #### Formulários
488
- ```tsx
489
- import { ... } from 'react-hook-form@7.55.0'; // Versão específica obrigatória
490
- ```
491
-
492
- #### Toast
493
- ```tsx
494
- import { toast } from 'sonner@2.0.3'; // Versão específica obrigatória
495
- ```
496
-
497
- ### Bibliotecas Proibidas
498
- - ❌ `konva` / `react-konva` (não suportado)
499
- - ❌ `react-resizable` (use `re-resizable` ao invés)
500
- - ❌ Qualquer biblioteca de ícones além do `lucide-react`
501
-
502
- ---
503
-
504
- ## 🔄 Temas e Troca de Tema
505
-
506
- O sistema suporta troca de temas via atributo `data-theme` no root:
507
-
508
- ```tsx
509
- // Uso do ThemeToggle
510
- import { ThemeToggle } from './ThemeToggle';
511
-
512
- <ThemeToggle />
513
- ```
514
-
515
- Temas disponíveis são gerenciados em `/styles/xertica/theme-map.css`.
516
-
517
- ---
518
-
519
- ## 🌐 Internacionalização
520
-
521
- O sistema possui suporte a múltiplos idiomas:
522
-
523
- ```tsx
524
- import { LanguageSelector } from './LanguageSelector';
525
-
526
- <LanguageSelector variant="minimal" showIcon={false} />
527
- ```
528
-
529
- ---
530
-
531
- ## 📝 Boas Práticas Gerais
532
-
533
- ### Estrutura de Arquivos
534
- ```
535
- /components/
536
- /ui/ ← Componentes do Design System (NÃO MODIFICAR)
537
- /examples/ ← Exemplos de uso
538
- /media/ ← Componentes de mídia
539
- MinhaPage.tsx ← Página wrapper
540
- MinhaPageContent.tsx ← Conteúdo da página
541
- ```
542
-
543
- ### Nomenclatura
544
- - **Páginas**: `NomePage.tsx` e `NomePageContent.tsx`
545
- - **Componentes**: `PascalCase.tsx`
546
- - **Utilitários**: `camelCase.ts`
547
- - **Rotas**: `kebab-case` (`/minha-pagina`)
548
-
549
- ### Imports
550
- ```tsx
551
- // Componentes UI (sempre de /ui/)
552
- import { Button } from './ui/button';
553
- import { Card, CardHeader } from './ui/card';
554
-
555
- // Ícones (sempre lucide-react)
556
- import { Home, Settings } from 'lucide-react';
557
-
558
- // Contextos
559
- import { useTheme } from '../contexts/ThemeContext';
560
-
561
- // Router
562
- import { useNavigate, useLocation } from 'react-router-dom';
563
- ```
564
-
565
- ### Responsividade
566
- Sempre use breakpoints mobile-first:
567
- ```tsx
568
- className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3"
569
- className="p-2 sm:p-4 md:p-6"
570
- className="text-sm md:text-base"
571
- ```
572
-
573
- ### Acessibilidade
574
- - Use labels em inputs
575
- - Use aria-labels quando necessário
576
- - Mantenha contraste adequado (use variáveis do design system)
577
- - Suporte navegação por teclado
578
-
579
- ---
580
-
581
- ## 🚀 CLI-Ready e Portabilidade
582
-
583
- ### Princípios CLI-First
584
-
585
- Todos os componentes devem:
586
- 1. ✅ Ser independentes e não depender de CSS global oculto
587
- 2. ✅ Usar apenas variáveis CSS semânticas de `tokens.css`
588
- 3. ✅ Funcionar quando copiados para outro projeto
589
- 4. ✅ Ter zero dependências de arquivos externos (exceto tokens.css)
590
- 5. ✅ Ser publicáveis no NPM sem modificações
591
-
592
- ### Overrides Opt-in
593
-
594
- Componentes podem ter overrides específicos usando atributos `data-*`:
595
-
596
- ```tsx
597
- <div data-xertica-chat="true">
598
- {/* Componente com estilo específico de chat */}
599
- </div>
600
- ```
601
-
602
- Esses overrides são definidos em `/styles/xertica/app-overrides/`.
603
-
604
- ---
605
-
606
- ## ✅ Checklist: Antes de Criar Algo Novo
607
-
608
- Antes de criar qualquer componente ou página:
609
-
610
- - [ ] Consultei `/components/ui/` para ver se já existe?
611
- - [ ] Posso combinar componentes existentes ao invés de criar novo?
612
- - [ ] Estou usando APENAS variáveis CSS de `tokens.css`?
613
- - [ ] Estou usando APENAS ícones do `lucide-react`?
614
- - [ ] Estou usando a fonte Roboto (definida em globals.css)?
615
- - [ ] Segui a estrutura padrão de página (header, sidebar, conteúdo)?
616
- - [ ] Adicionei a rota em `routes.tsx`?
617
- - [ ] Adicionei card na Home (se página primária)?
618
- - [ ] Adicionei roteamento em `App.tsx`?
619
- - [ ] Testei responsividade (mobile, tablet, desktop)?
620
- - [ ] O componente é portável e CLI-ready?
621
-
622
- ---
623
-
624
- ## 🎓 Exemplos de Referência
625
-
626
- ### Páginas Exemplo
627
- - `/components/HomePage.tsx` e `/components/HomeContent.tsx`
628
- - `/components/TemplatePage.tsx` e `/components/TemplateContent.tsx`
629
- - `/components/LoginPage.tsx`
630
-
631
- ### Componentes Complexos
632
- - `/components/Sidebar.tsx` (navegação com subitens)
633
- - `/components/AssistenteXertica.tsx` (painel lateral)
634
- - `/components/ui/xertica-assistant.tsx` (componente especializado)
635
-
636
- ### Uso de Componentes UI
637
- - `/components/examples/` (diversos exemplos de componentes)
638
-
639
- ---
640
-
641
- ## 📌 Notas Finais
642
-
643
- Este Design System foi construído para ser:
644
- - **Consistente**: Todos usam as mesmas variáveis e componentes
645
- - **Escalável**: Fácil adicionar novas páginas e funcionalidades
646
- - **Portável**: Componentes funcionam em qualquer projeto React
647
- - **Profissional**: Pronto para publicação no NPM
648
- - **Manutenível**: Estrutura clara e bem documentada
649
-
650
- **Lembre-se**: Quando em dúvida, consulte os componentes existentes e siga os padrões estabelecidos. A consistência é a chave para um Design System de sucesso.
651
-
652
- ---
653
-
654
- **Última atualização**: Janeiro 2025
655
- **Versão**: 1.1.0
656
- **Arquitetura**: CLI-First (modelo shadcn/ui)
657
- **Status**: 100% CLI-Ready | Pronto para NPM
1
+ # Xertica UI Library Guidelines
2
+
3
+ > **Scope**: These guidelines apply to contributors developing the `xertica-ui` package itself (components, documentation, build system). For guidelines on projects that **consume** the package, see `templates/guidelines/Guidelines.md`.
4
+
5
+ ---
6
+
7
+ ## 1. What Xertica UI Is
8
+
9
+ Xertica UI is an enterprise-grade React component library distributed as an npm package. It is designed to be consumed by both human developers and AI coding agents (LLMs, Cursor, Claude Code, Copilot). Every design decision — from the component API to the documentation format — must serve both audiences.
10
+
11
+ **Stack:** React 18 · TypeScript 5 · Tailwind CSS v4 · Radix UI · Lucide React · Vite 6
12
+
13
+ ---
14
+
15
+ ## 2. AI-First Documentation
16
+
17
+ Documentation is a first-class deliverable. Every component ships with:
18
+
19
+ | File | Purpose | Location |
20
+ |---|---|---|
21
+ | `llms.txt` | Index file following the llmstxt.org standard. Links to all docs. | `/llms.txt` |
22
+ | `llms-compact.txt` | ~4K token quick reference. Critical rules, imports, 12 key components with examples. | `/llms-compact.txt` |
23
+ | `llms-full.txt` | Complete documentation of all 97 components in one file for large-context LLMs. | `/llms-full.txt` |
24
+ | `components.json` | Machine-readable registry: name, category, import path, keywords, related components. | `/components.json` |
25
+ | `docs/decision-tree.md` | Decision trees: Dialog vs Sheet, Tooltip vs HoverCard, etc. | `/docs/decision-tree.md` |
26
+ | `docs/components/[name].md` | Individual component reference with props, examples, and AI rules. | `/docs/components/` |
27
+ | `docs/ai-usage.md` | Mandatory rules for AI agents operating on this library. | `/docs/ai-usage.md` |
28
+ | `CLAUDE.md` | Auto-generated system prompt for consumer projects (injected by CLI). | `/templates/CLAUDE.md` |
29
+
30
+ ### When to update documentation
31
+
32
+ Every PR that changes a component **must** update:
33
+ - `docs/components/[name].md` — if props, behavior, or examples changed
34
+ - `llms-full.txt` — the relevant component section
35
+ - `components.json` — if the component name, import path, or description changed
36
+ - `CHANGELOG.md` — under the current unreleased version
37
+
38
+ ---
39
+
40
+ ## 3. Package Structure
41
+
42
+ ```
43
+ xertica-ui/
44
+ ├── components/ # Source components (ships in package)
45
+ │ ├── ui/ # Design system primitives
46
+ ├── layout/ # Sidebar, Header
47
+ ├── brand/ # XerticaProvider, logos, ThemeToggle
48
+ │ ├── assistant/ # XerticaAssistant, MarkdownMessage, CodeBlock
49
+ │ ├── media/ # VideoPlayer, AudioPlayer
50
+ │ ├── pages/ # Full-page template components
51
+ │ └── shared/ # Internal utils (use-mobile, assistant-utils)
52
+ ├── contexts/ # React contexts (LayoutContext, ThemeContext, etc.)
53
+ ├── hooks/ # Hook re-exports
54
+ ├── utils/ # Utility functions (demo-responses, gemini)
55
+ ├── styles/ # Global CSS and token maps
56
+ ├── templates/ # CLI scaffold template (FSD/FDA project)
57
+ ├── bin/ # CLI source and compiled output
58
+ ├── dist/ # Compiled library (ES + CJS + CSS + types)
59
+ ├── docs/ # Markdown docs (ships in package for AI agents)
60
+ ├── llms.txt # AI documentation index
61
+ ├── llms-compact.txt # Compact AI reference
62
+ ├── llms-full.txt # Full AI documentation
63
+ └── components.json # Machine-readable component registry
64
+ ```
65
+
66
+ ### Why source ships with the package
67
+
68
+ The `components/` directory is intentionally included in the npm package (via the `files` field in `package.json`). AI agents running in consumer projects can inspect source, stories, and documentation directly from `node_modules/xertica-ui/`. This is the primary AI-first design decision.
69
+
70
+ ---
71
+
72
+ ## 4. Subpath Exports
73
+
74
+ The package exposes 7 entry points. Always use the most specific subpath:
75
+
76
+ ```tsx
77
+ import { Button, Card, Input } from 'xertica-ui/ui';
78
+ import { Sidebar, Header } from 'xertica-ui/layout';
79
+ import { XerticaProvider, XerticaLogo } from 'xertica-ui/brand';
80
+ import { XerticaAssistant } from 'xertica-ui/assistant';
81
+ import { VideoPlayer, AudioPlayer } from 'xertica-ui/media';
82
+ import { useLayout, useTheme } from 'xertica-ui/hooks';
83
+ import 'xertica-ui/style.css'; // once, at root
84
+ ```
85
+
86
+ The root `from 'xertica-ui'` exports everything and remains supported for backward compatibility.
87
+
88
+ ### Adding a new export to a subpath
89
+
90
+ 1. Add the export to the relevant barrel (`components/[category]/index.ts`)
91
+ 2. Verify it appears in the compiled `dist/[category].es.js` after `npm run build`
92
+ 3. If adding a new top-level category, also update `vite.config.ts` (`lib.entry`) and `package.json` (`exports`)
93
+
94
+ ---
95
+
96
+ ## 5. Design Tokens — Rules for Component Authors
97
+
98
+ All components must use semantic CSS tokens exclusively. Never hardcode colors, radii, or shadows:
99
+
100
+ ```tsx
101
+ // ✅ Correct
102
+ className="bg-primary text-primary-foreground rounded-[var(--radius)]"
103
+
104
+ // Wrong
105
+ className="bg-blue-600 text-white rounded-lg"
106
+ style={{ backgroundColor: '#3b82f6' }}
107
+ ```
108
+
109
+ ### Token reference
110
+
111
+ ```
112
+ bg-background / text-foreground Page background and body text
113
+ bg-card / text-card-foreground Card surfaces
114
+ bg-muted / text-muted-foreground Subdued backgrounds and secondary text
115
+ bg-primary / text-primary-foreground Primary actions and active states
116
+ bg-secondary / text-secondary-fg Secondary actions
117
+ bg-destructive Danger / error states
118
+ bg-accent / text-accent-foreground Hover states
119
+ bg-success / bg-info / bg-warning Semantic state colors
120
+ border-border Standard borders
121
+ border-input Form field borders
122
+ ring-ring Focus rings
123
+ ```
124
+
125
+ ### Border radius
126
+
127
+ Always use `rounded-[var(--radius)]` — never `rounded-sm`, `rounded-lg`, or any fixed radius class. The radius is a brand token that must be overridable by consumers.
128
+
129
+ ---
130
+
131
+ ## 6. Component Authoring Rules
132
+
133
+ ### Non-negotiable
134
+
135
+ - **Never use native HTML interactive elements** where a library component exists. `<Button>` wraps `<button>`, `<Input>` wraps `<input>`. New components must follow the same pattern.
136
+ - **All interactive components must be keyboard navigable** and follow ARIA patterns. Build on Radix UI primitives.
137
+ - **Icons come from `lucide-react` only.** No custom SVGs, no other icon libraries.
138
+ - **No raw inline styles** (except for dynamic values like `sidebarWidth` that genuinely require them).
139
+
140
+ ### Component file structure
141
+
142
+ ```
143
+ components/ui/my-component/
144
+ index.ts ← public re-exports only
145
+ my-component.tsx ← implementation
146
+ my-component.stories.tsx
147
+ my-component.mdx
148
+ my-component.test.tsx
149
+ ```
150
+
151
+ ### Stories requirements
152
+
153
+ Every component must have:
154
+ - A `Default` story showing the most common usage
155
+ - Stories for all major prop variants
156
+ - An MDX page with: overview, when to use / not to use, props table, examples, AI Rules
157
+
158
+ ### AI Rules section (mandatory in every component doc)
159
+
160
+ The `## AI Rules` section at the bottom of every `docs/components/[name].md` must contain:
161
+ - What the agent must NEVER do with this component
162
+ - What the agent must ALWAYS do
163
+ - Common mistakes the AI makes and their correct form
164
+
165
+ ---
166
+
167
+ ## 7. Adding a New Component
168
+
169
+ 1. Create `components/ui/[name]/` with the 4 required files (source, stories, mdx, test)
170
+ 2. Export from `components/ui/index.ts`
171
+ 3. Create `docs/components/[name].md` following the existing format
172
+ 4. Add an entry to `components.json` with all fields: `name`, `docPath`, `sourcePath`, `description`, `category`, `import`, `keywords`, `relatedComponents`
173
+ 5. Add the component to the relevant section of `llms-full.txt`
174
+ 6. Add a one-line entry to `llms.txt` under the correct category
175
+ 7. Update `llms-compact.txt` if the component is commonly used
176
+ 8. Update `docs/decision-tree.md` if it overlaps with existing components
177
+ 9. Update the component count in `README.md`, `llms.txt`, `llms-full.txt`, and `docs/llms.md`
178
+ 10. Add a `CHANGELOG.md` entry
179
+
180
+ ---
181
+
182
+ ## 8. Build System
183
+
184
+ ```bash
185
+ npm run build # Vite multi-entry build (ES + CJS, 7 entry points)
186
+ npm run build:types # tsc declarations → dist/components/**/*.d.ts
187
+ npm run build:cli # tsup CLI build → dist/cli.js
188
+ npm run build:production # alias for npm run build
189
+ ```
190
+
191
+ **prepublishOnly** runs all three in sequence automatically on `npm publish`.
192
+
193
+ ### Multi-entry build
194
+
195
+ `vite.config.ts` uses `lib.entry` as an object with 7 keys. Output files follow `[entryName].[format].js`. UMD is NOT used (Vite does not support multi-entry + UMD). Format is `["es", "cjs"]`.
196
+
197
+ ### TypeScript declarations
198
+
199
+ `tsconfig.build.json` compiles declarations. It includes `components/**/*`, `contexts/**/*`, `hooks/**/*`. The `dist/components/` structure mirrors the source and is referenced by the `types` fields in `package.json` exports.
200
+
201
+ ---
202
+
203
+ ## 9. CLI
204
+
205
+ The CLI (`bin/cli.ts`) scaffolds new projects via `npx xertica-ui@latest init`.
206
+
207
+ **What the CLI does:**
208
+ 1. Copies root config files from `templates/`
209
+ 2. Copies `CLAUDE.md` to the project root (AI system prompt)
210
+ 3. Copies `src/app/` (App.tsx, AppLayout.tsx)
211
+ 4. Copies `src/shared/` (navigation.ts, auth.ts, types)
212
+ 5. Copies selected `src/features/` (auth, home, template)
213
+ 6. Copies selected `src/pages/` thin wrappers
214
+ 7. Generates a tailored `AuthGuard.tsx` based on selected pages
215
+ 8. Generates `src/styles/xertica/tokens.css` for the chosen color theme
216
+
217
+ **`update` command** lets users update theme only or update all project files to a specific version of `xertica-ui`.
218
+
219
+ ---
220
+
221
+ ## 10. Versioning
222
+
223
+ This project follows [Semantic Versioning](https://semver.org/):
224
+
225
+ - **Patch** (2.0.x): Bug fixes, doc updates, export additions that don't break anything
226
+ - **Minor** (2.x.0): New components, new subpath exports, new CLI features
227
+ - **Major** (x.0.0): Breaking changes to component APIs, token renames, export removals
228
+
229
+ Every version bump must:
230
+ 1. Update `version` in `package.json`
231
+ 2. Update `.version()` in `bin/cli.ts`
232
+ 3. Update the version badge in `README.md`
233
+ 4. Add a `CHANGELOG.md` entry with Added / Changed / Fixed sections
234
+ 5. Update `templates/package.json` `xertica-ui` dependency to `^[new-version]`
235
+
236
+ ---
237
+
238
+ ## 11. Pre-Release Checklist
239
+
240
+ Before running `npm publish`:
241
+
242
+ - [ ] `npm run build:production` passes without errors
243
+ - [ ] `npm run build:types` passes without errors
244
+ - [ ] `npm run build:cli` passes without errors
245
+ - [ ] All new components have docs in `docs/components/`, entry in `components.json`, and section in `llms-full.txt`
246
+ - [ ] `llms.txt` is up to date (component count, new entries)
247
+ - [ ] `CHANGELOG.md` has an entry for this version
248
+ - [ ] `README.md` version badge is updated
249
+ - [ ] `templates/package.json` references the new version
250
+ - [ ] `bin/cli.ts` `.version()` matches `package.json`