easy-mat-ui 0.0.3 → 0.0.4

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.
Files changed (43) hide show
  1. package/ng-package.json +19 -0
  2. package/package.json +16 -18
  3. package/src/lib/easy-mat-ui.component.spec.ts +23 -0
  4. package/src/lib/easy-mat-ui.component.ts +16 -0
  5. package/src/lib/easy-mat-ui.service.spec.ts +16 -0
  6. package/src/lib/easy-mat-ui.service.ts +9 -0
  7. package/src/lib/easy-multi-select/easy-multi-select.css +102 -0
  8. package/src/lib/easy-multi-select/easy-multi-select.html +51 -0
  9. package/src/lib/easy-multi-select/easy-multi-select.spec.ts +23 -0
  10. package/src/lib/easy-multi-select/easy-multi-select.ts +181 -0
  11. package/src/lib/easy-table/easy-table.component.css +117 -0
  12. package/src/lib/easy-table/easy-table.component.html +221 -0
  13. package/src/lib/easy-table/easy-table.component.spec.ts +23 -0
  14. package/src/lib/easy-table/easy-table.component.ts +568 -0
  15. package/src/lib/model/dictionary.model.ts +4 -0
  16. package/src/lib/model/mat-column-typed.model.ts +41 -0
  17. package/src/lib/model/mat-column.model.ts +35 -0
  18. package/src/lib/model/tuple.model.ts +8 -0
  19. package/src/lib/shared/table-toolbar/table-toolbar.css +26 -0
  20. package/src/lib/shared/table-toolbar/table-toolbar.html +80 -0
  21. package/src/lib/shared/table-toolbar/table-toolbar.ts +130 -0
  22. package/src/lib/styles/_backgrounds.scss +39 -0
  23. package/src/lib/styles/_buttons.scss +90 -0
  24. package/src/lib/styles/_colors.scss +67 -0
  25. package/src/lib/styles/_effects.scss +44 -0
  26. package/src/lib/styles/_material-overrides.scss +87 -0
  27. package/src/lib/styles/_spacing.scss +68 -0
  28. package/src/lib/styles/_tables.scss +71 -0
  29. package/src/lib/styles/_typography.scss +105 -0
  30. package/src/lib/styles.scss +30 -0
  31. package/src/lib/utils/enums.ts +49 -0
  32. package/src/lib/utils/matTabCommon.ts +59 -0
  33. package/src/lib/utils/utils.ts +68 -0
  34. package/{public-api.d.ts → src/public-api.ts} +8 -3
  35. package/tsconfig.lib.json +18 -0
  36. package/tsconfig.lib.prod.json +11 -0
  37. package/tsconfig.spec.json +15 -0
  38. package/fesm2022/easy-mat-ui.mjs +0 -110
  39. package/fesm2022/easy-mat-ui.mjs.map +0 -1
  40. package/index.d.ts +0 -5
  41. package/lib/easy-mat-ui.component.d.ts +0 -5
  42. package/lib/easy-mat-ui.service.d.ts +0 -6
  43. package/lib/easy-table/easy-table.component.d.ts +0 -15
