@pumpkin-tech/pumpkin-tech-ng 0.1.6 → 0.1.7

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.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { HostBinding, Input, Directive, Injectable, NgModule, EventEmitter, ElementRef, forwardRef, Output, ContentChild, ViewChild, ChangeDetectionStrategy, Component, HostListener, Inject, InjectionToken, Optional, Pipe, inject } from '@angular/core';
3
3
  import * as i1 from '@angular/cdk/layout';
4
- import * as i2$4 from 'rxjs';
4
+ import * as i2$5 from 'rxjs';
5
5
  import { Subject, BehaviorSubject, delay, tap, map, filter, of } from 'rxjs';
6
6
  import { takeUntil, filter as filter$1, switchMap } from 'rxjs/operators';
7
7
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
@@ -25,7 +25,9 @@ import * as i3 from '@angular/material/form-field';
25
25
  import { MatFormFieldModule } from '@angular/material/form-field';
26
26
  import * as i4 from '@angular/material/input';
27
27
  import { MatInputModule } from '@angular/material/input';
28
+ import * as i2$4 from '@angular/material/table';
28
29
  import { MatTableModule } from '@angular/material/table';
30
+ import * as i3$5 from '@angular/material/paginator';
29
31
  import { MatPaginatorIntl, MatPaginatorModule } from '@angular/material/paginator';
30
32
  import { MatSortModule } from '@angular/material/sort';
31
33
  import * as i3$1 from '@angular/material/icon';
@@ -62,6 +64,7 @@ import * as i2$3 from '@angular/platform-browser';
62
64
  import * as i6$3 from 'ngx-material-timepicker';
63
65
  import { NgxMaterialTimepickerModule } from 'ngx-material-timepicker';
64
66
  import { NgxCurrencyDirective } from 'ngx-currency';
67
+ import { SelectionModel } from '@angular/cdk/collections';
65
68
  import { faker } from '@faker-js/faker';
66
69
 
67
70
  const MEDIA$1 = {
@@ -3276,6 +3279,7 @@ class SelectEnumComponent extends BaseField {
3276
3279
  enum = {};
3277
3280
  disabledOptions = [];
3278
3281
  sort = () => 0;
3282
+ labelMap = {};
3279
3283
  selectionChange = new EventEmitter();
3280
3284
  enumList = [];
3281
3285
  _val;
@@ -3302,7 +3306,7 @@ class SelectEnumComponent extends BaseField {
3302
3306
  registerOnChange(fn) { this.onChange = fn; }
3303
3307
  registerOnTouched(fn) { this.onTouch = fn; }
3304
3308
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SelectEnumComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
3305
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: SelectEnumComponent, isStandalone: true, selector: "ptech-select-enum", inputs: { multiple: "multiple", enum: "enum", disabledOptions: "disabledOptions", sort: "sort" }, outputs: { selectionChange: "selectionChange" }, providers: [
3309
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: SelectEnumComponent, isStandalone: true, selector: "ptech-select-enum", inputs: { multiple: "multiple", enum: "enum", disabledOptions: "disabledOptions", sort: "sort", labelMap: "labelMap" }, outputs: { selectionChange: "selectionChange" }, providers: [
3306
3310
  {
3307
3311
  provide: NG_VALUE_ACCESSOR,
3308
3312
  useExisting: forwardRef(() => SelectEnumComponent),
@@ -3332,7 +3336,7 @@ class SelectEnumComponent extends BaseField {
3332
3336
  *ngFor="let e of enumList"
3333
3337
  [value]="e.key"
3334
3338
  [disabled]="disabledOptions?.includes(e.key)">
3335
- {{ e.value }}
3339
+ {{ labelMap[e.key] || e.value }}
3336
3340
  <span *ngIf="disabledOptions?.includes(e.key)">
3337
3341
  (indisponível)
3338
3342
  </span>
@@ -3381,7 +3385,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
3381
3385
  *ngFor="let e of enumList"
3382
3386
  [value]="e.key"
3383
3387
  [disabled]="disabledOptions?.includes(e.key)">
3384
- {{ e.value }}
3388
+ {{ labelMap[e.key] || e.value }}
3385
3389
  <span *ngIf="disabledOptions?.includes(e.key)">
3386
3390
  (indisponível)
3387
3391
  </span>
@@ -3405,6 +3409,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
3405
3409
  type: Input
3406
3410
  }], sort: [{
3407
3411
  type: Input
3412
+ }], labelMap: [{
3413
+ type: Input
3408
3414
  }], selectionChange: [{
3409
3415
  type: Output
3410
3416
  }] } });
@@ -4970,6 +4976,672 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
4970
4976
  args: ['style.grid-column']
4971
4977
  }] } });
4972
4978
 
