@muraai/mnl-form 0.0.1-alpha-70e67fe → 0.0.1-alpha-6687844

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.
@@ -838,61 +838,126 @@ class FormlyFieldTableComponent extends FieldArrayType {
838
838
  this.displayedColumns = [];
839
839
  this.columnsToDisplay = [];
840
840
  this.data = new MatTableDataSource([]);
841
+ this.columnConfigs = [];
842
+ this.enableSort = true;
843
+ this.enablePaginator = true;
841
844
  }
842
845
  ngAfterViewInit() {
843
- this.data.paginator = this.paginator;
844
- this.data.sort = this.sort;
846
+ if (this.enablePaginator) {
847
+ this.data.paginator = this.paginator;
848
+ }
849
+ if (this.enableSort) {
850
+ this.data.sort = this.sort;
851
+ }
845
852
  }
846
853
  ngOnInit() {
847
- this.data = new MatTableDataSource(this.field.props['gridOptions']?.data);
848
- this.displayedColumns = this.field.props['gridOptions']?.columnDefs;
854
+ const gridOptions = this.field.props?.['gridOptions'] || {};
855
+ this.enableSort = gridOptions.enableSort !== undefined ? gridOptions.enableSort : true;
856
+ this.enablePaginator = gridOptions.enablePaginator !== undefined ? gridOptions.enablePaginator : true;
857
+ const cols = gridOptions.columnDefs || [];
858
+ this.columnConfigs = cols.map((col) => {
859
+ if (typeof col === 'string') {
860
+ return { field: col, headerName: col };
861
+ }
862
+ return col;
863
+ });
864
+ this.displayedColumns = this.columnConfigs.map(c => c.field);
849
865
  this.columnsToDisplay = this.displayedColumns.slice();
866
+ this.data.data = gridOptions.data || [];
867
+ }
868
+ onButtonClick(action, row) {
869
+ if (action.onClick && typeof action.onClick === 'function') {
870
+ action.onClick(row);
871
+ }
850
872
  }
851
873
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.4", ngImport: i0, type: FormlyFieldTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
852
874
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.4", type: FormlyFieldTableComponent, isStandalone: true, selector: "mu-table", viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true }, { propertyName: "sort", first: true, predicate: MatSort, descendants: true }], usesInheritance: true, ngImport: i0, template: `
853
-
854
- <table mat-table [dataSource]="data" matSort class="mat-elevation-z8">
855
- @for (column of displayedColumns; track column) {
856
- <ng-container [matColumnDef]="column">
857
- <th mat-header-cell mat-sort-header *matHeaderCellDef> {{column}} </th>
858
- <td mat-cell *matCellDef="let element"> {{element[column]}} </td>
859
- </ng-container>
860
- }
875
+ <table mat-table [dataSource]="data" matSort class="mat-elevation-z8 mu-table">
876
+ @for (column of columnConfigs; track column.field) {
877
+ <ng-container [matColumnDef]="column.field">
878
+ <th mat-header-cell *matHeaderCellDef
879
+ [mat-sort-header]="enableSort ? column.field : null"
880
+ [disabled]="!enableSort"
881
+ [style.width]="column.width || '150px'">
882
+ {{ column.headerName || column.field }}
883
+ </th>
884
+ <td mat-cell *matCellDef="let element"
885
+ [matTooltip]="column.type !== 'actions' && column.type !== 'button' ? element[column.field] : ''"
886
+ [style.width]="column.width || '150px'">
887
+ @if (column.type === 'actions') {
888
+ <div class="flex gap-2">
889
+ @for (btn of column.actions; track btn.icon) {
890
+ <button mat-icon-button
891
+ (click)="onButtonClick(btn, element)"
892
+ [matTooltip]="btn.tooltip || ''">
893
+ <mat-icon>{{ btn.icon }}</mat-icon>
894
+ </button>
895
+ }
896
+ </div>
897
+ } @else {
898
+ {{ element[column.field] }}
899
+ }
900
+ </td>
901
+ </ng-container>
902
+ }
861
903
 
