@acontplus/ng-components 2.0.1 → 2.1.0

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/README.md CHANGED
@@ -353,53 +353,90 @@ import { Spinner } from '@acontplus/ng-components';
353
353
 
354
354
  ### Tables
355
355
 
356
- - **DynamicTable**: Angular Material-based dynamic table with advanced features
356
+ - **DataGrid**: Advanced data grid with Material table integration, signals, and modern Angular patterns
357
357
  - **TabulatorTable**: Advanced table with Tabulator.js integration
358
358
 
359
359
  ```typescript
360
- import { DynamicTable, TabulatorTable } from '@acontplus/ng-components';
360
+ import { DataGrid, DataGridColumn, TabulatorTable } from '@acontplus/ng-components';
361
361
  ```
362
362
 
363
- #### Dynamic Table Features
363
+ #### Data Grid Features
364
364
 
365
- - **Row Selection**: Single/multiple selection with disabled rows support
366
- - **Row Styling**: Theme-aware dynamic row colors based on data properties
367
- - **Expandable Rows**: Collapsible detail views
368
- - **Pagination**: Built-in pagination support
369
- - **Column Templates**: Custom column rendering
370
- - **Sorting & Filtering**: Material table sorting capabilities
365
+ The DataGrid is the primary table component, built with modern Angular 21+ patterns:
366
+
367
+ - **Signals Architecture**: Uses `signal()`, `computed()`, `effect()` for reactive state
368
+ - **Modern APIs**: Uses `input()` and `output()` functions
369
+ - **Row Selection**: Single/multiple selection with formatter support
370
+ - **Row Highlighting**: Visual highlighting with `highlightedRowIndex`
371
+ - **Keyboard Navigation**: Full accessibility with arrow keys, Home/End
372
+ - **Column Pinning**: Sticky left/right columns
373
+ - **Infinite Scroll**: Load more data on scroll
374
+ - **Server-side Support**: `pageOnFront`/`sortOnFront` toggles for backend pagination
375
+ - **Custom Templates**: Cell, header, and expansion templates
376
+ - **Sorting & Pagination**: Full Material integration
371
377
 
372
378
  ```typescript
373
- // Row styling example
374
- interface TableRow {
375
- rowStyle?: {
376
- backgroundColor?: string;
377
- color?: string;
378
- [key: string]: any;
379
- };
380
- disableSelection?: boolean;
379
+ // Basic usage
380
+ @Component({
381
+ imports: [DataGrid],
382
+ template: `
383
+ <acp-data-grid
384
+ [data]="items"
385
+ [columns]="columns"
386
+ [rowSelectable]="true"
387
+ [multiSelectable]="true"
388
+ [showPaginator]="true"
389
+ [pageOnFront]="false"
390
+ [length]="totalCount"
391
+ [pageIndex]="currentPage"
392
+ [pageSize]="pageSize"
393
+ [loading]="isLoading"
394
+ (rowSelectedChange)="onSelect($event)"
395
+ (page)="onPageChange($event)"
396
+ />
397
+ `,
398
+ })
399
+ export class MyComponent {
400
+ columns: DataGridColumn[] = [
401
+ { field: 'id', header: 'ID', type: 'number', sortable: true },
402
+ { field: 'name', header: 'Name', sortable: true },
403
+ { field: 'status', header: 'Status', cellTemplate: statusTemplate },
404
+ { field: 'actions', header: 'Actions', cellTemplate: actionsTemplate },
405
+ ];
381
406
  }
407
+ ```
382
408
 
383
- // Usage with theme-aware colors
384
- const data = [
409
+ #### Row Selection Formatting
410
+
411
+ ```typescript
412
+ // Disable selection for specific rows
413
+ <acp-data-grid
414
+ [rowSelectable]="true"
415
+ [rowSelectionFormatter]="{
416
+ disabled: (row, index) => row.status === 'locked',
417
+ hideCheckbox: (row, index) => row.isSystem
418
+ }"
419
+ />
420
+ ```
421
+
422
+ #### Column Configuration
423
+
424
+ ```typescript
425
+ const columns: DataGridColumn[] = [
385
426
  {
386
- id: 1,
387
- name: 'Item 1',
388
- status: 'active',
389
- rowStyle: {
390
- backgroundColor: 'var(--mat-sys-primary-container)',
391
- color: 'var(--mat-sys-on-primary-container)',
392
- },
427
+ field: 'price',
428
+ header: 'Price',
429
+ type: 'currency',
430
+ typeParameter: { currencyCode: 'USD' },
431
+ sortable: true,
432
+ pinned: 'left',
433
+ width: '120px',
393
434
  },
394
435
  {
395
- id: 2,
396
- name: 'Item 2',
397
- status: 'processing',
398
- disableSelection: true,
399
- rowStyle: {
400
- backgroundColor: '#e3f2fd',
401
- color: '#1565c0',
402
- },
436
+ field: 'date',
437
+ header: 'Created',
438
+ type: 'date',
439
+ typeParameter: { format: 'yyyy-MM-dd' },
403
440
  },
404
441
  ];
405
442
  ```
@@ -445,12 +482,49 @@ Row colors automatically adapt to light/dark themes using Material Design tokens
445
482
 
446
483
  ### Theme Toggle
447
484
 
448
- Dark/light mode toggle component for theme switching.
485
+ Dark/light mode toggle component for theme switching. Provides accessible theme switching with customizable icons and labels.
486
+
487
+ **Features:**
488
+
489
+ - ✅ Accessible - ARIA labels and pressed state
490
+ - ✅ Customizable icons and labels
491
+ - ✅ Signal-based reactive state
492
+ - ✅ Automatic theme persistence to localStorage
493
+ - ✅ System theme preference detection
494
+ - ✅ OnPush change detection for performance
449
495
 
450
496
  ```typescript
451
497
  import { ThemeToggle } from '@acontplus/ng-components';
498
+
499
+ @Component({
500
+ template: `
501
+ <!-- Basic usage -->
502
+ <acp-theme-toggle />
503
+
504
+ <!-- With custom labels (i18n ready) -->
505
+ <acp-theme-toggle lightModeLabel="Cambiar a modo claro" darkModeLabel="Cambiar a modo oscuro" />
506
+
507
+ <!-- With custom icons -->
508
+ <acp-theme-toggle lightModeIcon="wb_sunny" darkModeIcon="nightlight" />
509
+
510
+ <!-- With test ID for automated testing -->
511
+ <acp-theme-toggle testId="header-theme-toggle" />
512
+ `,
513
+ imports: [ThemeToggle],
514
+ })
515
+ export class HeaderComponent {}
452
516
  ```
453
517
 
518
+ **Theme Toggle API:**
519
+
520
+ | Input | Type | Default | Description |
521
+ | ---------------- | -------- | ------------------------ | --------------------------------------------- |
522
+ | `lightModeIcon` | `string` | `'light_mode'` | Icon shown when in dark mode (Material icon) |
523
+ | `darkModeIcon` | `string` | `'dark_mode'` | Icon shown when in light mode (Material icon) |
524
+ | `lightModeLabel` | `string` | `'Switch to light mode'` | Accessible label when in dark mode |
525
+ | `darkModeLabel` | `string` | `'Switch to dark mode'` | Accessible label when in light mode |
526
+ | `testId` | `string` | `''` | data-testid attribute for testing |
527
+
454
528
  ### Autocomplete Wrapper
455
529
 
456
530
  Enhanced autocomplete components with custom functionality.