@praxisui/core 0.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/LICENSE +7 -0
- package/README.md +799 -0
- package/fesm2022/praxisui-core.mjs +6775 -0
- package/fesm2022/praxisui-core.mjs.map +1 -0
- package/index.d.ts +6263 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
# @praxis/core
|
|
2
|
+
|
|
3
|
+
> Biblioteca central com interfaces e serviços fundamentais para o Praxis UI Workspace
|
|
4
|
+
|
|
5
|
+
## 🌟 Visão Geral
|
|
6
|
+
|
|
7
|
+
A biblioteca `@praxis/core` é o núcleo do Praxis UI Workspace, fornecendo interfaces robustas, serviços base e utilitários essenciais para todas as outras bibliotecas do ecossistema. Com a arquitetura unificada, oferece uma experiência de desenvolvimento consistente e type-safe.
|
|
8
|
+
|
|
9
|
+
### Concept Usage
|
|
10
|
+
|
|
11
|
+
- [Dynamic Component Rendering](../../../../docs/concepts/dynamic-component-rendering.md)
|
|
12
|
+
- [Headless UI & Design Systems](../../../../docs/concepts/headless-ui-and-design-systems.md)
|
|
13
|
+
- [Configuration‑driven development](../../../../docs/concepts/configuration-driven-development.md)
|
|
14
|
+
- [Declarative UI](../../../../docs/concepts/declarative-ui.md)
|
|
15
|
+
|
|
16
|
+
## ✨ Características Principais
|
|
17
|
+
|
|
18
|
+
### 🏗️ Arquitetura Unificada
|
|
19
|
+
|
|
20
|
+
- **TableConfig único**: Interface consolidada eliminando dualidade V1/V2
|
|
21
|
+
- **Type Safety**: Tipagem forte e consistente
|
|
22
|
+
- **Modular**: Interfaces bem definidas e organizadas
|
|
23
|
+
- **Extensível**: Arquitetura preparada para crescimento
|
|
24
|
+
|
|
25
|
+
### 🔧 Funcionalidades Core
|
|
26
|
+
|
|
27
|
+
- **Interfaces de Configuração**: Modelos robustos para tabelas e componentes
|
|
28
|
+
- **Serviços Base**: TableConfigService e utilitários essenciais
|
|
29
|
+
- **Type Guards**: Validação em runtime
|
|
30
|
+
- **Helper Functions**: Utilitários para manipulação de configurações
|
|
31
|
+
|
|
32
|
+
## 🚀 Instalação
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install @praxis/core
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Peer dependencies (Angular v20)
|
|
39
|
+
|
|
40
|
+
- `@angular/core` `^20.0.0`
|
|
41
|
+
- `@angular/common` `^20.0.0`
|
|
42
|
+
- `angular-gridster2` `^20.2.2` (necessário apenas para widgets baseados em Gridster)
|
|
43
|
+
|
|
44
|
+
## ⚡ Quick Start
|
|
45
|
+
|
|
46
|
+
### 1) `PraxisIconDirective`
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { Component } from '@angular/core';
|
|
50
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
51
|
+
import { PraxisIconDirective } from '@praxis/core';
|
|
52
|
+
|
|
53
|
+
@Component({
|
|
54
|
+
selector: 'app-icons-demo',
|
|
55
|
+
standalone: true,
|
|
56
|
+
imports: [MatIconModule, PraxisIconDirective],
|
|
57
|
+
template: `
|
|
58
|
+
<!-- Material Icons (ligatures) -->
|
|
59
|
+
<mat-icon [praxisIcon]="'mi:pending'"></mat-icon>
|
|
60
|
+
<!-- Material Symbols Outlined -->
|
|
61
|
+
<mat-icon [praxisIcon]="'mso:right_click'"></mat-icon>
|
|
62
|
+
`,
|
|
63
|
+
})
|
|
64
|
+
export class IconsDemoComponent {}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 2) `DynamicGridPageComponent`
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { Component } from '@angular/core';
|
|
71
|
+
import { DynamicGridPageComponent, GridPageDefinition } from '@praxis/core';
|
|
72
|
+
|
|
73
|
+
@Component({
|
|
74
|
+
selector: 'app-grid-demo',
|
|
75
|
+
standalone: true,
|
|
76
|
+
imports: [DynamicGridPageComponent],
|
|
77
|
+
template: `
|
|
78
|
+
<praxis-dynamic-grid-page [page]="page"></praxis-dynamic-grid-page>
|
|
79
|
+
`,
|
|
80
|
+
})
|
|
81
|
+
export class GridDemoComponent {
|
|
82
|
+
page: GridPageDefinition = {
|
|
83
|
+
options: { cols: 12, rowHeight: 80, gap: 12 },
|
|
84
|
+
widgets: [
|
|
85
|
+
{
|
|
86
|
+
key: 'w1',
|
|
87
|
+
layout: { col: 1, colSpan: 6, row: 1, rowSpan: 2 },
|
|
88
|
+
definition: {
|
|
89
|
+
// Substitua pelo ID de um componente registrado no ComponentMetadataRegistry
|
|
90
|
+
id: 'your-registered-widget-id',
|
|
91
|
+
inputs: { title: 'Hello' },
|
|
92
|
+
outputs: { loaded: 'emit' },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Observação: os IDs de widgets usados na página devem estar registrados via `ComponentMetadataRegistry` para que o carregador dinâmico resolva os componentes.
|
|
101
|
+
|
|
102
|
+
## 📚 API Surface
|
|
103
|
+
|
|
104
|
+
- Exports públicos: consulte `projects/praxis-core/src/public-api.ts` para a lista consolidada de serviços, tokens, modelos e utilitários disponíveis para importação.
|
|
105
|
+
|
|
106
|
+
## 🧩 Compatibilidade
|
|
107
|
+
|
|
108
|
+
- `@praxis/core` `0.0.x` → Angular `20.x`
|
|
109
|
+
- Module format: `ESM2022`
|
|
110
|
+
|
|
111
|
+
## 📝 Interfaces Principais
|
|
112
|
+
|
|
113
|
+
### MaterialTimepickerMetadata
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
const workShift: MaterialTimepickerMetadata = {
|
|
117
|
+
name: "workStart",
|
|
118
|
+
label: "Início do expediente",
|
|
119
|
+
controlType: "timePicker",
|
|
120
|
+
min: "08:00",
|
|
121
|
+
max: "18:00",
|
|
122
|
+
stepMinute: 30,
|
|
123
|
+
format: "24h",
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### TableConfig - Interface Unificada
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
interface TableConfig {
|
|
131
|
+
/** Metadados da configuração */
|
|
132
|
+
meta?: ConfigMetadata;
|
|
133
|
+
|
|
134
|
+
/** Definições de colunas */
|
|
135
|
+
columns: ColumnDefinition[];
|
|
136
|
+
|
|
137
|
+
/** Configurações de comportamento */
|
|
138
|
+
behavior?: TableBehaviorConfig;
|
|
139
|
+
|
|
140
|
+
/** Configurações de aparência */
|
|
141
|
+
appearance?: TableAppearanceConfig;
|
|
142
|
+
|
|
143
|
+
/** Configurações de toolbar */
|
|
144
|
+
toolbar?: ToolbarConfig;
|
|
145
|
+
|
|
146
|
+
/** Configurações de ações */
|
|
147
|
+
actions?: TableActionsConfig;
|
|
148
|
+
|
|
149
|
+
/** Configurações de exportação */
|
|
150
|
+
export?: ExportConfig;
|
|
151
|
+
|
|
152
|
+
/** Mensagens e textos */
|
|
153
|
+
messages?: MessagesConfig;
|
|
154
|
+
|
|
155
|
+
/** Localização e i18n */
|
|
156
|
+
localization?: LocalizationConfig;
|
|
157
|
+
|
|
158
|
+
/** Configurações de performance */
|
|
159
|
+
performance?: PerformanceConfig;
|
|
160
|
+
|
|
161
|
+
/** Configurações de acessibilidade */
|
|
162
|
+
accessibility?: AccessibilityConfig;
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### ColumnDefinition
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
interface ColumnDefinition {
|
|
170
|
+
/** Campo da fonte de dados */
|
|
171
|
+
field: string;
|
|
172
|
+
|
|
173
|
+
/** Cabeçalho da coluna */
|
|
174
|
+
header: string;
|
|
175
|
+
|
|
176
|
+
/** Tipo de dados para formatação */
|
|
177
|
+
type?: "string" | "number" | "date" | "boolean" | "currency" | "percentage" | "custom";
|
|
178
|
+
|
|
179
|
+
/** Largura da coluna */
|
|
180
|
+
width?: string;
|
|
181
|
+
|
|
182
|
+
/** Visibilidade da coluna */
|
|
183
|
+
visible?: boolean;
|
|
184
|
+
|
|
185
|
+
/** Permitir ordenação */
|
|
186
|
+
sortable?: boolean;
|
|
187
|
+
|
|
188
|
+
/** Permitir filtragem */
|
|
189
|
+
filterable?: boolean;
|
|
190
|
+
|
|
191
|
+
/** Permitir redimensionamento */
|
|
192
|
+
resizable?: boolean;
|
|
193
|
+
|
|
194
|
+
/** Coluna fixa (sticky) */
|
|
195
|
+
sticky?: boolean;
|
|
196
|
+
|
|
197
|
+
/** Alinhamento do conteúdo */
|
|
198
|
+
align?: "left" | "center" | "right";
|
|
199
|
+
|
|
200
|
+
/** Ordem de exibição */
|
|
201
|
+
order?: number;
|
|
202
|
+
|
|
203
|
+
/** Estilo CSS personalizado */
|
|
204
|
+
style?: string;
|
|
205
|
+
|
|
206
|
+
/** Formato de exibição dos dados */
|
|
207
|
+
format?: any;
|
|
208
|
+
|
|
209
|
+
/** Mapeamento de valores para exibição */
|
|
210
|
+
valueMapping?: { [key: string | number]: string };
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### ConfigMetadata
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
interface ConfigMetadata {
|
|
218
|
+
/** Versão da configuração */
|
|
219
|
+
version?: string;
|
|
220
|
+
|
|
221
|
+
/** Identificador único */
|
|
222
|
+
id?: string;
|
|
223
|
+
|
|
224
|
+
/** Nome amigável */
|
|
225
|
+
name?: string;
|
|
226
|
+
|
|
227
|
+
/** Descrição */
|
|
228
|
+
description?: string;
|
|
229
|
+
|
|
230
|
+
/** Tags para categorização */
|
|
231
|
+
tags?: string[];
|
|
232
|
+
|
|
233
|
+
/** Data de criação */
|
|
234
|
+
createdAt?: string;
|
|
235
|
+
|
|
236
|
+
/** Data de última modificação */
|
|
237
|
+
updatedAt?: string;
|
|
238
|
+
|
|
239
|
+
/** Autor da configuração */
|
|
240
|
+
author?: string;
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## 🎛️ Configurações de Comportamento
|
|
245
|
+
|
|
246
|
+
### TableBehaviorConfig
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
interface TableBehaviorConfig {
|
|
250
|
+
/** Configurações de paginação */
|
|
251
|
+
pagination?: PaginationConfig;
|
|
252
|
+
|
|
253
|
+
/** Configurações de ordenação */
|
|
254
|
+
sorting?: SortingConfig;
|
|
255
|
+
|
|
256
|
+
/** Configurações de filtragem */
|
|
257
|
+
filtering?: FilteringConfig;
|
|
258
|
+
|
|
259
|
+
/** Configurações de seleção */
|
|
260
|
+
selection?: SelectionConfig;
|
|
261
|
+
|
|
262
|
+
/** Configurações de interação */
|
|
263
|
+
interaction?: InteractionConfig;
|
|
264
|
+
|
|
265
|
+
/** Configurações de redimensionamento */
|
|
266
|
+
resizing?: ResizingConfig;
|
|
267
|
+
|
|
268
|
+
/** Configurações de arrastar e soltar */
|
|
269
|
+
dragging?: DraggingConfig;
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### PaginationConfig
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
interface PaginationConfig {
|
|
277
|
+
/** Habilitar paginação */
|
|
278
|
+
enabled: boolean;
|
|
279
|
+
|
|
280
|
+
/** Tamanho da página */
|
|
281
|
+
pageSize: number;
|
|
282
|
+
|
|
283
|
+
/** Opções de tamanho de página */
|
|
284
|
+
pageSizeOptions: number[];
|
|
285
|
+
|
|
286
|
+
/** Mostrar botões primeira/última */
|
|
287
|
+
showFirstLastButtons: boolean;
|
|
288
|
+
|
|
289
|
+
/** Mostrar números das páginas */
|
|
290
|
+
showPageNumbers: boolean;
|
|
291
|
+
|
|
292
|
+
/** Mostrar informações da página */
|
|
293
|
+
showPageInfo: boolean;
|
|
294
|
+
|
|
295
|
+
/** Posição do paginador */
|
|
296
|
+
position: "top" | "bottom" | "both";
|
|
297
|
+
|
|
298
|
+
/** Estilo do paginador */
|
|
299
|
+
style: "default" | "minimal" | "advanced";
|
|
300
|
+
|
|
301
|
+
/** Estratégia de paginação */
|
|
302
|
+
strategy: "client" | "server";
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### SortingConfig
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
interface SortingConfig {
|
|
310
|
+
/** Habilitar ordenação */
|
|
311
|
+
enabled: boolean;
|
|
312
|
+
|
|
313
|
+
/** Permitir ordenação múltipla */
|
|
314
|
+
multiSort: boolean;
|
|
315
|
+
|
|
316
|
+
/** Estratégia de ordenação */
|
|
317
|
+
strategy: "client" | "server";
|
|
318
|
+
|
|
319
|
+
/** Mostrar indicadores de ordenação */
|
|
320
|
+
showSortIndicators: boolean;
|
|
321
|
+
|
|
322
|
+
/** Posição do indicador */
|
|
323
|
+
indicatorPosition: "start" | "end";
|
|
324
|
+
|
|
325
|
+
/** Permitir limpar ordenação */
|
|
326
|
+
allowClearSort: boolean;
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## 🎨 Configurações de Aparência
|
|
331
|
+
|
|
332
|
+
### TableAppearanceConfig
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
interface TableAppearanceConfig {
|
|
336
|
+
/** Densidade da tabela */
|
|
337
|
+
density: "compact" | "comfortable" | "spacious";
|
|
338
|
+
|
|
339
|
+
/** Configurações de bordas */
|
|
340
|
+
borders?: BorderConfig;
|
|
341
|
+
|
|
342
|
+
/** Configurações de elevação */
|
|
343
|
+
elevation?: ElevationConfig;
|
|
344
|
+
|
|
345
|
+
/** Configurações de espaçamento */
|
|
346
|
+
spacing?: SpacingConfig;
|
|
347
|
+
|
|
348
|
+
/** Configurações de tipografia */
|
|
349
|
+
typography?: TypographyConfig;
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### BorderConfig
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
interface BorderConfig {
|
|
357
|
+
/** Mostrar bordas entre linhas */
|
|
358
|
+
showRowBorders: boolean;
|
|
359
|
+
|
|
360
|
+
/** Mostrar bordas entre colunas */
|
|
361
|
+
showColumnBorders: boolean;
|
|
362
|
+
|
|
363
|
+
/** Mostrar borda externa */
|
|
364
|
+
showOuterBorder: boolean;
|
|
365
|
+
|
|
366
|
+
/** Estilo da borda */
|
|
367
|
+
style: "solid" | "dashed" | "dotted";
|
|
368
|
+
|
|
369
|
+
/** Largura da borda */
|
|
370
|
+
width: number;
|
|
371
|
+
|
|
372
|
+
/** Cor da borda */
|
|
373
|
+
color: string;
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## ⚡ Configurações de Performance
|
|
378
|
+
|
|
379
|
+
### PerformanceConfig
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
interface PerformanceConfig {
|
|
383
|
+
/** Configurações de virtualização */
|
|
384
|
+
virtualization?: VirtualizationConfig;
|
|
385
|
+
|
|
386
|
+
/** Configurações de lazy loading */
|
|
387
|
+
lazyLoading?: LazyLoadingConfig;
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### VirtualizationConfig
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
interface VirtualizationConfig {
|
|
395
|
+
/** Habilitar virtualização */
|
|
396
|
+
enabled: boolean;
|
|
397
|
+
|
|
398
|
+
/** Altura do item */
|
|
399
|
+
itemHeight: number;
|
|
400
|
+
|
|
401
|
+
/** Tamanho do buffer */
|
|
402
|
+
bufferSize: number;
|
|
403
|
+
|
|
404
|
+
/** Altura mínima do container */
|
|
405
|
+
minContainerHeight: number;
|
|
406
|
+
|
|
407
|
+
/** Estratégia de virtualização */
|
|
408
|
+
strategy: "fixed" | "dynamic";
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## 🔍 Configurações de Acessibilidade
|
|
413
|
+
|
|
414
|
+
### AccessibilityConfig
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
interface AccessibilityConfig {
|
|
418
|
+
/** Habilitar recursos de acessibilidade */
|
|
419
|
+
enabled: boolean;
|
|
420
|
+
|
|
421
|
+
/** Configurações de anúncios */
|
|
422
|
+
announcements?: AnnouncementConfig;
|
|
423
|
+
|
|
424
|
+
/** Navegação por teclado */
|
|
425
|
+
keyboard?: KeyboardAccessibilityConfig;
|
|
426
|
+
|
|
427
|
+
/** Contraste alto */
|
|
428
|
+
highContrast?: boolean;
|
|
429
|
+
|
|
430
|
+
/** Reduzir movimento */
|
|
431
|
+
reduceMotion?: boolean;
|
|
432
|
+
|
|
433
|
+
/** Labels ARIA personalizados */
|
|
434
|
+
ariaLabels?: { [key: string]: string };
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### AnnouncementConfig
|
|
439
|
+
|
|
440
|
+
```typescript
|
|
441
|
+
interface AnnouncementConfig {
|
|
442
|
+
/** Anunciar mudanças de dados */
|
|
443
|
+
dataChanges: boolean;
|
|
444
|
+
|
|
445
|
+
/** Anunciar ações do usuário */
|
|
446
|
+
userActions: boolean;
|
|
447
|
+
|
|
448
|
+
/** Anunciar estados de carregamento */
|
|
449
|
+
loadingStates: boolean;
|
|
450
|
+
|
|
451
|
+
/** Tipo de live region */
|
|
452
|
+
liveRegion: "polite" | "assertive";
|
|
453
|
+
}
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
## 🛠️ Serviços
|
|
457
|
+
|
|
458
|
+
### TableConfigService
|
|
459
|
+
|
|
460
|
+
```typescript
|
|
461
|
+
class TableConfigService {
|
|
462
|
+
/** Definir configuração atual */
|
|
463
|
+
setConfig(config: TableConfig): void;
|
|
464
|
+
|
|
465
|
+
/** Obter configuração atual */
|
|
466
|
+
getCurrentConfig(): TableConfig;
|
|
467
|
+
|
|
468
|
+
/** Verificar se um recurso está habilitado */
|
|
469
|
+
isFeatureEnabled(feature: string): boolean;
|
|
470
|
+
|
|
471
|
+
/** Obter resumo da configuração */
|
|
472
|
+
getConfigSummary(): ConfigSummary;
|
|
473
|
+
|
|
474
|
+
/** Obter configurações de paginação */
|
|
475
|
+
getPaginationConfig(): PaginationConfig | undefined;
|
|
476
|
+
|
|
477
|
+
/** Obter configurações de ordenação */
|
|
478
|
+
getSortingConfig(): SortingConfig | undefined;
|
|
479
|
+
|
|
480
|
+
/** Obter configurações de filtragem */
|
|
481
|
+
getFilteringConfig(): FilteringConfig | undefined;
|
|
482
|
+
}
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### Exemplo de Uso do Serviço
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
import { TableConfigService } from '@praxis/core';
|
|
489
|
+
|
|
490
|
+
@Component({...})
|
|
491
|
+
export class MyComponent {
|
|
492
|
+
constructor(private configService: TableConfigService) {}
|
|
493
|
+
|
|
494
|
+
ngOnInit() {
|
|
495
|
+
// Definir configuração
|
|
496
|
+
this.configService.setConfig(this.tableConfig);
|
|
497
|
+
|
|
498
|
+
// Verificar recursos
|
|
499
|
+
const hasMultiSort = this.configService.isFeatureEnabled('multiSort');
|
|
500
|
+
const hasBulkActions = this.configService.isFeatureEnabled('bulkActions');
|
|
501
|
+
const hasExport = this.configService.isFeatureEnabled('export');
|
|
502
|
+
|
|
503
|
+
// Obter configurações específicas
|
|
504
|
+
const paginationConfig = this.configService.getPaginationConfig();
|
|
505
|
+
const sortingConfig = this.configService.getSortingConfig();
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
## 🔧 Helper Functions
|
|
511
|
+
|
|
512
|
+
### Configuração Padrão
|
|
513
|
+
|
|
514
|
+
```typescript
|
|
515
|
+
import { createDefaultTableConfig } from "@praxis/core";
|
|
516
|
+
|
|
517
|
+
// Criar configuração padrão
|
|
518
|
+
const defaultConfig = createDefaultTableConfig();
|
|
519
|
+
|
|
520
|
+
console.log(defaultConfig);
|
|
521
|
+
// {
|
|
522
|
+
// meta: { version: '2.0.0', ... },
|
|
523
|
+
// columns: [],
|
|
524
|
+
// behavior: { pagination: { enabled: true, ... }, ... },
|
|
525
|
+
// ...
|
|
526
|
+
// }
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
### Validação
|
|
530
|
+
|
|
531
|
+
```typescript
|
|
532
|
+
import { isValidTableConfig, isTableConfigV2 } from '@praxis/core';
|
|
533
|
+
|
|
534
|
+
// Validar configuração
|
|
535
|
+
const config = { columns: [...] };
|
|
536
|
+
|
|
537
|
+
if (isValidTableConfig(config)) {
|
|
538
|
+
console.log('Configuração válida');
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if (isTableConfigV2(config)) {
|
|
542
|
+
console.log('Configuração V2 detectada');
|
|
543
|
+
}
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
### Manipulação de Configurações
|
|
547
|
+
|
|
548
|
+
```typescript
|
|
549
|
+
import { cloneTableConfig, mergeTableConfigs, getEssentialConfig } from "@praxis/core";
|
|
550
|
+
|
|
551
|
+
// Clonar configuração
|
|
552
|
+
const clonedConfig = cloneTableConfig(originalConfig);
|
|
553
|
+
|
|
554
|
+
// Merge configurações
|
|
555
|
+
const mergedConfig = mergeTableConfigs(baseConfig, {
|
|
556
|
+
behavior: {
|
|
557
|
+
pagination: { pageSize: 25 },
|
|
558
|
+
},
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
// Extrair configurações essenciais
|
|
562
|
+
const essentialConfig = getEssentialConfig(fullConfig);
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
## 📊 Type Guards e Utilitários
|
|
566
|
+
|
|
567
|
+
### Type Guards
|
|
568
|
+
|
|
569
|
+
```typescript
|
|
570
|
+
// Verificar se é configuração V2
|
|
571
|
+
function isTableConfigV2(config: any): config is TableConfig;
|
|
572
|
+
|
|
573
|
+
// Validar estrutura da configuração
|
|
574
|
+
function isValidTableConfig(config: any): config is TableConfig;
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### Utilitários de Configuração
|
|
578
|
+
|
|
579
|
+
```typescript
|
|
580
|
+
// Criar configuração padrão
|
|
581
|
+
function createDefaultTableConfig(): TableConfig;
|
|
582
|
+
|
|
583
|
+
// Clonar configuração profundamente
|
|
584
|
+
function cloneTableConfig(config: TableConfig): TableConfig;
|
|
585
|
+
|
|
586
|
+
// Merge duas configurações
|
|
587
|
+
function mergeTableConfigs(base: TableConfig, override: Partial<TableConfig>): TableConfig;
|
|
588
|
+
|
|
589
|
+
// Extrair configurações essenciais
|
|
590
|
+
function getEssentialConfig(config: TableConfig): Partial<TableConfig>;
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
## 🧪 Testando com @praxis/core
|
|
594
|
+
|
|
595
|
+
### Setup de Testes
|
|
596
|
+
|
|
597
|
+
```typescript
|
|
598
|
+
import { TestBed } from "@angular/core/testing";
|
|
599
|
+
import { TableConfigService } from "@praxis/core";
|
|
600
|
+
|
|
601
|
+
describe("TableConfigService", () => {
|
|
602
|
+
let service: TableConfigService;
|
|
603
|
+
|
|
604
|
+
beforeEach(() => {
|
|
605
|
+
TestBed.configureTestingModule({
|
|
606
|
+
providers: [TableConfigService],
|
|
607
|
+
});
|
|
608
|
+
service = TestBed.inject(TableConfigService);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
it("should create", () => {
|
|
612
|
+
expect(service).toBeTruthy();
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
it("should set and get config", () => {
|
|
616
|
+
const config: TableConfig = {
|
|
617
|
+
columns: [{ field: "test", header: "Test" }],
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
service.setConfig(config);
|
|
621
|
+
expect(service.getCurrentConfig()).toEqual(config);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### Testes de Helper Functions
|
|
627
|
+
|
|
628
|
+
```typescript
|
|
629
|
+
import { createDefaultTableConfig, isValidTableConfig, cloneTableConfig } from "@praxis/core";
|
|
630
|
+
|
|
631
|
+
describe("Helper Functions", () => {
|
|
632
|
+
it("should create valid default config", () => {
|
|
633
|
+
const config = createDefaultTableConfig();
|
|
634
|
+
expect(isValidTableConfig(config)).toBe(true);
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
it("should clone config correctly", () => {
|
|
638
|
+
const original: TableConfig = {
|
|
639
|
+
columns: [{ field: "test", header: "Test" }],
|
|
640
|
+
behavior: { pagination: { enabled: true } },
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
const cloned = cloneTableConfig(original);
|
|
644
|
+
expect(cloned).toEqual(original);
|
|
645
|
+
expect(cloned).not.toBe(original); // Different reference
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
## 📋 Migration Guide
|
|
651
|
+
|
|
652
|
+
### Migração da Arquitetura V1/V2
|
|
653
|
+
|
|
654
|
+
#### Mudanças Principais
|
|
655
|
+
|
|
656
|
+
1. **Interface Unificada**:
|
|
657
|
+
|
|
658
|
+
```typescript
|
|
659
|
+
// Antes
|
|
660
|
+
import { TableConfigV1, TableConfigV2, TableConfigUnified } from "@praxis/core";
|
|
661
|
+
|
|
662
|
+
// Depois
|
|
663
|
+
import { TableConfig } from "@praxis/core";
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
2. **Serviços Simplificados**:
|
|
667
|
+
|
|
668
|
+
```typescript
|
|
669
|
+
// Antes
|
|
670
|
+
import { TableConfigAdapterService, TableConfigMigrationService } from "@praxis/core";
|
|
671
|
+
|
|
672
|
+
// Depois
|
|
673
|
+
import { TableConfigService } from "@praxisui/core";
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
3. **Type Guards Atualizados**:
|
|
677
|
+
|
|
678
|
+
```typescript
|
|
679
|
+
// Antes
|
|
680
|
+
isTableConfigV1(config) || isTableConfigV2(config);
|
|
681
|
+
|
|
682
|
+
// Depois
|
|
683
|
+
isTableConfigV2(config); // Sempre true para a nova arquitetura
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
## 🔍 Troubleshooting
|
|
687
|
+
|
|
688
|
+
### Problemas Comuns
|
|
689
|
+
|
|
690
|
+
#### Erros de Tipagem
|
|
691
|
+
|
|
692
|
+
```typescript
|
|
693
|
+
// Problema: Type error em propriedades opcionais
|
|
694
|
+
// Solução: Usar optional chaining
|
|
695
|
+
const pageSize = config.behavior?.pagination?.pageSize ?? 10;
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
#### Validação de Configuração
|
|
699
|
+
|
|
700
|
+
```typescript
|
|
701
|
+
// Verificar se configuração é válida antes de usar
|
|
702
|
+
import { isValidTableConfig } from "@praxisui/core";
|
|
703
|
+
|
|
704
|
+
if (!isValidTableConfig(userConfig)) {
|
|
705
|
+
console.error("Configuração inválida:", userConfig);
|
|
706
|
+
userConfig = createDefaultTableConfig();
|
|
707
|
+
}
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
#### Performance Issues
|
|
711
|
+
|
|
712
|
+
```typescript
|
|
713
|
+
// Para grandes volumes de dados, usar configuração otimizada
|
|
714
|
+
const optimizedConfig: TableConfig = {
|
|
715
|
+
columns: [...],
|
|
716
|
+
performance: {
|
|
717
|
+
virtualization: {
|
|
718
|
+
enabled: true,
|
|
719
|
+
itemHeight: 48,
|
|
720
|
+
bufferSize: 20
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
## 📚 API Reference Completa
|
|
727
|
+
|
|
728
|
+
### Exports Principais
|
|
729
|
+
|
|
730
|
+
```typescript
|
|
731
|
+
// Interfaces
|
|
732
|
+
export interface TableConfig;
|
|
733
|
+
export interface ColumnDefinition;
|
|
734
|
+
export interface ConfigMetadata;
|
|
735
|
+
export interface TableBehaviorConfig;
|
|
736
|
+
export interface TableAppearanceConfig;
|
|
737
|
+
export interface ToolbarConfig;
|
|
738
|
+
export interface TableActionsConfig;
|
|
739
|
+
export interface ExportConfig;
|
|
740
|
+
export interface MessagesConfig;
|
|
741
|
+
export interface LocalizationConfig;
|
|
742
|
+
export interface PerformanceConfig;
|
|
743
|
+
export interface AccessibilityConfig;
|
|
744
|
+
|
|
745
|
+
// Serviços
|
|
746
|
+
export class TableConfigService;
|
|
747
|
+
|
|
748
|
+
// Helper Functions
|
|
749
|
+
export function createDefaultTableConfig(): TableConfig;
|
|
750
|
+
export function isValidTableConfig(config: any): config is TableConfig;
|
|
751
|
+
export function isTableConfigV2(config: any): config is TableConfig;
|
|
752
|
+
export function cloneTableConfig(config: TableConfig): TableConfig;
|
|
753
|
+
export function mergeTableConfigs(base: TableConfig, override: Partial<TableConfig>): TableConfig;
|
|
754
|
+
export function getEssentialConfig(config: TableConfig): Partial<TableConfig>;
|
|
755
|
+
|
|
756
|
+
// Type Aliases
|
|
757
|
+
export type TableConfig = TableConfigV2;
|
|
758
|
+
export type TableConfigModern = TableConfigV2;
|
|
759
|
+
|
|
760
|
+
// Legacy (Deprecated)
|
|
761
|
+
export type LegacyTableConfig = TableConfig;
|
|
762
|
+
export const DEFAULT_TABLE_CONFIG = createDefaultTableConfig();
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
## 🤝 Contribuição
|
|
766
|
+
|
|
767
|
+
### Como Contribuir
|
|
768
|
+
|
|
769
|
+
1. Fork o projeto
|
|
770
|
+
2. Crie branch para feature (`git checkout -b feature/nova-interface`)
|
|
771
|
+
3. Commit mudanças (`git commit -m 'Add: nova interface para X'`)
|
|
772
|
+
4. Push para branch (`git push origin feature/nova-interface`)
|
|
773
|
+
5. Abra Pull Request
|
|
774
|
+
|
|
775
|
+
### Guidelines para Interfaces
|
|
776
|
+
|
|
777
|
+
- Usar nomes descritivos e consistentes
|
|
778
|
+
- Documentar todas as propriedades
|
|
779
|
+
- Manter backward compatibility quando possível
|
|
780
|
+
- Adicionar testes para novas interfaces
|
|
781
|
+
|
|
782
|
+
## 📊 Roadmap
|
|
783
|
+
|
|
784
|
+
### Próximas Versões
|
|
785
|
+
|
|
786
|
+
- ✅ Arquitetura unificada (v2.0.0)
|
|
787
|
+
- 🔄 Enhanced validation (v2.1.0)
|
|
788
|
+
- 📋 Plugin architecture (v2.2.0)
|
|
789
|
+
- 🎨 Theme system integration (v2.3.0)
|
|
790
|
+
|
|
791
|
+
## 📄 Licença
|
|
792
|
+
|
|
793
|
+
Apache-2.0 – veja o `LICENSE` empacotado com esta biblioteca ou o arquivo `LICENSE` na raiz do repositório.
|
|
794
|
+
|
|
795
|
+
---
|
|
796
|
+
|
|
797
|
+
**Biblioteca Central do Praxis UI Workspace**
|
|
798
|
+
**Versão**: 2.0.0 (Unified Architecture)
|
|
799
|
+
**Compatibilidade**: Angular 20.x | TypeScript 5.8+
|