4979
+ class TableComponent {
4980
+ title = '';
4981
+ loading = false;
4982
+ data = [];
4983
+ total = 0;
4984
+ pageIndex = 0; // zero-based
4985
+ pageSize = 10;
4986
+ pageSizeOptions = [5, 10, 20, 50];
4987
+ columns = [];
4988
+ actions = [];
4989
+ // seleção de linhas
4990
+ selectRow = false;
4991
+ selectMultipleRow = false;
4992
+ getRowId = (row) => row?._id ?? row?.id; // fallback
4993
+ /** imagem de fallback para <img> quebrada ou ausente */
4994
+ imageFallback = 'assets/images/placeholder-poster.svg';
4995
+ /** ativa visualização em cards no mobile */
4996
+ responsiveCards = false;
4997
+ selectedRows = new EventEmitter();
4998
+ selectedIds = new EventEmitter();
4999
+ page = new EventEmitter();
5000
+ displayedColumns = [];
5001
+ selection = new SelectionModel(this.selectMultipleRow, []);
5002
+ selectedIdSet = new Set();
5003
+ ngOnChanges(changes) {
5004
+ // colunas
5005
+ const cols = [...this.columns.map(c => c.key)];
5006
+ if (this.selectRow)
5007
+ cols.unshift('select');
5008
+ if (this.actions?.length)
5009
+ cols.push('__actions');
5010
+ this.displayedColumns = cols;
5011
+ // ressincroniza selection da página
5012
+ this.selection = new SelectionModel(this.selectMultipleRow, []);
5013
+ for (const row of this.data || []) {
5014
+ const id = this.getRowId(row);
5015
+ if (this.selectedIdSet.has(id)) {
5016
+ this.selection.select(row);
5017
+ }
5018
+ }
5019
+ // emite estado consolidado
5020
+ this.emitSelected();
5021
+ }
5022
+ // selecionar/deselecionar todos da PÁGINA atual
5023
+ toggleAllRows() {
5024
+ const pageAllSelected = (this.data || []).every(r => this.selectedIdSet.has(this.getRowId(r)));
5025
+ if (pageAllSelected) {
5026
+ for (const r of this.data || [])
5027
+ this.selectedIdSet.delete(this.getRowId(r));
5028
+ this.selection.clear();
5029
+ }
5030
+ else {
5031
+ for (const r of this.data || []) {
5032
+ const id = this.getRowId(r);
5033
+ if (!this.selectedIdSet.has(id)) {
5034
+ this.selectedIdSet.add(id);
5035
+ this.selection.select(r);
5036
+ }
5037
+ }
5038
+ }
5039
+ this.emitSelected();
5040
+ }
5041
+ /** Verifica se todas estão selecionadas */
5042
+ isAllSelected() {
5043
+ // “todos da página atual”
5044
+ return !!this.data?.length && (this.data || []).every(r => this.selectedIdSet.has(this.getRowId(r)));
5045
+ }
5046
+ // opcional: API para limpar seleção externamente
5047
+ clearSelection() {
5048
+ this.selectedIdSet.clear();
5049
+ this.selection.clear();
5050
+ this.emitSelected();
5051
+ }
5052
+ /** Marca/desmarca uma linha */
5053
+ toggleRow(row) {
5054
+ const id = this.getRowId(row);
5055
+ if (this.selectedIdSet.has(id)) {
5056
+ this.selectedIdSet.delete(id);
5057
+ this.selection.deselect(row);
5058
+ }
5059
+ else {
5060
+ if (!this.selectMultipleRow) {
5061
+ // modo single: limpa tudo antes
5062
+ this.selectedIdSet.clear();
5063
+ this.selection.clear();
5064
+ }
5065
+ this.selectedIdSet.add(id);
5066
+ this.selection.select(row);
5067
+ }
5068
+ this.emitSelected();
5069
+ }
5070
+ /** Emite o estado atual */
5071
+ emitSelected() {
5072
+ const selectedRows = [];
5073
+ const selectedIds = Array.from(this.selectedIdSet);
5074
+ // tenta reconstruir as linhas selecionadas (apenas as presentes na página atual)
5075
+ for (const row of this.data || []) {
5076
+ const id = this.getRowId(row);
5077
+ if (this.selectedIdSet.has(id))
5078
+ selectedRows.push(row);
5079
+ }
5080
+ this.selectedRows.emit(selectedRows);
5081
+ this.selectedIds.emit(selectedIds);
5082
+ }
5083
+ /** Verifica se uma linha está selecionada */
5084
+ isSelected(row) {
5085
+ return this.selectedIdSet.has(this.getRowId(row));
5086
+ }
5087
+ onPage(ev) {
5088
+ this.page.emit({ pageIndex: ev.pageIndex, pageSize: ev.pageSize });
5089
+ }
5090
+ renderCell(row, col) {
5091
+ if (col?.cell)
5092
+ return col.cell(row);
5093
+ const v = this.read(row, col.key);
5094
+ if (col.type === 'date' && v)
5095
+ return new Date(v);
5096
+ return v ?? '—';
5097
+ }
5098
+ resolveImage(row, col) {
5099
+ const key = (col.imageKey || col.key);
5100
+ const url = this.read(row, key);
5101
+ return typeof url === 'string' && url.length > 0 ? url : null;
5102
+ }
5103
+ resolveAlt(row, col) {
5104
+ const key = (col.altKey || 'title');
5105
+ const v = this.read(row, key);
5106
+ return typeof v === 'string' ? v : null;
5107
+ }
5108
+ read(obj, path) {
5109
+ if (!obj || !path)
5110
+ return null;
5111
+ if (!path.includes('.'))
5112
+ return obj[path];
5113
+ return path.split('.').reduce((acc, k) => (acc ? acc[k] : undefined), obj);
5114
+ }
5115
+ onImgError(ev) {
5116
+ const img = ev.target;
5117
+ img.src = this.imageFallback;
5118
+ }
5119
+ /** BADGES: resolve a lista de badges para a linha+coluna */
5120
+ getBadges(row, col) {
5121
+ if (!col.badges)
5122
+ return [];
5123
+ const cfg = typeof col.badges === 'function' ? col.badges(row) : col.badges;
5124
+ if (!Array.isArray(cfg))
5125
+ return [];
5126
+ return cfg
5127
+ .filter(b => !b.visible || b.visible(row))
5128
+ .map(b => {
5129
+ const label = typeof b.label === 'function' ? b.label(row) : b.label;
5130
+ const rawColor = typeof b.color === 'function' ? b.color(row) : b.color;
5131
+ const color = rawColor ?? 'neutral';
5132
+ const rawVariant = typeof b.variant === 'function' ? b.variant(row) : b.variant;
5133
+ const variant = rawVariant ?? 'filled';
5134
+ const rawSize = typeof b.size === 'function' ? b.size(row) : b.size;
5135
+ const size = rawSize ?? 'md';
5136
+ return { label, color, variant, size };
5137
+ });
5138
+ }
5139
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
5140
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: TableComponent, isStandalone: true, selector: "ptech-table", inputs: { title: "title", loading: "loading", data: "data", total: "total", pageIndex: "pageIndex", pageSize: "pageSize", pageSizeOptions: "pageSizeOptions", columns: "columns", actions: "actions", selectRow: "selectRow", selectMultipleRow: "selectMultipleRow", getRowId: "getRowId", imageFallback: "imageFallback", responsiveCards: "responsiveCards" }, outputs: { selectedRows: "selectedRows", selectedIds: "selectedIds", page: "page" }, usesOnChanges: true, ngImport: i0, template: `
5141
+ <div class="table-container mat-elevation-z8">
5142
+ <div class="header-row" *ngIf="title">
5143
+ <h3>{{ title }}</h3>
5144
+ </div>
5145
+
5146
+ <ng-container *ngIf="!loading; else loadingTpl">
5147
+ <!-- TABELA (desktop / tablet ou mobile sem cards) -->
5148
+ <div class="table-scroll" [class.hide-on-mobile]="responsiveCards">
5149
+ <table mat-table [dataSource]="data">
5150
+ <!-- SELEÇÃO (checkbox ou radio) -->
5151
+ <ng-container *ngIf="selectRow" matColumnDef="select">
5152
+ <th mat-header-cell *matHeaderCellDef style="text-align: center">
5153
+ <mat-checkbox
5154
+ *ngIf="selectMultipleRow"
5155
+ (change)="toggleAllRows()"
5156
+ [checked]="isAllSelected()"
5157
+ [indeterminate]="selection.hasValue() && !isAllSelected()"
5158
+ aria-label="Selecionar todas"
5159
+ ></mat-checkbox>
5160
+ </th>
5161
+ <td mat-cell *matCellDef="let row" style="text-align: center">
5162
+ <mat-checkbox
5163
+ *ngIf="selectMultipleRow"
5164
+ [checked]="isSelected(row)"
5165
+ (change)="toggleRow(row)"
5166
+ aria-label="Selecionar linha"
5167
+ ></mat-checkbox>
5168
+
5169
+ <mat-radio-button
5170
+ *ngIf="!selectMultipleRow"
5171
+ [checked]="isSelected(row)"
5172
+ (change)="toggleRow(row)"
5173
+ aria-label="Selecionar linha"
5174
+ ></mat-radio-button>
5175
+ </td>
5176
+ </ng-container>
5177
+
5178
+ <ng-container *ngFor="let c of columns" [matColumnDef]="c.key">
5179
+ <th
5180
+ mat-header-cell
5181
+ *matHeaderCellDef
5182
+ [style.text-align]="c.align || 'left'"
5183
+ >
5184
+ {{ c.header }}
5185
+ </th>
5186
+ <td
5187
+ mat-cell
5188
+ *matCellDef="let row"
5189
+ [style.text-align]="c.align || 'left'"
5190
+ >
5191
+ <ng-container [ngSwitch]="c.type || 'text'">
5192
+ <!-- IMAGEM -->
5193
+ <ng-container *ngSwitchCase="'image'">
5194
+ <img
5195
+ class="td-thumb"
5196
+ [src]="resolveImage(row, c) || imageFallback"
5197
+ [alt]="resolveAlt(row, c) || ''"
5198
+ [style.width]="c.width || '40px'"
5199
+ [style.height]="c.width || '40px'"
5200
+ style="object-fit: cover; border-radius: 6px"
5201
+ (error)="onImgError($event)"
5202
+ />
5203
+ </ng-container>
5204
+
5205
+ <!-- DATE -->
5206
+ <ng-container *ngSwitchCase="'date'">
5207
+ {{ renderCell(row, c) | date : "dd/MM/yyyy HH:mm" }}
5208
+ </ng-container>
5209
+
5210
+ <!-- BADGE -->
5211
+ <ng-container *ngSwitchCase="'badge'">
5212
+ <ptech-badge-stack>
5213
+ <ng-container *ngFor="let b of getBadges(row, c)">
5214
+ <ptech-badge
5215
+ [label]="b.label"
5216
+ [color]="b.color"
5217
+ [variant]="b.variant"
5218
+ [size]="b.size"
5219
+ ></ptech-badge>
5220
+ </ng-container>
5221
+ </ptech-badge-stack>
5222
+ </ng-container>
5223
+
5224
+ <!-- DEFAULT (text/number) -->
5225
+ <ng-container *ngSwitchDefault>
5226
+ {{ renderCell(row, c) }}
5227
+ </ng-container>
5228
+ </ng-container>
5229
+ </td>
5230
+ </ng-container>
5231
+
5232
+ <ng-container *ngIf="actions.length" matColumnDef="__actions">
5233
+ <th mat-header-cell *matHeaderCellDef style="text-align: center">
5234
+ Ações
5235
+ </th>
5236
+ <td mat-cell *matCellDef="let r" style="text-align: center">
5237
+ <ng-container *ngFor="let a of actions">
5238
+ <ptech-button
5239
+ *ngIf="!a.visible || a.visible(r)"
5240
+ icon="{{ a.icon }}"
5241
+ type="icon"
5242
+ iconColor="{{ a.color }}"
5243
+ tooltip="{{ a.tooltip || '' }}"
5244
+ (click)="a.handler(r)"
5245
+ >
5246
+ </ptech-button>
5247
+ </ng-container>
5248
+ </td>
5249
+ </ng-container>
5250
+
5251
+ <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
5252
+ <tr
5253
+ mat-row
5254
+ *matRowDef="let row; columns: displayedColumns"
5255
+ [class.selected]="isSelected(row)"
5256
+ ></tr>
5257
+ </table>
5258
+ </div>
5259
+
5260
+ <!-- CARDS (mobile) -->
5261
+ <div
5262
+ *ngIf="responsiveCards"
5263
+ class="cards-container hide-on-desktop"
5264
+ >
5265
+ <div
5266
+ *ngFor="let row of data"
5267
+ class="card mat-elevation-z8"
5268
+ [class.selected]="isSelected(row)"
5269
+ >
5270
+ <!-- seleção no card -->
5271
+ <div *ngIf="selectRow" class="card-select">
5272
+ <mat-checkbox
5273
+ *ngIf="selectMultipleRow"
5274
+ [checked]="isSelected(row)"
5275
+ (change)="toggleRow(row)"
5276
+ aria-label="Selecionar card"
5277
+ ></mat-checkbox>
5278
+
5279
+ <mat-radio-button
5280
+ *ngIf="!selectMultipleRow"
5281
+ [checked]="isSelected(row)"
5282
+ (change)="toggleRow(row)"
5283
+ aria-label="Selecionar card"
5284
+ ></mat-radio-button>
5285
+ </div>
5286
+
5287
+ <div
5288
+ *ngFor="let c of columns"
5289
+ class="card-row"
5290
+ [ngSwitch]="c.type || 'text'"
5291
+ >
5292
+ <!-- IMAGEM -->
5293
+ <ng-container *ngSwitchCase="'image'">
5294
+ <img
5295
+ class="td-thumb"
5296
+ [src]="resolveImage(row, c) || imageFallback"
5297
+ [alt]="resolveAlt(row, c) || ''"
5298
+ style="width: 64px; height: 64px; object-fit: cover; border-radius: 6px"
5299
+ (error)="onImgError($event)"
5300
+ />
5301
+ </ng-container>
5302
+
5303
+ <!-- BADGE -->
5304
+ <ng-container *ngSwitchCase="'badge'">
5305
+ <div><strong>{{ c.header }}:</strong></div>
5306
+ <ptech-badge-stack>
5307
+ <ng-container *ngFor="let b of getBadges(row, c)">
5308
+ <ptech-badge
5309
+ [label]="b.label"
5310
+ [color]="b.color"
5311
+ [variant]="b.variant"
5312
+ [size]="b.size"
5313
+ ></ptech-badge>
5314
+ </ng-container>
5315
+ </ptech-badge-stack>
5316
+ </ng-container>
5317
+
5318
+ <!-- DATE -->
5319
+ <ng-container *ngSwitchCase="'date'">
5320
+ <div>
5321
+ <strong>{{ c.header }}:</strong>
5322
+ {{ renderCell(row, c) | date : "dd/MM/yyyy HH:mm" }}
5323
+ </div>
5324
+ </ng-container>
5325
+
5326
+ <!-- DEFAULT -->
5327
+ <ng-container *ngSwitchDefault>
5328
+ <div>
5329
+ <strong>{{ c.header }}:</strong>
5330
+ {{ renderCell(row, c) }}
5331
+ </div>
5332
+ </ng-container>
5333
+ </div>
5334
+
5335
+ <!-- AÇÕES -->
5336
+ <div *ngIf="actions?.length" class="card-actions">
5337
+ <ng-container *ngFor="let a of actions">
5338
+ <ptech-button
5339
+ *ngIf="!a.visible || a.visible(row)"
5340
+ icon="{{ a.icon }}"
5341
+ type="icon"
5342
+ iconColor="{{ a.color }}"
5343
+ tooltip="{{ a.tooltip || '' }}"
5344
+ (click)="a.handler(row)"
5345
+ >
5346
+ </ptech-button>
5347
+ </ng-container>
5348
+ </div>
5349
+ </div>
5350
+ </div>
5351
+
5352
+ <mat-paginator
5353
+ class="mat-paginator"
5354
+ [length]="total"
5355
+ [pageIndex]="pageIndex"
5356
+ [pageSize]="pageSize"
5357
+ [pageSizeOptions]="pageSizeOptions"
5358
+ showFirstLastButtons
5359
+ (page)="onPage($event)"
5360
+ >
5361
+ </mat-paginator>
5362
+
5363
+ <div *ngIf="!data?.length" class="muted" style="padding: 12px">
5364
+ Sem dados.
5365
+ </div>
5366
+ </ng-container>
5367
+
5368
+ <ng-template #loadingTpl>
5369
+ <mat-progress-bar mode="indeterminate"></mat-progress-bar>
5370
+ </ng-template>
5371
+ </div>
5372
+ `, isInline: true, styles: [":host{display:block;max-width:100%;overflow-x:hidden}.table-container{margin:20px!important;max-width:100%}.table-scroll{width:100%;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}.table-scroll table{width:max-content;min-width:100%;border-collapse:collapse;table-layout:auto}.td-thumb{box-shadow:0 1px 2px #00000026;background:#f4f6fa}tr.selected{background-color:#2196f314}.mat-column-select{width:56px;text-align:center}.mat-column-__actions{text-align:center;width:120px}.hide-on-mobile{display:block}.hide-on-desktop{display:none}@media (max-width: 768px){.table-container{margin:8px}.hide-on-mobile{display:none}.hide-on-desktop{display:block}.cards-container{display:flex;flex-direction:column;gap:12px;margin:8px}.card{padding:12px;border-radius:8px;background:#fff;border:1px solid transparent;transition:border-color .15s ease,box-shadow .15s ease,background-color .15s ease}.card.selected{border-color:#1976d2;background-color:#f3f7ff;box-shadow:0 0 0 1px #1976d226}.card-select{display:flex;justify-content:flex-end;margin-bottom:8px}.card-row{margin-bottom:4px;font-size:14px}.card-row strong{font-weight:600}.card-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:8px}}\n"], dependencies: [{ kind: "ngmodule", type: CoreMaterialModule }, { kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1$1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1$1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: i2$4.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i2$4.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i2$4.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i2$4.MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: i2$4.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i2$4.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i2$4.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i2$4.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i2$4.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i2$4.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "component", type: i3$5.MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }, { kind: "component", type: i1$2.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: i3$3.MatRadioButton, selector: "mat-radio-button", inputs: ["id", "name", "aria-label", "aria-labelledby", "aria-describedby", "disableRipple", "tabIndex", "checked", "value", "labelPosition", "disabled", "required", "color", "disabledInteractive"], outputs: ["change"], exportAs: ["matRadioButton"] }, { kind: "component", type: i7$1.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "pipe", type: i1$1.DatePipe, name: "date" }, { kind: "component", type: BadgeComponent, selector: "ptech-badge", inputs: ["label", "icon", "tooltip", "ariaLabel", "clickable", "disabled", "pill", "uppercase", "size", "variant", "color", "col"], outputs: ["badgeClick", "badgeKey"] }, { kind: "component", type: BadgeStackComponent, selector: "ptech-badge-stack", inputs: ["direction", "gap", "wrap", "align", "justify", "ariaLabel", "col"] }, { kind: "component", type: ButtonComponent, selector: "ptech-button", inputs: ["type", "size", "tooltip", "icon", "iconColor", "iconWidth", "iconHeight", "textColor", "link", "target", "shape", "color"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
5373
+ }
5374
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TableComponent, decorators: [{
5375
+ type: Component,
5376
+ args: [{ selector: 'ptech-table', standalone: true, imports: [CoreMaterialModule, BadgeComponent, BadgeStackComponent, ButtonComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: `
5377
+ <div class="table-container mat-elevation-z8">
5378
+ <div class="header-row" *ngIf="title">
5379
+ <h3>{{ title }}</h3>
5380
+ </div>
5381
+
5382
+ <ng-container *ngIf="!loading; else loadingTpl">
5383
+ <!-- TABELA (desktop / tablet ou mobile sem cards) -->
5384
+ <div class="table-scroll" [class.hide-on-mobile]="responsiveCards">
5385
+ <table mat-table [dataSource]="data">
5386
+ <!-- SELEÇÃO (checkbox ou radio) -->
5387
+ <ng-container *ngIf="selectRow" matColumnDef="select">
5388
+ <th mat-header-cell *matHeaderCellDef style="text-align: center">
5389
+ <mat-checkbox
5390
+ *ngIf="selectMultipleRow"
5391
+ (change)="toggleAllRows()"
5392
+ [checked]="isAllSelected()"
5393
+ [indeterminate]="selection.hasValue() && !isAllSelected()"
5394
+ aria-label="Selecionar todas"
5395
+ ></mat-checkbox>
5396
+ </th>
5397
+ <td mat-cell *matCellDef="let row" style="text-align: center">
5398
+ <mat-checkbox
5399
+ *ngIf="selectMultipleRow"
5400
+ [checked]="isSelected(row)"
5401
+ (change)="toggleRow(row)"
5402
+ aria-label="Selecionar linha"
5403
+ ></mat-checkbox>
5404
+
5405
+ <mat-radio-button
5406
+ *ngIf="!selectMultipleRow"
5407
+ [checked]="isSelected(row)"
5408
+ (change)="toggleRow(row)"
5409
+ aria-label="Selecionar linha"
5410
+ ></mat-radio-button>
5411
+ </td>
5412
+ </ng-container>
5413
+
5414
+ <ng-container *ngFor="let c of columns" [matColumnDef]="c.key">
5415
+ <th
5416
+ mat-header-cell
5417
+ *matHeaderCellDef
5418
+ [style.text-align]="c.align || 'left'"
5419
+ >
5420
+ {{ c.header }}
5421
+ </th>
5422
+ <td
5423
+ mat-cell
5424
+ *matCellDef="let row"
5425
+ [style.text-align]="c.align || 'left'"
5426
+ >
5427
+ <ng-container [ngSwitch]="c.type || 'text'">
5428
+ <!-- IMAGEM -->
5429
+ <ng-container *ngSwitchCase="'image'">
5430
+ <img
5431
+ class="td-thumb"
5432
+ [src]="resolveImage(row, c) || imageFallback"
5433
+ [alt]="resolveAlt(row, c) || ''"
5434
+ [style.width]="c.width || '40px'"
5435
+ [style.height]="c.width || '40px'"
5436
+ style="object-fit: cover; border-radius: 6px"
5437
+ (error)="onImgError($event)"
5438
+ />
5439
+ </ng-container>
5440
+
5441
+ <!-- DATE -->
5442
+ <ng-container *ngSwitchCase="'date'">
5443
+ {{ renderCell(row, c) | date : "dd/MM/yyyy HH:mm" }}
5444
+ </ng-container>
5445
+
5446
+ <!-- BADGE -->
5447
+ <ng-container *ngSwitchCase="'badge'">
5448
+ <ptech-badge-stack>
5449
+ <ng-container *ngFor="let b of getBadges(row, c)">
5450
+ <ptech-badge
5451
+ [label]="b.label"
5452
+ [color]="b.color"
5453
+ [variant]="b.variant"
5454
+ [size]="b.size"
5455
+ ></ptech-badge>
5456
+ </ng-container>
5457
+ </ptech-badge-stack>
5458
+ </ng-container>
5459
+
5460
+ <!-- DEFAULT (text/number) -->
5461
+ <ng-container *ngSwitchDefault>
5462
+ {{ renderCell(row, c) }}
5463
+ </ng-container>
5464
+ </ng-container>
5465
+ </td>
5466
+ </ng-container>
5467
+
5468
+ <ng-container *ngIf="actions.length" matColumnDef="__actions">
5469
+ <th mat-header-cell *matHeaderCellDef style="text-align: center">
5470
+ Ações
5471
+ </th>
5472
+ <td mat-cell *matCellDef="let r" style="text-align: center">
5473
+ <ng-container *ngFor="let a of actions">
5474
+ <ptech-button
5475
+ *ngIf="!a.visible || a.visible(r)"
5476
+ icon="{{ a.icon }}"
5477
+ type="icon"
5478
+ iconColor="{{ a.color }}"
5479
+ tooltip="{{ a.tooltip || '' }}"
5480
+ (click)="a.handler(r)"
5481
+ >
5482
+ </ptech-button>
5483
+ </ng-container>
5484
+ </td>
5485
+ </ng-container>
5486
+
5487
+ <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
5488
+ <tr
5489
+ mat-row
5490
+ *matRowDef="let row; columns: displayedColumns"
5491
+ [class.selected]="isSelected(row)"
5492
+ ></tr>
5493
+ </table>
5494
+ </div>
5495
+
5496
+ <!-- CARDS (mobile) -->
5497
+ <div
5498
+ *ngIf="responsiveCards"
5499
+ class="cards-container hide-on-desktop"
5500
+ >
5501
+ <div
5502
+ *ngFor="let row of data"
5503
+ class="card mat-elevation-z8"
5504
+ [class.selected]="isSelected(row)"
5505
+ >
5506
+ <!-- seleção no card -->
5507
+ <div *ngIf="selectRow" class="card-select">
5508
+ <mat-checkbox
5509
+ *ngIf="selectMultipleRow"
5510
+ [checked]="isSelected(row)"
5511
+ (change)="toggleRow(row)"
5512
+ aria-label="Selecionar card"
5513
+ ></mat-checkbox>
5514
+
5515
+ <mat-radio-button
5516
+ *ngIf="!selectMultipleRow"
5517
+ [checked]="isSelected(row)"
5518
+ (change)="toggleRow(row)"
5519
+ aria-label="Selecionar card"
5520
+ ></mat-radio-button>
5521
+ </div>
5522
+
5523
+ <div
5524
+ *ngFor="let c of columns"
5525
+ class="card-row"
5526
+ [ngSwitch]="c.type || 'text'"
5527
+ >
5528
+ <!-- IMAGEM -->
5529
+ <ng-container *ngSwitchCase="'image'">
5530
+ <img
5531
+ class="td-thumb"
5532
+ [src]="resolveImage(row, c) || imageFallback"
5533
+ [alt]="resolveAlt(row, c) || ''"
5534
+ style="width: 64px; height: 64px; object-fit: cover; border-radius: 6px"
5535
+ (error)="onImgError($event)"
5536
+ />
5537
+ </ng-container>
5538
+
5539
+ <!-- BADGE -->
5540
+ <ng-container *ngSwitchCase="'badge'">
5541
+ <div><strong>{{ c.header }}:</strong></div>
5542
+ <ptech-badge-stack>
5543
+ <ng-container *ngFor="let b of getBadges(row, c)">
5544
+ <ptech-badge
5545
+ [label]="b.label"
5546
+ [color]="b.color"
5547
+ [variant]="b.variant"
5548
+ [size]="b.size"
5549
+ ></ptech-badge>
5550
+ </ng-container>
5551
+ </ptech-badge-stack>
5552
+ </ng-container>
5553
+
5554
+ <!-- DATE -->
5555
+ <ng-container *ngSwitchCase="'date'">
5556
+ <div>
5557
+ <strong>{{ c.header }}:</strong>
5558
+ {{ renderCell(row, c) | date : "dd/MM/yyyy HH:mm" }}
5559
+ </div>
5560
+ </ng-container>
5561
+
5562
+ <!-- DEFAULT -->
5563
+ <ng-container *ngSwitchDefault>
5564
+ <div>
5565
+ <strong>{{ c.header }}:</strong>
5566
+ {{ renderCell(row, c) }}
5567
+ </div>
5568
+ </ng-container>
5569
+ </div>
5570
+
5571
+ <!-- AÇÕES -->
5572
+ <div *ngIf="actions?.length" class="card-actions">
5573
+ <ng-container *ngFor="let a of actions">
5574
+ <ptech-button
5575
+ *ngIf="!a.visible || a.visible(row)"
5576
+ icon="{{ a.icon }}"
5577
+ type="icon"
5578
+ iconColor="{{ a.color }}"
5579
+ tooltip="{{ a.tooltip || '' }}"
5580
+ (click)="a.handler(row)"
5581
+ >
5582
+ </ptech-button>
5583
+ </ng-container>
5584
+ </div>
5585
+ </div>
5586
+ </div>
5587
+
5588
+ <mat-paginator
5589
+ class="mat-paginator"
5590
+ [length]="total"
5591
+ [pageIndex]="pageIndex"
5592
+ [pageSize]="pageSize"
5593
+ [pageSizeOptions]="pageSizeOptions"
5594
+ showFirstLastButtons
5595
+ (page)="onPage($event)"
5596
+ >
5597
+ </mat-paginator>
5598
+
5599
+ <div *ngIf="!data?.length" class="muted" style="padding: 12px">
5600
+ Sem dados.
5601
+ </div>
5602
+ </ng-container>
5603
+
5604
+ <ng-template #loadingTpl>
5605
+ <mat-progress-bar mode="indeterminate"></mat-progress-bar>
5606
+ </ng-template>
5607
+ </div>
5608
+ `, styles: [":host{display:block;max-width:100%;overflow-x:hidden}.table-container{margin:20px!important;max-width:100%}.table-scroll{width:100%;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}.table-scroll table{width:max-content;min-width:100%;border-collapse:collapse;table-layout:auto}.td-thumb{box-shadow:0 1px 2px #00000026;background:#f4f6fa}tr.selected{background-color:#2196f314}.mat-column-select{width:56px;text-align:center}.mat-column-__actions{text-align:center;width:120px}.hide-on-mobile{display:block}.hide-on-desktop{display:none}@media (max-width: 768px){.table-container{margin:8px}.hide-on-mobile{display:none}.hide-on-desktop{display:block}.cards-container{display:flex;flex-direction:column;gap:12px;margin:8px}.card{padding:12px;border-radius:8px;background:#fff;border:1px solid transparent;transition:border-color .15s ease,box-shadow .15s ease,background-color .15s ease}.card.selected{border-color:#1976d2;background-color:#f3f7ff;box-shadow:0 0 0 1px #1976d226}.card-select{display:flex;justify-content:flex-end;margin-bottom:8px}.card-row{margin-bottom:4px;font-size:14px}.card-row strong{font-weight:600}.card-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:8px}}\n"] }]
5609
+ }], propDecorators: { title: [{
5610
+ type: Input
5611
+ }], loading: [{
5612
+ type: Input
5613
+ }], data: [{
5614
+ type: Input
5615
+ }], total: [{
5616
+ type: Input
5617
+ }], pageIndex: [{
5618
+ type: Input
5619
+ }], pageSize: [{
5620
+ type: Input
5621
+ }], pageSizeOptions: [{
5622
+ type: Input
5623
+ }], columns: [{
5624
+ type: Input
5625
+ }], actions: [{
5626
+ type: Input
5627
+ }], selectRow: [{
5628
+ type: Input
5629
+ }], selectMultipleRow: [{
5630
+ type: Input
5631
+ }], getRowId: [{
5632
+ type: Input
5633
+ }], imageFallback: [{
5634
+ type: Input
5635
+ }], responsiveCards: [{
5636
+ type: Input
5637
+ }], selectedRows: [{
5638
+ type: Output
5639
+ }], selectedIds: [{
5640
+ type: Output
5641
+ }], page: [{
5642
+ type: Output
5643
+ }] } });
5644
+
4973
5645
  class SnackbarMessageService {
4974
5646
  snackBar;
4975
5647
  constructor(snackBar) {
@@ -5061,7 +5733,8 @@ class PumpkinTechModule {
5061
5733
  CheckBoxComponent,
5062
5734
  ProgressBarComponent,
5063
5735
  ProgressBarMultipleComponent,
5064
- FlagComponent], exports: [
5736
+ FlagComponent,
5737
+ TableComponent], exports: [
5065
5738
  // reexporta tudo junto
5066
5739
  InputComponent,
5067
5740
  TextareaComponent,
@@ -5095,6 +5768,7 @@ class PumpkinTechModule {
5095
5768
  ProgressBarComponent,
5096
5769
  ProgressBarMultipleComponent,
5097
5770
  FlagComponent,
5771
+ TableComponent,
5098
5772
  CoreMaterialModule] });
5099
5773
  static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: PumpkinTechModule, providers: [
5100
5774
  {
@@ -5133,7 +5807,8 @@ class PumpkinTechModule {
5133
5807
  CheckBoxComponent,
5134
5808
  ProgressBarComponent,
5135
5809
  ProgressBarMultipleComponent,
5136
- FlagComponent, CoreMaterialModule] });
5810
+ FlagComponent,
5811
+ TableComponent, CoreMaterialModule] });
5137
5812
  }
