@aaamb/ngx-design-system 1.4.1 → 1.5.0
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/fesm2022/aaamb-ngx-design-system.mjs +4122 -0
- package/fesm2022/aaamb-ngx-design-system.mjs.map +1 -0
- package/package.json +14 -58
- package/styles/compiled.css +2 -0
- package/types/aaamb-ngx-design-system.d.ts +1150 -0
- package/.editorconfig +0 -17
- package/.nvmrc +0 -1
- package/.postcssrc.json +0 -5
- package/.storybook/main.ts +0 -20
- package/.storybook/preview.ts +0 -23
- package/.storybook/storybook.css +0 -1
- package/.storybook/tsconfig.json +0 -19
- package/.vscode/extensions.json +0 -4
- package/.vscode/launch.json +0 -20
- package/.vscode/tasks.json +0 -42
- package/CHANGELOG.md +0 -10
- package/LOCAL_DEVELOPMENT.md +0 -129
- package/angular.json +0 -74
- package/bitbucket-pipelines.yml +0 -41
- package/iac/bin/app.ts +0 -42
- package/iac/cdk.json +0 -82
- package/iac/lib/config/environments.ts +0 -19
- package/iac/lib/config/types.ts +0 -13
- package/iac/lib/stacks/certificate-stack.ts +0 -34
- package/iac/lib/stacks/frontend-stack.ts +0 -120
- package/iac/lib/stacks/index.ts +0 -2
- package/iac/package-lock.json +0 -726
- package/iac/package.json +0 -25
- package/iac/tsconfig.json +0 -24
- package/ng-package.json +0 -8
- package/src/components/button/button-green.stories.ts +0 -101
- package/src/components/button/button-text.stories.ts +0 -105
- package/src/components/button/button-white.stories.ts +0 -105
- package/src/components/button/button.component.stories.ts +0 -91
- package/src/components/button/button.component.ts +0 -93
- package/src/components/checkbox/checkbox.component.html +0 -30
- package/src/components/checkbox/checkbox.component.stories.ts +0 -183
- package/src/components/checkbox/checkbox.component.ts +0 -211
- package/src/components/datepicker-selector/datepicker-selector.component.html +0 -103
- package/src/components/datepicker-selector/datepicker-selector.component.stories.ts +0 -123
- package/src/components/datepicker-selector/datepicker-selector.component.ts +0 -337
- package/src/components/error-message/error-message.component.html +0 -3
- package/src/components/error-message/error-message.component.ts +0 -13
- package/src/components/filter-button/filter-button.component.html +0 -286
- package/src/components/filter-button/filter-button.component.stories.ts +0 -123
- package/src/components/filter-button/filter-button.component.ts +0 -582
- package/src/components/icon/icon.component.ts +0 -20
- package/src/components/icon/icon.html +0 -1424
- package/src/components/icon/icon.stories.ts +0 -49
- package/src/components/icon/icons-list.stories.ts +0 -42
- package/src/components/input/input.component.stories.ts +0 -101
- package/src/components/input/input.component.ts +0 -317
- package/src/components/input/input.html +0 -160
- package/src/components/input-datepicker/input-datepicker.component.ts +0 -356
- package/src/components/input-datepicker/input-datepicker.html +0 -69
- package/src/components/input-datepicker/input-datepicker.stories.ts +0 -99
- package/src/components/input-rangepicker/input-rangepicker.component.ts +0 -365
- package/src/components/input-rangepicker/input-rangepicker.html +0 -54
- package/src/components/input-rangepicker/input-rangepicker.stories.ts +0 -88
- package/src/components/input-weekpicker/input-weekpicker.component.ts +0 -417
- package/src/components/input-weekpicker/input-weekpicker.html +0 -54
- package/src/components/input-weekpicker/input-weekpicker.stories.ts +0 -103
- package/src/components/label/label.component.html +0 -20
- package/src/components/label/label.component.ts +0 -22
- package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.html +0 -32
- package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.stories.ts +0 -57
- package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.ts +0 -48
- package/src/components/modals/feedback-modal/feedback-modal.component.html +0 -118
- package/src/components/modals/feedback-modal/feedback-modal.component.stories.ts +0 -93
- package/src/components/modals/feedback-modal/feedback-modal.component.ts +0 -187
- package/src/components/modals/help-modal/help-modal.component.html +0 -32
- package/src/components/modals/help-modal/help-modal.component.stories.ts +0 -76
- package/src/components/modals/help-modal/help-modal.component.ts +0 -54
- package/src/components/modals/information-modal/information-modal.component.html +0 -24
- package/src/components/modals/information-modal/information-modal.component.stories.ts +0 -62
- package/src/components/modals/information-modal/information-modal.component.ts +0 -35
- package/src/components/modals/main-modal/main-modal.component.html +0 -85
- package/src/components/modals/main-modal/main-modal.component.stories.ts +0 -127
- package/src/components/modals/main-modal/main-modal.component.ts +0 -85
- package/src/components/modals/notification-modal/notification-modal.component.html +0 -22
- package/src/components/modals/notification-modal/notification-modal.component.stories.ts +0 -59
- package/src/components/modals/notification-modal/notification-modal.component.ts +0 -37
- package/src/components/selectors/multiple-selector/multiple-selector.component.html +0 -51
- package/src/components/selectors/multiple-selector/multiple-selector.component.stories.ts +0 -306
- package/src/components/selectors/multiple-selector/multiple-selector.component.ts +0 -308
- package/src/components/selectors/single-selector/single-selector.component.html +0 -46
- package/src/components/selectors/single-selector/single-selector.component.stories.ts +0 -294
- package/src/components/selectors/single-selector/single-selector.component.ts +0 -239
- package/src/components/side-nav/side-nav.component.stories.ts +0 -176
- package/src/components/side-nav/side-nav.component.ts +0 -325
- package/src/components/snackbar/snackbar.component.ts +0 -150
- package/src/components/snackbar/snackbar.html +0 -21
- package/src/components/snackbar/snackbar.stories.ts +0 -51
- package/src/components/state/state.component.ts +0 -30
- package/src/components/state/state.html +0 -13
- package/src/components/state/state.stories.ts +0 -74
- package/src/components/table/table.component.html +0 -466
- package/src/components/table/table.component.scss +0 -28
- package/src/components/table/table.component.stories.ts +0 -655
- package/src/components/table/table.component.ts +0 -475
- package/src/components/tabs/tabs.component.stories.ts +0 -114
- package/src/components/tabs/tabs.component.ts +0 -69
- package/src/core/types.ts +0 -494
- package/src/public-api.ts +0 -23
- package/tsconfig.json +0 -37
- package/tsconfig.lib.json +0 -17
- package/tsconfig.lib.prod.json +0 -9
- package/tsconfig.spec.json +0 -13
|
@@ -1,475 +0,0 @@
|
|
|
1
|
-
import { Attribute, Component, EventEmitter, Input, Output } from '@angular/core';
|
|
2
|
-
import { NgClass, NgStyle } from '@angular/common';
|
|
3
|
-
import { CdkDrag, CdkDropList, DragDropModule } from '@angular/cdk/drag-drop';
|
|
4
|
-
import { FlexRenderDirective, Row, Table } from '@tanstack/angular-table';
|
|
5
|
-
import { IconComponent } from '../icon/icon.component';
|
|
6
|
-
import { ButtonComponent } from '../button/button.component';
|
|
7
|
-
import { NzTooltipModule } from 'ng-zorro-antd/tooltip';
|
|
8
|
-
import { StateComponent } from '../state/state.component';
|
|
9
|
-
import type {
|
|
10
|
-
TableActionButton,
|
|
11
|
-
TableDragDropEvent,
|
|
12
|
-
TableStateStyle,
|
|
13
|
-
TableStateStylesMap,
|
|
14
|
-
} from '../../core/types';
|
|
15
|
-
import {
|
|
16
|
-
containerShapes,
|
|
17
|
-
stateBackgroundColors,
|
|
18
|
-
stateBorderColors,
|
|
19
|
-
stateTextColors,
|
|
20
|
-
} from '../../core/types';
|
|
21
|
-
|
|
22
|
-
export type { TableActionButton, TableDragDropEvent } from '../../core/types';
|
|
23
|
-
|
|
24
|
-
@Component({
|
|
25
|
-
selector: 'ads-table',
|
|
26
|
-
standalone: true,
|
|
27
|
-
imports: [
|
|
28
|
-
DragDropModule,
|
|
29
|
-
FlexRenderDirective,
|
|
30
|
-
IconComponent,
|
|
31
|
-
ButtonComponent,
|
|
32
|
-
StateComponent,
|
|
33
|
-
NgClass,
|
|
34
|
-
NgStyle,
|
|
35
|
-
CdkDrag,
|
|
36
|
-
CdkDropList,
|
|
37
|
-
NzTooltipModule
|
|
38
|
-
],
|
|
39
|
-
templateUrl: './table.component.html',
|
|
40
|
-
styleUrl: './table.component.scss',
|
|
41
|
-
})
|
|
42
|
-
export class TableComponent {
|
|
43
|
-
readonly statusShape = containerShapes.ROUNDED;
|
|
44
|
-
|
|
45
|
-
private readonly defaultStatusStateStyles: TableStateStylesMap = {
|
|
46
|
-
Completed: {
|
|
47
|
-
borderColor: stateBorderColors.BORDER_GREEN1,
|
|
48
|
-
bgColor: stateBackgroundColors.BG_GREEN1,
|
|
49
|
-
textColor: stateTextColors.TEXT_GREEN6,
|
|
50
|
-
shape: containerShapes.ROUNDED,
|
|
51
|
-
boldText: true,
|
|
52
|
-
fullWidth: false,
|
|
53
|
-
},
|
|
54
|
-
Pending: {
|
|
55
|
-
borderColor: stateBorderColors.BORDER_YELLOW2,
|
|
56
|
-
bgColor: stateBackgroundColors.BG_YELLOW1,
|
|
57
|
-
textColor: stateTextColors.WHITE,
|
|
58
|
-
shape: containerShapes.ROUNDED,
|
|
59
|
-
boldText: true,
|
|
60
|
-
fullWidth: false,
|
|
61
|
-
},
|
|
62
|
-
'On hold': {
|
|
63
|
-
borderColor: stateBorderColors.BORDER_RED3,
|
|
64
|
-
bgColor: stateBackgroundColors.BG_RED1,
|
|
65
|
-
textColor: stateTextColors.TEXT_RED5,
|
|
66
|
-
shape: containerShapes.ROUNDED,
|
|
67
|
-
boldText: true,
|
|
68
|
-
fullWidth: false,
|
|
69
|
-
},
|
|
70
|
-
default: {
|
|
71
|
-
borderColor: stateBorderColors.BORDER_AQUA1,
|
|
72
|
-
bgColor: stateBackgroundColors.BG_AQUA1,
|
|
73
|
-
textColor: stateTextColors.TEXT_AQUA6,
|
|
74
|
-
shape: containerShapes.ROUNDED,
|
|
75
|
-
boldText: true,
|
|
76
|
-
fullWidth: false,
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
private readonly defaultActiveStateStyles: TableStateStylesMap = {
|
|
81
|
-
true: {
|
|
82
|
-
text: 'Yes',
|
|
83
|
-
borderColor: stateBorderColors.BORDER_GREEN1,
|
|
84
|
-
bgColor: stateBackgroundColors.BG_GREEN1,
|
|
85
|
-
textColor: stateTextColors.TEXT_GREEN6,
|
|
86
|
-
shape: containerShapes.ROUNDED,
|
|
87
|
-
boldText: true,
|
|
88
|
-
fullWidth: false,
|
|
89
|
-
},
|
|
90
|
-
false: {
|
|
91
|
-
text: 'No',
|
|
92
|
-
borderColor: stateBorderColors.NEUTRAL,
|
|
93
|
-
bgColor: stateBackgroundColors.NEUTRAL,
|
|
94
|
-
textColor: stateTextColors.BLACK,
|
|
95
|
-
shape: containerShapes.ROUNDED,
|
|
96
|
-
boldText: true,
|
|
97
|
-
fullWidth: false,
|
|
98
|
-
},
|
|
99
|
-
default: {
|
|
100
|
-
borderColor: stateBorderColors.BORDER_AQUA1,
|
|
101
|
-
bgColor: stateBackgroundColors.BG_AQUA1,
|
|
102
|
-
textColor: stateTextColors.TEXT_AQUA6,
|
|
103
|
-
shape: containerShapes.ROUNDED,
|
|
104
|
-
boldText: true,
|
|
105
|
-
fullWidth: false,
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
@Output() sortEvent = new EventEmitter<any>();
|
|
110
|
-
@Output() columnOrderChange = new EventEmitter<TableDragDropEvent>();
|
|
111
|
-
@Output() pageChange = new EventEmitter<number>();
|
|
112
|
-
@Output() columnSizingChange = new EventEmitter<{ [key: string]: number }>();
|
|
113
|
-
@Output() pageSizeChange = new EventEmitter<number>();
|
|
114
|
-
@Output() multiSortEvent = new EventEmitter<any>();
|
|
115
|
-
|
|
116
|
-
@Input() table: Table<any> | null = null;
|
|
117
|
-
@Input() isLoading = false;
|
|
118
|
-
@Input() selectedSortingHeader = '';
|
|
119
|
-
@Input() sortDirection: string | null = null;
|
|
120
|
-
@Input() showButtons = true;
|
|
121
|
-
@Input() allContentLeft = false;
|
|
122
|
-
@Input() totalRegisters = 0;
|
|
123
|
-
@Input() areColumnsDraggable = true;
|
|
124
|
-
@Input() currentPage = 1;
|
|
125
|
-
@Input() totalPages = 1;
|
|
126
|
-
@Input() pageSize = 25;
|
|
127
|
-
@Input() enableMultiSort = false;
|
|
128
|
-
@Input() multiSortCriteria: Array<{ field: string; direction: string }> = [];
|
|
129
|
-
@Input() actionButtons: TableActionButton[] = [];
|
|
130
|
-
@Input() statusStateStyles: TableStateStylesMap = this.defaultStatusStateStyles;
|
|
131
|
-
@Input() activeStateStyles: TableStateStylesMap = this.defaultActiveStateStyles;
|
|
132
|
-
|
|
133
|
-
headerRenderVersion = 0;
|
|
134
|
-
|
|
135
|
-
constructor(@Attribute('data-testid') private readonly hostTestId: string | null) {}
|
|
136
|
-
|
|
137
|
-
get testId(): string {
|
|
138
|
-
return this.hostTestId || 'data-table';
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
get contentTestId(): string {
|
|
142
|
-
return `${this.testId}-content`;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
getHeaderGroups(): Array<{ headers: any[] }> {
|
|
146
|
-
return this.table?.getHeaderGroups?.() ?? [];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
getHeaderCells(): any[] {
|
|
150
|
-
return this.getHeaderGroups()[0]?.headers ?? [];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
getRows(): Row<any>[] {
|
|
154
|
-
return this.table?.getRowModel?.()?.rows ?? [];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
getOriginalColumnProperty(column: any): string {
|
|
158
|
-
return column?.column?.columnDef?.meta?.originalProperty ?? column?.id ?? '';
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
isColumnSortable(column: any): boolean {
|
|
162
|
-
return Boolean(column?.column?.columnDef?.meta?.isSortable);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
isStatusColumn(column: any): boolean {
|
|
166
|
-
const property = this.getOriginalColumnProperty(column)?.toLowerCase?.() ?? '';
|
|
167
|
-
const id = column?.id?.toLowerCase?.() ?? '';
|
|
168
|
-
const type = column?.column?.columnDef?.meta?.propertyType?.toLowerCase?.() ?? '';
|
|
169
|
-
|
|
170
|
-
return property === 'status' || id === 'status' || type === 'status';
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
columnDirectionByType(column: any): string {
|
|
174
|
-
if (this.isStatusColumn(column)) {
|
|
175
|
-
return 'center';
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const colType = column?.column?.columnDef?.meta?.propertyType;
|
|
179
|
-
|
|
180
|
-
if (colType === 'number' || colType === 'currency' || colType === 'date') {
|
|
181
|
-
return 'right';
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (colType === 'boolean') {
|
|
185
|
-
return 'center';
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return 'left';
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
trackByFn(index: number, row: Row<any>): string | number {
|
|
192
|
-
return row?.original?.id ?? index;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
sort(column: any, event: MouseEvent): void {
|
|
196
|
-
if (this.enableMultiSort && event.shiftKey) {
|
|
197
|
-
this.multiSortEvent.emit(column);
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
this.sortEvent.emit(column);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
getSortEntry(column: any): { index: number; direction: string } | null {
|
|
205
|
-
const property = this.getOriginalColumnProperty(column);
|
|
206
|
-
|
|
207
|
-
if (this.multiSortCriteria.length > 0) {
|
|
208
|
-
const index = this.multiSortCriteria.findIndex((criterion) => criterion.field === property);
|
|
209
|
-
|
|
210
|
-
if (index === -1) {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return { index, direction: this.multiSortCriteria[index].direction };
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (property === this.selectedSortingHeader && this.sortDirection) {
|
|
218
|
-
return { index: 0, direction: this.sortDirection };
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
drop(event: { previousIndex: number; currentIndex: number }): void {
|
|
225
|
-
this.columnOrderChange.emit({
|
|
226
|
-
previousIndex: event.previousIndex,
|
|
227
|
-
currentIndex: event.currentIndex,
|
|
228
|
-
});
|
|
229
|
-
this.headerRenderVersion += 1;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
previousPage(): void {
|
|
233
|
-
if (this.currentPage > 1) {
|
|
234
|
-
this.pageChange.emit(this.currentPage - 1);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
nextPage(): void {
|
|
239
|
-
if (this.currentPage < this.totalPages) {
|
|
240
|
-
this.pageChange.emit(this.currentPage + 1);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
goToPage(page: number): void {
|
|
245
|
-
if (page >= 1 && page <= this.totalPages && page !== this.currentPage) {
|
|
246
|
-
this.pageChange.emit(page);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
getPageNumbers(): (number | null)[] {
|
|
251
|
-
const total = this.totalPages;
|
|
252
|
-
const current = this.currentPage;
|
|
253
|
-
|
|
254
|
-
if (total <= 6) {
|
|
255
|
-
return Array.from({ length: total }, (_, index) => index + 1);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (current <= 3) {
|
|
259
|
-
return [1, 2, 3, null, total];
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (current >= total - 2) {
|
|
263
|
-
return [1, null, total - 2, total - 1, total];
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return [1, null, current - 1, current, current + 1, null, total];
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
startResize(event: MouseEvent | TouchEvent, column: any): void {
|
|
270
|
-
event.preventDefault();
|
|
271
|
-
event.stopPropagation();
|
|
272
|
-
|
|
273
|
-
const startX = (event instanceof MouseEvent ? event.clientX : event.touches[0].clientX) ?? 0;
|
|
274
|
-
const startWidth = column.getSize();
|
|
275
|
-
|
|
276
|
-
const handlePointerMove = (moveEvent: MouseEvent | TouchEvent): void => {
|
|
277
|
-
const currentX = (moveEvent instanceof MouseEvent ? moveEvent.clientX : moveEvent.touches?.[0]?.clientX) ?? 0;
|
|
278
|
-
const delta = currentX - startX;
|
|
279
|
-
const newWidth = Math.max(80, Math.min(300, startWidth + delta));
|
|
280
|
-
|
|
281
|
-
const currentSizing = this.table?.getState?.().columnSizing ?? {};
|
|
282
|
-
this.columnSizingChange.emit({
|
|
283
|
-
...currentSizing,
|
|
284
|
-
[column.id]: newWidth,
|
|
285
|
-
});
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
const stopResize = (): void => {
|
|
289
|
-
document.removeEventListener('mousemove', handlePointerMove);
|
|
290
|
-
document.removeEventListener('touchmove', handlePointerMove);
|
|
291
|
-
document.removeEventListener('mouseup', stopResize);
|
|
292
|
-
document.removeEventListener('touchend', stopResize);
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
document.addEventListener('mousemove', handlePointerMove);
|
|
296
|
-
document.addEventListener('touchmove', handlePointerMove);
|
|
297
|
-
document.addEventListener('mouseup', stopResize);
|
|
298
|
-
document.addEventListener('touchend', stopResize);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
getColumnHeaderStyles(column: any): { [key: string]: any } {
|
|
302
|
-
const baseStyles = {
|
|
303
|
-
width: `${column.getSize()}px`,
|
|
304
|
-
position: 'relative',
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
if (this.allContentLeft) {
|
|
308
|
-
return {
|
|
309
|
-
...baseStyles,
|
|
310
|
-
'text-align': 'left',
|
|
311
|
-
padding: '0.5rem 0',
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return baseStyles;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
getTooltipText(button: TableActionButton, row: any): string {
|
|
319
|
-
return typeof button.tooltip === 'function' ? button.tooltip(row) : button.tooltip;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
isActionButtonDisabled(button: TableActionButton, row: any): boolean {
|
|
323
|
-
return button.disabled ? button.disabled(row) : false;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
iconNameFor(value: string): any {
|
|
327
|
-
return value as any;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
getHeaderTestId(column: any): string {
|
|
331
|
-
return `${this.contentTestId}-header-${column.id}`;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
getRowTestId(row: Row<any>, index: number): string {
|
|
335
|
-
return `${this.contentTestId}-row-${row.original?.id ?? index}`;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
getActionButtonTestId(row: Row<any>, button: TableActionButton, index: number): string {
|
|
339
|
-
return `${this.contentTestId}-action-${row.original?.id ?? 'row'}-${button.icon}-${index}`;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
onPageSizeChange(event: Event): void {
|
|
343
|
-
const select = event.target as HTMLSelectElement;
|
|
344
|
-
this.pageSizeChange.emit(Number(select.value));
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
headerAlignmentClass(column: any): string {
|
|
348
|
-
if (this.isStatusColumn(column)) {
|
|
349
|
-
return 'justify-center text-center';
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
const direction = this.columnDirectionByType(column);
|
|
353
|
-
|
|
354
|
-
if (this.allContentLeft) {
|
|
355
|
-
return 'justify-start text-left';
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (direction === 'right') {
|
|
359
|
-
return 'justify-end text-right';
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
if (direction === 'center') {
|
|
363
|
-
return 'justify-center text-center';
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
return 'justify-start text-left';
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
isSortIconLeading(column: any): boolean {
|
|
370
|
-
if (this.allContentLeft) {
|
|
371
|
-
return false;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
return this.columnDirectionByType(column) === 'right';
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
cellAlignmentClass(column: any): string {
|
|
378
|
-
if (this.isStatusColumn(column)) {
|
|
379
|
-
return 'justify-center text-center';
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
const direction = this.columnDirectionByType(column);
|
|
383
|
-
|
|
384
|
-
if (this.allContentLeft) {
|
|
385
|
-
return 'justify-start text-left px-0';
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (direction === 'right') {
|
|
389
|
-
return 'justify-end text-right';
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
if (direction === 'center') {
|
|
393
|
-
return 'justify-center text-center';
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
return 'justify-start text-left';
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
isStatusCell(cell: any): boolean {
|
|
400
|
-
const property = cell?.column?.columnDef?.meta?.originalProperty?.toLowerCase?.() ?? '';
|
|
401
|
-
const id = cell?.column?.id?.toLowerCase?.() ?? '';
|
|
402
|
-
const type = cell?.column?.columnDef?.meta?.propertyType?.toLowerCase?.() ?? '';
|
|
403
|
-
|
|
404
|
-
return property === 'status' || id === 'status' || type === 'status';
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
isActiveCell(cell: any): boolean {
|
|
408
|
-
const property = cell?.column?.columnDef?.meta?.originalProperty?.toLowerCase?.() ?? '';
|
|
409
|
-
const id = cell?.column?.id?.toLowerCase?.() ?? '';
|
|
410
|
-
const type = cell?.column?.columnDef?.meta?.propertyType?.toLowerCase?.() ?? '';
|
|
411
|
-
|
|
412
|
-
return property === 'active' || id === 'active' || type === 'boolean';
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
isStateCell(cell: any): boolean {
|
|
416
|
-
return this.isStatusCell(cell) || this.isActiveCell(cell);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
getCellText(cell: any): string {
|
|
420
|
-
const value = cell?.getContext?.()?.getValue?.();
|
|
421
|
-
return String(value ?? '');
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
getStateStyle(cell: any): TableStateStyle {
|
|
425
|
-
const rawValue = cell?.getContext?.()?.getValue?.();
|
|
426
|
-
|
|
427
|
-
if (this.isActiveCell(cell)) {
|
|
428
|
-
const key = String(Boolean(rawValue));
|
|
429
|
-
return this.activeStateStyles[key] ?? this.activeStateStyles['default'] ?? this.defaultActiveStateStyles['default'];
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
const key = String(rawValue ?? '');
|
|
433
|
-
return this.statusStateStyles[key] ?? this.statusStateStyles['default'] ?? this.defaultStatusStateStyles['default'];
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
getStateText(cell: any): string {
|
|
437
|
-
const style = this.getStateStyle(cell);
|
|
438
|
-
|
|
439
|
-
if (style.text) {
|
|
440
|
-
return style.text;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (this.isActiveCell(cell)) {
|
|
444
|
-
const rawValue = cell?.getContext?.()?.getValue?.();
|
|
445
|
-
return Boolean(rawValue) ? 'Yes' : 'No';
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
return this.getCellText(cell);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
getStatusBorderColor(status: string): stateBorderColors {
|
|
452
|
-
if (status === 'Completed') return stateBorderColors.BORDER_GREEN1;
|
|
453
|
-
if (status === 'Pending') return stateBorderColors.BORDER_YELLOW2;
|
|
454
|
-
if (status === 'On hold') return stateBorderColors.BORDER_RED3;
|
|
455
|
-
return stateBorderColors.BORDER_AQUA1;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
getStatusBackgroundColor(status: string): stateBackgroundColors {
|
|
459
|
-
if (status === 'Completed') return stateBackgroundColors.BG_GREEN1;
|
|
460
|
-
if (status === 'Pending') return stateBackgroundColors.BG_YELLOW1;
|
|
461
|
-
if (status === 'On hold') return stateBackgroundColors.BG_RED1;
|
|
462
|
-
return stateBackgroundColors.BG_AQUA1;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
getStatusTextColor(status: string): stateTextColors {
|
|
466
|
-
if (status === 'Completed') return stateTextColors.TEXT_GREEN6;
|
|
467
|
-
if (status === 'Pending') return stateTextColors.WHITE;
|
|
468
|
-
if (status === 'On hold') return stateTextColors.TEXT_RED5;
|
|
469
|
-
return stateTextColors.TEXT_AQUA6;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
getEmptyColspan(): number {
|
|
473
|
-
return this.getHeaderCells().length + (this.showButtons ? 1 : 0);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/angular';
|
|
2
|
-
import { TabsComponent } from './tabs.component';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<TabsComponent> = {
|
|
5
|
-
title: 'Components/Tabs',
|
|
6
|
-
component: TabsComponent,
|
|
7
|
-
argTypes: {
|
|
8
|
-
selectedTabId: {
|
|
9
|
-
control: 'select',
|
|
10
|
-
description: 'The ID of the currently selected tab',
|
|
11
|
-
},
|
|
12
|
-
tabChanged: {
|
|
13
|
-
action: 'tabChanged',
|
|
14
|
-
description: 'Emitted when a tab is selected',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
render: (args) => ({
|
|
18
|
-
props: {
|
|
19
|
-
...args,
|
|
20
|
-
onTabChange: (tabId: string) => {
|
|
21
|
-
console.log('Tab changed to:', tabId);
|
|
22
|
-
args.selectedTabId = tabId;
|
|
23
|
-
args.tabChanged(tabId);
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
template: `
|
|
27
|
-
<ads-tabs
|
|
28
|
-
[tabs]="tabs"
|
|
29
|
-
[selectedTabId]="selectedTabId"
|
|
30
|
-
(tabChanged)="onTabChange($event)"
|
|
31
|
-
></ads-tabs>
|
|
32
|
-
<div style="margin-top: 1rem; padding: 1rem; background: #f5f5f5; border-radius: 0.5rem;">
|
|
33
|
-
<p><strong>Selected Tab ID:</strong> {{ selectedTabId }}</p>
|
|
34
|
-
</div>
|
|
35
|
-
`,
|
|
36
|
-
}),
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default meta;
|
|
40
|
-
type Story = StoryObj<TabsComponent>;
|
|
41
|
-
|
|
42
|
-
export const Default: Story = {
|
|
43
|
-
args: {
|
|
44
|
-
tabs: [
|
|
45
|
-
{ id: 'shift-1', name: 'Morning' },
|
|
46
|
-
{ id: 'shift-2', name: 'Afternoon' },
|
|
47
|
-
{ id: 'shift-3', name: 'Evening' },
|
|
48
|
-
],
|
|
49
|
-
selectedTabId: 'shift-1',
|
|
50
|
-
},
|
|
51
|
-
argTypes: {
|
|
52
|
-
selectedTabId: {
|
|
53
|
-
control: 'select',
|
|
54
|
-
options: ['shift-1', 'shift-2', 'shift-3'],
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const MultipleShifts: Story = {
|
|
60
|
-
args: {
|
|
61
|
-
tabs: [
|
|
62
|
-
{ id: 'shift-monday', name: 'Monday' },
|
|
63
|
-
{ id: 'shift-tuesday', name: 'Tuesday' },
|
|
64
|
-
{ id: 'shift-wednesday', name: 'Wednesday' },
|
|
65
|
-
{ id: 'shift-thursday', name: 'Thursday' },
|
|
66
|
-
{ id: 'shift-friday', name: 'Friday' },
|
|
67
|
-
{ id: 'shift-saturday', name: 'Saturday' },
|
|
68
|
-
],
|
|
69
|
-
selectedTabId: 'shift-monday',
|
|
70
|
-
},
|
|
71
|
-
argTypes: {
|
|
72
|
-
selectedTabId: {
|
|
73
|
-
control: 'select',
|
|
74
|
-
options: [
|
|
75
|
-
'shift-monday',
|
|
76
|
-
'shift-tuesday',
|
|
77
|
-
'shift-wednesday',
|
|
78
|
-
'shift-thursday',
|
|
79
|
-
'shift-friday',
|
|
80
|
-
'shift-saturday',
|
|
81
|
-
],
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const LongTabNames: Story = {
|
|
87
|
-
args: {
|
|
88
|
-
tabs: [
|
|
89
|
-
{ id: 'shift-1', name: 'Morning Shift - 6:00 AM' },
|
|
90
|
-
{ id: 'shift-2', name: 'Afternoon Shift - 2:00 PM' },
|
|
91
|
-
{ id: 'shift-3', name: 'Evening Shift - 8:00 PM' },
|
|
92
|
-
],
|
|
93
|
-
selectedTabId: 'shift-2',
|
|
94
|
-
},
|
|
95
|
-
argTypes: {
|
|
96
|
-
selectedTabId: {
|
|
97
|
-
control: 'select',
|
|
98
|
-
options: ['shift-1', 'shift-2', 'shift-3'],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export const SingleTab: Story = {
|
|
104
|
-
args: {
|
|
105
|
-
tabs: [{ id: 'only-shift', name: 'Dialysis Shift' }],
|
|
106
|
-
selectedTabId: 'only-shift',
|
|
107
|
-
},
|
|
108
|
-
argTypes: {
|
|
109
|
-
selectedTabId: {
|
|
110
|
-
control: 'select',
|
|
111
|
-
options: ['only-shift'],
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { NgClass } from '@angular/common';
|
|
2
|
-
import { Component, input, output } from '@angular/core';
|
|
3
|
-
import { Tab } from '../../core/types';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'ads-tabs',
|
|
7
|
-
standalone: true,
|
|
8
|
-
imports: [NgClass],
|
|
9
|
-
template: `
|
|
10
|
-
<div class="w-full flex items-center justify-between">
|
|
11
|
-
<div
|
|
12
|
-
class="flex w-full h-full overflow-y-hidden overflow-x-auto border border-neutral-disabled-bg rounded-[0.62rem] scrollbar-green min-w-30"
|
|
13
|
-
>
|
|
14
|
-
@for (tab of tabs(); track tab.id) {
|
|
15
|
-
<button
|
|
16
|
-
class="cursor-pointer border-none flex-1 min-w-44 px-6 h-10 bg-white transition-all duration-300 text-green-base font-normal text-base whitespace-nowrap hover:brightness-90"
|
|
17
|
-
[ngClass]="{
|
|
18
|
-
'tab-active': selectedTabId() === tab.id,
|
|
19
|
-
}"
|
|
20
|
-
(click)="selectTab(tab.id)"
|
|
21
|
-
[attr.data-testid]="'tab-button-' + tab.id"
|
|
22
|
-
type="button"
|
|
23
|
-
>
|
|
24
|
-
{{ tab.name }}
|
|
25
|
-
</button>
|
|
26
|
-
}
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
`,
|
|
30
|
-
styles: [
|
|
31
|
-
`
|
|
32
|
-
.scrollbar-green::-webkit-scrollbar {
|
|
33
|
-
height: 3px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.scrollbar-green::-webkit-scrollbar-track {
|
|
37
|
-
background: transparent;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.scrollbar-green::-webkit-scrollbar-thumb {
|
|
41
|
-
background: #014744;
|
|
42
|
-
border-radius: 3px;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.scrollbar-green::-webkit-scrollbar-thumb:hover {
|
|
46
|
-
background: #012f2d;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.scrollbar-green {
|
|
50
|
-
scrollbar-width: thin;
|
|
51
|
-
scrollbar-color: #014744 transparent;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.tab-active {
|
|
55
|
-
background-color: #ddf0ef;
|
|
56
|
-
}
|
|
57
|
-
`,
|
|
58
|
-
],
|
|
59
|
-
})
|
|
60
|
-
export class TabsComponent {
|
|
61
|
-
tabs = input.required<Tab[]>();
|
|
62
|
-
selectedTabId = input<string>('');
|
|
63
|
-
|
|
64
|
-
tabChanged = output<string>();
|
|
65
|
-
|
|
66
|
-
selectTab(tabId: string): void {
|
|
67
|
-
this.tabChanged.emit(tabId);
|
|
68
|
-
}
|
|
69
|
-
}
|