ngx-opalbytes-components 1.8.1 → 1.9.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/README.md CHANGED
@@ -179,6 +179,81 @@ Um componente para exibir alertas de sucesso, erro, informação ou aviso. Geral
179
179
 
180
180
  ---
181
181
 
182
+ ### `AlertService`
183
+ O `AlertService` é responsável por exibir os alertas na tela. Por padrão, ele utiliza o componente `BaseAlert`.
184
+
185
+ **Como estender o `AlertService` para usar um componente de alerta customizado:**
186
+
187
+ Para personalizar a aparência ou o comportamento dos alertas, você pode estender o `AlertService` e sobrescrever o método `generateComponentPortal()`. Este método deve retornar o seu componente customizado, que **DEVE** estender o `BaseAlert`.
188
+
189
+ **Exemplo:**
190
+
191
+ 1. **Crie seu componente de alerta customizado** (ex: `CustomAlertComponent`):
192
+
193
+ ```typescript
194
+ // custom-alert.component.ts
195
+ import { Component } from '@angular/core';
196
+ import { BaseAlert } from 'ngx-opalbytes-components';
197
+
198
+ @Component({
199
+ selector: 'app-custom-alert',
200
+ template: `
201
+ <div class="custom-alert-container" [ngClass]="data.type">
202
+ <img *ngIf="data.alertIcon" [src]="data.alertIcon" alt="Alert Icon" class="alert-icon">
203
+ <div class="content">
204
+ <h3 class="title">{{ data.title }}</h3>
205
+ <p class="message">{{ data.message }}</p>
206
+ </div>
207
+ </div>
208
+ `,
209
+ styles: [`
210
+ .custom-alert-container {
211
+ /* seus estilos personalizados */
212
+ }
213
+ `]
214
+ })
215
+ export class CustomAlertComponent extends BaseAlert {
216
+ // Você pode adicionar lógica específica aqui se precisar
217
+ }
218
+ ```
219
+
220
+ 2. **Crie um serviço que estende o `AlertService`**:
221
+
222
+ ```typescript
223
+ // custom-alert.service.ts
224
+ import { Injectable } from '@angular/core';
225
+ import { AlertService } from 'ngx-opalbytes-components';
226
+ import { CustomAlertComponent } from './custom-alert.component'; // Importe seu componente customizado
227
+
228
+ @Injectable({
229
+ providedIn: 'root'
230
+ })
231
+ export class CustomAlertService extends AlertService {
232
+ override generateComponentPortal(): typeof CustomAlertComponent {
233
+ return CustomAlertComponent;
234
+ }
235
+ }
236
+ ```
237
+
238
+ 3. **No seu `app.module.ts` ou onde seu serviço é provido, use o `CustomAlertService`**:
239
+
240
+ ```typescript
241
+ // app.module.ts ou o módulo onde você quer usar o serviço customizado
242
+ import { NgModule } from '@angular/core';
243
+ import { AlertService } from 'ngx-opalbytes-components'; // Importe o serviço original
244
+ import { CustomAlertService } from './custom-alert.service'; // Importe seu serviço customizado
245
+
246
+ @NgModule({
247
+ providers: [
248
+ { provide: AlertService, useClass: CustomAlertService } // Prover seu serviço customizado no lugar do original
249
+ ]
250
+ })
251
+ export class AppModule { }
252
+ ```
253
+ Dessa forma, toda vez que você injetar e usar o `AlertService` em sua aplicação, na verdade estará utilizando o `CustomAlertService` que exibirá seu `CustomAlertComponent` personalizado.
254
+
255
+ ---
256
+
182
257
  ### `BaseDialog`
183
258
  Exibe uma caixa de diálogo modal para interações que exigem confirmação do usuário.
184
259
 
@@ -1277,7 +1277,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
1277
1277
  }]
1278
1278
  }] });
1279
1279
 
1280
- class TableService {
1280
+ class BaseTableService {
1281
1281
  tableConfigSubject = new BehaviorSubject(null);
1282
1282
  dataSubject = new BehaviorSubject([]);
1283
1283
  columnsSubject = new BehaviorSubject([]);
@@ -1388,10 +1388,10 @@ class TableService {
1388
1388
  updateTableData(data) {
1389
1389
  this.setData(data);
1390
1390
  }
1391
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TableService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1392
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TableService, providedIn: "root" });
1391
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseTableService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1392
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseTableService, providedIn: "root" });
1393
1393
  }
