@acontplus/ng-components 3.2.0 → 4.0.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
@@ -14,7 +14,7 @@ pnpm add @acontplus/ng-components
14
14
 
15
15
  ## Features
16
16
 
17
- - **UI Components**: Dynamic cards, dialogs, icons, input chips, buttons, spinners, dynamic/tabulator tables, theme toggle, autocomplete wrapper
17
+ - **UI Components**: Cards, KPI cards, dialogs, icons, input chips, buttons, spinners, dynamic/tabulator tables, theme toggle, search select
18
18
  - **Directives**: Text transformation (to-upper-case)
19
19
  - **Pipes**: Data transformation (get-total, status-display)
20
20
  - **Services**: Dialog management, overlay, theme management (dark/light mode), autocomplete
@@ -75,33 +75,89 @@ bounds, and the `ngx-datex` behavior options. `MATERIAL_LIGHT_THEME`,
75
75
 
76
76
  ### Cards
77
77
 
78
- #### DynamicCard
78
+ #### AcpCard
79
79
 
80
- Versatile card component wrapping Angular Material's mat-card with additional functionality.
80
+ Material Design 3 card built on `mat-card`. Props can be passed in three ways,
81
+ from lowest to highest priority: injected defaults, plain inputs, and slot
82
+ templates for rich content.
81
83
 
82
84
  ```typescript
83
- import { DynamicCard } from '@acontplus/ng-components';
85
+ import { ACP_CARD_SLOTS, AcpCard, provideAcpCardDefaults } from '@acontplus/ng-components';
86
+
87
+ // app.config.ts (optional, application-wide defaults)
88
+ providers: [provideAcpCardDefaults({ appearance: 'outlined', rounded: 12 })];
84
89
 
85
90
  @Component({
86
91
  template: `
87
- <acp-dynamic-card
88
- [cardTitle]="'Product Details'"
89
- [cardSubtitle]="'Premium Package'"
90
- [isHeaderVisible]="true"
91
- [areActionsVisible]="true"
92
- [primaryButtonText]="'Buy Now'"
93
- [secondaryButtonText]="'Learn More'"
94
- (primaryButtonClicked)="onPurchase()"
95
- (secondaryButtonClicked)="onLearnMore()"
92
+ <acp-card
93
+ title="Order #1024"
94
+ subtitle="Pending"
95
+ color="surface-container"
96
+ imageRatio="16:9"
97
+ actionsAlign="end"
98
+ clickable
99
+ (clicked)="open()"
96
100
  >
101
+ <ng-template acpCardMedia><img src="cover.jpg" alt="" /></ng-template>
97
102
  <p>Card content goes here</p>
98
- </acp-dynamic-card>
103
+ <ng-template acpCardActions><acp-button text="Pay" /></ng-template>
104
+ </acp-card>
99
105
  `,
100
- imports: [DynamicCard],
106
+ imports: [AcpCard, ACP_CARD_SLOTS],
101
107
  })
102
- export class ProductComponent {}
108
+ export class OrderComponent {}
109
+ ```
110
+
111
+ - Inputs: `title`, `subtitle`, `appearance` (`elevated` | `outlined` | `filled`),
112
+ `color`, `elevation` (0-5), `rounded` (`true` | `false` | px), `padding`
113
+ (`none` | `small` | `medium` | `large`), `hoverable`, `clickable`, `disabled`,
114
+ `loading`, `imageRatio`, `actionsAlign`, `fullHeight`, `fullWidth`,
115
+ `ariaLabel` and `passThrough` (per-section `class`/`style`).
116
+ - Output: `clicked`, emitted on click, Enter or Space when `clickable`. Clicks on
117
+ actions or nested buttons/links are ignored.
118
+ - Slots: `acpCardHeader`, `acpCardMedia`, `acpCardAvatar`, `acpCardTitle`,
119
+ `acpCardSubtitle`, `acpCardActions` and `acpCardFooter`. Slot templates win
120
+ over `title`/`subtitle`. Legacy `#title`-style template refs still work.
121
+ - Styling hooks: `--acp-card-shape`, `--acp-card-elevation`, `--acp-card-padding`,
122
+ `--acp-card-container-color`, `--acp-card-on-color`, `--acp-card-subtitle-color`
123
+ and `--acp-card-outline-color`.
124
+ - Removed in this major: `backgroundColor` (use `color`), `hover` (use
125
+ `hoverable`), `outlined` (use `appearance="outlined"`), the appearances
126
+ `default`, `interactive` and `compact`, and the unused `AcpCardBadge` and
127
+ `AcpCardBackgroundColor` types. `DynamicCard` (`acp-dynamic-card`) was removed;
128
+ use `AcpCard`.
129
+
130
+ #### AcpKpiCard
131
+
132
+ Metric card for dashboards. Numeric values and changes are formatted with
133
+ `Intl.NumberFormat` using the app `LOCALE_ID` (or `locale`).
134
+
135
+ ```html
136
+ <acp-kpi-card
137
+ title="Expenses"
138
+ icon="payments"
139
+ [value]="45900"
140
+ [valueFormat]="{ style: 'currency', currency: 'USD', maximumFractionDigits: 0 }"
141
+ [percentage]="-4.1"
142
+ lowerIsBetter
143
+ trendLabel="vs last month"
144
+ variant="outlined"
145
+ />
103
146
  ```
