@aaamb/ngx-design-system 1.3.9 → 1.4.1

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 (108) hide show
  1. package/.editorconfig +17 -0
  2. package/.nvmrc +1 -0
  3. package/.postcssrc.json +5 -0
  4. package/.storybook/main.ts +20 -0
  5. package/.storybook/preview.ts +23 -0
  6. package/.storybook/storybook.css +1 -0
  7. package/.storybook/tsconfig.json +19 -0
  8. package/.vscode/extensions.json +4 -0
  9. package/.vscode/launch.json +20 -0
  10. package/.vscode/tasks.json +42 -0
  11. package/CHANGELOG.md +10 -0
  12. package/LOCAL_DEVELOPMENT.md +129 -0
  13. package/angular.json +74 -0
  14. package/bitbucket-pipelines.yml +41 -0
  15. package/iac/bin/app.ts +42 -0
  16. package/iac/cdk.json +82 -0
  17. package/iac/lib/config/environments.ts +19 -0
  18. package/iac/lib/config/types.ts +13 -0
  19. package/iac/lib/stacks/certificate-stack.ts +34 -0
  20. package/iac/lib/stacks/frontend-stack.ts +120 -0
  21. package/iac/lib/stacks/index.ts +2 -0
  22. package/iac/package-lock.json +726 -0
  23. package/iac/package.json +25 -0
  24. package/iac/tsconfig.json +24 -0
  25. package/ng-package.json +8 -0
  26. package/package.json +58 -14
  27. package/src/components/button/button-green.stories.ts +101 -0
  28. package/src/components/button/button-text.stories.ts +105 -0
  29. package/src/components/button/button-white.stories.ts +105 -0
  30. package/src/components/button/button.component.stories.ts +91 -0
  31. package/src/components/button/button.component.ts +93 -0
  32. package/src/components/checkbox/checkbox.component.html +30 -0
  33. package/src/components/checkbox/checkbox.component.stories.ts +183 -0
  34. package/src/components/checkbox/checkbox.component.ts +211 -0
  35. package/src/components/datepicker-selector/datepicker-selector.component.html +103 -0
  36. package/src/components/datepicker-selector/datepicker-selector.component.stories.ts +123 -0
  37. package/src/components/datepicker-selector/datepicker-selector.component.ts +337 -0
  38. package/src/components/error-message/error-message.component.html +3 -0
  39. package/src/components/error-message/error-message.component.ts +13 -0
  40. package/src/components/filter-button/filter-button.component.html +286 -0
  41. package/src/components/filter-button/filter-button.component.stories.ts +123 -0
  42. package/src/components/filter-button/filter-button.component.ts +582 -0
  43. package/src/components/icon/icon.component.ts +20 -0
  44. package/src/components/icon/icon.html +1424 -0
  45. package/src/components/icon/icon.stories.ts +49 -0
  46. package/src/components/icon/icons-list.stories.ts +42 -0
  47. package/src/components/input/input.component.stories.ts +101 -0
  48. package/src/components/input/input.component.ts +317 -0
  49. package/src/components/input/input.html +160 -0
  50. package/src/components/input-datepicker/input-datepicker.component.ts +356 -0
  51. package/src/components/input-datepicker/input-datepicker.html +69 -0
  52. package/src/components/input-datepicker/input-datepicker.stories.ts +99 -0
  53. package/src/components/input-rangepicker/input-rangepicker.component.ts +365 -0
  54. package/src/components/input-rangepicker/input-rangepicker.html +54 -0
  55. package/src/components/input-rangepicker/input-rangepicker.stories.ts +88 -0
  56. package/src/components/input-weekpicker/input-weekpicker.component.ts +417 -0
  57. package/src/components/input-weekpicker/input-weekpicker.html +54 -0
  58. package/src/components/input-weekpicker/input-weekpicker.stories.ts +103 -0
  59. package/src/components/label/label.component.html +20 -0
  60. package/src/components/label/label.component.ts +22 -0
  61. package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.html +32 -0
  62. package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.stories.ts +57 -0
  63. package/src/components/modals/delicate-confirmation-modal/delicate-confirmation-modal.component.ts +48 -0
  64. package/src/components/modals/feedback-modal/feedback-modal.component.html +118 -0
  65. package/src/components/modals/feedback-modal/feedback-modal.component.stories.ts +93 -0
  66. package/src/components/modals/feedback-modal/feedback-modal.component.ts +187 -0
  67. package/src/components/modals/help-modal/help-modal.component.html +32 -0
  68. package/src/components/modals/help-modal/help-modal.component.stories.ts +76 -0
  69. package/src/components/modals/help-modal/help-modal.component.ts +54 -0
  70. package/src/components/modals/information-modal/information-modal.component.html +24 -0
  71. package/src/components/modals/information-modal/information-modal.component.stories.ts +62 -0
  72. package/src/components/modals/information-modal/information-modal.component.ts +35 -0
  73. package/src/components/modals/main-modal/main-modal.component.html +85 -0
  74. package/src/components/modals/main-modal/main-modal.component.stories.ts +127 -0
  75. package/src/components/modals/main-modal/main-modal.component.ts +85 -0
  76. package/src/components/modals/notification-modal/notification-modal.component.html +22 -0
  77. package/src/components/modals/notification-modal/notification-modal.component.stories.ts +59 -0
  78. package/src/components/modals/notification-modal/notification-modal.component.ts +37 -0
  79. package/src/components/selectors/multiple-selector/multiple-selector.component.html +51 -0
  80. package/src/components/selectors/multiple-selector/multiple-selector.component.stories.ts +306 -0
  81. package/src/components/selectors/multiple-selector/multiple-selector.component.ts +308 -0
  82. package/src/components/selectors/single-selector/single-selector.component.html +46 -0
  83. package/src/components/selectors/single-selector/single-selector.component.stories.ts +294 -0
  84. package/src/components/selectors/single-selector/single-selector.component.ts +239 -0
  85. package/src/components/side-nav/side-nav.component.stories.ts +176 -0
  86. package/src/components/side-nav/side-nav.component.ts +325 -0
  87. package/src/components/snackbar/snackbar.component.ts +150 -0
  88. package/src/components/snackbar/snackbar.html +21 -0
  89. package/src/components/snackbar/snackbar.stories.ts +51 -0
  90. package/src/components/state/state.component.ts +30 -0
  91. package/src/components/state/state.html +13 -0
  92. package/src/components/state/state.stories.ts +74 -0
  93. package/src/components/table/table.component.html +466 -0
  94. package/src/components/table/table.component.scss +28 -0
  95. package/src/components/table/table.component.stories.ts +655 -0
  96. package/src/components/table/table.component.ts +475 -0
  97. package/src/components/tabs/tabs.component.stories.ts +114 -0
  98. package/src/components/tabs/tabs.component.ts +69 -0
  99. package/src/core/types.ts +494 -0
  100. package/src/public-api.ts +23 -0
  101. package/tsconfig.json +37 -0
  102. package/tsconfig.lib.json +17 -0
  103. package/tsconfig.lib.prod.json +9 -0
  104. package/tsconfig.spec.json +13 -0
  105. package/fesm2022/aaamb-ngx-design-system.mjs +0 -4075
  106. package/fesm2022/aaamb-ngx-design-system.mjs.map +0 -1
  107. package/styles/compiled.css +0 -2
  108. package/types/aaamb-ngx-design-system.d.ts +0 -1142
@@ -0,0 +1,475 @@
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
+ }
@@ -0,0 +1,114 @@
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
+ };
@@ -0,0 +1,69 @@
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
+ }