1394
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TableService, decorators: [{
1394
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseTableService, decorators: [{
1395
1395
  type: Injectable,
1396
1396
  args: [{
1397
1397
  providedIn: "root",
@@ -1445,7 +1445,7 @@ class BaseTable {
1445
1445
  getAllColumns() {
1446
1446
  return ["select", ...this.displayedColumns];
1447
1447
  }
1448
- tableService = inject(TableService);
1448
+ tableService = inject(BaseTableService);
1449
1449
  liveAnnouncer = inject(LiveAnnouncer);
1450
1450
  filterTableService = inject(BaseFilterTableService);
1451
1451
  constructor() {
@@ -1714,23 +1714,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
1714
1714
  args: [MatPaginator]
1715
1715
  }] } });
1716
1716
 
1717
- class FilterTablePaginatedService {
1717
+ class BaseFilterTablePaginatedService {
1718
1718
  filterSubject = new Subject();
1719
1719
  filter$ = this.filterSubject.asObservable();
1720
1720
  updateFilter(filterValue) {
1721
1721
  this.filterSubject.next(filterValue);
1722
1722
  }
1723
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FilterTablePaginatedService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1724
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FilterTablePaginatedService, providedIn: "root" });
1723
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseFilterTablePaginatedService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1724
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseFilterTablePaginatedService, providedIn: "root" });
1725
1725
  }
1726
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FilterTablePaginatedService, decorators: [{
1726
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseFilterTablePaginatedService, decorators: [{
1727
1727
  type: Injectable,
1728
1728
  args: [{
1729
1729
  providedIn: "root",
1730
1730
  }]
1731
1731
  }] });
1732
1732
 
1733
- class PaginationService {
1733
+ class BasePaginationService {
1734
1734
  pageSubject = new BehaviorSubject(1);
1735
1735
  pageSizeSubject = new BehaviorSubject(10);
1736
1736
  totalItemsSubject = new BehaviorSubject(0);
@@ -1791,10 +1791,10 @@ class PaginationService {
1791
1791
  this.pageSizeSubject.next(10);
1792
1792
  this.totalItemsSubject.next(0);
1793
1793
  }
1794
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: PaginationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1795
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: PaginationService, providedIn: "root" });
1794
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BasePaginationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1795
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BasePaginationService, providedIn: "root" });
1796
1796
  }