104
147
 
148
+ - `trend` is inferred from the sign of `percentage` when unset. The delta badge
149
+ color comes from the trend sentiment, not from the card `color`; set
150
+ `lowerIsBetter` for costs, churn or error rates.
151
+ - Other inputs: `subtitle`, `prefix`, `suffix`, `description`, `footer`,
152
+ `variant`, `color` (including `surface` and `custom`), `size`, `align`
153
+ (`start` | `center` | `end`), `showTrendIcon`, `icon`,
154
+ `svgIcon`, `avatar`, `avatarInitials`, `progress`, `progressColor`, `loading`,
155
+ `disabled`, `clickable`, `selected`, `routerLink`, `ariaLabel`,
156
+ `menuAriaLabel` and `tooltip`. Output: `clicked` (click, Enter or Space).
157
+ - Templates: `#icon`, `#avatar`, `#footer` and `#actions` (rendered in a menu).
158
+ - Styling hooks: `--acp-kpi-card-custom-bg`, `--acp-kpi-card-custom-fg` and
159
+ `--acp-kpi-card-custom-accent`, plus the `kpi-card-*` theme tokens.
160
+
105
161
  ### Buttons
106
162
 
107
163
  > **The legacy `Button` component is deprecated.** New code should import and
@@ -438,14 +494,38 @@ export class HeaderComponent {}
438
494
  | `darkModeLabel` | `string` | `'Switch to dark mode'` | Accessible label when in light mode |
439
495
  | `testId` | `string` | `''` | data-testid attribute for testing |
440
496
 
441
- ### Autocomplete Wrapper
497
+ ### AcpSearchSelect
442
498
 
443
- Enhanced autocomplete components with custom functionality.
499
+ Searchable select built on `mat-autocomplete`. Accepts flat lists or one-level
500
+ groups (items with a `children` array), ignores accents when searching and works
501
+ with `ngModel`, reactive forms (including the `required` error state) and `[(value)]`.
444
502
 
445
- ```typescript
446
- import { AutocompleteWrapperComponent } from '@acontplus/ng-components';
503
+ ```html
504
+ <acp-search-select [items]="cities" [(ngModel)]="cityId" [emptyValue]="0" label="Ciudad" />
505
+
506
+ <!-- Server-side search: debounce in the consumer and pass the results back -->
507
+ <acp-search-select
508
+ [items]="customers()"
509
+ [localFilter]="false"
510
+ [loading]="loading()"
511
+ (searchChange)="search($event)"
512
+ label="Cliente"
513
+ />
447
514
  ```
448
515
 
516
+ - Defaults match the backend lookup shape `{ id, value, children? }`:
517
+ `bindValue="id"`, `bindLabel="value"`, `groupLabel="value"`. Each accessor
518
+ also accepts a function, e.g. `[bindLabel]="labelOf"`.
519
+ - Inputs: `items`, `bindLabel`, `bindValue`, `children`, `groupLabel`,
520
+ `compareWith` (matches `1` and `'1'` by default), `filterFn`, `localFilter`,
521
+ `emptyValue`, `label`, `placeholder`, `hint`, `errorText`, `noResultsText`,
522
+ `clearLabel`, `appearance`, `required`, `disabled`, `clearable` and `loading`.
523
+ - Outputs: `optionSelected` (`{ value, item, group }`), `cleared` and
524
+ `searchChange`.
525
+ - Custom option content: `<ng-template #option let-item let-group="group">`.
526
+ - Typed text that is not selected is discarded when the panel closes, so the
527
+ field always shows the current value.
528
+
449
529
  ## Directives
450
530
 
451
531
  ### ToUpperCase