5138
5813
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: PumpkinTechModule, decorators: [{
5139
5814
  type: NgModule,
@@ -5173,7 +5848,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
5173
5848
  CheckBoxComponent,
5174
5849
  ProgressBarComponent,
5175
5850
  ProgressBarMultipleComponent,
5176
- FlagComponent
5851
+ FlagComponent,
5852
+ TableComponent
5177
5853
  ],
5178
5854
  exports: [
5179
5855
  // reexporta tudo junto
@@ -5209,6 +5885,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
5209
5885
  ProgressBarComponent,
5210
5886
  ProgressBarMultipleComponent,
5211
5887
  FlagComponent,
5888
+ TableComponent,
5212
5889
  CoreMaterialModule,
5213
5890
  ],
5214
5891
  providers: [
@@ -6326,7 +7003,7 @@ class BreadcrumbService {
6326
7003
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BreadcrumbService, decorators: [{
6327
7004
  type: Injectable,
6328
7005
  args: [{ providedIn: 'root' }]
6329
- }], ctorParameters: () => [{ type: i2$2.Router }, { type: i2$4.Observable, decorators: [{
7006
+ }], ctorParameters: () => [{ type: i2$2.Router }, { type: i2$5.Observable, decorators: [{
6330
7007
  type: Optional
6331
7008
  }, {
6332
7009
  type: Inject,
@@ -6640,5 +7317,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
6640
7317
  * Generated bundle index. Do not edit.
6641
7318
  */
6642
7319
 
6643
- export { ActionDialogComponent, ActionResultDialogComponent, ActionRowComponent, AlertComponent, ArrayUtil, BREADCRUMB_PREFIX$, BadgeComponent, BadgeStackComponent, BreadcrumbComponent, BreadcrumbService, ButtonComponent, CheckBoxComponent, ClickCatcherDirective, ConfirmationDialogComponent, CoreMaterialModule, CurrencyBrlPipe, CurrencyPreferenceService, CurrencyUtil, DateAgoPipe, DateMaskDirective, DateUtil, DefaultConsoleMessageService, DefaultMessageService, DialogService, DirectivesModule, DocumentUtil, DynamicTabDirective, FakeDataService, FlagComponent, FooterComponent, ForDirective, GetFirstStringBeforeSpacePipe, HeaderComponent, IconComponent, InfoDetailComponent, InfoDetailDialogComponent, InputComponent, InputCurrencyComponent, InputDateComponent, InputDateRangeComponent, InputTimeComponent, IsLongerThanPipe, LineBreakAfterPeriodPipe, LineBreakAfterPipe, LoadingOverlayComponent, LoadingService, LowerCaseDirective, MESSAGE_SERVICE, MY_DATE_FORMATS, MemoryFormatPipe, ModuleChangeService, NavComponent, NavService, NumberUtil, ObjectUtil, PhoneBrazilPipe, PhoneMaskBrazilDirective, PhoneMaskSpainDirective, PhoneSpainPipe, PipesModule, ProfileMenuComponent, ProgressBarComponent, ProgressBarMultipleComponent, PtechColDirective, PtechGridDirective, PumpkinTechModule, QuantityItemsComponent, RadioGroupEntityComponent, RadioGroupEnumComponent, RedDirective, SelectEntityComponent, SelectEnumComponent, SlideToggleComponent, SnackbarMessageService, SpaceDropDirective, StringUtil, TextareaComponent, TimeDurationPipe, TitleComponent, UpperCaseDirective, UptimeFormatPipe, UuidUtil };
7320
+ export { ActionDialogComponent, ActionResultDialogComponent, ActionRowComponent, AlertComponent, ArrayUtil, BREADCRUMB_PREFIX$, BadgeComponent, BadgeStackComponent, BreadcrumbComponent, BreadcrumbService, ButtonComponent, CheckBoxComponent, ClickCatcherDirective, ConfirmationDialogComponent, CoreMaterialModule, CurrencyBrlPipe, CurrencyPreferenceService, CurrencyUtil, DateAgoPipe, DateMaskDirective, DateUtil, DefaultConsoleMessageService, DefaultMessageService, DialogService, DirectivesModule, DocumentUtil, DynamicTabDirective, FakeDataService, FlagComponent, FooterComponent, ForDirective, GetFirstStringBeforeSpacePipe, HeaderComponent, IconComponent, InfoDetailComponent, InfoDetailDialogComponent, InputComponent, InputCurrencyComponent, InputDateComponent, InputDateRangeComponent, InputTimeComponent, IsLongerThanPipe, LineBreakAfterPeriodPipe, LineBreakAfterPipe, LoadingOverlayComponent, LoadingService, LowerCaseDirective, MESSAGE_SERVICE, MY_DATE_FORMATS, MemoryFormatPipe, ModuleChangeService, NavComponent, NavService, NumberUtil, ObjectUtil, PhoneBrazilPipe, PhoneMaskBrazilDirective, PhoneMaskSpainDirective, PhoneSpainPipe, PipesModule, ProfileMenuComponent, ProgressBarComponent, ProgressBarMultipleComponent, PtechColDirective, PtechGridDirective, PumpkinTechModule, QuantityItemsComponent, RadioGroupEntityComponent, RadioGroupEnumComponent, RedDirective, SelectEntityComponent, SelectEnumComponent, SlideToggleComponent, SnackbarMessageService, SpaceDropDirective, StringUtil, TableComponent, TextareaComponent, TimeDurationPipe, TitleComponent, UpperCaseDirective, UptimeFormatPipe, UuidUtil };
6644
7321
  //# sourceMappingURL=pumpkin-tech-pumpkin-tech-ng.mjs.map