@pumpkin-tech/pumpkin-tech-ng 0.2.63 → 0.2.64

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
@@ -26,6 +26,19 @@ ng build pumpkin-tech-ng
26
26
 
27
27
  This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
28
 
29
+ ## PTech table pagination
30
+
31
+ `ptech-table` paginates local arrays when `paginator` is enabled. Set
32
+ `serverSidePagination` (or the legacy alias `backendPagination`) when `data`
33
+ already contains a backend page; in that mode the component preserves all
34
+ received rows and emits `page`/`pageChange` for the consumer to load the next
35
+ page. Existing consumers are also recognized automatically when the declared
36
+ total is larger than `data.length` or a non-zero page index is supplied.
37
+
38
+ `responsiveCards` uses the same page as the desktop table. Optional
39
+ `tableAriaLabel`, `paginatorAriaLabel`, and `emptyAriaLabel` inputs provide
40
+ context when a visible title is not enough.
41
+
29
42
  ### Publishing the Library
30
43
 
31
44
  Once the project is built, you can publish your library by following these steps:
@@ -6804,6 +6804,9 @@ class TableComponent {
6804
6804
  shadow = true;
6805
6805
  disabled = false;
6806
6806
  emptyText = 'Sem dados.';
6807
+ emptyAriaLabel = '';
6808
+ tableAriaLabel = '';
6809
+ paginatorAriaLabel = '';
6807
6810
  stickyHeader = false;
6808
6811
  rowClickable = false;
6809
6812
  data = [];
@@ -6853,6 +6856,8 @@ class TableComponent {
6853
6856
  selection = new SelectionModel(this.selectMultipleRow, []);
6854
6857
  selectedIdSet = new Set();
6855
6858
  dataDiffer;
6859
+ clientPageIndex = 0;
6860
+ clientPageSize = 10;
6856
6861
  matTable;
6857
6862
  cellTemplates;
6858
6863
  actionsTemplate;
@@ -6887,13 +6892,27 @@ class TableComponent {
6887
6892
  return !!this.actionsTemplate || !!this.actions?.length;
6888
6893
  }
6889
6894
  get resolvedTotal() {
6890
- return this.totalElements ?? this.paginatorLength ?? this.total ?? this.renderData?.length ?? 0;
6895
+ if (!this.usesServerPagination) {
6896
+ return this.data?.length ?? 0;
6897
+ }
6898
+ return this.totalElements ?? this.paginatorLength ?? this.total ?? this.data?.length ?? 0;
6891
6899
  }
6892
6900
  get resolvedPageIndex() {
6893
- return this.paginatorPageIndex ?? this.pageIndex ?? 0;
6901
+ return this.usesServerPagination
6902
+ ? (this.paginatorPageIndex ?? this.pageIndex ?? 0)
6903
+ : this.clientPageIndex;
6894
6904
  }
6895
6905
  get resolvedPageSize() {
6896
- return this.paginatorPageSize ?? this.pageSize ?? 10;
6906
+ return this.usesServerPagination
6907
+ ? (this.paginatorPageSize ?? this.pageSize ?? 10)
6908
+ : this.clientPageSize;
6909
+ }
6910
+ get usesServerPagination() {
6911
+ const declaredTotal = this.totalElements ?? this.paginatorLength ?? this.total ?? 0;
6912
+ const declaredPage = this.paginatorPageIndex ?? this.pageIndex ?? 0;
6913
+ return this.serverSidePagination || this.backendPagination
6914
+ || declaredTotal > (this.data?.length ?? 0)
6915
+ || declaredPage > 0;
6897
6916
  }
6898
6917
  normalizeColumn(column) {
6899
6918
  const key = this.columnKey(column);
@@ -6933,6 +6952,12 @@ class TableComponent {
6933
6952
  if (this.hasActionsColumn)
6934
6953
  cols.push('__actions');
6935
6954
  this.displayedColumns = cols;
6955
+ if (changes['pageIndex'] || changes['paginatorPageIndex']) {
6956
+ this.clientPageIndex = this.paginatorPageIndex ?? this.pageIndex ?? 0;
6957
+ }
6958
+ if (changes['pageSize'] || changes['paginatorPageSize']) {
6959
+ this.clientPageSize = this.paginatorPageSize ?? this.pageSize ?? 10;
6960
+ }
6936
6961
  if (changes['data']) {
6937
6962
  this.dataDiffer = this.iterableDiffers.find(this.data || []).create();
6938
6963
  this.syncRenderData();
@@ -6961,7 +6986,16 @@ class TableComponent {
6961
6986
  }
6962
6987
  }
6963
6988
  syncRenderData() {
6964
- this.renderData = [...(this.data || [])];
6989
+ const rows = this.data || [];
6990
+ if (!this.paginator || this.usesServerPagination) {
6991
+ this.renderData = [...rows];
6992
+ return;
6993
+ }
6994
+ const pageSize = Math.max(1, this.clientPageSize || 10);
6995
+ const lastPageIndex = Math.max(0, Math.ceil(rows.length / pageSize) - 1);
6996
+ this.clientPageIndex = Math.min(Math.max(0, this.clientPageIndex), lastPageIndex);
6997
+ const start = this.clientPageIndex * pageSize;
6998
+ this.renderData = rows.slice(start, start + pageSize);
6965
6999
  }
6966
7000
  // selecionar/deselecionar todos da PÁGINA atual
6967
7001
  toggleAllRows() {
@@ -7037,6 +7071,12 @@ class TableComponent {
7037
7071
  return this.selectedIdSet.has(this.getRowId(row));
7038
7072
  }
7039
7073
  onPage(ev) {
7074
+ if (!this.usesServerPagination) {
7075
+ this.clientPageIndex = ev.pageIndex;
7076
+ this.clientPageSize = ev.pageSize;
7077
+ this.syncRenderData();
7078
+ this.matTable?.renderRows();
7079
+ }
7040
7080
  const pageEvent = {
7041
7081
  pageIndex: ev.pageIndex,
7042
7082
  pageSize: ev.pageSize,
@@ -7191,7 +7231,7 @@ class TableComponent {
7191
7231
  });
7192
7232
  }
7193
7233
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: TableComponent, deps: [{ token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Component });
7194
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: TableComponent, isStandalone: true, selector: "ptech-table", inputs: { title: "title", loading: "loading", shadow: "shadow", disabled: "disabled", emptyText: "emptyText", stickyHeader: "stickyHeader", rowClickable: "rowClickable", data: "data", total: "total", pageIndex: "pageIndex", pageSize: "pageSize", pageSizeOptions: "pageSizeOptions", totalElements: "totalElements", paginatorLength: "paginatorLength", paginatorPageIndex: "paginatorPageIndex", paginatorPageSize: "paginatorPageSize", serverSidePagination: "serverSidePagination", backendPagination: "backendPagination", paginator: "paginator", sortField: "sortField", sortDirection: "sortDirection", serverSideSorting: "serverSideSorting", columns: "columns", actions: "actions", actionsDisplay: "actionsDisplay", actionsMenuLabel: "actionsMenuLabel", actionsTriggerColor: "actionsTriggerColor", selectRow: "selectRow", selectMultipleRow: "selectMultipleRow", selectionMode: "selectionMode", usePtechSelectionControls: "usePtechSelectionControls", getRowId: "getRowId", imageFallback: "imageFallback", responsiveCards: "responsiveCards", reorderable: "reorderable" }, outputs: { selectedRows: "selectedRows", selectedRow: "selectedRow", selectedIds: "selectedIds", selectionChange: "selectionChange", page: "page", pageChange: "pageChange", sortChange: "sortChange", rowClick: "rowClick", reorder: "reorder", toggleChange: "toggleChange" }, queries: [{ propertyName: "actionsTemplate", first: true, predicate: ["actions"], descendants: true }, { propertyName: "footerTemplate", first: true, predicate: ["footer"], descendants: true }, { propertyName: "emptyTemplate", first: true, predicate: ["empty"], descendants: true }, { propertyName: "cellTemplates", predicate: TableCellDirective }], viewQueries: [{ propertyName: "matTable", first: true, predicate: MatTable, descendants: true }], usesOnChanges: true, ngImport: i0, template: `
7234
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: TableComponent, isStandalone: true, selector: "ptech-table", inputs: { title: "title", loading: "loading", shadow: "shadow", disabled: "disabled", emptyText: "emptyText", emptyAriaLabel: "emptyAriaLabel", tableAriaLabel: "tableAriaLabel", paginatorAriaLabel: "paginatorAriaLabel", stickyHeader: "stickyHeader", rowClickable: "rowClickable", data: "data", total: "total", pageIndex: "pageIndex", pageSize: "pageSize", pageSizeOptions: "pageSizeOptions", totalElements: "totalElements", paginatorLength: "paginatorLength", paginatorPageIndex: "paginatorPageIndex", paginatorPageSize: "paginatorPageSize", serverSidePagination: "serverSidePagination", backendPagination: "backendPagination", paginator: "paginator", sortField: "sortField", sortDirection: "sortDirection", serverSideSorting: "serverSideSorting", columns: "columns", actions: "actions", actionsDisplay: "actionsDisplay", actionsMenuLabel: "actionsMenuLabel", actionsTriggerColor: "actionsTriggerColor", selectRow: "selectRow", selectMultipleRow: "selectMultipleRow", selectionMode: "selectionMode", usePtechSelectionControls: "usePtechSelectionControls", getRowId: "getRowId", imageFallback: "imageFallback", responsiveCards: "responsiveCards", reorderable: "reorderable" }, outputs: { selectedRows: "selectedRows", selectedRow: "selectedRow", selectedIds: "selectedIds", selectionChange: "selectionChange", page: "page", pageChange: "pageChange", sortChange: "sortChange", rowClick: "rowClick", reorder: "reorder", toggleChange: "toggleChange" }, queries: [{ propertyName: "actionsTemplate", first: true, predicate: ["actions"], descendants: true }, { propertyName: "footerTemplate", first: true, predicate: ["footer"], descendants: true }, { propertyName: "emptyTemplate", first: true, predicate: ["empty"], descendants: true }, { propertyName: "cellTemplates", predicate: TableCellDirective }], viewQueries: [{ propertyName: "matTable", first: true, predicate: MatTable, descendants: true }], usesOnChanges: true, ngImport: i0, template: `
7195
7235
  <div class="table-container mat-elevation-z8" [class.disabled]="disabled">
7196
7236
  <div class="header-row" *ngIf="title">
7197
7237
  <h3>{{ title }}</h3>
@@ -7213,6 +7253,7 @@ class TableComponent {
7213
7253
  <div class="table-scroll" [class.hide-on-mobile]="responsiveCards">
7214
7254
  <table
7215
7255
  mat-table
7256
+ [attr.aria-label]="tableAriaLabel || title || null"
7216
7257
  matSort
7217
7258
  [matSortActive]="sortField"
7218
7259
  [matSortDirection]="sortDirection"
@@ -7278,7 +7319,6 @@ class TableComponent {
7278
7319
  [style.width]="cssWidth(c.width)"
7279
7320
  [mat-sort-header]="columnKey(c)"
7280
7321
  [disabled]="!c.sortable"
7281
- [sticky]="stickyHeader"
7282
7322
  >
7283
7323
  <ng-container *ngIf="c.templateHeader; else defaultHeader">
7284
7324
  <ng-container *ngTemplateOutlet="c.templateHeader; context: { $implicit: data, column: c }"></ng-container>
@@ -7433,11 +7473,13 @@ class TableComponent {
7433
7473
  <div
7434
7474
  *ngIf="responsiveCards"
7435
7475
  class="cards-container hide-on-desktop"
7476
+ role="list"
7436
7477
  >
7437
7478
  <div
7438
7479
  *ngFor="let row of renderData; let rowIndex = index"
7439
7480
  class="card mat-elevation-z8"
7440
7481
  [class.selected]="isSelected(row)"
7482
+ role="listitem"
7441
7483
  >
7442
7484
  <!-- seleção no card -->
7443
7485
  <div *ngIf="selectRow" class="card-select">
@@ -7604,6 +7646,7 @@ class TableComponent {
7604
7646
  <mat-paginator
7605
7647
  *ngIf="paginator"
7606
7648
  class="mat-paginator"
7649
+ [attr.aria-label]="paginatorAriaLabel || null"
7607
7650
  [length]="resolvedTotal"
7608
7651
  [pageIndex]="resolvedPageIndex"
7609
7652
  [pageSize]="resolvedPageSize"
@@ -7614,7 +7657,8 @@ class TableComponent {
7614
7657
  >
7615
7658
  </mat-paginator>
7616
7659
 
7617
- <div *ngIf="!renderData?.length" class="muted" style="padding: 12px">
7660
+ <div *ngIf="!renderData?.length" class="muted" style="padding: 12px"
7661
+ role="status" [attr.aria-label]="emptyAriaLabel || null">
7618
7662
  <ng-container *ngIf="emptyTemplate; else defaultEmpty">
7619
7663
  <ng-container *ngTemplateOutlet="emptyTemplate"></ng-container>
7620
7664
  </ng-container>
@@ -7652,6 +7696,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
7652
7696
  <div class="table-scroll" [class.hide-on-mobile]="responsiveCards">
7653
7697
  <table
7654
7698
  mat-table
7699
+ [attr.aria-label]="tableAriaLabel || title || null"
7655
7700
  matSort
7656
7701
  [matSortActive]="sortField"
7657
7702
  [matSortDirection]="sortDirection"
@@ -7717,7 +7762,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
7717
7762
  [style.width]="cssWidth(c.width)"
7718
7763
  [mat-sort-header]="columnKey(c)"
7719
7764
  [disabled]="!c.sortable"
7720
- [sticky]="stickyHeader"
7721
7765
  >
7722
7766
  <ng-container *ngIf="c.templateHeader; else defaultHeader">
7723
7767
  <ng-container *ngTemplateOutlet="c.templateHeader; context: { $implicit: data, column: c }"></ng-container>
@@ -7872,11 +7916,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
7872
7916
  <div
7873
7917
  *ngIf="responsiveCards"
7874
7918
  class="cards-container hide-on-desktop"
7919
+ role="list"
7875
7920
  >
7876
7921
  <div
7877
7922
  *ngFor="let row of renderData; let rowIndex = index"
7878
7923
  class="card mat-elevation-z8"
7879
7924
  [class.selected]="isSelected(row)"
7925
+ role="listitem"
7880
7926
  >
7881
7927
  <!-- seleção no card -->
7882
7928
  <div *ngIf="selectRow" class="card-select">
@@ -8043,6 +8089,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
8043
8089
  <mat-paginator
8044
8090
  *ngIf="paginator"
8045
8091
  class="mat-paginator"
8092
+ [attr.aria-label]="paginatorAriaLabel || null"
8046
8093
  [length]="resolvedTotal"
8047
8094
  [pageIndex]="resolvedPageIndex"
8048
8095
  [pageSize]="resolvedPageSize"
@@ -8053,7 +8100,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
8053
8100
  >
8054
8101
  </mat-paginator>
8055
8102
 
8056
- <div *ngIf="!renderData?.length" class="muted" style="padding: 12px">
8103
+ <div *ngIf="!renderData?.length" class="muted" style="padding: 12px"
8104
+ role="status" [attr.aria-label]="emptyAriaLabel || null">
8057
8105
  <ng-container *ngIf="emptyTemplate; else defaultEmpty">
8058
8106
  <ng-container *ngTemplateOutlet="emptyTemplate"></ng-container>
8059
8107
  </ng-container>
@@ -8076,6 +8124,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
8076
8124
  type: Input
8077
8125
  }], emptyText: [{
8078
8126
  type: Input
8127
+ }], emptyAriaLabel: [{
8128
+ type: Input
8129
+ }], tableAriaLabel: [{
8130
+ type: Input
8131
+ }], paginatorAriaLabel: [{
8132
+ type: Input
8079
8133
  }], stickyHeader: [{
8080
8134
  type: Input
8081
8135
  }], rowClickable: [{