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.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/bin/cli.ts +2 -1
- package/components/assistant/markdown-message/markdown-message.mdx +1 -1
- package/components/brand/language-selector/language-selector.mdx +1 -1
- package/components/brand/theme-toggle/theme-toggle.mdx +1 -1
- package/components/brand/xertica-logo/xertica-logo.mdx +1 -1
- package/components/brand/xertica-provider/xertica-provider.mdx +1 -1
- package/components/brand/xertica-xlogo/xertica-xlogo.mdx +1 -1
- package/components/index.ts +6 -0
- package/components/layout/header/header.mdx +1 -1
- package/components/layout/sidebar/sidebar.mdx +2 -1
- package/components/media/floating-media-wrapper.mdx +2 -2
- package/components/pages/forgot-password-page/ForgotPasswordPage.tsx +2 -4
- package/components/pages/home-content/HomeContent.tsx +1 -1
- package/components/pages/home-content/home-content.mdx +1 -1
- package/components/pages/home-page/HomePage.stories.tsx +39 -0
- package/components/pages/home-page/HomePage.tsx +2 -3
- package/components/pages/home-page/home-page.mdx +56 -0
- package/components/pages/login-page/LoginPage.tsx +2 -5
- package/components/pages/reset-password-page/reset-password-page.mdx +6 -2
- package/components/pages/template-page/TemplatePage.stories.tsx +39 -0
- package/components/pages/template-page/TemplatePage.tsx +3 -1
- package/components/pages/template-page/template-page.mdx +54 -0
- package/components/pages/verify-email-page/VerifyEmailPage.tsx +2 -4
- package/components/ui/accordion/accordion.stories.tsx +27 -1
- package/components/ui/alert-dialog/alert-dialog.stories.tsx +30 -0
- package/components/ui/button/button.stories.tsx +23 -0
- package/components/ui/checkbox/checkbox.stories.tsx +20 -1
- package/components/ui/dialog/dialog.stories.tsx +30 -0
- package/components/ui/google-maps-loader/google-maps-loader.mdx +1 -1
- package/components/ui/input/input.stories.tsx +24 -0
- package/components/ui/switch/switch.stories.tsx +20 -1
- package/components/ui/tabs/tabs.stories.tsx +26 -1
- package/components.json +1507 -530
- package/dist/cli.js +3 -2
- package/dist/components/index.d.ts +6 -0
- package/dist/index.cjs.js +1233 -484
- package/dist/index.es.js +778 -28
- package/dist/ui.cjs.js +178 -178
- package/dist/ui.es.js +1 -1
- package/dist/use-mobile-CaENcqm-.js +4508 -0
- package/dist/use-mobile-DMOvImGQ.cjs +4542 -0
- package/dist/xertica-ui.css +1 -1
- package/docs/decision-tree.md +287 -0
- package/guidelines/Guidelines.md +250 -657
- package/llms-compact.txt +327 -0
- package/llms.txt +160 -71
- package/package.json +193 -192
- package/templates/CLAUDE.md +160 -0
- package/templates/guidelines/Guidelines.md +245 -99
- package/templates/package.json +3 -3
package/guidelines/Guidelines.md
CHANGED
|
@@ -1,657 +1,250 @@
|
|
|
1
|
-
# Xertica UI
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- `
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
- `
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
- `
|
|
155
|
-
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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`
|