@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,655 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/angular';
|
|
2
|
-
import type { Table } from '@tanstack/angular-table';
|
|
3
|
-
import { TableComponent } from './table.component';
|
|
4
|
-
import type {
|
|
5
|
-
StoryTable,
|
|
6
|
-
StoryTableCellContext,
|
|
7
|
-
StoryTableColumn,
|
|
8
|
-
StoryTableRow,
|
|
9
|
-
StoryTableRowData,
|
|
10
|
-
TableActionButton,
|
|
11
|
-
TableDragDropEvent,
|
|
12
|
-
TableStateStylesMap,
|
|
13
|
-
TableSortCriterion,
|
|
14
|
-
TableSortDirection,
|
|
15
|
-
} from '../../core/types';
|
|
16
|
-
import {
|
|
17
|
-
containerShapes,
|
|
18
|
-
stateBackgroundColors,
|
|
19
|
-
stateBorderColors,
|
|
20
|
-
stateTextColors,
|
|
21
|
-
} from '../../core/types';
|
|
22
|
-
|
|
23
|
-
type TableStoryArgs = TableComponent & {
|
|
24
|
-
demoRows: StoryTableRowData[];
|
|
25
|
-
disableActionButtons: boolean;
|
|
26
|
-
statusStateStyles: TableStateStylesMap;
|
|
27
|
-
activeStateStyles: TableStateStylesMap;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const defaultStatusStateStyles: TableStateStylesMap = {
|
|
31
|
-
Completed: {
|
|
32
|
-
borderColor: stateBorderColors.BORDER_GREEN1,
|
|
33
|
-
bgColor: stateBackgroundColors.BG_GREEN1,
|
|
34
|
-
textColor: stateTextColors.TEXT_GREEN6,
|
|
35
|
-
shape: containerShapes.ROUNDED,
|
|
36
|
-
boldText: true,
|
|
37
|
-
fullWidth: false,
|
|
38
|
-
},
|
|
39
|
-
Pending: {
|
|
40
|
-
borderColor: stateBorderColors.BORDER_YELLOW2,
|
|
41
|
-
bgColor: stateBackgroundColors.BG_YELLOW1,
|
|
42
|
-
textColor: stateTextColors.WHITE,
|
|
43
|
-
shape: containerShapes.ROUNDED,
|
|
44
|
-
boldText: true,
|
|
45
|
-
fullWidth: false,
|
|
46
|
-
},
|
|
47
|
-
'On hold': {
|
|
48
|
-
borderColor: stateBorderColors.BORDER_RED3,
|
|
49
|
-
bgColor: stateBackgroundColors.BG_RED1,
|
|
50
|
-
textColor: stateTextColors.TEXT_RED5,
|
|
51
|
-
shape: containerShapes.ROUNDED,
|
|
52
|
-
boldText: true,
|
|
53
|
-
fullWidth: false,
|
|
54
|
-
},
|
|
55
|
-
default: {
|
|
56
|
-
borderColor: stateBorderColors.BORDER_AQUA1,
|
|
57
|
-
bgColor: stateBackgroundColors.BG_AQUA1,
|
|
58
|
-
textColor: stateTextColors.TEXT_AQUA6,
|
|
59
|
-
shape: containerShapes.ROUNDED,
|
|
60
|
-
boldText: true,
|
|
61
|
-
fullWidth: false,
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const defaultActiveStateStyles: TableStateStylesMap = {
|
|
66
|
-
true: {
|
|
67
|
-
text: 'Yes',
|
|
68
|
-
borderColor: stateBorderColors.BORDER_GREEN1,
|
|
69
|
-
bgColor: stateBackgroundColors.BG_GREEN1,
|
|
70
|
-
textColor: stateTextColors.TEXT_GREEN6,
|
|
71
|
-
shape: containerShapes.ROUNDED,
|
|
72
|
-
boldText: true,
|
|
73
|
-
fullWidth: false,
|
|
74
|
-
},
|
|
75
|
-
false: {
|
|
76
|
-
text: 'No',
|
|
77
|
-
borderColor: stateBorderColors.NEUTRAL,
|
|
78
|
-
bgColor: stateBackgroundColors.NEUTRAL,
|
|
79
|
-
textColor: stateTextColors.BLACK,
|
|
80
|
-
shape: containerShapes.ROUNDED,
|
|
81
|
-
boldText: true,
|
|
82
|
-
fullWidth: false,
|
|
83
|
-
},
|
|
84
|
-
default: {
|
|
85
|
-
borderColor: stateBorderColors.BORDER_AQUA1,
|
|
86
|
-
bgColor: stateBackgroundColors.BG_AQUA1,
|
|
87
|
-
textColor: stateTextColors.TEXT_AQUA6,
|
|
88
|
-
shape: containerShapes.ROUNDED,
|
|
89
|
-
boldText: true,
|
|
90
|
-
fullWidth: false,
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const columns: StoryTableColumn[] = [
|
|
95
|
-
{
|
|
96
|
-
id: 'patient',
|
|
97
|
-
header: 'Patient',
|
|
98
|
-
size: 220,
|
|
99
|
-
meta: {
|
|
100
|
-
originalProperty: 'patient',
|
|
101
|
-
isSortable: true,
|
|
102
|
-
propertyType: 'text',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
id: 'encounter',
|
|
107
|
-
header: 'Encounter',
|
|
108
|
-
size: 160,
|
|
109
|
-
meta: {
|
|
110
|
-
originalProperty: 'encounter',
|
|
111
|
-
isSortable: true,
|
|
112
|
-
propertyType: 'date',
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
id: 'amount',
|
|
117
|
-
header: 'Amount',
|
|
118
|
-
size: 130,
|
|
119
|
-
meta: {
|
|
120
|
-
originalProperty: 'amount',
|
|
121
|
-
isSortable: true,
|
|
122
|
-
propertyType: 'currency',
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
id: 'status',
|
|
127
|
-
header: 'Status',
|
|
128
|
-
size: 140,
|
|
129
|
-
meta: {
|
|
130
|
-
originalProperty: 'status',
|
|
131
|
-
isSortable: false,
|
|
132
|
-
propertyType: 'status',
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
id: 'active',
|
|
137
|
-
header: 'Active',
|
|
138
|
-
size: 100,
|
|
139
|
-
meta: {
|
|
140
|
-
originalProperty: 'active',
|
|
141
|
-
isSortable: true,
|
|
142
|
-
propertyType: 'boolean',
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
];
|
|
146
|
-
|
|
147
|
-
const rows: StoryTableRowData[] = [
|
|
148
|
-
{
|
|
149
|
-
id: 1001,
|
|
150
|
-
patient: 'Marina Alvarez',
|
|
151
|
-
encounter: '04/08/2026',
|
|
152
|
-
amount: '$1,240.00',
|
|
153
|
-
status: 'Ready for review',
|
|
154
|
-
active: true,
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
id: 1002,
|
|
158
|
-
patient: 'Daniel Brooks',
|
|
159
|
-
encounter: '04/10/2026',
|
|
160
|
-
amount: '$820.50',
|
|
161
|
-
status: 'Pending',
|
|
162
|
-
active: false,
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
id: 1003,
|
|
166
|
-
patient: 'Sofia Chen',
|
|
167
|
-
encounter: '04/11/2026',
|
|
168
|
-
amount: '$2,154.33',
|
|
169
|
-
status: 'Completed',
|
|
170
|
-
active: true,
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
id: 1004,
|
|
174
|
-
patient: 'Thomas Reed',
|
|
175
|
-
encounter: '04/14/2026',
|
|
176
|
-
amount: '$410.00',
|
|
177
|
-
status: 'On hold',
|
|
178
|
-
active: false,
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
id: 1005,
|
|
182
|
-
patient: 'Alicia Morgan',
|
|
183
|
-
encounter: '04/15/2026',
|
|
184
|
-
amount: '$965.20',
|
|
185
|
-
status: 'Ready for review',
|
|
186
|
-
active: true,
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
id: 1006,
|
|
190
|
-
patient: 'Noah Bennett',
|
|
191
|
-
encounter: '04/16/2026',
|
|
192
|
-
amount: '$1,780.10',
|
|
193
|
-
status: 'Pending',
|
|
194
|
-
active: true,
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
id: 1007,
|
|
198
|
-
patient: 'Emma Wright',
|
|
199
|
-
encounter: '04/16/2026',
|
|
200
|
-
amount: '$552.30',
|
|
201
|
-
status: 'Completed',
|
|
202
|
-
active: false,
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
id: 1008,
|
|
206
|
-
patient: 'Liam Foster',
|
|
207
|
-
encounter: '04/17/2026',
|
|
208
|
-
amount: '$2,022.00',
|
|
209
|
-
status: 'On hold',
|
|
210
|
-
active: false,
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
id: 1009,
|
|
214
|
-
patient: 'Olivia James',
|
|
215
|
-
encounter: '04/17/2026',
|
|
216
|
-
amount: '$1,115.75',
|
|
217
|
-
status: 'Ready for review',
|
|
218
|
-
active: true,
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
id: 1010,
|
|
222
|
-
patient: 'Lucas Rivera',
|
|
223
|
-
encounter: '04/18/2026',
|
|
224
|
-
amount: '$730.60',
|
|
225
|
-
status: 'Pending',
|
|
226
|
-
active: true,
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
id: 1011,
|
|
230
|
-
patient: 'Mia Cooper',
|
|
231
|
-
encounter: '04/18/2026',
|
|
232
|
-
amount: '$1,390.00',
|
|
233
|
-
status: 'Completed',
|
|
234
|
-
active: true,
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
id: 1012,
|
|
238
|
-
patient: 'Ethan Hughes',
|
|
239
|
-
encounter: '04/19/2026',
|
|
240
|
-
amount: '$460.95',
|
|
241
|
-
status: 'On hold',
|
|
242
|
-
active: false,
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
id: 1013,
|
|
246
|
-
patient: 'Ava Stewart',
|
|
247
|
-
encounter: '04/19/2026',
|
|
248
|
-
amount: '$1,008.40',
|
|
249
|
-
status: 'Pending',
|
|
250
|
-
active: false,
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
id: 1014,
|
|
254
|
-
patient: 'Mason Powell',
|
|
255
|
-
encounter: '04/20/2026',
|
|
256
|
-
amount: '$2,415.90',
|
|
257
|
-
status: 'Ready for review',
|
|
258
|
-
active: true,
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
id: 1015,
|
|
262
|
-
patient: 'Isabella Diaz',
|
|
263
|
-
encounter: '04/20/2026',
|
|
264
|
-
amount: '$890.15',
|
|
265
|
-
status: 'Completed',
|
|
266
|
-
active: true,
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
id: 1016,
|
|
270
|
-
patient: 'Henry Sanders',
|
|
271
|
-
encounter: '04/20/2026',
|
|
272
|
-
amount: '$615.50',
|
|
273
|
-
status: 'Pending',
|
|
274
|
-
active: false,
|
|
275
|
-
},
|
|
276
|
-
];
|
|
277
|
-
|
|
278
|
-
const baseActionButtons: TableActionButton<StoryTableRowData>[] = [
|
|
279
|
-
{
|
|
280
|
-
icon: 'eye',
|
|
281
|
-
tooltip: 'View details',
|
|
282
|
-
callback: (row) => console.log('View', row),
|
|
283
|
-
disabled: (row) => row.status === 'On hold',
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
icon: 'edit',
|
|
287
|
-
tooltip: 'Edit record',
|
|
288
|
-
callback: (row) => console.log('Edit', row),
|
|
289
|
-
disabled: (row) => row.status === 'Completed',
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
icon: 'delete',
|
|
293
|
-
tooltip: (row) => `Delete ${row.patient}`,
|
|
294
|
-
callback: (row) => console.log('Delete', row),
|
|
295
|
-
disabled: (row) => row.status === 'Completed',
|
|
296
|
-
},
|
|
297
|
-
];
|
|
298
|
-
|
|
299
|
-
const getActionButtons = (
|
|
300
|
-
disableAll: boolean,
|
|
301
|
-
): TableActionButton<StoryTableRowData>[] =>
|
|
302
|
-
baseActionButtons.map((button) => ({
|
|
303
|
-
...button,
|
|
304
|
-
disabled: (row: StoryTableRowData) => {
|
|
305
|
-
const rowDisabled = button.disabled ? button.disabled(row) : false;
|
|
306
|
-
return disableAll || rowDisabled;
|
|
307
|
-
},
|
|
308
|
-
}));
|
|
309
|
-
|
|
310
|
-
const getColumnField = (column: any): string =>
|
|
311
|
-
column?.column?.columnDef?.meta?.originalProperty ?? column?.id ?? '';
|
|
312
|
-
|
|
313
|
-
const getColumnByField = (field: string): StoryTableColumn | undefined =>
|
|
314
|
-
columns.find((column) => column.meta.originalProperty === field);
|
|
315
|
-
|
|
316
|
-
const parseAmericanDate = (value: string): number => {
|
|
317
|
-
const [monthPart, dayPart, yearPart] = value
|
|
318
|
-
.split('/')
|
|
319
|
-
.map((part) => Number(part));
|
|
320
|
-
|
|
321
|
-
if (!monthPart || !dayPart || !yearPart) {
|
|
322
|
-
return Number(new Date(value).getTime() || 0);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return Number(new Date(yearPart, monthPart - 1, dayPart).getTime() || 0);
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
const toComparableValue = (
|
|
329
|
-
row: StoryTableRowData,
|
|
330
|
-
column?: StoryTableColumn,
|
|
331
|
-
): string | number => {
|
|
332
|
-
if (!column) return '';
|
|
333
|
-
|
|
334
|
-
const field = column.meta.originalProperty as keyof StoryTableRowData;
|
|
335
|
-
const raw = row[field];
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
column.meta.propertyType === 'currency' ||
|
|
339
|
-
column.meta.propertyType === 'number'
|
|
340
|
-
) {
|
|
341
|
-
const normalized = String(raw).replace(/[^0-9.-]/g, '');
|
|
342
|
-
return Number(normalized || 0);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (column.meta.propertyType === 'date') {
|
|
346
|
-
return parseAmericanDate(String(raw));
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (column.meta.propertyType === 'boolean') {
|
|
350
|
-
return raw ? 1 : 0;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
return String(raw ?? '').toLowerCase();
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
const applySorting = (
|
|
357
|
-
inputRows: StoryTableRowData[],
|
|
358
|
-
criteria: TableSortCriterion[],
|
|
359
|
-
selectedSortingHeader: string,
|
|
360
|
-
sortDirection: TableSortDirection | null,
|
|
361
|
-
): StoryTableRowData[] => {
|
|
362
|
-
const activeCriteria: TableSortCriterion[] =
|
|
363
|
-
criteria.length > 0
|
|
364
|
-
? criteria
|
|
365
|
-
: selectedSortingHeader && sortDirection
|
|
366
|
-
? [{ field: selectedSortingHeader, direction: sortDirection }]
|
|
367
|
-
: [];
|
|
368
|
-
|
|
369
|
-
if (activeCriteria.length === 0) {
|
|
370
|
-
return [...inputRows];
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return [...inputRows].sort((a, b) => {
|
|
374
|
-
for (const criterion of activeCriteria) {
|
|
375
|
-
const column = getColumnByField(criterion.field);
|
|
376
|
-
const left = toComparableValue(a, column);
|
|
377
|
-
const right = toComparableValue(b, column);
|
|
378
|
-
|
|
379
|
-
if (left === right) {
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
const multiplier = criterion.direction === 'ASC' ? 1 : -1;
|
|
384
|
-
return left > right ? 1 * multiplier : -1 * multiplier;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return 0;
|
|
388
|
-
});
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
const createTable = (
|
|
392
|
-
inputRows: StoryTableRowData[],
|
|
393
|
-
inputColumns: StoryTableColumn[],
|
|
394
|
-
columnSizing: Record<string, number>,
|
|
395
|
-
): StoryTable => {
|
|
396
|
-
const headerGroups = [
|
|
397
|
-
{
|
|
398
|
-
headers: inputColumns.map((column) => ({
|
|
399
|
-
id: column.id,
|
|
400
|
-
getSize: () => columnSizing[column.id] ?? column.size,
|
|
401
|
-
column: {
|
|
402
|
-
columnDef: {
|
|
403
|
-
header: column.header,
|
|
404
|
-
meta: column.meta,
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
})),
|
|
408
|
-
},
|
|
409
|
-
];
|
|
410
|
-
|
|
411
|
-
const tableRows: StoryTableRow[] = inputRows.map((row) => ({
|
|
412
|
-
original: row,
|
|
413
|
-
getVisibleCells: () =>
|
|
414
|
-
inputColumns.map((column) => ({
|
|
415
|
-
id: `${row.id}-${column.id}`,
|
|
416
|
-
column: {
|
|
417
|
-
columnDef: {
|
|
418
|
-
meta: column.meta,
|
|
419
|
-
cell: (context: StoryTableCellContext) => {
|
|
420
|
-
const value = context.getValue();
|
|
421
|
-
|
|
422
|
-
if (column.id === 'status') {
|
|
423
|
-
return String(value ?? '');
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (column.id === 'active') {
|
|
427
|
-
return String(value ?? '');
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
return `<span>${value}</span>`;
|
|
431
|
-
},
|
|
432
|
-
},
|
|
433
|
-
},
|
|
434
|
-
getContext: (): StoryTableCellContext => ({
|
|
435
|
-
getValue: () => row[column.id as keyof StoryTableRowData],
|
|
436
|
-
row: {
|
|
437
|
-
original: row,
|
|
438
|
-
getVisibleCells: () => [],
|
|
439
|
-
} as StoryTableRow,
|
|
440
|
-
column,
|
|
441
|
-
}),
|
|
442
|
-
})),
|
|
443
|
-
}));
|
|
444
|
-
|
|
445
|
-
return {
|
|
446
|
-
getHeaderGroups: () => headerGroups,
|
|
447
|
-
getRowModel: () => ({ rows: tableRows }),
|
|
448
|
-
getState: () => ({ columnSizing }),
|
|
449
|
-
};
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
const castTable = (value: StoryTable): Table<any> =>
|
|
453
|
-
value as unknown as Table<any>;
|
|
454
|
-
|
|
455
|
-
const meta: Meta<TableStoryArgs> = {
|
|
456
|
-
title: 'Components/Table',
|
|
457
|
-
component: TableComponent,
|
|
458
|
-
argTypes: {
|
|
459
|
-
isLoading: { control: 'boolean' },
|
|
460
|
-
showButtons: { control: 'boolean' },
|
|
461
|
-
disableActionButtons: { control: 'boolean' },
|
|
462
|
-
allContentLeft: { control: 'boolean' },
|
|
463
|
-
areColumnsDraggable: { control: 'boolean' },
|
|
464
|
-
enableMultiSort: { control: 'boolean' },
|
|
465
|
-
statusStateStyles: { control: 'object' },
|
|
466
|
-
activeStateStyles: { control: 'object' },
|
|
467
|
-
currentPage: { control: { type: 'number', min: 1, step: 1 } },
|
|
468
|
-
totalPages: { control: { type: 'number', min: 1, step: 1 } },
|
|
469
|
-
pageSize: { control: 'select', options: [10, 25, 50, 100] },
|
|
470
|
-
demoRows: { control: false },
|
|
471
|
-
},
|
|
472
|
-
render: (args) => ({
|
|
473
|
-
props: (() => {
|
|
474
|
-
const storyProps: any = {
|
|
475
|
-
...args,
|
|
476
|
-
disableActionButtons: Boolean(args.disableActionButtons),
|
|
477
|
-
actionButtons: getActionButtons(Boolean(args.disableActionButtons)),
|
|
478
|
-
orderedColumns: [...columns],
|
|
479
|
-
currentSizing: {} as Record<string, number>,
|
|
480
|
-
selectedSortingHeader: '',
|
|
481
|
-
sortDirection: null as TableSortDirection | null,
|
|
482
|
-
multiSortCriteria: [] as TableSortCriterion[],
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
storyProps.refreshTable = function (): void {
|
|
486
|
-
this.actionButtons = getActionButtons(
|
|
487
|
-
Boolean(this.disableActionButtons),
|
|
488
|
-
);
|
|
489
|
-
|
|
490
|
-
const sortedRows = applySorting(
|
|
491
|
-
this.demoRows ?? [],
|
|
492
|
-
this.multiSortCriteria,
|
|
493
|
-
this.selectedSortingHeader,
|
|
494
|
-
this.sortDirection,
|
|
495
|
-
);
|
|
496
|
-
|
|
497
|
-
this.table = castTable(
|
|
498
|
-
createTable(sortedRows, this.orderedColumns, this.currentSizing),
|
|
499
|
-
);
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
storyProps.sortEvent = function (column: unknown): void {
|
|
503
|
-
const field = getColumnField(column);
|
|
504
|
-
if (!field) return;
|
|
505
|
-
|
|
506
|
-
if (this.selectedSortingHeader !== field) {
|
|
507
|
-
this.selectedSortingHeader = field;
|
|
508
|
-
this.sortDirection = 'ASC';
|
|
509
|
-
} else if (this.sortDirection === 'ASC') {
|
|
510
|
-
this.sortDirection = 'DESC';
|
|
511
|
-
} else if (this.sortDirection === 'DESC') {
|
|
512
|
-
this.selectedSortingHeader = '';
|
|
513
|
-
this.sortDirection = null;
|
|
514
|
-
} else {
|
|
515
|
-
this.sortDirection = 'ASC';
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
this.multiSortCriteria = [];
|
|
519
|
-
this.refreshTable();
|
|
520
|
-
};
|
|
521
|
-
|
|
522
|
-
storyProps.multiSortEvent = function (column: unknown): void {
|
|
523
|
-
const field = getColumnField(column);
|
|
524
|
-
if (!field) return;
|
|
525
|
-
|
|
526
|
-
const current: TableSortCriterion[] = [...this.multiSortCriteria];
|
|
527
|
-
const existingIndex = current.findIndex(
|
|
528
|
-
(criterion) => criterion.field === field,
|
|
529
|
-
);
|
|
530
|
-
|
|
531
|
-
if (existingIndex === -1) {
|
|
532
|
-
current.push({ field, direction: 'ASC' });
|
|
533
|
-
} else if (current[existingIndex].direction === 'ASC') {
|
|
534
|
-
current[existingIndex] = {
|
|
535
|
-
...current[existingIndex],
|
|
536
|
-
direction: 'DESC',
|
|
537
|
-
};
|
|
538
|
-
} else {
|
|
539
|
-
current.splice(existingIndex, 1);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
this.multiSortCriteria = current;
|
|
543
|
-
this.selectedSortingHeader = '';
|
|
544
|
-
this.sortDirection = null;
|
|
545
|
-
this.refreshTable();
|
|
546
|
-
};
|
|
547
|
-
|
|
548
|
-
storyProps.columnOrderChange = function (
|
|
549
|
-
event: TableDragDropEvent,
|
|
550
|
-
): void {
|
|
551
|
-
const next = [...this.orderedColumns];
|
|
552
|
-
const moved = next.splice(event.previousIndex, 1)[0];
|
|
553
|
-
if (!moved) return;
|
|
554
|
-
|
|
555
|
-
next.splice(event.currentIndex, 0, moved);
|
|
556
|
-
this.orderedColumns = next;
|
|
557
|
-
this.refreshTable();
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
storyProps.columnSizingChange = function (
|
|
561
|
-
event: Record<string, number>,
|
|
562
|
-
): void {
|
|
563
|
-
this.currentSizing = { ...event };
|
|
564
|
-
this.refreshTable();
|
|
565
|
-
};
|
|
566
|
-
|
|
567
|
-
storyProps.pageChange = (page: number): void => {
|
|
568
|
-
console.log('page change', page);
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
storyProps.pageSizeChange = (size: number): void => {
|
|
572
|
-
console.log('page size change', size);
|
|
573
|
-
};
|
|
574
|
-
|
|
575
|
-
storyProps.refreshTable();
|
|
576
|
-
return storyProps;
|
|
577
|
-
})(),
|
|
578
|
-
template: `
|
|
579
|
-
<div class="min-h-screen bg-[linear-gradient(180deg,#f7fbfb_0%,#edf6f5_100%)] p-6">
|
|
580
|
-
<div class="mx-auto max-w-7xl rounded-[28px] bg-white-base p-6 shadow-[0_24px_80px_rgba(1,71,68,0.08)]">
|
|
581
|
-
<div class="mb-6 flex flex-col gap-2">
|
|
582
|
-
<h2 class="text-2xl font-semibold text-aqua-base">Table component</h2>
|
|
583
|
-
<p class="max-w-3xl text-sm text-neutral-disabled-text">
|
|
584
|
-
Design system table demo with sorting, resizing, column dragging, row actions, and pagination.
|
|
585
|
-
</p>
|
|
586
|
-
</div>
|
|
587
|
-
|
|
588
|
-
<ads-table
|
|
589
|
-
[table]="table"
|
|
590
|
-
[isLoading]="isLoading"
|
|
591
|
-
[showButtons]="showButtons"
|
|
592
|
-
[allContentLeft]="allContentLeft"
|
|
593
|
-
[areColumnsDraggable]="areColumnsDraggable"
|
|
594
|
-
[enableMultiSort]="enableMultiSort"
|
|
595
|
-
[statusStateStyles]="statusStateStyles"
|
|
596
|
-
[activeStateStyles]="activeStateStyles"
|
|
597
|
-
[selectedSortingHeader]="selectedSortingHeader"
|
|
598
|
-
[sortDirection]="sortDirection"
|
|
599
|
-
[multiSortCriteria]="multiSortCriteria"
|
|
600
|
-
[currentPage]="currentPage"
|
|
601
|
-
[totalPages]="totalPages"
|
|
602
|
-
[pageSize]="pageSize"
|
|
603
|
-
[totalRegisters]="totalRegisters"
|
|
604
|
-
[actionButtons]="actionButtons"
|
|
605
|
-
(sortEvent)="sortEvent($event)"
|
|
606
|
-
(multiSortEvent)="multiSortEvent($event)"
|
|
607
|
-
(columnOrderChange)="columnOrderChange($event)"
|
|
608
|
-
(columnSizingChange)="columnSizingChange($event)"
|
|
609
|
-
(pageChange)="pageChange($event)"
|
|
610
|
-
(pageSizeChange)="pageSizeChange($event)"
|
|
611
|
-
></ads-table>
|
|
612
|
-
</div>
|
|
613
|
-
</div>
|
|
614
|
-
`,
|
|
615
|
-
}),
|
|
616
|
-
};
|
|
617
|
-
|
|
618
|
-
export default meta;
|
|
619
|
-
type Story = StoryObj<TableStoryArgs>;
|
|
620
|
-
|
|
621
|
-
export const Playground: Story = {
|
|
622
|
-
args: {
|
|
623
|
-
demoRows: rows,
|
|
624
|
-
isLoading: false,
|
|
625
|
-
showButtons: true,
|
|
626
|
-
disableActionButtons: false,
|
|
627
|
-
allContentLeft: false,
|
|
628
|
-
areColumnsDraggable: true,
|
|
629
|
-
enableMultiSort: true,
|
|
630
|
-
statusStateStyles: defaultStatusStateStyles,
|
|
631
|
-
activeStateStyles: defaultActiveStateStyles,
|
|
632
|
-
currentPage: 2,
|
|
633
|
-
totalPages: 8,
|
|
634
|
-
pageSize: 25,
|
|
635
|
-
totalRegisters: 432,
|
|
636
|
-
},
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
export const EmptyState: Story = {
|
|
640
|
-
args: {
|
|
641
|
-
demoRows: [],
|
|
642
|
-
isLoading: false,
|
|
643
|
-
showButtons: false,
|
|
644
|
-
disableActionButtons: false,
|
|
645
|
-
allContentLeft: true,
|
|
646
|
-
areColumnsDraggable: false,
|
|
647
|
-
enableMultiSort: false,
|
|
648
|
-
statusStateStyles: defaultStatusStateStyles,
|
|
649
|
-
activeStateStyles: defaultActiveStateStyles,
|
|
650
|
-
currentPage: 1,
|
|
651
|
-
totalPages: 1,
|
|
652
|
-
pageSize: 25,
|
|
653
|
-
totalRegisters: 0,
|
|
654
|
-
},
|
|
655
|
-
};
|