862
- <tr mat-header-row *matHeaderRowDef="columnsToDisplay"></tr>
863
- <tr mat-row *matRowDef="let row; columns: columnsToDisplay;"></tr>
864
- </table>
865
- <mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" aria-label="Select page of users"></mat-paginator>
866
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: MatTableModule }, { kind: "component", type: i1$5.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i1$5.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i1$5.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i1$5.MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: i1$5.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i1$5.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i1$5.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i1$5.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i1$5.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i1$5.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "ngmodule", type: FormlyMaterialModule }, { kind: "ngmodule", type: FormlyModule }, { kind: "ngmodule", type: MatSortModule }, { kind: "directive", type: i2$2.MatSort, selector: "[matSort]", inputs: ["matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear", "matSortDisabled"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { kind: "component", type: i2$2.MatSortHeader, selector: "[mat-sort-header]", inputs: ["mat-sort-header", "arrowPosition", "start", "disabled", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { kind: "ngmodule", type: MatPaginatorModule }, { kind: "component", type: i3.MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }] }); }
904
+ <tr mat-header-row *matHeaderRowDef="columnsToDisplay"></tr>
905
+ <tr mat-row *matRowDef="let row; columns: columnsToDisplay;"></tr>
906
+ </table>
907
+ @if (enablePaginator) {
908
+ <mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" aria-label="Select page of items"></mat-paginator>
909
+ }
910
+ `, isInline: true, styles: [".mu-table{width:100%;table-layout:fixed}.mu-table th.mat-mdc-header-cell{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mu-table td.mat-mdc-cell{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mu-table th.mat-header-cell ::ng-deep .mat-sort-header-button{font-weight:600}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatTableModule }, { kind: "component", type: i1$5.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i1$5.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i1$5.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i1$5.MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: i1$5.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i1$5.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i1$5.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i1$5.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i1$5.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i1$5.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "ngmodule", type: FormlyMaterialModule }, { kind: "ngmodule", type: FormlyModule }, { kind: "ngmodule", type: MatSortModule }, { kind: "directive", type: i2$2.MatSort, selector: "[matSort]", inputs: ["matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear", "matSortDisabled"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { kind: "component", type: i2$2.MatSortHeader, selector: "[mat-sort-header]", inputs: ["mat-sort-header", "arrowPosition", "start", "disabled", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { kind: "ngmodule", type: MatPaginatorModule }, { kind: "component", type: i3.MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i6.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i5.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }] }); }
867
911
  }
868
912
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.4", ngImport: i0, type: FormlyFieldTableComponent, decorators: [{
869
913
  type: Component,
870
- args: [{
871
- selector: 'mu-table',
872
- standalone: true,
873
- imports: [
914
+ args: [{ selector: 'mu-table', standalone: true, imports: [
915
+ CommonModule,
874
916
  MatTableModule,
875
917
  FormlyMaterialModule,
876
918
  FormlyModule,
877
919
  MatSortModule,
878
- MatPaginatorModule
879
- ],
880
- template: `
881
-
882
- <table mat-table [dataSource]="data" matSort class="mat-elevation-z8">
883
- @for (column of displayedColumns; track column) {
884
- <ng-container [matColumnDef]="column">
885
- <th mat-header-cell mat-sort-header *matHeaderCellDef> {{column}} </th>
886
- <td mat-cell *matCellDef="let element"> {{element[column]}} </td>
887
- </ng-container>
888
- }
920
+ MatPaginatorModule,
921
+ MatButtonModule,
922
+ MatIconModule,
923
+ MatTooltipModule
924
+ ], template: `
925
+ <table mat-table [dataSource]="data" matSort class="mat-elevation-z8 mu-table">
926
+ @for (column of columnConfigs; track column.field) {
927
+ <ng-container [matColumnDef]="column.field">
928
+ <th mat-header-cell *matHeaderCellDef
929
+ [mat-sort-header]="enableSort ? column.field : null"
930
+ [disabled]="!enableSort"
931
+ [style.width]="column.width || '150px'">
932
+ {{ column.headerName || column.field }}
933
+ </th>
934
+ <td mat-cell *matCellDef="let element"
935
+ [matTooltip]="column.type !== 'actions' && column.type !== 'button' ? element[column.field] : ''"
936
+ [style.width]="column.width || '150px'">
937
+ @if (column.type === 'actions') {
938
+ <div class="flex gap-2">
939
+ @for (btn of column.actions; track btn.icon) {
940
+ <button mat-icon-button
941
+ (click)="onButtonClick(btn, element)"
942
+ [matTooltip]="btn.tooltip || ''">
943
+ <mat-icon>{{ btn.icon }}</mat-icon>
944
+ </button>
945
+ }
946
+ </div>
947
+ } @else {
948
+ {{ element[column.field] }}
949
+ }
950
+ </td>
951
+ </ng-container>
952
+ }
889
953
 
890
- <tr mat-header-row *matHeaderRowDef="columnsToDisplay"></tr>
891
- <tr mat-row *matRowDef="let row; columns: columnsToDisplay;"></tr>
892
- </table>
893
- <mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" aria-label="Select page of users"></mat-paginator>
894
- `
895
- }]
954
+ <tr mat-header-row *matHeaderRowDef="columnsToDisplay"></tr>
955
+ <tr mat-row *matRowDef="let row; columns: columnsToDisplay;"></tr>
956
+ </table>
957
+ @if (enablePaginator) {
958
+ <mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" aria-label="Select page of items"></mat-paginator>
959
+ }
960
+ `, styles: [".mu-table{width:100%;table-layout:fixed}.mu-table th.mat-mdc-header-cell{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mu-table td.mat-mdc-cell{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mu-table th.mat-header-cell ::ng-deep .mat-sort-header-button{font-weight:600}\n"] }]
896
961
  }], propDecorators: { paginator: [{
897
962
  type: ViewChild,
898
963
  args: [MatPaginator]