@seniorsistemas/components-ai 0.0.0-master-d4a804fe

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/CONTRIBUTING.md +317 -0
  3. package/README.md +161 -0
  4. package/docs/API.md +486 -0
  5. package/docs/COMPONENTS.md +272 -0
  6. package/docs/EXAMPLES.md +559 -0
  7. package/docs/MIGRATION.md +367 -0
  8. package/esm2022/lib/angular-components.module.mjs +25 -0
  9. package/esm2022/lib/components/breadcrumb/breadcrumb.component.mjs +121 -0
  10. package/esm2022/lib/components/bulk-delete-dialog/bulk-delete-dialog.component.mjs +176 -0
  11. package/esm2022/lib/components/dynamic-form/dynamic-form.component.mjs +625 -0
  12. package/esm2022/lib/components/dynamic-form/fields/dynamic-field-date.component.mjs +86 -0
  13. package/esm2022/lib/components/dynamic-form/fields/dynamic-field-dropdown.component.mjs +103 -0
  14. package/esm2022/lib/components/dynamic-form/fields/dynamic-field-lookup.component.mjs +599 -0
  15. package/esm2022/lib/components/dynamic-form/fields/dynamic-field-number.component.mjs +92 -0
  16. package/esm2022/lib/components/dynamic-form/fields/dynamic-field-text.component.mjs +163 -0
  17. package/esm2022/lib/components/dynamic-form/fields/dynamic-field-textarea.component.mjs +81 -0
  18. package/esm2022/lib/components/dynamic-form/fields/dynamic-field-wrapper.component.mjs +93 -0
  19. package/esm2022/lib/components/dynamic-form/fields/index.mjs +8 -0
  20. package/esm2022/lib/components/dynamic-form/models/dynamic-form.models.mjs +2 -0
  21. package/esm2022/lib/components/export-dialog/export-dialog.component.mjs +219 -0
  22. package/esm2022/lib/config/translation.config.mjs +70 -0
  23. package/esm2022/lib/directives/cep-mask.directive.mjs +79 -0
  24. package/esm2022/lib/directives/document-mask.directive.mjs +62 -0
  25. package/esm2022/lib/directives/phone-mask.directive.mjs +59 -0
  26. package/esm2022/lib/interceptors/api.interceptor.mjs +55 -0
  27. package/esm2022/lib/models/base-entity.interface.mjs +2 -0
  28. package/esm2022/lib/models/entity-list.config.mjs +2 -0
  29. package/esm2022/lib/pipes/translate.pipe.mjs +74 -0
  30. package/esm2022/lib/services/auth.service.mjs +169 -0
  31. package/esm2022/lib/services/cookie.service.mjs +90 -0
  32. package/esm2022/lib/services/entity.service.mjs +208 -0
  33. package/esm2022/lib/services/mask.service.mjs +121 -0
  34. package/esm2022/lib/services/permission.service.mjs +180 -0
  35. package/esm2022/lib/services/senior-token.service.mjs +209 -0
  36. package/esm2022/lib/services/theme.service.mjs +85 -0
  37. package/esm2022/lib/services/translation.service.mjs +232 -0
  38. package/esm2022/public-api.mjs +90 -0
  39. package/esm2022/seniorsistemas-components-ai.mjs +5 -0
  40. package/fesm2022/seniorsistemas-components-ai.mjs +4006 -0
  41. package/fesm2022/seniorsistemas-components-ai.mjs.map +1 -0
  42. package/index.d.ts +5 -0
  43. package/lib/angular-components.module.d.ts +13 -0
  44. package/lib/components/breadcrumb/breadcrumb.component.d.ts +23 -0
  45. package/lib/components/bulk-delete-dialog/bulk-delete-dialog.component.d.ts +46 -0
  46. package/lib/components/dynamic-form/dynamic-form.component.d.ts +97 -0
  47. package/lib/components/dynamic-form/fields/dynamic-field-date.component.d.ts +16 -0
  48. package/lib/components/dynamic-form/fields/dynamic-field-dropdown.component.d.ts +17 -0
  49. package/lib/components/dynamic-form/fields/dynamic-field-lookup.component.d.ts +52 -0
  50. package/lib/components/dynamic-form/fields/dynamic-field-number.component.d.ts +16 -0
  51. package/lib/components/dynamic-form/fields/dynamic-field-text.component.d.ts +17 -0
  52. package/lib/components/dynamic-form/fields/dynamic-field-textarea.component.d.ts +16 -0
  53. package/lib/components/dynamic-form/fields/dynamic-field-wrapper.component.d.ts +20 -0
  54. package/lib/components/dynamic-form/fields/index.d.ts +7 -0
  55. package/lib/components/dynamic-form/models/dynamic-form.models.d.ts +178 -0
  56. package/lib/components/export-dialog/export-dialog.component.d.ts +56 -0
  57. package/lib/config/translation.config.d.ts +24 -0
  58. package/lib/directives/cep-mask.directive.d.ts +13 -0
  59. package/lib/directives/document-mask.directive.d.ts +19 -0
  60. package/lib/directives/phone-mask.directive.d.ts +11 -0
  61. package/lib/interceptors/api.interceptor.d.ts +2 -0
  62. package/lib/models/base-entity.interface.d.ts +7 -0
  63. package/lib/models/entity-list.config.d.ts +161 -0
  64. package/lib/pipes/translate.pipe.d.ts +21 -0
  65. package/lib/services/auth.service.d.ts +82 -0
  66. package/lib/services/cookie.service.d.ts +31 -0
  67. package/lib/services/entity.service.d.ts +99 -0
  68. package/lib/services/mask.service.d.ts +36 -0
  69. package/lib/services/permission.service.d.ts +91 -0
  70. package/lib/services/senior-token.service.d.ts +70 -0
  71. package/lib/services/theme.service.d.ts +16 -0
  72. package/lib/services/translation.service.d.ts +54 -0
  73. package/package.json +53 -0
  74. package/public-api.d.ts +17 -0
  75. package/src/lib/styles/entity-list.shared.scss +383 -0
  76. package/src/lib/styles/index.scss +10 -0