1797
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: PaginationService, decorators: [{
1797
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BasePaginationService, decorators: [{
1798
1798
  type: Injectable,
1799
1799
  args: [{
1800
1800
  providedIn: "root",
@@ -1968,10 +1968,10 @@ class BaseTablePaginated {
1968
1968
  pageSize = 10;
1969
1969
  currentPage = 1;
1970
1970
  previousPage = 1;
1971
- paginationService = inject(PaginationService);
1971
+ paginationService = inject(BasePaginationService);
1972
1972
  tableService = inject(TablePaginatedService);
1973
1973
  liveAnnouncer = inject(LiveAnnouncer);
1974
- filterTableService = inject(FilterTablePaginatedService);
1974
+ filterTableService = inject(BaseFilterTablePaginatedService);
1975
1975
  constructor() {
1976
1976
  this.initializeSortingAccessor();
1977
1977
  this.initializeFilterPredicate();
@@ -2179,6 +2179,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
2179
2179
  args: [MatPaginator]
2180
2180
  }] } });
2181
2181
 
2182
+ class BaseAlert {
2183
+ data;
2184
+ iconPath;
2185
+ titleClass;
2186
+ iconPaths = {
2187
+ success: "https://placehold.co/600x400",
2188
+ error: "https://placehold.co/600x400",
2189
+ info: "https://placehold.co/600x400",
2190
+ warning: "https://placehold.co/600x400",
2191
+ };
2192
+ ngOnInit() {
2193
+ this.iconPath = this.iconPaths[this.data.type];
2194
+ this.titleClass = `title-${this.data.type}`;
2195
+ }
2196
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseAlert, deps: [], target: i0.ɵɵFactoryTarget.Component });
2197
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.6", type: BaseAlert, isStandalone: true, selector: "cao-base-alert", ngImport: i0, template: "<div class=\"dialog-container\">\n <div class=\"dialog-content\">\n <img alt=\"Logo\" class=\"logo\" [ngSrc]=\"data.alertIcon ?? ''\" [fill]=\"true\" />\n <div class=\"alert-wrapper\">\n <div class=\"text-content\">\n @if (data.title) {\n <div class=\"title\" [ngClass]=\"titleClass\">{{ data.title }}</div>\n } @if (data.title && data.message) {\n <div class=\"message-spacer\"></div>\n } @if (data.message) {\n <div class=\"message\">{{ data.message }}</div>\n }\n </div>\n <div class=\"icon-container\">\n <img alt=\"Alert Icon\" class=\"alert-icon\" [ngSrc]=\"iconPath\" [fill]=\"true\" />\n </div>\n </div>\n </div>\n</div>\n", styles: [":host{position:fixed;top:10%;left:55%;transform:translate(-50%);z-index:1000;display:block;animation:slide-in .3s ease-out}@keyframes slide-in{0%{opacity:0;transform:translate(-50%,-20px)}to{opacity:1;transform:translate(-50%)}}.dialog-container{width:600px;border-radius:30px;overflow:hidden;box-shadow:0 4px 6px #0000001a;background-color:var(--white)}.dialog-content{padding:20px 30px;box-sizing:border-box}.logo{width:150px;height:24px;margin-bottom:15px}.alert-wrapper{display:flex;align-items:center;justify-content:space-between}.text-content{flex-grow:1;margin:20px;padding-right:20px}.title{font-family:Lato,sans-serif;font-weight:700;font-size:24px;color:var(--primary);margin-bottom:5px}.title.success{color:var(--primary)}.title.error{color:var(--error-color)}.title.warning{color:var(--support-orange)}.title.info,.title.title-success{color:var(--primary)}.title.title-error{color:var(--error)}.title.title-warning{color:var(--support-orange)}.title.title-info{color:var(--primary)}.message-spacer{height:16px}.message{font-family:Lato,sans-serif;font-weight:400;font-size:26px;line-height:100%;color:var(--message-color)}.icon-container{width:150px;height:150px;flex-shrink:0}.alert-icon{width:100%;height:100%;object-fit:contain}@media(max-width:768px){:host{left:55%;max-width:95%}.dialog-container{max-width:90%;width:400px}.alert-wrapper{flex-direction:column;text-align:center}.text-content{padding-right:0;margin-bottom:10px}.icon-container{width:100px;height:100px}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgOptimizedImage, selector: "img[ngSrc]", inputs: ["ngSrc", "ngSrcset", "sizes", "width", "height", "decoding", "loading", "priority", "loaderParams", "disableOptimizedSrcset", "fill", "placeholder", "placeholderConfig", "src", "srcset"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2198
+ }
2199
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseAlert, decorators: [{
2200
+ type: Component,
2201
+ args: [{ selector: 'cao-base-alert', imports: [CommonModule, NgOptimizedImage], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"dialog-container\">\n <div class=\"dialog-content\">\n <img alt=\"Logo\" class=\"logo\" [ngSrc]=\"data.alertIcon ?? ''\" [fill]=\"true\" />\n <div class=\"alert-wrapper\">\n <div class=\"text-content\">\n @if (data.title) {\n <div class=\"title\" [ngClass]=\"titleClass\">{{ data.title }}</div>\n } @if (data.title && data.message) {\n <div class=\"message-spacer\"></div>\n } @if (data.message) {\n <div class=\"message\">{{ data.message }}</div>\n }\n </div>\n <div class=\"icon-container\">\n <img alt=\"Alert Icon\" class=\"alert-icon\" [ngSrc]=\"iconPath\" [fill]=\"true\" />\n </div>\n </div>\n </div>\n</div>\n", styles: [":host{position:fixed;top:10%;left:55%;transform:translate(-50%);z-index:1000;display:block;animation:slide-in .3s ease-out}@keyframes slide-in{0%{opacity:0;transform:translate(-50%,-20px)}to{opacity:1;transform:translate(-50%)}}.dialog-container{width:600px;border-radius:30px;overflow:hidden;box-shadow:0 4px 6px #0000001a;background-color:var(--white)}.dialog-content{padding:20px 30px;box-sizing:border-box}.logo{width:150px;height:24px;margin-bottom:15px}.alert-wrapper{display:flex;align-items:center;justify-content:space-between}.text-content{flex-grow:1;margin:20px;padding-right:20px}.title{font-family:Lato,sans-serif;font-weight:700;font-size:24px;color:var(--primary);margin-bottom:5px}.title.success{color:var(--primary)}.title.error{color:var(--error-color)}.title.warning{color:var(--support-orange)}.title.info,.title.title-success{color:var(--primary)}.title.title-error{color:var(--error)}.title.title-warning{color:var(--support-orange)}.title.title-info{color:var(--primary)}.message-spacer{height:16px}.message{font-family:Lato,sans-serif;font-weight:400;font-size:26px;line-height:100%;color:var(--message-color)}.icon-container{width:150px;height:150px;flex-shrink:0}.alert-icon{width:100%;height:100%;object-fit:contain}@media(max-width:768px){:host{left:55%;max-width:95%}.dialog-container{max-width:90%;width:400px}.alert-wrapper{flex-direction:column;text-align:center}.text-content{padding-right:0;margin-bottom:10px}.icon-container{width:100px;height:100px}}\n"] }]
2202
+ }] });
2203
+
2204
+ class BaseAlertService {
2205
+ overlay;
2206
+ constructor(overlay) {
2207
+ this.overlay = overlay;
2208
+ }
2209
+ defaultTime = 3000;
2210
+ show(config) {
2211
+ const overlayRef = this.overlay.create({
2212
+ hasBackdrop: false,
2213
+ positionStrategy: this.overlay.position().global().centerHorizontally().top("10%"),
2214
+ scrollStrategy: this.overlay.scrollStrategies.block(),
2215
+ });
2216
+ const alertPortal = new ComponentPortal(this.generateComponentPortal());
2217
+ const componentRef = overlayRef.attach(alertPortal);
2218
+ componentRef.instance.data = config;
2219
+ setTimeout(() => {
2220
+ overlayRef.dispose();
2221
+ }, this.defaultTime);
2222
+ }
2223
+ generateComponentPortal() {
2224
+ return BaseAlert;
2225
+ }
2226
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseAlertService, deps: [{ token: i1$4.Overlay }], target: i0.ɵɵFactoryTarget.Injectable });
2227
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseAlertService, providedIn: "root" });
2228
+ }
2229
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: BaseAlertService, decorators: [{
2230
+ type: Injectable,
2231
+ args: [{
2232
+ providedIn: "root",
2233
+ }]
2234
+ }], ctorParameters: () => [{ type: i1$4.Overlay }] });
2235
+
2182
2236
  /*
2183
2237
  * Public API Surface of ngx-opalbytes-components
2184
2238
  */
@@ -2187,5 +2241,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
2187
2241
  * Generated bundle index. Do not edit.
2188
2242
  */
2189
2243
 
2190
- export { BaseButton, BaseDialog, BaseDialogService, BaseFilterTableService, BaseInput, BaseModal, BaseModalService, BaseTable, BaseTablePaginated, BaseTimeRange, DropDownComponent, FilterTablePaginatedService, Footer, LinksButton, PaginationService, Paginator, RnvAutocompleteComponent, TablePaginatedService, TableService, TimePicker, getPtBrPaginatorIntlBasePaginated, getPtBrPaginatorIntlBaseTable };
2244
+ export { BaseAlert, BaseAlertService, BaseButton, BaseDialog, BaseDialogService, BaseFilterTablePaginatedService, BaseFilterTableService, BaseInput, BaseModal, BaseModalService, BasePaginationService, BaseTable, BaseTablePaginated, BaseTableService, BaseTimeRange, DropDownComponent, Footer, LinksButton, Paginator, RnvAutocompleteComponent, TablePaginatedService, TimePicker, getPtBrPaginatorIntlBasePaginated, getPtBrPaginatorIntlBaseTable };
2191
2245
  //# sourceMappingURL=ngx-opalbytes-components.mjs.map