@llmnative/react 1.48.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1682 -1620
- package/dist/index.mjs.map +1 -1
- package/dist/types/src/I18n.d.ts +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/ui/fields/Input.d.ts +11 -1
- package/dist/types/src/components/widgets/Form.d.ts +69 -41
- package/llms-full.txt +1526 -1487
- package/package.json +1 -1
package/llms-full.txt
CHANGED
|
@@ -1,1487 +1,1526 @@
|
|
|
1
|
-
# @llmnative/react — Riferimento completo
|
|
2
|
-
|
|
3
|
-
Framework React AI-first per generazione deterministica di UI. Data-driven di default, schema-driven opzionale.
|
|
4
|
-
Versione 1.0.0 — Apache-2.0
|
|
5
|
-
|
|
6
|
-
```bash
|
|
7
|
-
npm install @llmnative/react
|
|
8
|
-
import '@llmnative/react/dist/index.css'
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Regole fondamentali
|
|
14
|
-
|
|
15
|
-
- Tutti gli import da `'@llmnative/react'` — mai da sottodirectory
|
|
16
|
-
- I provider sono iniettati via `<App providers={...}>` — mai importati direttamente nei componenti
|
|
17
|
-
- Usare `useDataProvider()`, `useAuthProvider()`, ecc. nei componenti, non istanze dirette
|
|
18
|
-
- TypeScript strict: no `any` — usare `unknown`, `Record<string, unknown>`, tipi specifici
|
|
19
|
-
- Naming props: `view` (presentazione contenuto), `appearance` (guscio visuale), `layout` (disposizione spaziale), `mode` (comportamento operativo), `variant` (tono semantico), `position` (ancoraggio), `size` (scala)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## App — Entry point
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
<App
|
|
27
|
-
providers={{
|
|
28
|
-
firebase: { // FirebaseConfig — tutte le chiavi flat
|
|
29
|
-
apiKey, authDomain, databaseURL, projectId,
|
|
30
|
-
storageBucket, messagingSenderId, appId,
|
|
31
|
-
},
|
|
32
|
-
supabase: { url, anonKey },
|
|
33
|
-
google: { clientId, scope }, // flat — NON { oAuth2: { clientId } }
|
|
34
|
-
dropbox: { clientId }, // DropboxConfig
|
|
35
|
-
mock: { data: mockData },
|
|
36
|
-
ai: { // AIConfig — NON una prop separata di <App>
|
|
37
|
-
openaiApiKey, geminiApiKey, anthropicApiKey,
|
|
38
|
-
deepSeekApiKey, mistralApiKey, openRouterApiKey,
|
|
39
|
-
groqApiKey,
|
|
40
|
-
cloudflare: { apiToken, accountId }, // Cloudflare Workers AI
|
|
41
|
-
},
|
|
42
|
-
proxy: { enable: true, route: '/api/proxy' },
|
|
43
|
-
custom: { data: { myAdapter: new MyDataProvider() } },
|
|
44
|
-
services: {
|
|
45
|
-
data: 'dbRealtime', // DataDriverName
|
|
46
|
-
storage: 'firestorage', // StorageDriverName | null
|
|
47
|
-
auth: 'googleAuth', // AuthDriverName | null
|
|
48
|
-
email: 'gmail', // EmailDriverName | null
|
|
49
|
-
ai: 'openai', // AIDriverName | null
|
|
50
|
-
credentials: 'googleServiceAccount',
|
|
51
|
-
},
|
|
52
|
-
}}
|
|
53
|
-
iconProvider="lucide" // 'lucide' | 'phosphor' | AppIconProviderConfig
|
|
54
|
-
themeProvider="default" // 'default' | 'flat' | 'cyber' | AppThemeProviderConfig
|
|
55
|
-
menuConfig={menuConfig}
|
|
56
|
-
importPage={(path) => import(path)}
|
|
57
|
-
LayoutDefault={MyLayout} // layout wrapper custom (opzionale)
|
|
58
|
-
appName="MyApp" // nome app (opzionale)
|
|
59
|
-
i18n={{ locale: 'it', translations: { ... } }}
|
|
60
|
-
contextProviders={MyContextProvider}
|
|
61
|
-
errorReportUrl="/api/errors"
|
|
62
|
-
debug={import.meta.env.DEV}
|
|
63
|
-
/>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Testi dei componenti (i18n)
|
|
67
|
-
|
|
68
|
-
I testi fissi dei componenti vengono da `I18nDict` e seguono `i18n.locale` (en, it, de, ru, ar, zh
|
|
69
|
-
inclusi): un testo si cambia con `i18n.translations`, non nel codice. Namespace dei componenti:
|
|
70
|
-
`notifications` (`markAllRead`, `empty`, `emptyHint`), `errorBoundary` (schermata d'errore; fuori da
|
|
71
|
-
`<I18nProvider>`, come l'`ErrorBoundary` radice di `<App>`, resta in inglese), `themeSwitcher`,
|
|
72
|
-
`imageField` (anche i dialoghi immagine di `RichText`), `richText`, `tabDynamic` (`addTab`),
|
|
73
|
-
`breadcrumbs` (`label`, l'`aria-label` del `nav`), `grid` (`tableView`, `galleryView`, `columns`,
|
|
74
|
-
`fields`), `prompt` (anche `Chatbot`: `role`, `language`, `voice`, `style`, `temperature`, `stop`),
|
|
75
|
-
`chat` (`ChatReasoning` e `ChatQuestions`: `reasoning`, `reasoningFor`, `other`, `review`, `submit`, …;
|
|
76
|
-
il codice di `ChatMarkdown` usa `code`).
|
|
77
|
-
|
|
78
|
-
```tsx
|
|
79
|
-
<App i18n={{ locale: 'it', translations: { it: { notifications: { emptyHint: 'Niente di nuovo' } } } }} />
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### AppThemeProviderConfig
|
|
83
|
-
```ts
|
|
84
|
-
{
|
|
85
|
-
mode?: 'light' | 'dark' | 'system';
|
|
86
|
-
theme: string;
|
|
87
|
-
themes?: Record<string, {
|
|
88
|
-
preset?: { colors?: ColorScale; radius?: number; font?: string };
|
|
89
|
-
motion?: MotionRegistry;
|
|
90
|
-
components?: Record<string, Partial<ThemeComponent>>;
|
|
91
|
-
}>;
|
|
92
|
-
themeOverride?: Record<string, Partial<ThemeComponent>>;
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Built-in themes: `default`, `flat`, `cyber`, `vscode-dark-modern`, `vscode-light-modern`, `vscode-dark-plus`, `vscode-light-plus`, `tokyo-night`, `tokyo-night-light`.
|
|
97
|
-
The VS Code and Tokyo Night themes are compiled from the original VS Code theme JSON (`scripts/themes/vscode`), filling the keys a theme does not list with VS Code's color registry defaults; each one has both modes (`vscode-dark-*` starts dark, `vscode-light-*` light). Status colors (destructive/success/warning/info) stay the framework's.
|
|
98
|
-
|
|
99
|
-
`ColorScale` tokens: `background`, `foreground`, `canvas` (page floor behind cards and panels, `bg-canvas`; falls back to `background`), `card`, `popover`, `primary`, `secondary`, `muted`, `accent`, `destructive`, `success`, `warning`, `info` (each with its `*Foreground`), `border`, `input` (border of form fields), `ring`. A consumer bridging the tokens in its own `@theme inline` adds `--color-canvas: hsl(var(--rf-canvas, var(--rf-background)));`.
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
## Provider System
|
|
104
|
-
|
|
105
|
-
### Matrix completa
|
|
106
|
-
|
|
107
|
-
| Servizio | Interfaccia | Driver | Config key | Obbligatorio |
|
|
108
|
-
|---|---|---|---|---|
|
|
109
|
-
| data | `DataProviderAdapter` | `mock`, `dbRealtime`, `firestoreDb`, `supabaseDb` | `providers.mock/firebase/supabase` | sì (fallback: mock) |
|
|
110
|
-
| storage | `StorageProviderAdapter` | `firestorage`, `supabaseStorage` | `providers.firebase/supabase` | no |
|
|
111
|
-
| auth | `AuthProviderAdapter` | `googleAuth`, `firebaseAuth`, `supabaseAuth`, `dropboxAuth`, `githubAuth` | `providers.google/firebase/supabase/dropbox/github` | sì (fallback: googleAuth) |
|
|
112
|
-
| email | `EmailProviderAdapter` | `gmail` | `providers.google` | no |
|
|
113
|
-
| ai | `AIProviderAdapter` | `openai`, `gemini`, `anthropic`, `deepseek`, `mistral`, `openrouter`, `opencode`, `opencode-go`, `cloudflare`, `groq` | `Config.tsx AIConfig` | no |
|
|
114
|
-
| credentials | `CredentialsAdapter` | `googleServiceAccount` | `providers.google.serviceAccount` | no |
|
|
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
|
-
await
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
|
298
|
-
|
|
299
|
-
| `
|
|
300
|
-
| `
|
|
301
|
-
| `
|
|
302
|
-
| `
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
```tsx
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
<
|
|
371
|
-
<
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
<
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
|
443
|
-
|
|
444
|
-
| `
|
|
445
|
-
| `
|
|
446
|
-
| `
|
|
447
|
-
| `
|
|
448
|
-
| `
|
|
449
|
-
| `
|
|
450
|
-
| `
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
`
|
|
585
|
-
`
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
`
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
<
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
|
665
|
-
|
|
666
|
-
| `
|
|
667
|
-
| `
|
|
668
|
-
| `
|
|
669
|
-
| `
|
|
670
|
-
| `
|
|
671
|
-
| `
|
|
672
|
-
| `
|
|
673
|
-
| `
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
|
698
|
-
|
|
699
|
-
| `
|
|
700
|
-
| `
|
|
701
|
-
| `
|
|
702
|
-
| `
|
|
703
|
-
| `
|
|
704
|
-
| `
|
|
705
|
-
| `
|
|
706
|
-
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
|
740
|
-
|
|
741
|
-
| `
|
|
742
|
-
| `
|
|
743
|
-
| `
|
|
744
|
-
| `
|
|
745
|
-
| `
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
```
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
<
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
|
779
|
-
|
|
780
|
-
| `
|
|
781
|
-
| `
|
|
782
|
-
| `
|
|
783
|
-
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
```tsx
|
|
812
|
-
<
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
<
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
<
|
|
910
|
-
<
|
|
911
|
-
<
|
|
912
|
-
<
|
|
913
|
-
<
|
|
914
|
-
<
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
<
|
|
932
|
-
<
|
|
933
|
-
{
|
|
934
|
-
|
|
935
|
-
<
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
/>
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
`
|
|
983
|
-
|
|
|
984
|
-
|
|
985
|
-
| `
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
|
992
|
-
|
|
993
|
-
| `
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
|
1014
|
-
|
|
1015
|
-
| `
|
|
1016
|
-
| `
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
|
1040
|
-
|
|
1041
|
-
| `
|
|
1042
|
-
| `
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
|
1053
|
-
|
|
1054
|
-
| `
|
|
1055
|
-
| `
|
|
1056
|
-
| `
|
|
1057
|
-
| `
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
```
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
<
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
//
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
//
|
|
1127
|
-
//
|
|
1128
|
-
//
|
|
1129
|
-
//
|
|
1130
|
-
<
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
/>
|
|
1138
|
-
// className, classNames={{ root,
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
//
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
//
|
|
1163
|
-
// {
|
|
1164
|
-
|
|
1165
|
-
// Il
|
|
1166
|
-
//
|
|
1167
|
-
//
|
|
1168
|
-
//
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
//
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
//
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
//
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
(
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
//
|
|
1229
|
-
const registry =
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
//
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
```
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
```
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
|
1475
|
-
|
|
1476
|
-
|
|
|
1477
|
-
|
|
|
1478
|
-
|
|
|
1479
|
-
|
|
|
1480
|
-
|
|
|
1481
|
-
|
|
|
1482
|
-
|
|
|
1483
|
-
|
|
|
1484
|
-
|
|
|
1485
|
-
|
|
|
1486
|
-
|
|
1487
|
-
|
|
1
|
+
# @llmnative/react — Riferimento completo
|
|
2
|
+
|
|
3
|
+
Framework React AI-first per generazione deterministica di UI. Data-driven di default, schema-driven opzionale.
|
|
4
|
+
Versione 1.0.0 — Apache-2.0
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @llmnative/react
|
|
8
|
+
import '@llmnative/react/dist/index.css'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Regole fondamentali
|
|
14
|
+
|
|
15
|
+
- Tutti gli import da `'@llmnative/react'` — mai da sottodirectory
|
|
16
|
+
- I provider sono iniettati via `<App providers={...}>` — mai importati direttamente nei componenti
|
|
17
|
+
- Usare `useDataProvider()`, `useAuthProvider()`, ecc. nei componenti, non istanze dirette
|
|
18
|
+
- TypeScript strict: no `any` — usare `unknown`, `Record<string, unknown>`, tipi specifici
|
|
19
|
+
- Naming props: `view` (presentazione contenuto), `appearance` (guscio visuale), `layout` (disposizione spaziale), `mode` (comportamento operativo), `variant` (tono semantico), `position` (ancoraggio), `size` (scala)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## App — Entry point
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
<App
|
|
27
|
+
providers={{
|
|
28
|
+
firebase: { // FirebaseConfig — tutte le chiavi flat
|
|
29
|
+
apiKey, authDomain, databaseURL, projectId,
|
|
30
|
+
storageBucket, messagingSenderId, appId,
|
|
31
|
+
},
|
|
32
|
+
supabase: { url, anonKey },
|
|
33
|
+
google: { clientId, scope }, // flat — NON { oAuth2: { clientId } }
|
|
34
|
+
dropbox: { clientId }, // DropboxConfig
|
|
35
|
+
mock: { data: mockData },
|
|
36
|
+
ai: { // AIConfig — NON una prop separata di <App>
|
|
37
|
+
openaiApiKey, geminiApiKey, anthropicApiKey,
|
|
38
|
+
deepSeekApiKey, mistralApiKey, openRouterApiKey,
|
|
39
|
+
groqApiKey,
|
|
40
|
+
cloudflare: { apiToken, accountId }, // Cloudflare Workers AI
|
|
41
|
+
},
|
|
42
|
+
proxy: { enable: true, route: '/api/proxy' },
|
|
43
|
+
custom: { data: { myAdapter: new MyDataProvider() } },
|
|
44
|
+
services: {
|
|
45
|
+
data: 'dbRealtime', // DataDriverName
|
|
46
|
+
storage: 'firestorage', // StorageDriverName | null
|
|
47
|
+
auth: 'googleAuth', // AuthDriverName | null
|
|
48
|
+
email: 'gmail', // EmailDriverName | null
|
|
49
|
+
ai: 'openai', // AIDriverName | null
|
|
50
|
+
credentials: 'googleServiceAccount',
|
|
51
|
+
},
|
|
52
|
+
}}
|
|
53
|
+
iconProvider="lucide" // 'lucide' | 'phosphor' | AppIconProviderConfig
|
|
54
|
+
themeProvider="default" // 'default' | 'flat' | 'cyber' | AppThemeProviderConfig
|
|
55
|
+
menuConfig={menuConfig}
|
|
56
|
+
importPage={(path) => import(path)}
|
|
57
|
+
LayoutDefault={MyLayout} // layout wrapper custom (opzionale): avvolge ogni voce di menuConfig senza `layout`
|
|
58
|
+
appName="MyApp" // nome app (opzionale)
|
|
59
|
+
i18n={{ locale: 'it', translations: { ... } }}
|
|
60
|
+
contextProviders={MyContextProvider}
|
|
61
|
+
errorReportUrl="/api/errors"
|
|
62
|
+
debug={import.meta.env.DEV}
|
|
63
|
+
/>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Testi dei componenti (i18n)
|
|
67
|
+
|
|
68
|
+
I testi fissi dei componenti vengono da `I18nDict` e seguono `i18n.locale` (en, it, de, ru, ar, zh
|
|
69
|
+
inclusi): un testo si cambia con `i18n.translations`, non nel codice. Namespace dei componenti:
|
|
70
|
+
`notifications` (`markAllRead`, `empty`, `emptyHint`), `errorBoundary` (schermata d'errore; fuori da
|
|
71
|
+
`<I18nProvider>`, come l'`ErrorBoundary` radice di `<App>`, resta in inglese), `themeSwitcher`,
|
|
72
|
+
`imageField` (anche i dialoghi immagine di `RichText`), `richText`, `tabDynamic` (`addTab`),
|
|
73
|
+
`breadcrumbs` (`label`, l'`aria-label` del `nav`), `grid` (`tableView`, `galleryView`, `columns`,
|
|
74
|
+
`fields`), `prompt` (anche `Chatbot`: `role`, `language`, `voice`, `style`, `temperature`, `stop`),
|
|
75
|
+
`chat` (`ChatReasoning` e `ChatQuestions`: `reasoning`, `reasoningFor`, `other`, `review`, `submit`, …;
|
|
76
|
+
il codice di `ChatMarkdown` usa `code`).
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<App i18n={{ locale: 'it', translations: { it: { notifications: { emptyHint: 'Niente di nuovo' } } } }} />
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### AppThemeProviderConfig
|
|
83
|
+
```ts
|
|
84
|
+
{
|
|
85
|
+
mode?: 'light' | 'dark' | 'system';
|
|
86
|
+
theme: string;
|
|
87
|
+
themes?: Record<string, {
|
|
88
|
+
preset?: { colors?: ColorScale; radius?: number; font?: string };
|
|
89
|
+
motion?: MotionRegistry;
|
|
90
|
+
components?: Record<string, Partial<ThemeComponent>>;
|
|
91
|
+
}>;
|
|
92
|
+
themeOverride?: Record<string, Partial<ThemeComponent>>;
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Built-in themes: `default`, `flat`, `cyber`, `vscode-dark-modern`, `vscode-light-modern`, `vscode-dark-plus`, `vscode-light-plus`, `tokyo-night`, `tokyo-night-light`.
|
|
97
|
+
The VS Code and Tokyo Night themes are compiled from the original VS Code theme JSON (`scripts/themes/vscode`), filling the keys a theme does not list with VS Code's color registry defaults; each one has both modes (`vscode-dark-*` starts dark, `vscode-light-*` light). Status colors (destructive/success/warning/info) stay the framework's.
|
|
98
|
+
|
|
99
|
+
`ColorScale` tokens: `background`, `foreground`, `canvas` (page floor behind cards and panels, `bg-canvas`; falls back to `background`), `card`, `popover`, `primary`, `secondary`, `muted`, `accent`, `destructive`, `success`, `warning`, `info` (each with its `*Foreground`), `border`, `input` (border of form fields), `ring`. A consumer bridging the tokens in its own `@theme inline` adds `--color-canvas: hsl(var(--rf-canvas, var(--rf-background)));`.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Provider System
|
|
104
|
+
|
|
105
|
+
### Matrix completa
|
|
106
|
+
|
|
107
|
+
| Servizio | Interfaccia | Driver | Config key | Obbligatorio |
|
|
108
|
+
|---|---|---|---|---|
|
|
109
|
+
| data | `DataProviderAdapter` | `mock`, `dbRealtime`, `firestoreDb`, `supabaseDb` | `providers.mock/firebase/supabase` | sì (fallback: mock) |
|
|
110
|
+
| storage | `StorageProviderAdapter` | `firestorage`, `supabaseStorage` | `providers.firebase/supabase` | no |
|
|
111
|
+
| auth | `AuthProviderAdapter` | `googleAuth`, `firebaseAuth`, `supabaseAuth`, `dropboxAuth`, `githubAuth` | `providers.google/firebase/supabase/dropbox/github` | sì (fallback: googleAuth) |
|
|
112
|
+
| email | `EmailProviderAdapter` | `gmail` | `providers.google` | no |
|
|
113
|
+
| ai | `AIProviderAdapter` | `openai`, `gemini`, `anthropic`, `deepseek`, `mistral`, `openrouter`, `opencode`, `opencode-go`, `cloudflare`, `groq` | `Config.tsx AIConfig` | no |
|
|
114
|
+
| credentials | `CredentialsAdapter` | `googleServiceAccount` | `providers.google.serviceAccount` | no |
|
|
115
|
+
|
|
116
|
+
### Firebase: quale app usano auth, dati e storage
|
|
117
|
+
|
|
118
|
+
- `providers.firebase` inizializza l'app Firebase **di default** dell'SDK (`[DEFAULT]`). `firestoreDb` e `firestorage` la
|
|
119
|
+
usano, e il driver `firebaseAuth` (`services.auth: 'firebaseAuth'`) fa login su quella stessa app: login, Firestore
|
|
120
|
+
e Storage condividono la sessione.
|
|
121
|
+
- Un'app che chiama già `initializeApp(config)` per conto suo condivide l'app di default con il framework solo se ha lo
|
|
122
|
+
**stesso `appId`**. Con un `appId` diverso il framework chiude quell'app e la reinizializza con la propria config, e
|
|
123
|
+
la sessione dell'app cade. Per questo il client Firebase si crea una volta sola: o `providers.firebase`, o il codice
|
|
124
|
+
dell'app con la stessa config.
|
|
125
|
+
- Una sessione separata, che non deve cadere quando l'app di default cambia (cambio di tenant): istanziare
|
|
126
|
+
`new FirebaseAuthProvider({ config, appName: 'control-plane' })`. `appName` è un'app con un nome suo; senza
|
|
127
|
+
`config` usa un'app già inizializzata con quel nome.
|
|
128
|
+
- Le Cloud Functions callable: `callFirebaseFunction(name, data, appName?, region?)`, sull'app di default se non si
|
|
129
|
+
passa `appName`. Il token della sessione lo aggiunge l'SDK.
|
|
130
|
+
|
|
131
|
+
### Layout per voce di menu
|
|
132
|
+
|
|
133
|
+
Ogni voce di `menuConfig` è una route. Viene avvolta da `item.layout` se presente, altrimenti da `LayoutDefault` di
|
|
134
|
+
`<App>`, altrimenti da `LayoutEmpty`. Una pagina con un guscio diverso, per esempio l'accesso a tutta pagina senza
|
|
135
|
+
sidebar, dichiara `layout` sulla sua voce:
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
export const menuConfig: MenuConfig = {
|
|
139
|
+
main: [
|
|
140
|
+
{ path: '/', title: 'Home', icon: 'home', page: HomePage }, // LayoutDefault
|
|
141
|
+
],
|
|
142
|
+
public: [
|
|
143
|
+
{ path: '/login', page: LoginPage, layout: AccessLayout }, // senza header né sidebar
|
|
144
|
+
],
|
|
145
|
+
};
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
La home va dichiarata con `path: '/'`: senza quella voce, `/` mostra "Missing Page".
|
|
149
|
+
|
|
150
|
+
### Hooks
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
const data = useDataProvider() // DataProviderAdapter | null
|
|
154
|
+
const storage = useStorageProvider() // StorageProviderAdapter | null
|
|
155
|
+
const auth = useAuthProvider() // AuthProviderAdapter | null
|
|
156
|
+
const email = useEmailProvider() // EmailProviderAdapter | null
|
|
157
|
+
const ai = useAIProvider() // AIProviderAdapter | null
|
|
158
|
+
const creds = useCredentialsProvider() // CredentialsAdapter | null
|
|
159
|
+
|
|
160
|
+
// Named provider (multi-provider setup)
|
|
161
|
+
const supabase = useDataProvider('supabase')
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### GitHub (`githubAuth`, sessione sul server dell'app)
|
|
165
|
+
|
|
166
|
+
GitHub richiede il client secret per scambiare il codice: scambio, token e sessione stanno sul server
|
|
167
|
+
dell'app, il browser vede solo il profilo. Config `providers.github = { sessionUrl: '/api/auth/github' }`,
|
|
168
|
+
driver `auth: 'githubAuth'`; funziona con `AuthButton` (pulsante e `aspect="avatar"`) e
|
|
169
|
+
`useAuthProvider('githubAuth')`. Il server espone sotto `sessionUrl`:
|
|
170
|
+
|
|
171
|
+
| Rotta | Risposta |
|
|
172
|
+
|---|---|
|
|
173
|
+
| `GET /login?returnTo=<path>[&scope=…]` | redirect a GitHub, poi di nuovo a `<path>` |
|
|
174
|
+
| `GET /me` | `{ login, name, avatarUrl, email }`, 401 senza sessione |
|
|
175
|
+
| `POST /logout` | chiude la sessione |
|
|
176
|
+
|
|
177
|
+
Lato server, da `@llmnative/react/server`:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
const oauth = createGitHubOAuth({ clientId, clientSecret, scopes: ['read:org'] })
|
|
181
|
+
oauth.authorizeUrl({ state, redirectUri, codeChallenge }) // PKCE S256
|
|
182
|
+
const { accessToken } = await oauth.exchangeCode({ code, redirectUri, codeVerifier }) // GitHubOAuthError se rifiutato
|
|
183
|
+
await oauth.getUser(accessToken) // { login, name, avatarUrl, email }
|
|
184
|
+
await oauth.getOrganizations(accessToken) // [{ login, avatarUrl, role: 'admin' | 'member' }]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Interfacce principali
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
// DataProviderAdapter
|
|
191
|
+
read(path, options?) / set(path, data) / update(path, data) / remove(path)
|
|
192
|
+
subscribe(path, callback: (records: RecordArray) => void): () => void
|
|
193
|
+
count?(path, where?): Promise<number>
|
|
194
|
+
|
|
195
|
+
// StorageProviderAdapter
|
|
196
|
+
upload(file, path): Promise<string|undefined>
|
|
197
|
+
getURL(path) / download(path): Promise<Blob|undefined> / delete(path): Promise<boolean>
|
|
198
|
+
|
|
199
|
+
// AuthProviderAdapter
|
|
200
|
+
signIn(intent?, options?) / signOut() / getUser(): UserProfile|null
|
|
201
|
+
onAuthChange(callback) / getAccessToken(): Promise<string|null>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Auth sign-in methods
|
|
205
|
+
|
|
206
|
+
| method | Firebase | Supabase | Google |
|
|
207
|
+
|---|---|---|---|
|
|
208
|
+
| `password` | ✅ | ✅ | — |
|
|
209
|
+
| `anonymous` | ✅ | ✅ | — |
|
|
210
|
+
| `magic_link` | — | ✅ | — |
|
|
211
|
+
| `oauth` (github, apple…) | ✅ | ✅ | — |
|
|
212
|
+
| GIS + scoped token | — | — | ✅ |
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
await auth.signIn({ method: 'password', email: '...', password: '...' })
|
|
216
|
+
await auth.signIn({ method: 'oauth', provider: 'github' })
|
|
217
|
+
// Google: token per API scope
|
|
218
|
+
const token = await auth.getAccessToken('https://www.googleapis.com/auth/gmail.send')
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### CredentialsAdapter (Google Service Account)
|
|
222
|
+
```tsx
|
|
223
|
+
// Chiama Google APIs lato browser senza Node.js
|
|
224
|
+
<App providers={{ google: { serviceAccount: { clientEmail, privateKey } }, services: { credentials: 'googleServiceAccount' } }} />
|
|
225
|
+
|
|
226
|
+
const creds = useCredentialsProvider()
|
|
227
|
+
const token = await creds.getToken('https://www.googleapis.com/auth/solar')
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Provider custom
|
|
231
|
+
```ts
|
|
232
|
+
import { DataProviderAdapter, RecordArray } from '@llmnative/react'
|
|
233
|
+
|
|
234
|
+
export class RestDataProvider implements DataProviderAdapter {
|
|
235
|
+
async read(path: string): Promise<unknown> { ... }
|
|
236
|
+
async set(path: string, data: object): Promise<void> { ... }
|
|
237
|
+
async update(path: string, data: object): Promise<void> { ... }
|
|
238
|
+
async remove(path: string): Promise<void> { ... }
|
|
239
|
+
subscribe(path: string | undefined, callback: (records: RecordArray) => void): () => void {
|
|
240
|
+
return () => undefined
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Grid — CRUD table/gallery
|
|
248
|
+
|
|
249
|
+
```tsx
|
|
250
|
+
<Grid
|
|
251
|
+
path="/users" // DataProvider-backed — oppure records={array} per in-memory
|
|
252
|
+
columns={[
|
|
253
|
+
{ key: 'name', label: 'Nome', sortable: true },
|
|
254
|
+
{ key: 'email', label: 'Email' },
|
|
255
|
+
{ key: 'role', label: 'Ruolo', render: ({ value }) => <Badge>{value}</Badge> },
|
|
256
|
+
{ key: 'date', label: 'Data', render: 'date' },
|
|
257
|
+
]}
|
|
258
|
+
actions={['add', 'edit', 'delete']} // oppure Record<string, GridAction>
|
|
259
|
+
view="table" // 'table' | 'gallery'
|
|
260
|
+
pagination={{ limit: 20 }}
|
|
261
|
+
groupBy="status"
|
|
262
|
+
sortable={{ field: 'name', dir: 'asc' }}
|
|
263
|
+
form={<FormFields />}
|
|
264
|
+
onSave={async ({ record, action }) => record._key}
|
|
265
|
+
onComplete={async ({ record, action }) => true}
|
|
266
|
+
selection={{ mode: 'multiple', onChange: (sel) => {} }}
|
|
267
|
+
reorderable
|
|
268
|
+
onReorder={(records, meta) => {}}
|
|
269
|
+
header={(ctx) => <div>{ctx.title}</div>}
|
|
270
|
+
footer={(ctx) => <div>{ctx.records.length} records</div>}
|
|
271
|
+
/>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
| Prop | Tipo | Note |
|
|
275
|
+
|---|---|---|---|
|
|
276
|
+
| `path` | `string \| "fromUrl"` | Path provider-backed |
|
|
277
|
+
| `records` | `RecordArray` | Dati in memoria (alternativa a path) |
|
|
278
|
+
| `columns` | `GridColumn[]` | `{ key, label, sortable?, render?, className? }` |
|
|
279
|
+
| `actions` | `Array<'add'\|'edit'\|'delete'> \| Record<string, GridAction>` | |
|
|
280
|
+
| `view` | `'table' \| 'gallery'` | |
|
|
281
|
+
| `groupBy` | `string \| string[]` | |
|
|
282
|
+
| `pagination` | `PaginationParams` | `{ limit, page?, maxPageButtons?, align?, sticky? }` |
|
|
283
|
+
| `sortable` | `boolean \| OrderConfig` | |
|
|
284
|
+
| `selection` | `false \| 'single' \| 'multiple' \| GridSelectionConfig` | |
|
|
285
|
+
| `form` | `ReactElement \| ((ctx) => ReactNode)` | Form condiviso per CRUD |
|
|
286
|
+
| `onSave` | `GridMutationSaveHandler` | `async ({ record, action }) => string` |
|
|
287
|
+
| `onDelete` | `GridMutationDeleteHandler` | `async ({ record }) => string` |
|
|
288
|
+
| `onComplete` | `GridAfterActionHandler` | `async ({ record, action }) => boolean` |
|
|
289
|
+
| `onRowClick` | `(record) => void` | |
|
|
290
|
+
| `reorderable` | `boolean` | Abilita drag & drop righe |
|
|
291
|
+
| `onReorder` | `GridReorderHandler` | `(records, meta) => void` |
|
|
292
|
+
| `onLoad` | `(records) => TRecord[]` | Trasforma records dopo il fetch |
|
|
293
|
+
| `editDeepLink` | `boolean` | Sincronizza modal edit con URL |
|
|
294
|
+
| `audit` | `boolean` | Logga mutazioni |
|
|
295
|
+
| `sticky` | `'top' \| 'bottom'` | Header/footer sticky |
|
|
296
|
+
| `wrapperClassName` | `string` | CSS wrapper esterno |
|
|
297
|
+
| `loading` | `boolean` | Stato loading override |
|
|
298
|
+
| `title` | `ReactNode` | Titolo header grid |
|
|
299
|
+
| `before` / `after` | `ReactNode` | Slot prima/dopo il contenuto |
|
|
300
|
+
| `header` / `footer` | `ReactNode \| ((ctx) => ReactNode)` | Header/footer custom |
|
|
301
|
+
| `searchable` | `boolean \| GridSearchConfig` | Search box nell'header default — `{ fields?, placeholder? }` |
|
|
302
|
+
| `filters` | `GridFilterConfig[]` | Checkbox toggle nell'header default, applicati PRIMA di `searchable` — `{ key, label, defaultValue?, predicate(record, value) }` |
|
|
303
|
+
|
|
304
|
+
**GridAction kind:** `'modal'` (default), `'route'`, `'external'`, `'inline'`, `'delete'`
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Form — form CRUD con lifecycle
|
|
309
|
+
|
|
310
|
+
```tsx
|
|
311
|
+
<Form
|
|
312
|
+
path="/products"
|
|
313
|
+
appearance="card" // 'card' | 'empty'
|
|
314
|
+
showBack
|
|
315
|
+
defaultValues={{ status: 'draft' }}
|
|
316
|
+
keyGenerator={() => `prod_${Date.now()}`}
|
|
317
|
+
onLoad={(data) => { /* side-effect hook, non trasforma */ }}
|
|
318
|
+
onSave={async ({ record, action }) => { /* return storagePath or undefined */ }}
|
|
319
|
+
onDelete={async ({ record }) => { /* confirm */ }}
|
|
320
|
+
onComplete={async ({ action }) => { if (action === 'save') navigate('/products') }}
|
|
321
|
+
>
|
|
322
|
+
<Input name="title" label="Titolo" required />
|
|
323
|
+
<Input name="price" label="Prezzo" type="number" />
|
|
324
|
+
<Input name="address.city" label="Città" /> {/* oggetto annidato */}
|
|
325
|
+
<Repeat name="tags" defaultLength={1}>
|
|
326
|
+
{(i) => <Input name={`tags.${i}`} label={`Tag ${i+1}`} />}
|
|
327
|
+
</Repeat>
|
|
328
|
+
</Form>
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
| Prop | Tipo | Note |
|
|
332
|
+
|---|---|---|---|
|
|
333
|
+
| `path` | `string` | Path provider-backed |
|
|
334
|
+
| `appearance` | `'card' \| 'empty'` | Guscio visuale |
|
|
335
|
+
| `controller` | `FormController` | Controller condiviso per bottoni custom esterni |
|
|
336
|
+
| `showBack` | `boolean` | Pulsante Back nel footer |
|
|
337
|
+
| `defaultValues` | `RecordProps` | Valori iniziali per nuovo record |
|
|
338
|
+
| `keyGenerator` | `(record) => string` | Generatore chiave primaria custom |
|
|
339
|
+
| `draftBucket` | `string` | Bucket stabile che isola la bozza locale; omettilo per disabilitare la persistenza |
|
|
340
|
+
| `noticeAnchorRef` | `React.RefObject<HTMLElement>` | Ancoraggio sticky per notifiche |
|
|
341
|
+
| `showNotice` | `boolean` | Mostra notifiche save/delete (default `true`) |
|
|
342
|
+
| `onSubmit` | `FormSubmitHandler` | `async ({ record }) => void`. **Form d'azione** (CR-125): non legge e non scrive nulla; invia anche senza modifiche e con Invio in un campo; niente pulsante Salva né "Salvato" (il pulsante è tuo: `useFormController().save()`); l'errore lanciato appare nel suo avviso; restituire `false` = è fallito e la pagina dice già perché (nessun avviso né `onComplete`). Esclude `path`, `onSave`, `onDelete`, `keyGenerator` (errore di tipo e a runtime). Sostituisce `requireChanges={false}` della 1.x |
|
|
343
|
+
| `children` | `ReactNode \| ((fields) => ReactNode) \| (({ record }) => ReactNode)` | Contenuto form |
|
|
344
|
+
| `header` | `ReactNode` | Contenuto header custom |
|
|
345
|
+
| `footer` | `ReactNode` | Contenuto footer custom |
|
|
346
|
+
| `wrapperClassName` | `string` | CSS wrapper esterno |
|
|
347
|
+
| `headerClassName` | `string` | CSS header |
|
|
348
|
+
| `className` | `string` | CSS body form |
|
|
349
|
+
| `footerClassName` | `string` | CSS footer |
|
|
350
|
+
| `log` | `boolean` | Logga ogni modifica su console |
|
|
351
|
+
| `onLoad` | `(record) => void` | Side-effect dopo il caricamento (non trasforma) |
|
|
352
|
+
| `onRecordChange` | `(record) => void` | Cambio campo in tempo reale |
|
|
353
|
+
| `onSave` | `FormSaveHandler` | `async ({ record, prevRecord?, storagePath?, action }) => string \| undefined`. Form che **salva un record**, solo se un campo è cambiato: restituisce il path dove scriverlo, `undefined` = il `path` del Form (senza `path` non scrive), `false` = è fallito e la pagina dice già perché (non scrive, nessun avviso, `save()` dà `false`). Per un'azione (chiamare un comando) usa `onSubmit`. L'errore lanciato appare nell'avviso del Form |
|
|
354
|
+
| `onDelete` | `FormDeleteHandler` | `async ({ record }) => string \| undefined` |
|
|
355
|
+
| `onComplete` | `FormFinallyHandler` | `async ({ record, action }) => boolean`; `action` è `'create' \| 'update' \| 'delete' \| 'submit'` |
|
|
356
|
+
|
|
357
|
+
**Form controller** — stato e azioni native del form accessibili da qualsiasi punto della pagina.
|
|
358
|
+
|
|
359
|
+
Due hook:
|
|
360
|
+
|
|
361
|
+
| Hook | Dove usarlo | Cosa restituisce |
|
|
362
|
+
|---|---|---|
|
|
363
|
+
| `useFormController(controller?)` | Ovunque (anche fuori dal form) | Crea o si aggancia a un `FormController`. Senza argomenti ne crea uno locale stabile. Con un `controller` esistente ci si aggancia. |
|
|
364
|
+
| `useFormActions()` | Solo dentro `<Form>` (legge dal context) | Restituisce lo stesso `FormController` del form genitore. Lancia errore se usato fuori. |
|
|
365
|
+
|
|
366
|
+
Esempio — bottone custom fuori dal form:
|
|
367
|
+
```tsx
|
|
368
|
+
const form = useFormController();
|
|
369
|
+
|
|
370
|
+
<ActionButton disabled={form.saveDisabled} onClick={() => { void form.save(); }} />
|
|
371
|
+
<Form controller={form} draftBucket="workspace/acme" onSave={...} />
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Esempio — form d'azione: chiama un comando, non salva nulla (CR-125):
|
|
375
|
+
```tsx
|
|
376
|
+
const form = useFormController();
|
|
377
|
+
|
|
378
|
+
<Form controller={form} appearance="empty" onSubmit={({ record }) => call('verifyLoginCode', record)}>
|
|
379
|
+
<Input name="email" type="email" label="Email" required />
|
|
380
|
+
<Input name="code" label="Codice" required inputMode="numeric" maxLength={6} pattern="[0-9]{6}" autoComplete="one-time-code" />
|
|
381
|
+
</Form>
|
|
382
|
+
<LoadingButton label="Entra con il codice" loading={form.isSaving} onClick={() => form.save()} />
|
|
383
|
+
```
|
|
384
|
+
Con valori proposti (avviare una release con la versione proposta) si inviano anche senza modificarli:
|
|
385
|
+
`<Form controller={form} appearance="empty" defaultValues={{ version: '1.4.0' }} onSubmit={({ record }) => start(record)}>`.
|
|
386
|
+
|
|
387
|
+
Esempio — uso dentro il form (senza passare controller):
|
|
388
|
+
```tsx
|
|
389
|
+
function MySaveButton() {
|
|
390
|
+
const form = useFormActions();
|
|
391
|
+
return <LoadingButton disabled={form.saveDisabled} loading={form.isSaving} onClick={form.save} />;
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
Stato esposto dal controller: `record`, `isNewRecord`, `isDirty`, `canSave`, `canDelete`, `isSaving`, `isDeleting`, `saveDisabled`, `deleteDisabled`, `hasDraft`, `draftStatus`, `errors`, `hasErrors`.
|
|
396
|
+
|
|
397
|
+
Azioni: `save()`, `delete()`, `reset()`, `restoreDraft()`, `discardDraft()`.
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## Campi form
|
|
402
|
+
|
|
403
|
+
### Input
|
|
404
|
+
```tsx
|
|
405
|
+
<Input name="x" label="..." required /> // text (default)
|
|
406
|
+
<Input name="price" type="number" min={0} max={100} step={0.01} />
|
|
407
|
+
<Input name="email" type="email" />
|
|
408
|
+
<Input name="phone" type="tel" autoComplete="tel" /> // o <Tel name="phone" />
|
|
409
|
+
<Input name="code" inputMode="numeric" maxLength={6} pattern="[0-9]{6}" autoComplete="one-time-code" /> // un codice monouso
|
|
410
|
+
<Input name="pwd" type="password" />
|
|
411
|
+
<Input name="date" type="date" />
|
|
412
|
+
<Input name="color" type="color" />
|
|
413
|
+
<TextArea name="bio" minHeight={96} />
|
|
414
|
+
<Checkbox name="active" valueChecked="yes" />
|
|
415
|
+
<Switch name="gate" label="Passa dalla CI" disabled title="L'agente non committa" /> // CR-116: disabled (non cambia né con il clic né da tastiera), title anche sull'etichetta: il motivo al passaggio del mouse
|
|
416
|
+
```
|
|
417
|
+
`Input` props: `name`(req) `label` `type` `required` `disabled` `placeholder` `min` `max` `step` `inputMode` `maxLength` `pattern` `autoComplete` `validator:(v)=>string|undefined`
|
|
418
|
+
`type`: `'text' | 'number' | 'email' | 'tel' | 'password' | 'color' | 'date' | 'time' | 'datetime-local' | 'week' | 'month' | 'range' | 'checkbox' | 'radio' | 'url'`
|
|
419
|
+
|
|
420
|
+
**NOTA**: il tipo HTML si passa con `type`. `inputType` e i sotto-componenti `Input.Number`/`Input.Email`/`Input.Date` non esistono.
|
|
421
|
+
|
|
422
|
+
**Label come nodo**: `label` di tutti i campi di inserimento (`Input`, `TextArea`, `Checkbox`, `Select`, `Autocomplete`, `Checklist`, `Upload*`, `ImageField`, `CodeEditor`, `RichText`, `AddressAutocomplete`, `UploadCSV`, `Prompt`) accetta una stringa o un nodo React (tipo `FieldLabel`), disegnato dentro la `<label>` prima dell'asterisco di obbligatorio. Dove serve un testo (messaggio "obbligatorio", `aria-label`) si usa il testo del nodo, ricavabile anche con `labelText(node)`.
|
|
423
|
+
```tsx
|
|
424
|
+
<Select name="skill" required options={skills} label={<>Skill <ActionButton icon="info" ariaLabel="Apri la skill" variant="link" onClick={openSkill} /></>} />
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Select / Autocomplete / Checklist
|
|
428
|
+
```tsx
|
|
429
|
+
<Select name="role" options={[{ label: 'Admin', value: 'admin' }]} />
|
|
430
|
+
<Select name="categoryId" optionsSource={{ path: '/categories', labelField: 'name', valueField: '_key' }} />
|
|
431
|
+
<Autocomplete name="userId" optionsSource={{ path: '/users', labelField: 'email' }} maxItems={1} />
|
|
432
|
+
<Checklist name="tags" options={['a', 'b', 'c']} />
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
| Prop | Tipo | Note |
|
|
436
|
+
|---|---|---|
|
|
437
|
+
| `options` | `Option[] \| string[] \| number[]` | |
|
|
438
|
+
| `optionsSource` | `{ path, labelField, valueField?, where?, order?, fieldMap?, onLoad? }` | Carica da provider |
|
|
439
|
+
| `order` | `{ field: 'label' \| 'value', dir: 'asc' \| 'desc' }` | |
|
|
440
|
+
| `placeholderOption` | `Option` | Solo Select |
|
|
441
|
+
| `placeholder` | `string` | Solo Autocomplete |
|
|
442
|
+
| `creatable` | `boolean` | Solo Autocomplete — crea nuovi valori |
|
|
443
|
+
| `onCreate` | `(value) => void \| boolean \| Promise<void \| boolean>` | Solo Autocomplete — restituire `false` per non selezionare il valore creato (es. aprire un modulo di creazione) |
|
|
444
|
+
| `listClassName` / `optionClassName` | `string` | Solo Autocomplete — classi della lista e delle voci (anche da tema `Autocomplete.listClassName` / `optionClassName`) |
|
|
445
|
+
| `minItems` / `maxItems` | `number` | Solo Autocomplete |
|
|
446
|
+
| `itemClassName` | `string` | Solo Checklist |
|
|
447
|
+
| `validator` | `(value) => string \| undefined` | Tutte le varianti |
|
|
448
|
+
| `readOnlyAfterSet` | `boolean` | readonly dopo primo valore |
|
|
449
|
+
| `disabled` | `boolean` | |
|
|
450
|
+
| `title` | `string` | |
|
|
451
|
+
| `feedback` | `string` | Messaggio di errore/suggerimento |
|
|
452
|
+
|
|
453
|
+
`Autocomplete` è una combobox accessibile: la lista (in un portal, larga quanto il campo, stile popover del tema) mostra solo le label e filtra per label/value senza distinzione di maiuscole e accenti; i chip mostrano la label; tastiera: frecce, Invio, Esc (chiude solo la lista, non il `Modal`), Tab, Backspace su campo vuoto rimuove l'ultimo valore. Con `creatable` compare la voce "Crea «testo»". Il valore salvato è sempre l'array dei `value`. `Autocomplete` e `Checklist` sono export nominati: `Select.Autocomplete`/`Select.Checklist` non esistono.
|
|
454
|
+
|
|
455
|
+
### UploadImage / UploadDocument / UploadCSV
|
|
456
|
+
```tsx
|
|
457
|
+
<UploadImage name="cover" label="Copertina" /> {/* con crop editor */}
|
|
458
|
+
<UploadDocument name="pdf" label="PDF" />
|
|
459
|
+
<UploadCSV name="data" label="Importa CSV" /> {/* con preview tabellare */}
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
**UploadImageProps** (eredita FormFieldProps):
|
|
463
|
+
| Prop | Tipo | Note |
|
|
464
|
+
|---|---|---|
|
|
465
|
+
| `name` | `string` (required) | |
|
|
466
|
+
| `uploadPath` | `string` | Path storage per upload automatico |
|
|
467
|
+
| `accept` | `string` | MIME types accettati |
|
|
468
|
+
| `editable` | `boolean` | Abilita crop editor |
|
|
469
|
+
| `multiple` | `boolean` | Multipla selezione |
|
|
470
|
+
| `max` | `number` | Numero massimo file |
|
|
471
|
+
| `feedback` | `string` | Testo placeholder drop zone |
|
|
472
|
+
| `srcsetWidths` | `number[]` | Larghezze varianti responsive |
|
|
473
|
+
| `previewHeight` / `previewWidth` | `number` | Dimensioni preview |
|
|
474
|
+
|
|
475
|
+
**UploadDocumentProps** (eredita FormFieldProps): `name`, `uploadPath`, `accept`, `editable`, `multiple`, `max`
|
|
476
|
+
|
|
477
|
+
### UploadCSV
|
|
478
|
+
```tsx
|
|
479
|
+
<UploadCSV name="data" label="Importa CSV" />
|
|
480
|
+
```
|
|
481
|
+
| Prop | Tipo |
|
|
482
|
+
|---|---|
|
|
483
|
+
| `name` | `string` (required) |
|
|
484
|
+
| `onDataLoaded` | `(data: UploadCSVData) => void` |
|
|
485
|
+
| `onParseField` | `([key, value]) => [key, value] \| undefined` |
|
|
486
|
+
| `normalizeKeys` | `boolean` |
|
|
487
|
+
| `removeEmptyFields` | `boolean` |
|
|
488
|
+
| `delimiter` | `string` |
|
|
489
|
+
| `label` / `icon` | Opzionali |
|
|
490
|
+
|
|
491
|
+
### ImageField
|
|
492
|
+
```tsx
|
|
493
|
+
<ImageField
|
|
494
|
+
name="hero"
|
|
495
|
+
label="Hero image"
|
|
496
|
+
defaultValue={{ src: 'https://example.com/hero.jpg', alt: 'Hero shot' }}
|
|
497
|
+
srcsetWidths={[400, 800]}
|
|
498
|
+
uploadPath="/content/images"
|
|
499
|
+
/>
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
Gestisce un oggetto `{ src, alt, srcset?, sizes? }`, preview inline, crop editor e generazione opzionale di varianti responsive.
|
|
503
|
+
|
|
504
|
+
### CropImage
|
|
505
|
+
```tsx
|
|
506
|
+
<CropImage img={imageObj} title="Ritaglia" scales={{ '1:1': 1, '4:3': 1.33 }} />
|
|
507
|
+
```
|
|
508
|
+
Componente di ritaglio indipendente. `img` ha tipo `{ fileName, variants }` dove ogni variante è `{ fileName, type, scale, top, left, width, height, base64? }`. Usato internamente da `UploadImage` e `ImageField`, ma esportato pubblicamente per uso standalone.
|
|
509
|
+
|
|
510
|
+
### CodeEditor
|
|
511
|
+
```tsx
|
|
512
|
+
<CodeEditor
|
|
513
|
+
name="code"
|
|
514
|
+
label="Template"
|
|
515
|
+
language="html"
|
|
516
|
+
placeholder="Scrivi HTML..."
|
|
517
|
+
minHeight={200}
|
|
518
|
+
maxHeight={600}
|
|
519
|
+
disabled={false}
|
|
520
|
+
required
|
|
521
|
+
validateSyntax
|
|
522
|
+
commands={[{ name: 'wrap-section', handler: ({ value }) => `<section>\n${value}\n</section>` }]}
|
|
523
|
+
commandsTrigger="/"
|
|
524
|
+
/>
|
|
525
|
+
```
|
|
526
|
+
Editor basato su CodeMirror con syntax highlighting e validazione. Linguaggi: `liquid`, `html`, `json`, `js`, `ts`, `css`.
|
|
527
|
+
Quando `commands` e presente, `CodeEditor` apre internamente `ContextMenu` sul trigger configurato.
|
|
528
|
+
|
|
529
|
+
| Prop extra | Tipo |
|
|
530
|
+
|---|---|
|
|
531
|
+
| `language` | `CodeEditorLanguage` |
|
|
532
|
+
| `placeholder` | `string` |
|
|
533
|
+
| `minHeight` / `maxHeight` | `number` |
|
|
534
|
+
| `validateSyntax` | `boolean` |
|
|
535
|
+
| `validator` | `(value) => string \| undefined \| Promise<string \| undefined>` |
|
|
536
|
+
| `extensions` | `unknown[]` |
|
|
537
|
+
|
|
538
|
+
### RichText
|
|
539
|
+
```tsx
|
|
540
|
+
<RichText
|
|
541
|
+
name="body"
|
|
542
|
+
label="Article body"
|
|
543
|
+
placeholder="Scrivi..."
|
|
544
|
+
toolbar="fixed" // 'fixed' | 'floating' | false
|
|
545
|
+
toolbarCommands={['bold', 'italic', 'heading1', '|', 'bulletList', 'link']}
|
|
546
|
+
outputFormat="html" // 'html' | 'json' | 'text'
|
|
547
|
+
statusBar={{ tagBreadcrumb: true, wordCount: true }}
|
|
548
|
+
minHeight={200}
|
|
549
|
+
maxHeight={800}
|
|
550
|
+
imageUpload={{ path: '/content/images', srcsetWidths: [400, 800] }}
|
|
551
|
+
commands={[{ name: 'summary', icon: 'sparkles' }]}
|
|
552
|
+
commandsTrigger="/"
|
|
553
|
+
/>
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
| Prop extra | Tipo |
|
|
557
|
+
|---|---|
|
|
558
|
+
| `placeholder` | `string` |
|
|
559
|
+
| `disabled` | `boolean` |
|
|
560
|
+
| `feedback` | `string` |
|
|
561
|
+
| `toolbar` | `'fixed' \| 'floating' \| false` |
|
|
562
|
+
| `toolbarCommands` | `ToolbarCommand[]` |
|
|
563
|
+
| `outputFormat` | `'html' \| 'json' \| 'text'` |
|
|
564
|
+
| `statusBar` | `boolean \| StatusBarConfig` |
|
|
565
|
+
| `minHeight` / `maxHeight` | `number` |
|
|
566
|
+
| `imageUpload` | `RichTextImageUploadConfig` |
|
|
567
|
+
| `documentUpload` | `RichTextDocumentUploadConfig` |
|
|
568
|
+
| `validator` | `(value) => string \| undefined` |
|
|
569
|
+
|
|
570
|
+
### Repeat — array dinamici
|
|
571
|
+
```tsx
|
|
572
|
+
<Repeat name="items" defaultLength={3} minItems={1} maxItems={10} label="Elementi" layout="vertical" readOnly>
|
|
573
|
+
{({ index, record, records, remove }) => (
|
|
574
|
+
<>
|
|
575
|
+
<Input name={`items.${index}.name`} label="Nome" />
|
|
576
|
+
<UploadImage name={`items.${index}.photo`} label="Foto" />
|
|
577
|
+
</>
|
|
578
|
+
)}
|
|
579
|
+
</Repeat>
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
| Prop | Tipo | Note |
|
|
583
|
+
|---|---|---|
|
|
584
|
+
| `name` | `string` (required) | |
|
|
585
|
+
| `children` | `ReactNode \| ((args) => ReactNode)` | Render prop con `{ index, record, records, remove }` |
|
|
586
|
+
| `defaultLength` | `number` | Righe iniziali |
|
|
587
|
+
| `minItems` / `maxItems` | `number` | Min/max righe |
|
|
588
|
+
| `layout` | `'vertical' \| 'horizontal' \| 'inline'` | |
|
|
589
|
+
| `label` | `string` | Etichetta gruppo |
|
|
590
|
+
| `labelPosition` | `'top' \| 'bottom'` | |
|
|
591
|
+
| `hideRemoveButton` | `boolean` | Nascondi rimozione |
|
|
592
|
+
| `readOnly` | `boolean` | Sola lettura |
|
|
593
|
+
| `onChange` | `FieldOnChange` | |
|
|
594
|
+
| `onAdd` / `onRemove` | `(records) => void` | Callback aggiunta/rimozione |
|
|
595
|
+
|
|
596
|
+
### Prompt — campo AI-potenziato
|
|
597
|
+
```tsx
|
|
598
|
+
<Prompt
|
|
599
|
+
name="summary"
|
|
600
|
+
mode="run" // 'edit' | 'run'
|
|
601
|
+
onRunPrompt={async (prompt, options) => AI.fetch(prompt)}
|
|
602
|
+
commands={[{ name: 'translate', icon: 'languages', handler: (v) => `Translate:\n${v}` }]}
|
|
603
|
+
commandsTrigger="/" // default automatico quando commands e presente
|
|
604
|
+
attachments
|
|
605
|
+
statusItems={['tokensIn', 'tokensOut', 'contextPercent', 'duration']}
|
|
606
|
+
/>
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
Quando `commands` e presente in `mode="run"`, `Prompt` monta internamente `ContextMenu` sulla textarea del risultato. Il trigger di default e `"/"`; `commandsTrigger` permette di cambiarlo. Il menu diventa searchable automaticamente sopra una soglia interna di comandi.
|
|
610
|
+
|
|
611
|
+
`renderFallback`: quando l'AI non e configurata, `Prompt` monta un fallback testuale; passa `renderFallback` per personalizzarlo (riceve `{ name, label, required, onChange }`).
|
|
612
|
+
|
|
613
|
+
---
|
|
614
|
+
|
|
615
|
+
## UI Primitives
|
|
616
|
+
|
|
617
|
+
### Alert
|
|
618
|
+
```tsx
|
|
619
|
+
<Alert variant="success">Salvato!</Alert>
|
|
620
|
+
<Alert variant="warning" icon placement="fixed" timeout={3000}>Attenzione</Alert>
|
|
621
|
+
```
|
|
622
|
+
`variant`: `'info' | 'success' | 'warning' | 'danger' | 'primary' | 'secondary' | 'light' | 'dark'`
|
|
623
|
+
`appearance`: `'default' | 'text'`
|
|
624
|
+
`placement`: `'inline' | 'fixed'`
|
|
625
|
+
|
|
626
|
+
### Badge
|
|
627
|
+
```tsx
|
|
628
|
+
<Badge variant="success">Attivo</Badge>
|
|
629
|
+
```
|
|
630
|
+
`variant`: stessi valori di Alert
|
|
631
|
+
|
|
632
|
+
### Button variants
|
|
633
|
+
```tsx
|
|
634
|
+
<ActionButton variant="primary" label="Salva" icon="save" onClick={handleSave} />
|
|
635
|
+
<LoadingButton variant="primary" label="Invia" onClick={async (e, setMsg) => { await save(); setMsg('Salvato!') }} />
|
|
636
|
+
<BackLink label="Indietro" />
|
|
637
|
+
<GoSite href="https://..." label="Visita" />
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
**IButton props:** `variant`, `label`, `icon`, `badge`, `disabled`, `ariaLabel`, `title`, `iconClassName`, `onClick`
|
|
641
|
+
**LoadingButton aggiunge:** `loading`, `loadingLabel` — `onClick` riceve `(e, setMessage?) => Promise<unknown>`
|
|
642
|
+
|
|
643
|
+
### Card
|
|
644
|
+
```tsx
|
|
645
|
+
<Card title="Titolo" header={<Actions />} footer={<Pagination />} loading={isLoading}>
|
|
646
|
+
{children}
|
|
647
|
+
</Card>
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
### Modal
|
|
651
|
+
```tsx
|
|
652
|
+
<Modal title="Conferma" size="md" position="center" onClose={() => {}} onSave={handleSave} onDelete={handleDelete} motion="fade" allowFullscreen stackedBehind>
|
|
653
|
+
{content}
|
|
654
|
+
</Modal>
|
|
655
|
+
<ModalYesNo title="Sicuro?" onClose={() => {}} onYes={async () => true}>Eliminare il record?</ModalYesNo>
|
|
656
|
+
<ModalOk title="Completato!" onClose={() => {}}>Salvato.</ModalOk>
|
|
657
|
+
```
|
|
658
|
+
`size`: `'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'fullscreen'`
|
|
659
|
+
`position`: `'center' | 'top' | 'left' | 'right' | 'bottom'`
|
|
660
|
+
`ModalYesNo` e `ModalOk` sono export separati: `Modal.YesNo` e `Modal.Ok` non esistono.
|
|
661
|
+
Tastiera: Esc chiude il modal in cima alla pila (`closeOnEscape`, default `true`).
|
|
662
|
+
Accessibilità: il dialog ha `role="dialog"`, `aria-modal="true"` (non con `stackedBehind`) e `aria-labelledby` verso `title` (o `header` stringa) — nei test si trova con `getByRole('dialog', { name })`.
|
|
663
|
+
|
|
664
|
+
| Prop | Tipo | Note |
|
|
665
|
+
|---|---|---|
|
|
666
|
+
| `children` | `ReactNode` (required) | |
|
|
667
|
+
| `title` | `ReactNode` | |
|
|
668
|
+
| `header` / `footer` | `ReactNode \| false` | Custom header/footer |
|
|
669
|
+
| `size` / `position` | Come sopra | |
|
|
670
|
+
| `onClose` | `() => void` | |
|
|
671
|
+
| `onSave` / `onDelete` | `(e) => Promise<boolean>` | |
|
|
672
|
+
| `allowFullscreen` | `boolean` | Toggle fullscreen |
|
|
673
|
+
| `showCancel` | `boolean` | Default `true` |
|
|
674
|
+
| `stackedBehind` | `boolean` | Modale sotto un'altra (stile Google Tag Manager): un velo la scurisce, il suo backdrop resta com'è (quello della modale sopra entra sopra, così la pagina si scurisce di un gradino per modale) e non riceve il puntatore. I pannelli laterali aperti sullo stesso lato si impilano da soli: quello in cima prende la larghezza con cui si è aperto il primo, ognuno sotto è largo il 10% in più di quello sopra (100%, 110%, 121%…), così ne sporge una striscia. Solo la larghezza cambia, con la transizione dello slide, in entrata e in uscita |
|
|
675
|
+
| `closeOnBackdrop` | `boolean` | Default `true` |
|
|
676
|
+
| `closeOnEscape` | `boolean` | Default `true` — solo il modal in cima reagisce |
|
|
677
|
+
| `zIndex` | `number` | |
|
|
678
|
+
| `motion` | `MotionReference` | Preset animazione |
|
|
679
|
+
| Classi CSS header/title/subtitle/body/footer | `string` | |
|
|
680
|
+
|
|
681
|
+
### Table
|
|
682
|
+
```tsx
|
|
683
|
+
<Table
|
|
684
|
+
columns={[{ key: 'name', label: 'Nome', sort: true }]}
|
|
685
|
+
records={records}
|
|
686
|
+
onRowClick={(record) => {}}
|
|
687
|
+
selection="multiple"
|
|
688
|
+
sortable={{ field: 'name', dir: 'asc' }}
|
|
689
|
+
pagination={{ limit: 20 }}
|
|
690
|
+
onReorder={(records, meta) => {}}
|
|
691
|
+
onSelectionChange={(sel) => {}}
|
|
692
|
+
groupBy="status"
|
|
693
|
+
renderCell={(record, key, index) => <CustomCell />}
|
|
694
|
+
/>
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
| Prop | Tipo |
|
|
698
|
+
|---|---|
|
|
699
|
+
| `columns` | `TableHeaderProp[]` |
|
|
700
|
+
| `records` | `RecordArray` |
|
|
701
|
+
| `sortable` | `boolean \| OrderConfig` |
|
|
702
|
+
| `pagination` | `PaginationParams` |
|
|
703
|
+
| `selection` | `'single' \| 'multiple'` |
|
|
704
|
+
| `onRowClick` | `(record) => void` |
|
|
705
|
+
| `onReorder` | `(records, meta) => void` |
|
|
706
|
+
| `onSelectionChange` | `(selection) => void` |
|
|
707
|
+
| `renderCell` | `(record, key, index) => ReactNode` |
|
|
708
|
+
| `groupBy` | `string \| string[]` |
|
|
709
|
+
| `activeKey` | `string \| null` |
|
|
710
|
+
| `selectedKeys` | `string[]` |
|
|
711
|
+
| `header` / `footer` | `ReactNode` |
|
|
712
|
+
| `headerClassName` / `bodyClassName` / `footerClassName` / `scrollClassName` / `selectedClassName` / `heightClassName` | `string` |
|
|
713
|
+
|
|
714
|
+
### Gallery
|
|
715
|
+
```tsx
|
|
716
|
+
<Gallery
|
|
717
|
+
records={records}
|
|
718
|
+
overlays={[{ position: 'topRight', badge: { variant: 'success', children: 'New' } }]}
|
|
719
|
+
columns={3}
|
|
720
|
+
gap={2}
|
|
721
|
+
sortable={{ field: 'name', dir: 'asc' }}
|
|
722
|
+
pagination={{ limit: 20 }}
|
|
723
|
+
onRowClick={(record) => {}}
|
|
724
|
+
onSelectionChange={(sel) => {}}
|
|
725
|
+
header="Titolo"
|
|
726
|
+
groupBy="status"
|
|
727
|
+
/>
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
`position`: `'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'middleLeft' | 'middleRight'`
|
|
731
|
+
|
|
732
|
+
| Prop | Tipo |
|
|
733
|
+
|---|---|
|
|
734
|
+
| `records` | `GalleryRecord[]` (`{ img?, thumbnail?, name?, width?, height? }`) |
|
|
735
|
+
| `columns` | `1 \| 2 \| 3 \| 4 \| 6` |
|
|
736
|
+
| `gap` | `0 \| 1 \| 2 \| 3 \| 4 \| 5` |
|
|
737
|
+
| `overlays` | `GalleryOverlay[]` |
|
|
738
|
+
| `sortable` | `boolean \| OrderConfig` |
|
|
739
|
+
| `pagination` | `PaginationParams` |
|
|
740
|
+
| `onRowClick` | `(record) => void` |
|
|
741
|
+
| `onSelectionChange` | `(selection) => void` |
|
|
742
|
+
| `groupBy` | `string \| string[]` |
|
|
743
|
+
| `selectedKeys` | `string[]` |
|
|
744
|
+
| `header` / `footer` | `ReactNode` |
|
|
745
|
+
| Classi CSS: `headerClassName`, `bodyClassName`, `footerClassName`, `scrollClassName`, `selectedClassName` | `string` |
|
|
746
|
+
|
|
747
|
+
### Tab
|
|
748
|
+
```tsx
|
|
749
|
+
import { Tab, TabItem } from '@llmnative/react'
|
|
750
|
+
|
|
751
|
+
<Tab defaultIndex={0} layout="top">
|
|
752
|
+
<TabItem label="Generale">{content1}</TabItem>
|
|
753
|
+
<TabItem label="SEO">{content2}</TabItem>
|
|
754
|
+
</Tab>
|
|
755
|
+
```
|
|
756
|
+
`layout`: `'default' | 'top' | 'left' | 'right' | 'bottom'`
|
|
757
|
+
Le schede sono `<TabItem>`, export separato: `Tab.Item` non esiste.
|
|
758
|
+
|
|
759
|
+
### Image
|
|
760
|
+
```tsx
|
|
761
|
+
<Image src="..." fit="cover" position="center" width={400} height={300} />
|
|
762
|
+
```
|
|
763
|
+
`fit`: `'cover' | 'contain' | 'fill' | 'scale-down' | 'none'`
|
|
764
|
+
|
|
765
|
+
### Pagination (standalone)
|
|
766
|
+
```tsx
|
|
767
|
+
<Pagination records={items} limit={20}>
|
|
768
|
+
{(pageRecords, offset) => pageRecords.map(r => <Row key={r._key} record={r} />)}
|
|
769
|
+
</Pagination>
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
### Percentage
|
|
773
|
+
```tsx
|
|
774
|
+
<Percentage value={75} appearance="bar" variant="success" showText />
|
|
775
|
+
<Percentage value={0.75} appearance="circle" size={60} />
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
| Prop | Tipo | Default |
|
|
779
|
+
|---|---|---|
|
|
780
|
+
| `value` | `number` | — |
|
|
781
|
+
| `max` | `number` | `100` |
|
|
782
|
+
| `min` | `number` | — |
|
|
783
|
+
| `appearance` | `'bar' \| 'circle'` | `'bar'` |
|
|
784
|
+
| `variant` | `ColorType` | — |
|
|
785
|
+
| `trackVariant` | `ColorType` | — |
|
|
786
|
+
| `thickness` | `number` | — (px) |
|
|
787
|
+
| `showText` | `boolean` | — |
|
|
788
|
+
| `size` | `number` | Diametro in modalità `'circle'` (px) |
|
|
789
|
+
| `fontSize` | `number` | — |
|
|
790
|
+
| `label` | `string` | — |
|
|
791
|
+
|
|
792
|
+
### DescriptionList
|
|
793
|
+
Coppie etichetta → valore in sola lettura (profilo, dati di un record, riepiloghi), rese come `<dl>`/`<dt>`/`<dd>`. Da usare al posto di markup `<dl>` scritto a mano; per dati modificabili usare i campi di `<Form>`, per molti record `<Table>`/`<Grid>`.
|
|
794
|
+
```tsx
|
|
795
|
+
<DescriptionList items={[{ label: 'Email', value: 'a@b.it' }, { label: 'Telefono', value: null }]} />
|
|
796
|
+
<DescriptionList layout="stacked" columns={4} truncate items={[{ label: 'Stato', value: <Badge variant="success">Spedito</Badge> }]} />
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
| Prop | Tipo | Default |
|
|
800
|
+
|---|---|---|
|
|
801
|
+
| `items` | `DescriptionListItem[]` — `{ key?, label, value?, title? }` | — |
|
|
802
|
+
| `layout` | `'horizontal' \| 'stacked'` | `'horizontal'` (etichette a sinistra, impilate su mobile) |
|
|
803
|
+
| `columns` | `1 \| 2 \| 3 \| 4 \| 5 \| 6` | `1` (solo `stacked`, dal breakpoint `lg`) |
|
|
804
|
+
| `labelWidth` | `string` (lunghezza CSS) | `'12rem'` (solo `horizontal`) |
|
|
805
|
+
| `emptyValue` | `ReactNode` | `'—'` per `null` / `undefined` / `''` (lo `0` resta) |
|
|
806
|
+
| `truncate` | `boolean` | `false`; un valore testuale diventa il suo `title` |
|
|
807
|
+
| Classi | `wrapperClassName`, `className`, `itemClassName`, `labelClassName`, `valueClassName` | tema `DescriptionList` |
|
|
808
|
+
|
|
809
|
+
### Tree
|
|
810
|
+
Albero accessibile di nodi (cartelle e file, gerarchie): pattern WAI-ARIA tree, un solo tab stop, frecce per muoversi, → / ← per aprire e chiudere, Invio o Spazio per selezionare. Le cartelle si aprono al click, le foglie si selezionano.
|
|
811
|
+
```tsx
|
|
812
|
+
<Tree nodes={treeFromPaths(paths)} defaultExpanded selectedId={path} onSelect={(node) => setPath(node.id)} ariaLabel="File" />
|
|
813
|
+
<Tree nodes={[{ id: 'a', label: 'Docs', children: [{ id: 'a/1', label: 'README.md', badge: <Badge>new</Badge> }] }]} />
|
|
814
|
+
```
|
|
815
|
+
| Prop | Tipo | Note |
|
|
816
|
+
|---|---|---|
|
|
817
|
+
| `nodes` | `TreeNode[]` — `{ id, label, icon?, badge?, description?, children?, disabled? }` | `id` unico; con `children` è una cartella |
|
|
818
|
+
| `selectedId` + `onSelect` / `defaultSelectedId` | `string \| null` | selezione controllata o no |
|
|
819
|
+
| `expanded` + `onExpandedChange` / `defaultExpanded` | `string[]`; `defaultExpanded` anche `true` (tutto aperto) | apertura controllata o no |
|
|
820
|
+
| `selectableBranches` | `boolean` (default `false`) | anche le cartelle si selezionano |
|
|
821
|
+
| `ariaLabel` | `string` | nome accessibile |
|
|
822
|
+
| Classi | `wrapperClassName`, `className`, `itemClassName`, `selectedClassName` | tema `Tree` |
|
|
823
|
+
|
|
824
|
+
`treeFromPaths(paths, leaf?)` costruisce l'albero da percorsi `a/b/c`: cartelle prima dei file, ordinati; l'id di un file è il percorso, quello di una cartella `percorso/`; `leaf(path)` decora le foglie (label, icona, descrizione…).
|
|
825
|
+
|
|
826
|
+
### Dropdown
|
|
827
|
+
```tsx
|
|
828
|
+
<Dropdown trigger={<Icon name="menu" />} position="end">
|
|
829
|
+
<DropdownItem label="Modifica" icon="edit" onClick={() => {}} />
|
|
830
|
+
<DropdownItem label="Elimina" icon="trash" variant="danger" />
|
|
831
|
+
<DropdownDivider />
|
|
832
|
+
<DropdownHeader label="Azioni rapide" />
|
|
833
|
+
</Dropdown>
|
|
834
|
+
```
|
|
835
|
+
|
|
836
|
+
Azioni secondarie di una voce (CR-107): `actions` mostra icone in fondo alla riga, al passaggio
|
|
837
|
+
del mouse o al focus (sempre sui dispositivi touch). Non selezionano la voce e lasciano il menu aperto
|
|
838
|
+
salvo `closeOnClick`.
|
|
839
|
+
|
|
840
|
+
```tsx
|
|
841
|
+
<DropdownItem icon="messages-square" onClick={() => open(chat)}
|
|
842
|
+
actions={[{ icon: 'archive', label: 'Archivia', onClick: () => archive(chat) }]}>
|
|
843
|
+
{chat.title}
|
|
844
|
+
</DropdownItem>
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
Per elenchi caricati dinamicamente usare `AsyncDropdown`: gestisce ricerca con debounce,
|
|
848
|
+
cancellazione delle richieste precedenti tramite `AbortSignal` e stati loading/empty/error.
|
|
849
|
+
|
|
850
|
+
```tsx
|
|
851
|
+
<AsyncDropdown
|
|
852
|
+
trigger={<ActionButton label="Select user" />}
|
|
853
|
+
loadItems={(query, signal) => users.search(query, { signal })}
|
|
854
|
+
getItemId={user => user.id}
|
|
855
|
+
renderItem={user => user.name}
|
|
856
|
+
onSelect={user => setUser(user)}
|
|
857
|
+
selectedId={user?.id}
|
|
858
|
+
/>
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
### ContextMenu
|
|
862
|
+
```tsx
|
|
863
|
+
<ContextMenu trigger="/" searchable>
|
|
864
|
+
<ContextMenu.Heading>Comandi</ContextMenu.Heading>
|
|
865
|
+
<ContextMenu.Item label="Titolo" value="# " icon="heading" />
|
|
866
|
+
<ContextMenu.Separator />
|
|
867
|
+
<ContextMenu.Item label="Bold" value="**bold**" icon="bold" />
|
|
868
|
+
</ContextMenu>
|
|
869
|
+
```
|
|
870
|
+
Funziona su qualsiasi `<textarea>` / `<input>` figlio. Trigger custom (`/`, `@`, `{`), filtro searchable, navigazione tastiera, floating positioning.
|
|
871
|
+
`ContextMenu.Item` accetta `description` (opzionale): seconda riga attenuata (`text-muted-foreground`)
|
|
872
|
+
sotto la label, troncata; il menu è largo al massimo 28rem e il testo completo resta nel `title`
|
|
873
|
+
della voce. Il filtro cerca nel testo digitato dopo il trigger su label, value e description (CR-111).
|
|
874
|
+
|
|
875
|
+
```tsx
|
|
876
|
+
<ContextMenu.Item label="/plan" value="plan" icon="list" description="Scrive il piano della release" />
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
| Prop | Tipo | Note |
|
|
880
|
+
|---|---|---|
|
|
881
|
+
| `trigger` | `string` (required) | Es. `"/"`, `"@"`, `"{"` |
|
|
882
|
+
| `searchable` | `boolean` | Filtro testuale |
|
|
883
|
+
| `controlled` | `ContextMenuControlledState` | Stato controllato esterno |
|
|
884
|
+
| `onSelect` | `(item, context) => void` | |
|
|
885
|
+
|
|
886
|
+
**EditorCommand** (usato da `commands` prop su `Chatbot`, `Prompt`, `RichText`, `CodeEditor`):
|
|
887
|
+
```ts
|
|
888
|
+
{
|
|
889
|
+
name: string;
|
|
890
|
+
description?: string;
|
|
891
|
+
icon?: string;
|
|
892
|
+
group?: string;
|
|
893
|
+
consumeSuffix?: string;
|
|
894
|
+
handler?: (context: TextCommandContext) => string | Promise<string>;
|
|
895
|
+
}
|
|
896
|
+
```
|
|
897
|
+
|
|
898
|
+
`description` compare sotto `/name` nel menu dei comandi di tutti e quattro i consumer e il filtro
|
|
899
|
+
la usa (digitare `/release` trova un comando descritto come "…release…"). Un comando senza `handler`
|
|
900
|
+
sostituisce il trigger con `/name ` (spazio finale) e il testo resta tale: in `Chatbot`/`Prompt` il
|
|
901
|
+
messaggio inviato è letteralmente `"/name …"`, da interpretare a cura di chi lo riceve.
|
|
902
|
+
|
|
903
|
+
`consumeSuffix` elimina una chiusura automatica adiacente durante la sostituzione del trigger,
|
|
904
|
+
utile quando un comando cambia famiglia sintattica (per esempio da `{{ ... }}` a `{% ... %}`).
|
|
905
|
+
|
|
906
|
+
### Altre primitive
|
|
907
|
+
```tsx
|
|
908
|
+
<Icon name="user" size={20} /> // usa provider icone configurato
|
|
909
|
+
<ImageAvatar src="..." title="Mario" alt="Mario" width={40} height={40} />
|
|
910
|
+
<Identicon value="acme/app" size={32} title="acme/app" /> // icona generata dal valore, stile GitHub
|
|
911
|
+
<Loader show={isLoading}>{content}</Loader> // indicatore al posto dei figli finché show è true
|
|
912
|
+
<Loader show>{null}</Loader> // solo indicatore (es. pagina in caricamento)
|
|
913
|
+
<Code language="tsx">{snippet}</Code> // syntax highlight
|
|
914
|
+
<GridSystem.Row><GridSystem.Col xs={12} md={6}>...</GridSystem.Col></GridSystem.Row>
|
|
915
|
+
<LocaleSwitcher locales={[{ code: 'it', label: 'Italiano' }]} />
|
|
916
|
+
<ThemeSwitcher />
|
|
917
|
+
<ProviderSwitcher />
|
|
918
|
+
<LayoutBuilder components={...} />
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
### Charts (CR-112)
|
|
922
|
+
Grafici SVG senza dipendenze, dal modulo `charts`. Colori come token del tema: `color` è uno slot della
|
|
923
|
+
palette categoriale (`1…8` → `--rf-chart-N`, definiti in `globals.css` con la variante scura e
|
|
924
|
+
sovrascrivibili dal consumer) o un token (`'--rf-success'`); le serie senza colore prendono lo slot
|
|
925
|
+
della loro posizione. Larghezza dal contenitore (ResizeObserver), animazioni spente con
|
|
926
|
+
`prefers-reduced-motion`, tooltip che segue il puntatore e la tastiera (le aree prendono il focus
|
|
927
|
+
finché sono al massimo 40), tabella dei dati `sr-only` con `ariaLabel` come didascalia, stato vuoto
|
|
928
|
+
`charts.noData`. `format` è facoltativo: di default il numero nella locale dell'app.
|
|
929
|
+
|
|
930
|
+
```tsx
|
|
931
|
+
<ColumnChart ariaLabel="CR chiuse al giorno" columns={[{ label: 'lun', value: 4 }]} markers={[{ position: 3.5, label: 'mediana', dashed: true }]} onColumnClick={(column) => {}} />
|
|
932
|
+
<StackedColumnChart ariaLabel="Ore per agente" labels={days} labelEvery={2} format={(v) => `${v} h`}
|
|
933
|
+
series={[{ id: 'dev', label: 'Developer', values: dev }, { id: 'qa', label: 'Tester', values: qa, color: 3 }]}
|
|
934
|
+
comparison={previousTotals} comparisonLabel="periodo precedente" />
|
|
935
|
+
<MeasureBarList ariaLabel="Agenti" // CR-115: barre raggruppate, ogni agente una volta, una barra per misura (colore in legenda), ognuna sulla sua scala
|
|
936
|
+
columns={[{ id: 'time', label: 'Ore', format: (v) => `${v} h` }, { id: 'cost', label: 'Costo' },
|
|
937
|
+
{ id: 'tokens', label: 'Token', parts: [{ id: 'in', label: 'Input' }, { id: 'out', label: 'Output' }] }]} // parts: la barra divisa in proporzione
|
|
938
|
+
rows={[{ id: 'dev', label: 'Developer', values: { time: 18, cost: 4.27, tokens: [2400000, 190000] }, trailing: { text: '18 back', tone: 'bad' } }]} />
|
|
939
|
+
<SequenceColumnChart ariaLabel="Turni per CR" format={(v) => `${v} min`} // CR-114: ogni colonna nel suo ordine, una serie può tornare
|
|
940
|
+
series={[{ id: 'dev', label: 'Developer' }, { id: 'rev', label: 'Reviewer' }]}
|
|
941
|
+
columns={[{ label: '#34', title: 'CR #34', segments: [{ series: 'dev', value: 18 }, { series: 'rev', value: 6 }, { series: 'dev', value: 11 }] }]}
|
|
942
|
+
onColumnClick={(column) => {}} />
|
|
943
|
+
<LineChart ariaLabel="Lead time" labels={days} threshold={{ value: 6.5, label: 'obiettivo' }} baseline={0} domain={[0, 10]}
|
|
944
|
+
series={[{ id: 'now', label: 'Ora', values: [3, null, 5], area: true, band: { min, max } }, { id: 'before', label: 'Prima', values: prev, dashed: true }]} />
|
|
945
|
+
<AreaChart ariaLabel="Flusso cumulativo" labels={days} stacked series={[{ id: 'closed', label: 'Chiuse', values: closed }]} />
|
|
946
|
+
<ScatterChart ariaLabel="Costo contro rework" xLabel="Costo" yLabel="Rework" sizeLabel="Turni"
|
|
947
|
+
series={[{ id: 'sonnet', label: 'Sonnet' }]} points={[{ id: '1', label: 'Developer', x: 0.04, y: 0.3, size: 30, series: 'sonnet' }]} onPointClick={(point) => {}} />
|
|
948
|
+
<DivergingBarChart ariaLabel="Valore e costo" upLabel="Valore" downLabel="Costo" bars={[{ label: 'lun', up: 120, down: null }]} />
|
|
949
|
+
<BarList ariaLabel="Costo per agente" rows={[{ id: 'dev', label: 'Developer', value: 1.84, trailing: { text: '+12%', tone: 'bad' } }]} />
|
|
950
|
+
<Heatmap ariaLabel="Turni per ora" rowLabels={agents} columnLabels={hours} columnLabelEvery={2} values={matrix} />
|
|
951
|
+
<CalendarHeatmap ariaLabel="Turni per giorno" days={[{ date: '2026-11-02', value: 4 }, { date: '2026-11-03', value: null }]} />
|
|
952
|
+
<Sparkline values={[1, 3, null, 2]} ariaLabel="Andamento" /> // senza ariaLabel è decorativa
|
|
953
|
+
<AnimatedNumber value={3.85} format={(v) => `$${v.toFixed(2)}`} />
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
Parti comuni per grafici propri: `useChartTooltip()` (`show`, `showAt`, `hide`, `element`), `ChartLegend`,
|
|
957
|
+
`ChartDataTable`, `useChartWidth(fallback)`, `useAnimatedValues(values)`, `useReveal(key)`,
|
|
958
|
+
`useChartFormat(format?)`, `chartToken(color)`, `chartFill(token, alpha?)`, `niceMax`, `ticks`.
|
|
959
|
+
|
|
960
|
+
---
|
|
961
|
+
|
|
962
|
+
## Blocks
|
|
963
|
+
|
|
964
|
+
```tsx
|
|
965
|
+
<Breadcrumbs trail={[{ label: 'Home', href: '/' }, { label: 'Utenti' }]} separator="/" jsonLd />
|
|
966
|
+
<Brand url="/" label="MyApp" logo="/logo.svg" width={120} />
|
|
967
|
+
<Search onQueryChange={(e) => setQ(e.target.value)} />
|
|
968
|
+
<Notifications items={[...]} seeAllUrl="/notifications" onMarkAllRead={() => {}} onItemClick={(item) => markRead(item.id)} />
|
|
969
|
+
<Notifications items={[{ id: 'a', title: 'Fonte senza Action', description: 'crm · sources/notes/a.md', url: '/projects/crm', time: 'ora', icon: 'file', actions: [{ label: "Apri l'Action", icon: 'play', onClick: openAction, variant: 'primary' }] }]} />
|
|
970
|
+
<Carousel images={[...]} />
|
|
971
|
+
<Toolbar items={[...]}>
|
|
972
|
+
{children}
|
|
973
|
+
</Toolbar>
|
|
974
|
+
<SideNav />
|
|
975
|
+
<ListCard records={records} onRowClick={(r) => {}} />
|
|
976
|
+
```
|
|
977
|
+
|
|
978
|
+
**Brand:**
|
|
979
|
+
| Prop | Tipo |
|
|
980
|
+
|---|---|
|
|
981
|
+
| `url` | `string` |
|
|
982
|
+
| `label` | `string` |
|
|
983
|
+
| `logo` | `string` |
|
|
984
|
+
| `width` / `height` | `number` |
|
|
985
|
+
| `wrapperClassName` / `className` / `logoClassName` / `labelClassName` | `string` |
|
|
986
|
+
|
|
987
|
+
**SideNav:**
|
|
988
|
+
| Prop | Tipo |
|
|
989
|
+
|---|---|
|
|
990
|
+
| `items` | `SideNavItemDef[]` (in alternativa a `menuKey`) |
|
|
991
|
+
| `menuKey` | `string` — voci dal menu registrato in `<App>` |
|
|
992
|
+
| `bottomItems` | `SideNavItemDef[]` — voci fissate in fondo, sopra il footer e fuori dalla lista scorrevole (es. Impostazioni) |
|
|
993
|
+
| `header` / `footer` | `ReactNode` |
|
|
994
|
+
| `collapsed` + `onCollapsedChange` / `defaultCollapsed` | `boolean` — compressione controllata o no |
|
|
995
|
+
| `showIcons` / `showCollapseButton` | `boolean` (default `true`) |
|
|
996
|
+
| `embedded` | `boolean` — solo le voci, senza guscio (drawer, pannelli); `bottomItems` seguono le voci principali |
|
|
997
|
+
|
|
998
|
+
`SideNavItemDef`: `{ path, title?, icon?, group?, end?, badge?, children? }`. La voce attiva ha
|
|
999
|
+
`aria-current="page"`.
|
|
1000
|
+
|
|
1001
|
+
```tsx
|
|
1002
|
+
<SideNav
|
|
1003
|
+
items={[{ path: '/dashboard', title: 'Dashboard', icon: 'home' }]}
|
|
1004
|
+
bottomItems={[{ path: '/settings', title: 'Impostazioni', icon: 'settings' }]}
|
|
1005
|
+
/>
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
**ImageAvatar:**
|
|
1009
|
+
| Prop | Tipo |
|
|
1010
|
+
|---|---|
|
|
1011
|
+
| `src` | `string` (obbligatoria) |
|
|
1012
|
+
| `width` / `height` | `number` |
|
|
1013
|
+
| `title` / `alt` | `string` |
|
|
1014
|
+
| `fit` | `AvatarFit` |
|
|
1015
|
+
| `badge` | `BadgeDescriptor` |
|
|
1016
|
+
| `feedback` | `ReactNode` |
|
|
1017
|
+
|
|
1018
|
+
**Identicon:** l'icona di un'entità senza immagine (repository, tenant, utente senza foto), come quelle di
|
|
1019
|
+
GitHub: griglia 5×5 simmetrica, celle e tinta da un hash di `value`. Lo stesso valore dà sempre la stessa
|
|
1020
|
+
icona; niente rete né storage. Default: `rounded-md bg-muted` (tema `Identicon.className`).
|
|
1021
|
+
`identiconPattern(value)` restituisce celle e tinta, per chi la disegna altrove.
|
|
1022
|
+
| Prop | Tipo |
|
|
1023
|
+
|---|---|
|
|
1024
|
+
| `value` | `string` (obbligatoria) |
|
|
1025
|
+
| `size` | `number` (px, default 40) |
|
|
1026
|
+
| `title` | `string`: nome accessibile (`role="img"`); senza, `aria-hidden` |
|
|
1027
|
+
| `before` / `after` / `className` / `wrapperClassName` | come le altre primitive |
|
|
1028
|
+
|
|
1029
|
+
**Search:**
|
|
1030
|
+
| Prop | Tipo |
|
|
1031
|
+
|---|---|
|
|
1032
|
+
| `onQueryChange` | `(e: React.ChangeEvent<HTMLInputElement>) => void` |
|
|
1033
|
+
|
|
1034
|
+
**Notifications:**
|
|
1035
|
+
| Prop | Tipo |
|
|
1036
|
+
|---|---|
|
|
1037
|
+
| `items` | `NotificationItem[]` |
|
|
1038
|
+
| `badge` | `BadgeProps` |
|
|
1039
|
+
| `seeAllUrl` | `string` |
|
|
1040
|
+
| `onMarkAllRead` | `() => void` |
|
|
1041
|
+
| `onItemClick` | `(item, index) => void` — una voce aperta (es. per segnarla letta); il menu si chiude |
|
|
1042
|
+
| `motion` | `MotionReference` |
|
|
1043
|
+
|
|
1044
|
+
`NotificationItem`: `{ id?, title, description?, url?, external?, time, icon, read?, actions? }`. `description` è la
|
|
1045
|
+
riga sotto il titolo; senza `url` la voce si mostra e basta; con `external` l'`url` è un indirizzo aperto
|
|
1046
|
+
in una nuova scheda (`<a target="_blank">`), altrimenti una rotta (`Link`). `actions`
|
|
1047
|
+
(`NotificationAction[]`: `{ label, icon?, onClick, variant?: 'primary' | 'default', closeOnClick? }`) sono
|
|
1048
|
+
pulsanti sotto la voce: non la aprono, mostrano il caricamento finché la promessa di `onClick` è in corso
|
|
1049
|
+
e lasciano il menu aperto salvo `closeOnClick`.
|
|
1050
|
+
|
|
1051
|
+
**ListCard:**
|
|
1052
|
+
| Prop | Tipo |
|
|
1053
|
+
|---|---|
|
|
1054
|
+
| `title` / `description` / `meta` | `ReactNode` |
|
|
1055
|
+
| `badge` | `ReactNode` |
|
|
1056
|
+
| `icon` | `string \| ReactNode` |
|
|
1057
|
+
| `trailing` / `footer` / `children` | `ReactNode` |
|
|
1058
|
+
| `href` | `string` |
|
|
1059
|
+
| `external` / `active` / `disabled` / `dashed` / `compact` | `boolean` |
|
|
1060
|
+
| `align` | `'start' \| 'center'` |
|
|
1061
|
+
| `onClick` | `(e) => void` |
|
|
1062
|
+
| Classi CSS: `titleClassName`, `descriptionClassName`, `metaClassName`, `badgeClassName`, `leadingClassName`, `bodyClassName`, `headerClassName`, `trailingClassName`, `footerClassName` | `string` |
|
|
1063
|
+
|
|
1064
|
+
**SortableList (CR-120):** card compatte (ListCard) in un ordine che la persona sceglie: le trascina per la
|
|
1065
|
+
maniglia, o con le frecce su/giù sulla maniglia; l'annuncio della nuova posizione va agli screen reader.
|
|
1066
|
+
```tsx
|
|
1067
|
+
<SortableList
|
|
1068
|
+
items={accounts}
|
|
1069
|
+
getKey={(a) => a.id}
|
|
1070
|
+
label="Account"
|
|
1071
|
+
numbered
|
|
1072
|
+
onReorder={(next, { fromIndex, toIndex, item }) => setAccounts(next)}
|
|
1073
|
+
renderItem={(a) => ({ title: a.email, meta: a.added, badge: <Badge variant="success">Disponibile</Badge>, trailing: <ActionButton icon="trash-2" … /> })}
|
|
1074
|
+
emptyState={<p>Nessun account</p>}
|
|
1075
|
+
/>
|
|
1076
|
+
moveItem(['a', 'b', 'c'], 0, 2) // ['b', 'c', 'a']
|
|
1077
|
+
```
|
|
1078
|
+
| Prop | Tipo |
|
|
1079
|
+
|---|---|
|
|
1080
|
+
| `items` / `getKey` | `TItem[]` / `(item) => string` |
|
|
1081
|
+
| `renderItem` | `(item, index) => SortableListCard` (`title`, `description`, `meta`, `badge`, `icon`, `trailing`, `active`, `disabled` di ListCard) |
|
|
1082
|
+
| `onReorder` | `(items, { fromIndex, toIndex, item }) => void`; senza, nessuna maniglia |
|
|
1083
|
+
| `label` / `numbered` / `disabled` / `emptyState` | `string` / `boolean` / `boolean` / `ReactNode` |
|
|
1084
|
+
| Classi CSS: `className`, `itemClassName`, `cardClassName` | `string` |
|
|
1085
|
+
|
|
1086
|
+
**Dropdown:**
|
|
1087
|
+
| Prop | Tipo |
|
|
1088
|
+
|---|---|
|
|
1089
|
+
| `trigger` | `string \| ReactNode \| DropdownTogglerProps` |
|
|
1090
|
+
| `badge` | `BadgeProps` |
|
|
1091
|
+
| `header` / `footer` | `ReactNode` |
|
|
1092
|
+
| `defaultOpen` / `open` | `boolean` |
|
|
1093
|
+
| `onOpenChange` | `(open) => void` |
|
|
1094
|
+
| `position` | `'start' \| 'end'` |
|
|
1095
|
+
| `placement` | `'auto' \| 'top' \| 'bottom'` |
|
|
1096
|
+
| `strategy` | `'fixed' \| 'absolute'` |
|
|
1097
|
+
|
|
1098
|
+
// Menu — renderizza una sezione del menuConfig passato ad <App>
|
|
1099
|
+
<Menu menuKey="main" /> // 'main' o qualsiasi chiave definita in MenuConfig
|
|
1100
|
+
<Menu menuKey="topbar" className="nav flex-row gap-2" />
|
|
1101
|
+
// NON usare context= — la prop si chiama menuKey
|
|
1102
|
+
|
|
1103
|
+
// AuthButton — login/logout con il provider auth configurato
|
|
1104
|
+
<AuthButton />
|
|
1105
|
+
```
|
|
1106
|
+
|
|
1107
|
+
---
|
|
1108
|
+
|
|
1109
|
+
## Widgets
|
|
1110
|
+
|
|
1111
|
+
### MarkdownReader
|
|
1112
|
+
```tsx
|
|
1113
|
+
<MarkdownReader
|
|
1114
|
+
content={markdownString}
|
|
1115
|
+
onInternalLinkClick={(href, e) => { e.preventDefault(); navigate(href) }}
|
|
1116
|
+
wrapperClassName="prose"
|
|
1117
|
+
/>
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
### Messaggi di chat: ChatMarkdown, ChatReasoning, ChatQuestions (CR-109), ChatActivity (CR-123)
|
|
1121
|
+
|
|
1122
|
+
Parti di un messaggio di un modello, da comporre nel proprio thread (anche accanto a `Chatbot`).
|
|
1123
|
+
|
|
1124
|
+
```tsx
|
|
1125
|
+
// Markdown GFM del messaggio: tabelle (scorrono dentro di sé in un pannello stretto), elenchi,
|
|
1126
|
+
// titoli, citazioni, task list, codice con evidenziazione (Prism, lazy) e pulsante Copia, link a
|
|
1127
|
+
// indirizzi in una nuova scheda (noopener). Sanitizzato: niente HTML grezzo, niente javascript:.
|
|
1128
|
+
// streaming: chiude ciò che la fine del testo lascia aperto (fence, intestazione di tabella,
|
|
1129
|
+
// **grassetto**, `codice`, link) così il layout non salta mentre arriva. Off per un messaggio finito.
|
|
1130
|
+
<ChatMarkdown content={text} streaming={running} onLinkClick={(href) => navigate(href)} />
|
|
1131
|
+
// tone="muted", highlight={false}, components (come react-markdown), className,
|
|
1132
|
+
// classNames={{ root, paragraph, heading, list, blockquote, tableWrapper, table, th, td, codeBlock, codeHeader, code, inlineCode, link }}
|
|
1133
|
+
// repairStreamingMarkdown(text) è la stessa riparazione, pura.
|
|
1134
|
+
|
|
1135
|
+
// Ragionamento: chiuso dietro "Ragionamento" / "Ha ragionato per 12 s"; aperto mentre arriva
|
|
1136
|
+
// (se l'utente non lo chiude) e richiuso alla fine. Contenuto con ChatMarkdown, tono attenuato.
|
|
1137
|
+
<ChatReasoning content={reasoning} streaming={thinking} duration={12} />
|
|
1138
|
+
// defaultOpen, open + onOpenChange (controllato), label, icon ('brain'), className, classNames={{ root, trigger, content }}
|
|
1139
|
+
|
|
1140
|
+
// Domande interattive (formato dello strumento `question` di opencode / elicitation MCP):
|
|
1141
|
+
<ChatQuestions
|
|
1142
|
+
questions={[
|
|
1143
|
+
{ id: 'db', header: 'Database', question: 'Quale database?', recommended: 0,
|
|
1144
|
+
options: [{ label: 'Postgres', description: 'Relazionale' }, { label: 'SQLite' }] },
|
|
1145
|
+
{ id: 'features', header: 'Funzioni', question: 'Quali funzioni?', multiple: true,
|
|
1146
|
+
options: [{ label: 'Auth' }, { label: 'Ricerca' }] },
|
|
1147
|
+
]}
|
|
1148
|
+
onSubmit={async (answers) => send(answers)} // [{ id, header, values: string[] }] in ordine
|
|
1149
|
+
/>
|
|
1150
|
+
// Una scheda per domanda (header) + Riepilogo e un solo Invia; opzioni numerate 1-2-3 o A-B-C
|
|
1151
|
+
// (numbering, altrimenti dedotto da etichette "A) …" / "1. …", che vengono tolte); consigliata
|
|
1152
|
+
// (recommended: indice da 0 o etichetta; anche il suffisso "(Recommended)"); multiple; "Altro" con
|
|
1153
|
+
// testo libero (allowOther, default true; per domanda `custom`); senza options è a testo libero.
|
|
1154
|
+
// Il testo libero è una textarea (CR-110) di 2 righe che cresce col testo fino a ~160px e poi
|
|
1155
|
+
// scorre; ridimensionabile in verticale. Lì Invio va a capo, Ctrl/Cmd+Invio prosegue o invia
|
|
1156
|
+
// (suggerimento `chat.textKeyboardHint` nel piè mentre si scrive).
|
|
1157
|
+
// Tastiera: numeri (o lettere con A-B-C) scelgono, frecce sinistra/destra tra le schede, su/giù tra
|
|
1158
|
+
// le opzioni, Spazio seleziona, Invio prosegue o invia (su una scelta singola prima la sceglie;
|
|
1159
|
+
// nel testo libero serve Ctrl/Cmd+Invio).
|
|
1160
|
+
// Ruoli tablist/tab/tabpanel, radiogroup/radio o group/checkbox.
|
|
1161
|
+
// Scelta singola: il click sceglie e passa alla domanda dopo. onSubmit che rifiuta lascia il form.
|
|
1162
|
+
// answers={[…]} mostra un insieme già risposto (sola lettura); disabled, autoFocus, submitLabel,
|
|
1163
|
+
// classNames={{ root, tabs, tab, panel, question, option, optionSelected, footer, summary }}
|
|
1164
|
+
|
|
1165
|
+
// Il lavoro di un agente (CR-123), come negli assistenti AI: gruppi di passi (icona, label, quanti,
|
|
1166
|
+
// dettagli brevi: query, file, comandi; quanti falliti) con le righe sotto aperte da "Comandi";
|
|
1167
|
+
// le parole dell'agente in Markdown; come è finito; i file cambiati con "Vedi le modifiche";
|
|
1168
|
+
// il registro grezzo a un clic. Il consumer traduce il suo log negli item.
|
|
1169
|
+
<ChatActivity
|
|
1170
|
+
items={[
|
|
1171
|
+
{ type: 'steps', icon: 'search', label: 'Esplora il repository', count: 3, detail: ['git status'], lines: ['git status --short'] },
|
|
1172
|
+
{ type: 'text', text: 'Aggiungo il comando e il suo test.' },
|
|
1173
|
+
{ type: 'end', ok: true, text: 'success · 9 steps' },
|
|
1174
|
+
]}
|
|
1175
|
+
files={['functions/src/catalog/index.js']} onShowChanges={() => openDiff()} log={rawLines}
|
|
1176
|
+
/>
|
|
1177
|
+
// className, classNames={{ root, step, text, files, log }}
|
|
1178
|
+
```
|
|
1179
|
+
|
|
1180
|
+
### ImageEditor
|
|
1181
|
+
```tsx
|
|
1182
|
+
<ImageEditor src="..." onSave={(dataUrl) => save(dataUrl)} />
|
|
1183
|
+
```
|
|
1184
|
+
|
|
1185
|
+
`ImageEditor` e un singolo componente pubblico. La libreria pesante `tui-image-editor` viene importata lazy a runtime dentro il componente, quindi non viene scaricata finche l'editor non viene effettivamente montato.
|
|
1186
|
+
|
|
1187
|
+
### TabDynamic
|
|
1188
|
+
Tab con lazy loading dei contenuti — gestione dinamica aggiunta/rimozione tab.
|
|
1189
|
+
|
|
1190
|
+
---
|
|
1191
|
+
|
|
1192
|
+
## AI Integration
|
|
1193
|
+
|
|
1194
|
+
```ts
|
|
1195
|
+
import { useAIProvider, getAIModelCatalog, createAIProviderRegistry } from '@llmnative/react'
|
|
1196
|
+
|
|
1197
|
+
// Hooks
|
|
1198
|
+
const provider = useAIProvider() // provider di default
|
|
1199
|
+
const registry = useAIProviderRegistry() // tutti i provider AI registrati
|
|
1200
|
+
const catalog = getAIModelCatalog() // modelli disponibili
|
|
1201
|
+
// ogni modello: { id, provider, model, label, pricing? } — pricing in USD per 1M token
|
|
1202
|
+
// { input, output, currency: 'USD', source: 'provider' | 'models.dev' }; assente = prezzo
|
|
1203
|
+
// non trovato (il modello resta in lista). isFreeAIModel(m) → input e output a 0.
|
|
1204
|
+
// Il model picker di Prompt/Chatbot mostra "$in / $out", evidenzia i free, segnala i mancanti,
|
|
1205
|
+
// e raggruppa per provider (ChatbotModelOption.group = providerLabel) con header sticky.
|
|
1206
|
+
// CR-121: il pulsante mostra la `label` del modello scelto (non il suo valore); `groupBadge: { label, variant? }`
|
|
1207
|
+
// su un'opzione mette un Badge a destra nell'header del suo gruppo (es. Abbonamento / A consumo).
|
|
1208
|
+
|
|
1209
|
+
// Provider adapter restituito da useAIProvider()
|
|
1210
|
+
const text = await provider.fetch("Scrivi un titolo per: {keyword}", { keyword: "React" })
|
|
1211
|
+
const json = await provider.json("Lista di 5 categorie per blog tech")
|
|
1212
|
+
const arr = await provider.array("5 tag per: machine learning")
|
|
1213
|
+
|
|
1214
|
+
// Provider custom
|
|
1215
|
+
class MyAIProvider implements AIProviderAdapter {
|
|
1216
|
+
async fetch(prompt: string, options?: AIRequestOptions): Promise<string> { ... }
|
|
1217
|
+
async json<T>(prompt: string, options?: AIRequestOptions): Promise<T> { ... }
|
|
1218
|
+
async array(prompt: string, options?: AIRequestOptions): Promise<string[]> { ... }
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
// Quanto ragiona il modello (CR-122): `reasoning: 'low' | 'medium' | 'high' | 'max'` (AIReasoningLevel) su
|
|
1222
|
+
// una richiesta. Anthropic: `output_config.effort` sui Claude 4.6 e successivi (+ thinking adaptive su Opus
|
|
1223
|
+
// 4.6-4.8 e Sonnet 4.6); OpenAI e compatibili (OpenCode, DeepSeek, Groq…): `reasoning_effort` solo sui modelli
|
|
1224
|
+
// di ragionamento di OpenAI (serie o, GPT-5; max = high); OpenRouter: `reasoning.effort` su ogni modello.
|
|
1225
|
+
// Altrove (modelli più vecchi, Gemini) non si manda nulla: il default del modello.
|
|
1226
|
+
await ai.complete({ prompt: 'Rivedi questo piano', model: 'claude-opus-5-5', reasoning: 'high' })
|
|
1227
|
+
|
|
1228
|
+
// Factory per registri esterni
|
|
1229
|
+
const registry = createAIProviderRegistry(definitions)
|
|
1230
|
+
// Azioni di Chatbot (CR-107): con `content` aprono un menu; senza, sono pulsanti con `onClick`.
|
|
1231
|
+
// <Chatbot actions={[{ key: 'finish', icon: 'git-pull-request', label: 'Concludi', showLabel: true,
|
|
1232
|
+
// disabled: running, onClick: finish }]} … />
|
|
1233
|
+
// Allegati di Chatbot (`attachments`): file scelti, trascinati o incollati con Ctrl+V (uno screenshot diventa
|
|
1234
|
+
// `pasted-<data>.png`, CR-124); il testo incollato resta testo. Arrivano in `onSubmit` come `files`.
|
|
1235
|
+
// Comandi "/" di Chatbot: `commands` (EditorCommand[]) + `commandsTrigger` (default "/").
|
|
1236
|
+
// Il menu mostra `/name` e sotto la `description`; il filtro cerca in entrambi (CR-111).
|
|
1237
|
+
// Senza `handler` la scelta inserisce "/name " e l'invio manda il testo così com'è.
|
|
1238
|
+
// Tastiera: Invio invia a menu chiuso e sceglie il comando evidenziato a menu aperto;
|
|
1239
|
+
// Maiusc+Invio (e Invio durante la composizione IME) va a capo.
|
|
1240
|
+
// <Chatbot commands={[{ name: 'plan', icon: 'list', description: 'Scrive il piano' }]} … />
|
|
1241
|
+
```
|
|
1242
|
+
|
|
1243
|
+
### Identità dei modelli indipendente dal provider (CR-103)
|
|
1244
|
+
|
|
1245
|
+
```ts
|
|
1246
|
+
const index = await loadModelIdentityIndex() // models.dev, un fetch per sessione
|
|
1247
|
+
canonicalModelName('DeepSeek V4.1 Flash (Alibaba Cloud)') // 'deepseek v4.1 flash'
|
|
1248
|
+
index.models['deepseek v4.1 flash'] // { key, name, family?, providers: { openrouter: [{ id, name }], … } }
|
|
1249
|
+
resolveModel(index, 'DeepSeek V4.1 Flash', ['openrouter', 'deepseek'])
|
|
1250
|
+
// → { provider: 'openrouter', model: 'deepseek/deepseek-v4.1-flash', ref: 'openrouter/deepseek/deepseek-v4.1-flash' }
|
|
1251
|
+
modelOffers(index, 'DeepSeek V4.1 Flash', ['openrouter', 'deepseek']) // CR-119: tutti quelli che lo servono
|
|
1252
|
+
// → [{ provider: 'openrouter', model, ref, cost: { input: 0.15, output: 0.3 } }, { provider: 'deepseek', … }]
|
|
1253
|
+
// senza `providers`: tutto il catalogo, per chiave del provider. `cost` in USD per 1M token, assente se models.dev non lo dà
|
|
1254
|
+
```
|
|
1255
|
+
|
|
1256
|
+
Il nome canonico toglie data, Free, Latest e host o regione tra parentesi; una modalità
|
|
1257
|
+
("(Thinking)", "(Reasoning)", "(Fast)") resta. Per ogni provider l'id preferito è quello stabile (non
|
|
1258
|
+
alias `~`, non free tier, non datato). I provider sono le chiavi di models.dev, le stesse di opencode.
|
|
1259
|
+
Puro: anche da `@llmnative/react/server`.
|
|
1260
|
+
|
|
1261
|
+
### Chiavi tenute dal server (CR-102)
|
|
1262
|
+
|
|
1263
|
+
Per un'app che non mette mai le chiavi dei provider nel browser. Il browser conosce solo quali
|
|
1264
|
+
provider sono collegati; il proxy dell'app mette la chiave.
|
|
1265
|
+
|
|
1266
|
+
```ts
|
|
1267
|
+
// Browser: gli stessi adapter, con un segnaposto dove andrebbe la chiave. Serve il proxy attivo.
|
|
1268
|
+
const registry = createServerCredentialAIRegistry(
|
|
1269
|
+
[{ id: 'anthropic' }, { id: 'cloudflare', accountId }, { id: 'openai-compatible', baseUrl }],
|
|
1270
|
+
{ scope: companyId }, // lettere, cifre, - e _
|
|
1271
|
+
)
|
|
1272
|
+
Object.entries(registry).forEach(([id, adapter]) => setProvider('ai', id, adapter))
|
|
1273
|
+
|
|
1274
|
+
// Server (Node, nessuna dipendenza da React): nel proxy, prima di inoltrare.
|
|
1275
|
+
import { resolveServerCredentials } from '@llmnative/react/server'
|
|
1276
|
+
const resolved = await resolveServerCredentials({ url: target, headers },
|
|
1277
|
+
(scope, provider) => keysOf(scope)[provider]) // { id, apiKey, accountId?, baseUrl? } | undefined
|
|
1278
|
+
if (!resolved.ok) return reply(resolved.status, resolved.error) // 404 non collegato, 403 host estraneo
|
|
1279
|
+
await fetch(resolved.url, { headers: resolved.headers, ... })
|
|
1280
|
+
```
|
|
1281
|
+
|
|
1282
|
+
La chiave va solo agli host del provider (`AI_PROVIDER_HOSTS`, il `baseUrl` di openai-compatible,
|
|
1283
|
+
l'account di Cloudflare): una destinazione diversa è rifiutata. `createProxyPlugin(route, log,
|
|
1284
|
+
lookup)` fa lo stesso nel proxy di sviluppo di Vite. Senza proxy, `proxyFetch` rifiuta di inviare
|
|
1285
|
+
un segnaposto. `createAIProviderRegistry` (chiavi nel browser) resta com'è.
|
|
1286
|
+
|
|
1287
|
+
Configurazione API key in `Config.tsx`: `geminiApiKey`, `openaiApiKey`, `anthropicApiKey`, `deepSeekApiKey`, `mistralApiKey`, `openRouterApiKey`, `groqApiKey`, `cloudflare: { apiToken, accountId }` (Cloudflare Workers AI: l'account id fa parte dell'URL; discovery via `ai/models/search`, modelli Workers Paid esclusi salvo `includePaidModels`).
|
|
1288
|
+
|
|
1289
|
+
---
|
|
1290
|
+
|
|
1291
|
+
## Theme e icone
|
|
1292
|
+
|
|
1293
|
+
```tsx
|
|
1294
|
+
const theme = useThemeController()
|
|
1295
|
+
theme.applyTheme('flat') // BuiltInThemeId ('default' | 'flat' | 'cyber' | 'vscode-dark-modern' | …) | custom
|
|
1296
|
+
theme.setMode('dark') // 'light' | 'dark' | 'system'
|
|
1297
|
+
|
|
1298
|
+
const icons = useIconController()
|
|
1299
|
+
icons.setProvider('phosphor') // 'lucide' | 'phosphor' | custom
|
|
1300
|
+
```
|
|
1301
|
+
|
|
1302
|
+
---
|
|
1303
|
+
|
|
1304
|
+
## Head (SEO)
|
|
1305
|
+
|
|
1306
|
+
```ts
|
|
1307
|
+
useHead({
|
|
1308
|
+
title: 'Pagina',
|
|
1309
|
+
description: '...',
|
|
1310
|
+
robots: 'noindex',
|
|
1311
|
+
canonical: 'https://...',
|
|
1312
|
+
og: { title: '...', image: '...' }
|
|
1313
|
+
})
|
|
1314
|
+
```
|
|
1315
|
+
|
|
1316
|
+
---
|
|
1317
|
+
|
|
1318
|
+
## Global state (localStorage)
|
|
1319
|
+
|
|
1320
|
+
```ts
|
|
1321
|
+
const vars = useGlobalVars()
|
|
1322
|
+
getGlobalVars('key')
|
|
1323
|
+
setGlobalVars({ key: 'value' })
|
|
1324
|
+
removeGlobalVars('key')
|
|
1325
|
+
```
|
|
1326
|
+
|
|
1327
|
+
---
|
|
1328
|
+
|
|
1329
|
+
## Hooks completi
|
|
1330
|
+
|
|
1331
|
+
| Hook | Ritorna |
|
|
1332
|
+
|---|---|
|
|
1333
|
+
| `useDataProvider(name?)` | `DataProviderAdapter \| null` |
|
|
1334
|
+
| `useStorageProvider(name?)` | `StorageProviderAdapter \| null` |
|
|
1335
|
+
| `useAuthProvider(name?)` | `AuthProviderAdapter \| null` |
|
|
1336
|
+
| `useEmailProvider(name?)` | `EmailProviderAdapter \| null` |
|
|
1337
|
+
| `useAIProvider(name?)` | `AIProviderAdapter \| null` |
|
|
1338
|
+
| `useAIProviderRegistry()` | `Record<string, AIProviderAdapter>` |
|
|
1339
|
+
| `useCredentialsProvider()` | `CredentialsAdapter \| null` |
|
|
1340
|
+
| `useTheme()` | `Theme \| undefined` |
|
|
1341
|
+
| `useThemeController()` | `ThemeController` |
|
|
1342
|
+
| `useIconController()` | `IconController` |
|
|
1343
|
+
| `useAccessToken(clientID, renew?)` | `boolean` | Ottiene token per servizio esterno (true = ok) |
|
|
1344
|
+
| `useGlobalVars()` | `Record<string, unknown>` |
|
|
1345
|
+
| `useHead()` | `HeadController` |
|
|
1346
|
+
| `useDocumentHead()` | `HeadController` |
|
|
1347
|
+
| `useAssetsHead(title?)` | `void` |
|
|
1348
|
+
| `useLanguageHead(lang?)` | `void` |
|
|
1349
|
+
| `useSocialHead(config)` | `void` |
|
|
1350
|
+
| `usePaginationHead(config)` | `void` |
|
|
1351
|
+
| `usePwaHead(config)` | `void` |
|
|
1352
|
+
| `useSchemaOrgHead(config)` | `void` |
|
|
1353
|
+
| `useHeadLinks(links)` | `void` |
|
|
1354
|
+
| `useProxy()` | `(url, init?) => Promise<Response>` |
|
|
1355
|
+
| `useImage()` | `UseImageResult` |
|
|
1356
|
+
| `useI18n()` | `I18nController` |
|
|
1357
|
+
| `useMenu()` | Menu hook |
|
|
1358
|
+
| `useFormController(controller?)` | `FormController` |
|
|
1359
|
+
| `useFormActions()` | `FormController` |
|
|
1360
|
+
| `useApiProvider(pathname?)` | `ApiProviderAdapter \| null` |
|
|
1361
|
+
| `useSetProvider(service, driver?)` | `void` |
|
|
1362
|
+
| `useProvider(name)` | `ProviderConfigurationState` |
|
|
1363
|
+
| `useProviderSession()` | `ProviderSession` |
|
|
1364
|
+
| `useDropBoxConnect(config?)` | `DropBoxConnectResult` |
|
|
1365
|
+
| `useEnterMotion(baseStyle?, ref?, fallback?)` | `CSSProperties` |
|
|
1366
|
+
| `useMotionState(active, ref?, fallback?, baseStyle?)` | `CSSProperties` |
|
|
1367
|
+
| `useMotionEffect(ref?, fallback?)` | `ResolvedMotionEffect` |
|
|
1368
|
+
| `usePressMotion(hovered, baseStyle?, ref?, fallback?)` | `{ style, pressHandlers }` |
|
|
1369
|
+
| `useIconProvider()` | `IconProvider` |
|
|
1370
|
+
|
|
1371
|
+
---
|
|
1372
|
+
|
|
1373
|
+
## Tipi chiave
|
|
1374
|
+
|
|
1375
|
+
```ts
|
|
1376
|
+
type RecordProps = Record<string, FieldValue>
|
|
1377
|
+
type FieldValue = string | number | boolean | null | undefined | Record<string, unknown> | unknown[]
|
|
1378
|
+
type RecordArray = RecordProps[]
|
|
1379
|
+
|
|
1380
|
+
type OrderConfig = { field: string; dir: 'asc' | 'desc' }
|
|
1381
|
+
type WhereClause = { field: string; op: '==' | '!=' | '<' | '<=' | '>' | '>=' | 'in' | 'not-in' | 'array-contains' | 'array-contains-any'; value: unknown }
|
|
1382
|
+
|
|
1383
|
+
interface UIProps {
|
|
1384
|
+
before?: React.ReactNode
|
|
1385
|
+
after?: React.ReactNode
|
|
1386
|
+
wrapperClassName?: string
|
|
1387
|
+
className?: string
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
type UserProfile = { uid?: string; email?: string; displayName?: string; photoURL?: string; [key: string]: unknown }
|
|
1391
|
+
```
|
|
1392
|
+
|
|
1393
|
+
---
|
|
1394
|
+
|
|
1395
|
+
## Utilities
|
|
1396
|
+
|
|
1397
|
+
```ts
|
|
1398
|
+
import { cn, converter, Sanitizer, Order, path, fetchJson, fetchRest, fetchWithRetry } from '@llmnative/react'
|
|
1399
|
+
import { getKeywordIdeas, getGoogleTrendsData, getGoogleTrendsRelated } from '@llmnative/react'
|
|
1400
|
+
|
|
1401
|
+
cn('base', condition && 'extra', className) // tailwind-merge classname
|
|
1402
|
+
new Sanitizer().sanitize(html) // XSS sanitizer (non usare dangerouslySetInnerHTML)
|
|
1403
|
+
new Order().order(records, { field: 'name', dir: 'asc' }) // ordina record array
|
|
1404
|
+
fetchJson(url, init?) // fetch + JSON parse + error handling
|
|
1405
|
+
fetchRest(path, init?) // fetch REST con auth
|
|
1406
|
+
getKeywordIdeas(keyword) // Google Ads Keyword Ideas
|
|
1407
|
+
getGoogleTrendsData(keyword) // Google Trends interest over time
|
|
1408
|
+
getGoogleTrendsRelated(keyword) // Google Trends related queries
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
---
|
|
1412
|
+
|
|
1413
|
+
## Scaffold (npx create)
|
|
1414
|
+
|
|
1415
|
+
```bash
|
|
1416
|
+
npx @llmnative/react create
|
|
1417
|
+
npx @llmnative/react create --yes --provider=mock --template=admin
|
|
1418
|
+
```
|
|
1419
|
+
|
|
1420
|
+
Flag disponibili: `--name` `--provider=firebase|supabase|mock|custom` `--ai-provider` `--icon-provider` `--theme` `--template=blank|admin|crm|inventory|project`
|
|
1421
|
+
|
|
1422
|
+
**5 template disponibili:**
|
|
1423
|
+
| Template | Pagine incluse | Uso tipico |
|
|
1424
|
+
|---|---|---|
|
|
1425
|
+
| `blank` | home | App vuota — massima libertà |
|
|
1426
|
+
| `admin` | home, users, roles, settings | Dashboard admin/backoffice |
|
|
1427
|
+
| `crm` | home, companies, contacts, deals | CRM |
|
|
1428
|
+
| `inventory` | home + gestione inventario | Magazzino |
|
|
1429
|
+
| `project` | home + gestione progetti | PM tool |
|
|
1430
|
+
|
|
1431
|
+
**Struttura generata in-place nella current directory:**
|
|
1432
|
+
```
|
|
1433
|
+
src/
|
|
1434
|
+
index.tsx ← App entry
|
|
1435
|
+
vite-env.d.ts
|
|
1436
|
+
conf/
|
|
1437
|
+
app.ts ← providers config letta da .env (VITE_PROVIDER, VITE_AI_PROVIDER...)
|
|
1438
|
+
menu.ts ← MenuConfig con path, title, icon, page (layout opzionale: c'è LayoutDefault)
|
|
1439
|
+
data/
|
|
1440
|
+
mockData.ts ← dati fake per MockDataProvider
|
|
1441
|
+
layouts/
|
|
1442
|
+
Default.tsx ← layout wrapper (header + sidebar + main + footer)
|
|
1443
|
+
sections/
|
|
1444
|
+
Header.tsx / Sidebar.tsx / PageHeader.tsx / Footer.tsx ← solo componenti pubblici (SideNav, AuthButton, ActionButton, Brand, Breadcrumbs)
|
|
1445
|
+
pages/
|
|
1446
|
+
home/HomePage.tsx
|
|
1447
|
+
[altre pagine dal template scelto]
|
|
1448
|
+
styles/
|
|
1449
|
+
globals.css ← @import '@llmnative/react/dist/index.css' + Tailwind override
|
|
1450
|
+
.env ← VITE_PROVIDER, VITE_THEME, chiavi API (non committare)
|
|
1451
|
+
.env.example ← stessa struttura, valori vuoti (committare)
|
|
1452
|
+
vite.config.ts / tsconfig.json / postcss.config.js / index.html
|
|
1453
|
+
```
|
|
1454
|
+
|
|
1455
|
+
**Pattern conf/app.ts** (auto-generato, leggere per capire come funziona):
|
|
1456
|
+
```ts
|
|
1457
|
+
import type { AppProvidersConfig } from '@llmnative/react'
|
|
1458
|
+
import { mockData } from '../data/mockData'
|
|
1459
|
+
const env = import.meta.env
|
|
1460
|
+
|
|
1461
|
+
export const providers: AppProvidersConfig = {
|
|
1462
|
+
mock: { data: mockData },
|
|
1463
|
+
ai: { openaiApiKey: env.VITE_OPENAI_API_KEY ?? '' }, // AI dentro providers, non prop <App>
|
|
1464
|
+
services: { data: 'mock', auth: 'googleAuth' },
|
|
1465
|
+
}
|
|
1466
|
+
```
|
|
1467
|
+
|
|
1468
|
+
Driver per `VITE_PROVIDER`: `firebase` → `firestoreDb` + `firestorage` + `firebaseAuth`; `supabase` → `supabaseDb` + `supabaseStorage` + `supabaseAuth`; `mock` → `mock` + `googleAuth`. `index.tsx` passa `LayoutDefault={Default}` ad `<App>`.
|
|
1469
|
+
|
|
1470
|
+
---
|
|
1471
|
+
|
|
1472
|
+
## Gotchas — pitfall frequenti
|
|
1473
|
+
|
|
1474
|
+
| Errore | Causa | Fix |
|
|
1475
|
+
|---|---|---|
|
|
1476
|
+
| `aiConfig` prop non esiste su `<App>` | La config AI va dentro `providers.ai`, NON come prop separata | `providers={{ ai: { openaiApiKey } }}` |
|
|
1477
|
+
| `inputType` o `Input.Number`/`Input.Email` non esistono | Il tipo HTML è la prop `type` | `<Input type="number">`, `<Input type="email">`, `<Input type="date">` |
|
|
1478
|
+
| `Menu context=` non esiste | La prop si chiama `menuKey` | `<Menu menuKey="main" />` |
|
|
1479
|
+
| `SignInButton` non esiste | Rinominato | `<AuthButton />` |
|
|
1480
|
+
| `firebase: { config: ... }` errato | FirebaseConfig è flat | `firebase: { apiKey, authDomain, databaseURL, ... }` |
|
|
1481
|
+
| `google: { oAuth2: { clientId } }` errato | GoogleProviderConfig è flat | `google: { clientId, scope }` |
|
|
1482
|
+
| `children` su `Grid` | Grid non accetta children | Usa `form={<Fields />}` per il form inline |
|
|
1483
|
+
| `recordId` su `Form` | Prop non esiste | La chiave del record viene da URL automaticamente |
|
|
1484
|
+
| `MenuConfig` non importabile | Era type interno | Ora esportato: `import type { MenuConfig } from '@llmnative/react'` |
|
|
1485
|
+
| `GridCellContext` non importabile | Mancava dall'index | Ora esportato: `import type { GridCellContext } from '@llmnative/react'` |
|
|
1486
|
+
|
|
1487
|
+
---
|
|
1488
|
+
|
|
1489
|
+
## Dove cercare nel codice sorgente
|
|
1490
|
+
|
|
1491
|
+
| Cosa | File |
|
|
1492
|
+
|---|---|
|
|
1493
|
+
| Form | `src/components/widgets/Form.tsx` |
|
|
1494
|
+
| Grid | `src/components/widgets/Grid.tsx` |
|
|
1495
|
+
| Prompt | `src/components/widgets/Prompt.tsx` |
|
|
1496
|
+
| Campi form | `src/components/ui/fields/` |
|
|
1497
|
+
| Blocks (Menu, Toolbar, Notifications, Dropdown…) | `src/components/blocks/` |
|
|
1498
|
+
| Provider data Firebase (RTDB) | `src/providers/data/firebase.ts` |
|
|
1499
|
+
| Provider data Firestore | `src/providers/data/firestore.ts` |
|
|
1500
|
+
| Provider data Supabase | `src/providers/data/supabase.ts` |
|
|
1501
|
+
| Provider storage Firebase | `src/providers/storage/firebase.ts` |
|
|
1502
|
+
| Provider storage Supabase | `src/providers/storage/supabase.ts` |
|
|
1503
|
+
| Provider auth Firebase | `src/providers/auth/firebase/FirebaseAuthProvider.ts` |
|
|
1504
|
+
| Provider auth Supabase | `src/providers/auth/supabase/` |
|
|
1505
|
+
| Provider auth Google | `src/providers/auth/google/` |
|
|
1506
|
+
| Provider auth Dropbox | `src/providers/auth/dropbox/` |
|
|
1507
|
+
| Provider email Gmail | `src/providers/email/google/GmailEmailProvider.ts` |
|
|
1508
|
+
| Provider AI definitions | `src/providers/ai/` |
|
|
1509
|
+
| Provider credenziali | `src/providers/credentials/` |
|
|
1510
|
+
| Provider session | `src/providers/ProviderSession.ts` |
|
|
1511
|
+
| Proxy CORS | `src/providers/proxy.ts` |
|
|
1512
|
+
| Motion system | `src/motion.ts` |
|
|
1513
|
+
| I18n | `src/I18n.tsx` |
|
|
1514
|
+
| Dropbox integration | `src/providers/dropbox/` |
|
|
1515
|
+
| Interfaccia DataProvider | `src/providers/data/DataProvider.ts` |
|
|
1516
|
+
| Interfaccia StorageProvider | `src/providers/storage/StorageProvider.ts` |
|
|
1517
|
+
| Interfaccia AuthProvider | `src/providers/auth/AuthProvider.ts` |
|
|
1518
|
+
| Interfaccia EmailProvider | `src/providers/email/EmailProvider.ts` |
|
|
1519
|
+
| Interfaccia AIProvider | `src/providers/ai/AIProvider.ts` |
|
|
1520
|
+
| Registry provider | `src/providers/manifest.ts` |
|
|
1521
|
+
| Config provider | `src/providers/ProviderConfiguration.ts` |
|
|
1522
|
+
| SEO / Google Trends | `src/providers/seo/google/` |
|
|
1523
|
+
| Sistema tema | `src/Theme.tsx` |
|
|
1524
|
+
| Config runtime | `src/Config.tsx` |
|
|
1525
|
+
| Tipi TypeScript | `src/types/` |
|
|
1526
|
+
| Utilities pure | `src/libs/` |
|