@@ -0,0 +1,559 @@
1
+ # Exemplos Práticos
2
+
3
+ ## 📚 Guia de Exemplos
4
+
5
+ Este documento contém exemplos práticos de uso dos componentes da biblioteca `@seniorsistemas/components-ia`.
6
+
7
+ ---
8
+
9
+ ## 🎯 Dynamic Form - Exemplos Completos
10
+
11
+ ### Exemplo 1: Formulário de Cadastro Simples
12
+
13
+ ```typescript
14
+ import { Component } from '@angular/core';
15
+ import { DynamicFormComponent, DynamicFormFieldConfig, FieldType } from '@seniorsistemas/components-ia';
16
+
17
+ @Component({
18
+ selector: 'app-product-form',
19
+ template: `
20
+ <sia-dynamic-form
21
+ [formFields]="formFields"
22
+ [mode]="'create'"
23
+ (onSubmit)="handleSubmit($event)"
24
+ ></sia-dynamic-form>
25
+ `
26
+ })
27
+ export class ProductFormComponent {
28
+ formFields: DynamicFormFieldConfig[] = [
29
+ {
30
+ name: 'name',
31
+ label: 'Nome do Produto',
32
+ type: FieldType.TEXT,
33
+ required: true,
34
+ placeholder: 'Digite o nome do produto',
35
+ cols: 12
36
+ },
37
+ {
38
+ name: 'description',
39
+ label: 'Descrição',
40
+ type: FieldType.TEXTAREA,
41
+ rows: 4,
42
+ cols: 12
43
+ },
44
+ {
45
+ name: 'price',
46
+ label: 'Preço',
47
+ type: FieldType.NUMBER,
48
+ required: true,
49
+ min: 0,
50
+ step: 0.01,
51
+ cols: 6
52
+ },
53
+ {
54
+ name: 'stock',
55
+ label: 'Estoque',
56
+ type: FieldType.NUMBER,
57
+ required: true,
58
+ min: 0,
59
+ cols: 6
60
+ },
61
+ {
62
+ name: 'active',
63
+ label: 'Ativo',
64
+ type: FieldType.SWITCH,
65
+ value: true,
66
+ cols: 12
67
+ }
68
+ ];
69
+
70
+ handleSubmit(formValue: any): void {
71
+ console.log('Produto criado:', formValue);
72
+ // Chamar serviço para salvar
73
+ }
74
+ }
75
+ ```
76
+
77
+ ---
78
+
79
+ ### Exemplo 2: Formulário com Seções
80
+
81
+ ```typescript
82
+ import { Component } from '@angular/core';
83
+ import { DynamicFormSection, FieldType } from '@seniorsistemas/components-ia';
84
+
85
+ @Component({
86
+ selector: 'app-customer-form',
87
+ template: `
88
+ <sia-dynamic-form
89
+ [formSections]="formSections"
90
+ [mode]="'create'"
91
+ (onSubmit)="handleSubmit($event)"
92
+ ></sia-dynamic-form>
93
+ `
94
+ })
95
+ export class CustomerFormComponent {
96
+ formSections: DynamicFormSection[] = [
97
+ {
98
+ title: 'Dados Pessoais',
99
+ fields: [
100
+ {
101
+ name: 'name',
102
+ label: 'Nome Completo',
103
+ type: FieldType.TEXT,
104
+ required: true,
105
+ cols: 8
106
+ },
107
+ {
108
+ name: 'document',
109
+ label: 'CPF',
110
+ type: FieldType.TEXT,
111
+ required: true,
112
+ mask: '000.000.000-00',
113
+ cols: 4
114
+ },
115
+ {
116
+ name: 'email',
117
+ label: 'E-mail',
118
+ type: FieldType.EMAIL,
119
+ required: true,
120
+ cols: 6
121
+ },
122
+ {
123
+ name: 'phone',
124
+ label: 'Telefone',
125
+ type: FieldType.TEXT,
126
+ mask: '(00) 00000-0000',
127
+ cols: 6
128
+ }
129
+ ]
130
+ },
131
+ {
132
+ title: 'Endereço',
133
+ collapsible: true,
134
+ fields: [
135
+ {
136
+ name: 'zipCode',
137
+ label: 'CEP',
138
+ type: FieldType.TEXT,
139
+ mask: '00000-000',
140
+ cols: 4
141
+ },
142
+ {
143
+ name: 'street',
144
+ label: 'Rua',
145
+ type: FieldType.TEXT,
146
+ cols: 8
147
+ },
148
+ {
149
+ name: 'number',
150
+ label: 'Número',
151
+ type: FieldType.TEXT,
152
+ cols: 3
153
+ },
154
+ {
155
+ name: 'complement',
156
+ label: 'Complemento',
157
+ type: FieldType.TEXT,
158
+ cols: 3
159
+ },
160
+ {
161
+ name: 'neighborhood',
162
+ label: 'Bairro',
163
+ type: FieldType.TEXT,
164
+ cols: 6
165
+ },
166
+ {
167
+ name: 'city',
168
+ label: 'Cidade',
169
+ type: FieldType.TEXT,
170
+ cols: 6
171
+ },
172
+ {
173
+ name: 'state',
174
+ label: 'Estado',
175
+ type: FieldType.SELECT,
176
+ options: [
177
+ { label: 'São Paulo', value: 'SP' },
178
+ { label: 'Rio de Janeiro', value: 'RJ' },
179
+ { label: 'Minas Gerais', value: 'MG' }
180
+ ],
181
+ cols: 6
182
+ }
183
+ ]
184
+ }
185
+ ];
186
+
187
+ handleSubmit(formValue: any): void {
188
+ console.log('Cliente criado:', formValue);
189
+ }
190
+ }
191
+ ```
192
+
193
+ ---
194
+
195
+ ### Exemplo 3: Formulário em Dialog
196
+
197
+ ```typescript
198
+ import { Component } from '@angular/core';
199
+ import { DynamicFormFieldConfig, FieldType } from '@seniorsistemas/components-ia';
200
+
201
+ @Component({
202
+ selector: 'app-category-list',
203
+ template: `
204
+ <p-button
205
+ label="Nova Categoria"
206
+ icon="pi pi-plus"
207
+ (onClick)="openDialog()"
208
+ ></p-button>
209
+
210
+ <sia-dynamic-form
211
+ [(visible)]="showDialog"
212
+ [formFields]="formFields"
213
+ [entity]="selectedCategory"
214
+ [mode]="selectedCategory ? 'edit' : 'create'"
215
+ [displayMode]="'dialog'"
216
+ [dialogHeader]="selectedCategory ? 'Editar Categoria' : 'Nova Categoria'"
217
+ (onSubmit)="handleSubmit($event)"
218
+ ></sia-dynamic-form>
219
+ `
220
+ })
221
+ export class CategoryListComponent {
222
+ showDialog = false;
223
+ selectedCategory: any = null;
224
+
225
+ formFields: DynamicFormFieldConfig[] = [
226
+ {
227
+ name: 'name',
228
+ label: 'Nome',
229
+ type: FieldType.TEXT,
230
+ required: true,
231
+ cols: 12
232
+ },
233
+ {
234
+ name: 'description',
235
+ label: 'Descrição',
236
+ type: FieldType.TEXTAREA,
237
+ rows: 3,
238
+ cols: 12
239
+ },
240
+ {
241
+ name: 'active',
242
+ label: 'Ativa',
243
+ type: FieldType.SWITCH,
244
+ value: true,
245
+ cols: 12
246
+ }
247
+ ];
248
+
249
+ openDialog(category?: any): void {
250
+ this.selectedCategory = category || null;
251
+ this.showDialog = true;
252
+ }
253
+
254
+ handleSubmit(formValue: any): void {
255
+ if (this.selectedCategory) {
256
+ console.log('Categoria atualizada:', formValue);
257
+ // Chamar serviço de update
258
+ } else {
259
+ console.log('Categoria criada:', formValue);
260
+ // Chamar serviço de create
261
+ }
262
+ this.showDialog = false;
263
+ }
264
+ }
265
+ ```
266
+
267
+ ---
268
+
269
+ ### Exemplo 4: Formulário de Filtro
270
+
271
+ ```typescript
272
+ import { Component } from '@angular/core';
273
+ import { DynamicFormFieldConfig, FieldType } from '@seniorsistemas/components-ia';
274
+
275
+ @Component({
276
+ selector: 'app-product-list',
277
+ template: `
278
+ <sia-dynamic-form
279
+ [formFields]="filterFields"
280
+ [mode]="'filter'"
281
+ [submitButtonLabel]="'Filtrar'"
282
+ (onSubmit)="applyFilter($event)"
283
+ ></sia-dynamic-form>
284
+
285
+ <!-- Tabela de produtos -->
286
+ `
287
+ })
288
+ export class ProductListComponent {
289
+ filterFields: DynamicFormFieldConfig[] = [
290
+ {
291
+ name: 'name',
292
+ label: 'Nome',
293
+ type: FieldType.TEXT,
294
+ placeholder: 'Buscar por nome',
295
+ cols: 4
296
+ },
297
+ {
298
+ name: 'category',
299
+ label: 'Categoria',
300
+ type: FieldType.SELECT,
301
+ options: [
302
+ { label: 'Todas', value: null },
303
+ { label: 'Eletrônicos', value: 1 },
304
+ { label: 'Roupas', value: 2 },
305
+ { label: 'Alimentos', value: 3 }
306
+ ],
307
+ cols: 4
308
+ },
309
+ {
310
+ name: 'active',
311
+ label: 'Status',
312
+ type: FieldType.SELECT,
313
+ options: [
314
+ { label: 'Todos', value: null },
315
+ { label: 'Ativos', value: true },
316
+ { label: 'Inativos', value: false }
317
+ ],
318
+ cols: 4
319
+ }
320
+ ];
321
+
322
+ applyFilter(filterValues: any): void {
323
+ console.log('Filtros aplicados:', filterValues);
324
+ // Chamar serviço com filtros
325
+ }
326
+ }
327
+ ```
328
+
329
+ ---
330
+
331
+ ### Exemplo 5: Formulário com Lookup
332
+
333
+ ```typescript
334
+ import { Component } from '@angular/core';
335
+ import { DynamicFormFieldConfig, FieldType } from '@seniorsistemas/components-ia';
336
+
337
+ @Component({
338
+ selector: 'app-order-form',
339
+ template: `
340
+ <sia-dynamic-form
341
+ [formFields]="formFields"
342
+ [mode]="'create'"
343
+ (onSubmit)="handleSubmit($event)"
344
+ ></sia-dynamic-form>
345
+ `
346
+ })
347
+ export class OrderFormComponent {
348
+ formFields: DynamicFormFieldConfig[] = [
349
+ {
350
+ name: 'customer',
351
+ label: 'Cliente',
352
+ type: FieldType.LOOKUP,
353
+ required: true,
354
+ lookupConfig: {
355
+ service: this.customerService,
356
+ displayField: 'name',
357
+ valueField: 'id',
358
+ searchFields: ['name', 'document'],
359
+ columns: [
360
+ { field: 'name', header: 'Nome' },
361
+ { field: 'document', header: 'CPF/CNPJ' },
362
+ { field: 'email', header: 'E-mail' }
363
+ ]
364
+ },
365
+ cols: 12
366
+ },
367
+ {
368
+ name: 'product',
369
+ label: 'Produto',
370
+ type: FieldType.LOOKUP,
371
+ required: true,
372
+ lookupConfig: {
373
+ service: this.productService,
374
+ displayField: 'name',
375
+ valueField: 'id',
376
+ searchFields: ['name', 'code'],
377
+ columns: [
378
+ { field: 'code', header: 'Código' },
379
+ { field: 'name', header: 'Nome' },
380
+ { field: 'price', header: 'Preço' }
381
+ ]
382
+ },
383
+ cols: 8
384
+ },
385
+ {
386
+ name: 'quantity',
387
+ label: 'Quantidade',
388
+ type: FieldType.NUMBER,
389
+ required: true,
390
+ min: 1,
391
+ value: 1,
392
+ cols: 4
393
+ },
394
+ {
395
+ name: 'deliveryDate',
396
+ label: 'Data de Entrega',
397
+ type: FieldType.DATE,
398
+ required: true,
399
+ minDate: new Date(),
400
+ cols: 6
401
+ },
402
+ {
403
+ name: 'notes',
404
+ label: 'Observações',
405
+ type: FieldType.TEXTAREA,
406
+ rows: 3,
407
+ cols: 12
408
+ }
409
+ ];
410
+
411
+ constructor(
412
+ private customerService: CustomerService,
413
+ private productService: ProductService
414
+ ) {}
415
+
416
+ handleSubmit(formValue: any): void {
417
+ console.log('Pedido criado:', formValue);
418
+ }
419
+ }
420
+ ```
421
+
422
+ ---
423
+
424
+ ## 📤 Export Dialog - Exemplo
425
+
426
+ ```typescript
427
+ import { Component } from '@angular/core';
428
+ import { ColumnOption } from '@seniorsistemas/components-ia';
429
+
430
+ @Component({
431
+ selector: 'app-product-list',
432
+ template: `
433
+ <p-button
434
+ label="Exportar"
435
+ icon="pi pi-download"
436
+ (onClick)="showExportDialog = true"
437
+ ></p-button>
438
+
439
+ <sia-export-dialog
440
+ [(visible)]="showExportDialog"
441
+ [data]="products"
442
+ [columns]="exportColumns"
443
+ [fileName]="'produtos'"
444
+ ></sia-export-dialog>
445
+ `
446
+ })
447
+ export class ProductListComponent {
448
+ showExportDialog = false;
449
+ products: any[] = [];
450
+
451
+ exportColumns: ColumnOption[] = [
452
+ { field: 'code', header: 'Código', selected: true },
453
+ { field: 'name', header: 'Nome', selected: true },
454
+ { field: 'category', header: 'Categoria', selected: true },
455
+ { field: 'price', header: 'Preço', selected: true },
456
+ { field: 'stock', header: 'Estoque', selected: true },
457
+ { field: 'active', header: 'Status', selected: false }
458
+ ];
459
+ }
460
+ ```
461
+
462
+ ---
463
+
464
+ ## 🗑️ Bulk Delete Dialog - Exemplo
465
+
466
+ ```typescript
467
+ import { Component } from '@angular/core';
468
+
469
+ @Component({
470
+ selector: 'app-product-list',
471
+ template: `
472
+ <p-button
473
+ label="Excluir Selecionados"
474
+ icon="pi pi-trash"
475
+ [disabled]="selectedProducts.length === 0"
476
+ (onClick)="showBulkDeleteDialog = true"
477
+ ></p-button>
478
+
479
+ <sia-bulk-delete-dialog
480
+ [(visible)]="showBulkDeleteDialog"
481
+ [selectedItems]="selectedProducts"
482
+ [entityName]="'produto'"
483
+ [entityPluralName]="'produtos'"
484
+ (onConfirm)="handleBulkDelete()"
485
+ ></sia-bulk-delete-dialog>
486
+ `
487
+ })
488
+ export class ProductListComponent {
489
+ showBulkDeleteDialog = false;
490
+ selectedProducts: any[] = [];
491
+
492
+ handleBulkDelete(): void {
493
+ const ids = this.selectedProducts.map(p => p.id);
494
+ this.productService.bulkDelete(ids).subscribe({
495
+ next: () => {
496
+ this.messageService.add({
497
+ severity: 'success',
498
+ summary: 'Sucesso',
499
+ detail: `${this.selectedProducts.length} produtos excluídos`
500
+ });
501
+ this.selectedProducts = [];
502
+ this.loadProducts();
503
+ },
504
+ error: (error: any) => {
505
+ this.messageService.add({
506
+ severity: 'error',
507
+ summary: 'Erro',
508
+ detail: 'Erro ao excluir produtos'
509
+ });
510
+ }
511
+ });
512
+ }
513
+ }
514
+ ```
515
+
516
+ ---
517
+
518
+ ## 🍞 Breadcrumb - Exemplo
519
+
520
+ ```typescript
521
+ import { Component, OnInit } from '@angular/core';
522
+ import { MenuItem } from 'primeng/api';
523
+ import { ActivatedRoute } from '@angular/router';
524
+
525
+ @Component({
526
+ selector: 'app-product-edit',
527
+ template: `
528
+ <sia-breadcrumb
529
+ [items]="breadcrumbItems"
530
+ [home]="{ icon: 'pi pi-home', routerLink: '/' }"
531
+ ></sia-breadcrumb>
532
+
533
+ <!-- Formulário de edição -->
534
+ `
535
+ })
536
+ export class ProductEditComponent implements OnInit {
537
+ breadcrumbItems: MenuItem[] = [];
538
+
539
+ constructor(private route: ActivatedRoute) {}
540
+
541
+ ngOnInit(): void {
542
+ const productId = this.route.snapshot.params['id'];
543
+
544
+ this.breadcrumbItems = [
545
+ { label: 'Cadastros' },
546
+ { label: 'Produtos', routerLink: '/products' },
547
+ { label: `Editar #${productId}` }
548
+ ];
549
+ }
550
+ }
551
+ ```
552
+
553
+ ---
554
+
555
+ ## 🔗 Veja Também
556
+
557
+ - [Documentação de Componentes](./COMPONENTS.md)
558
+ - [Referência da API](./API.md)
559
+ - [Guia de Migração](./MIGRATION.md)