@@ -0,0 +1,221 @@
1
+ @if (withToolbar) {
2
+ <lib-table-toolbar
3
+ [withTitle]="withTitle"
4
+ [icon]="icon"
5
+ [iconClass]="iconClass"
6
+ [source]="source"
7
+ [withGlobalFilter]="withGlobalFilter"
8
+ [isPreview]="isPreview"
9
+ [searchTableField]="searchTableField"
10
+ [readonly]="readonly"
11
+ [canCreate]="canCreate"
12
+ [canExport]="canExport"
13
+ [customActionEnable]="customActionEnable"
14
+ [customActionTitle]="customActionTitle"
15
+ [customActionIcon]="customActionIcon"
16
+ [customRowActionClass]="customRowActionClass"
17
+ [logout]="logout"
18
+ [isAndFilterOperator]="isAndFilterOperator"
19
+ [btnSize]="btnSize"
20
+ [customColumnFilter]="customColumnFilter"
21
+ (searchTableFieldChange)="searchTableField = $event; applyFilterFromToolbar()"
22
+ (applyFilterEvent)="applyFilter($event)"
23
+ (filterTypeEvent)="filterType()"
24
+ (clearTableFilterEvent)="clearTableFilter()"
25
+ (addItemEvent)="addItem()"
26
+ (exportToCsvEvent)="exportToCsv()"
27
+ (customActionEvent)="onClickCustomAction()"
28
+ (closeEvent)="close()"
29
+ (toggleChangedEvent)="OnToggleChanged($event)">
30
+ </lib-table-toolbar>
31
+ <br>
32
+ }
33
+
34
+
35
+ <div class="row p-0">
36
+ <div class="col-md-12 p-0" [ngClass]="fontSize">
37
+ <div class="table-responsive">
38
+ @if (expandableGroups) {
39
+ <div class="collapse-controls">
40
+ @for (group of availableGroups; track group) {
41
+ @if (group !== '_ungrouped') {
42
+ <button mat-button (click)="toggleGroup(group)"
43
+ [ngClass]="expandedGroups[group] ? 'active-item' : 'inactive-item'">
44
+ {{ group }} {{ expandedGroups[group] ? '▲' : '▼' }}
45
+ </button>
46
+ }
47
+ }
48
+ </div>
49
+ }
50
+
51
+ <table mat-table [dataSource]="dataSource" matSort [class.mat-elevation-z2]="isPreview"
52
+ [class.mat-elevation-z8]="!isPreview" class="mat-mdc-table w-100">
53
+
54
+ @for (grouped of groupedColumns; track grouped[0]) {
55
+ @if (grouped[0] !== '_ungrouped') {
56
+ <tr class="group-header-row">
57
+ <th [attr.colspan]="grouped[1].length" class="group-header-cell">
58
+ <button type="button" (click)="toggleGroup(grouped[0])">
59
+ <mat-icon>{{ expandedGroups[grouped[0]] ? 'expand_less' : 'expand_more' }}</mat-icon>
60
+ {{ grouped[0] }}
61
+ </button>
62
+ </th>
63
+ </tr>
64
+ }
65
+
66
+ @for (col of grouped[1]; track col.name) {
67
+ @if (grouped[0] === '_ungrouped' || expandedGroups[grouped[0]]) {
68
+
69
+ <ng-container [matColumnDef]="col.name">
70
+ <th mat-header-cell *matHeaderCellDef
71
+ [class.mat-sort-header]="!withFilterInHeader"
72
+ [ngClass]="[col.size, col.stickyClass, col.groupClass || ('group' + getGroupIndex(grouped[0]))]"
73
+ class="custom-th-cell">
74
+ <div class="header-label">{{ col.name | translate }}</div>
75
+
76
+ @if (withFilterInHeader) {
77
+ <div class="header-filter">
78
+ <lib-easy-multi-select #multiSelectDropdown
79
+ [class.visibility-hidden]="!col.enableFilter"
80
+ [data]="col.filterList"
81
+ [valueField]="'value'"
82
+ [displayField]="'value'"
83
+ (change)="onChangeMultiSelect($event, col)"
84
+ [title]="col.name"
85
+ [selectedData]="getSelectedList(col)"
86
+ [noPlaceholderNoHint]="true"
87
+ [padding]="'pd-t-l-5 h-50'">
88
+ </lib-easy-multi-select>
89
+ </div>
90
+ }
91
+ </th>
92
+
93
+ @if (col.name === '#') {
94
+ <td mat-cell *matCellDef="let element; let i = index"
95
+ [ngClass]="[col.stickyClass]"
96
+ title="ID = {{element[col.id]}}">
97
+ {{ i + 1 }}
98
+ </td>
99
+ } @else if (col.name === 'actions') {
100
+ <td mat-cell *matCellDef="let element" class="text-center action-link"
101
+ [ngClass]="[col.stickyClass]">
102
+ <div class="d-inline-flex gap-1 align-items-center">
103
+ @if (!readonly && canAuditTrail) {
104
+ <button mat-icon-button class="icon-only primary audit"
105
+ title="{{'AUDIT_TRAIL' | translate}}" (click)="auditTrailItem(element)">
106
+ <mat-icon>history</mat-icon>
107
+ </button>
108
+ }
109
+ <button mat-icon-button class="icon-only taupe" title="{{'link' | translate}}"
110
+ (click)="viewItem(element)">
111
+ <mat-icon>visibility</mat-icon>
112
+ </button>
113
+ @if (!readonly && canUpdate) {
114
+ <button mat-icon-button class="icon-only success {{element.statusName}}"
115
+ title="{{'edit' | translate}}" (click)="editItem(element)">
116
+ <mat-icon>edit</mat-icon>
117
+ </button>
118
+ }
119
+ @if (!readonly && canDelete) {
120
+ <button mat-icon-button class="icon-only danger"
121
+ title="{{'delete' | translate}}" (click)="deleteItem(element)">
122
+ <mat-icon>delete_forever</mat-icon>
123
+ </button>
124
+ }
125
+ </div>
126
+ </td>
127
+ } @else {
128
+ @if (col.isOverwriting) {
129
+ <td mat-cell *matCellDef="let element" [ngClass]="col.stickyClass">
130
+ @if (col.type === ColumnType.DROPDOWNLIST) {
131
+ <lib-easy-multi-select [data]="col.filterList" [valueField]="'value'"
132
+ [displayField]="'value'"
133
+ (change)="onChangeMultiSelect($event, col, false)"
134
+ [title]="col.name"
135
+ [selectedData]="getSelectedData(element, col)"
136
+ [noPlaceholderNoHint]="true"
137
+ [padding]="'pd-t-l-5 h-50'">
138
+ </lib-easy-multi-select>
139
+ } @else {
140
+ <input class="form-control form-control-sm cell-input hover h-40"
141
+ [ngClass]="col.type === ColumnType.NUMBER ? 'input-overwrite overwrite' : 'bg-white'"
142
+ [value]="element[col.name] ?? null"
143
+ (change)="onChangeOverwrite(element, col, $event)"/>
144
+ }
145
+ </td>
146
+ } @else {
147
+ @switch (col.type) {
148
+ @case (ColumnType.ICON) {
149
+ <td mat-cell *matCellDef="let element" class="text-center hover action-link"
150
+ [title]="getIconTitle(col, element[col.name])"
151
+ [ngClass]="[col.stickyClass]">
152
+ <mat-icon [class]="MatTabCommon.getCssClasses(col, element)">
153
+ {{ getIconColumn(col, element) }}
154
+ </mat-icon>
155
+ </td>
156
+ }
157
+ @case (ColumnType.ICON_AND_TEXT) {
158
+ <td mat-cell *matCellDef="let element"
159
+ class="action-link d-flex align-items-center gap-1"
160
+ [ngClass]="[col.stickyClass]">
161
+ <button mat-mini-fab class="btn btn-link p-0"
162
+ [class]="MatTabCommon.getCssClasses(col, element)"
163
+ [title]="getIconTitle(col, element[col.name])">
164
+ <mat-icon>{{ getIconColumn(col, element) }}</mat-icon>
165
+ </button>
166
+ <strong>{{ element[col.name] | translate }}</strong>
167
+ </td>
168
+ }
169
+ @case (ColumnType.PASSWORD) {
170
+ <td mat-cell *matCellDef="let element">
171
+ <div class="password-cell" [ngClass]="[col.cssClass, col.stickyClass]">
172
+ <span class="masked-text">
173
+ {{ isPasswordVisible[element[col.name]] ? element[col.name] : getMaskedValue(element[col.name]) }}
174
+ </span>
175
+ <button type="button" class="toggle-btn"
176
+ (click)="togglePassword(element[col.name])"
177
+ tabindex="-1" aria-label="Toggle password visibility">
178
+ <mat-icon>
179
+ {{ isPasswordVisible[element[col.name]] ? 'visibility_off' : 'visibility' }}
180
+ </mat-icon>
181
+ </button>
182
+ </div>
183
+ </td>
184
+ }
185
+ @case (ColumnType.BUTTON) {
186
+ <td mat-cell *matCellDef="let element"
187
+ [title]="getTitleColumn(col, element)"
188
+ [ngClass]="[col.stickyClass]">
189
+ <button class="p-0 w-100 no-border"
190
+ [class]="MatTabCommon.getCssClasses(col, element)">
191
+ {{ element[col.displayColumn ?? col.name] | translate }}
192
+ </button>
193
+ </td>
194
+ }
195
+ @default {
196
+ <td mat-cell *matCellDef="let element"
197
+ [ngClass]="[col.stickyClass]"
198
+ class="hover"
199
+ [class]="MatTabCommon.getCssClasses(col, element)"
200
+ [title]="getTitleColumn(col, element)">
201
+ {{ MatTabCommon.displayFormatTyped(col, element[col.name], sliceSize) }}
202
+ </td>
203
+ }
204
+ }
205
+ }
206
+ }
207
+ </ng-container>
208
+ }
209
+ }
210
+ }
211
+
212
+ <tr mat-header-row *matHeaderRowDef="getDisplayedColumnNames()"></tr>
213
+ <tr mat-row *matRowDef="let row; columns: getDisplayedColumnNames()"></tr>
214
+ </table>
215
+ </div>
216
+
217
+ <mat-paginator [pageSizeOptions]="[10, 25, 50]"
218
+ showFirstLastButtons
219
+ [class.opacity-0]="isPreview"></mat-paginator>
220
+ </div>
221
+ </div>
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { EasyTableComponent } from './easy-table.component';
4
+
5
+ describe('EasyTableComponent', () => {
6
+ let component: EasyTableComponent;
7
+ let fixture: ComponentFixture<EasyTableComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [EasyTableComponent]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(EasyTableComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });