@arbor-education/design-system.components 0.3.0 → 0.3.2
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/CHANGELOG.md +14 -0
- package/dist/components/formField/inputs/selectDropdown/SelectDropdown.d.ts +1 -0
- package/dist/components/formField/inputs/selectDropdown/SelectDropdown.d.ts.map +1 -1
- package/dist/components/formField/inputs/selectDropdown/SelectDropdown.js +19 -12
- package/dist/components/formField/inputs/selectDropdown/SelectDropdown.js.map +1 -1
- package/dist/components/table/DSDefaultColDef.d.ts +5 -0
- package/dist/components/table/DSDefaultColDef.d.ts.map +1 -0
- package/dist/components/table/DSDefaultColDef.js +32 -0
- package/dist/components/table/DSDefaultColDef.js.map +1 -0
- package/dist/components/table/Table.d.ts +6 -6
- package/dist/components/table/Table.d.ts.map +1 -1
- package/dist/components/table/Table.js +43 -22
- package/dist/components/table/Table.js.map +1 -1
- package/dist/components/table/Table.stories.d.ts +3 -0
- package/dist/components/table/Table.stories.d.ts.map +1 -1
- package/dist/components/table/Table.stories.js +265 -24
- package/dist/components/table/Table.stories.js.map +1 -1
- package/dist/components/table/Table.test.js +362 -7
- package/dist/components/table/Table.test.js.map +1 -1
- package/dist/components/table/cellColorStyles.d.ts +34 -0
- package/dist/components/table/cellColorStyles.d.ts.map +1 -0
- package/dist/components/table/cellColorStyles.js +52 -0
- package/dist/components/table/cellColorStyles.js.map +1 -0
- package/dist/components/table/cellRenderers/ButtonCellRenderer.d.ts.map +1 -1
- package/dist/components/table/cellRenderers/ButtonCellRenderer.js +15 -2
- package/dist/components/table/cellRenderers/ButtonCellRenderer.js.map +1 -1
- package/dist/components/table/cellRenderers/DefaultCellRenderer.d.ts +3 -0
- package/dist/components/table/cellRenderers/DefaultCellRenderer.d.ts.map +1 -0
- package/dist/components/table/cellRenderers/DefaultCellRenderer.js +11 -0
- package/dist/components/table/cellRenderers/DefaultCellRenderer.js.map +1 -0
- package/dist/components/table/cellRenderers/InlineTextCellRenderer.d.ts +7 -0
- package/dist/components/table/cellRenderers/InlineTextCellRenderer.d.ts.map +1 -0
- package/dist/components/table/cellRenderers/InlineTextCellRenderer.js +7 -0
- package/dist/components/table/cellRenderers/InlineTextCellRenderer.js.map +1 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellEditor.d.ts +8 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellEditor.d.ts.map +1 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellEditor.js +19 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellEditor.js.map +1 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.d.ts +8 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.d.ts.map +1 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.js +18 -0
- package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.js.map +1 -0
- package/dist/components/table/pagination/TableSettingsDropdown.js +4 -5
- package/dist/components/table/pagination/TableSettingsDropdown.js.map +1 -1
- package/dist/components/table/theme/baseThemeParams.d.ts +14 -0
- package/dist/components/table/theme/baseThemeParams.d.ts.map +1 -0
- package/dist/components/table/{tableTheme.js → theme/baseThemeParams.js} +3 -7
- package/dist/components/table/theme/baseThemeParams.js.map +1 -0
- package/dist/components/table/theme/defaultTheme.d.ts +2 -0
- package/dist/components/table/theme/defaultTheme.d.ts.map +1 -0
- package/dist/components/table/theme/defaultTheme.js +9 -0
- package/dist/components/table/theme/defaultTheme.js.map +1 -0
- package/dist/components/table/theme/tidyTheme.d.ts +2 -0
- package/dist/components/table/theme/tidyTheme.d.ts.map +1 -0
- package/dist/components/table/theme/tidyTheme.js +10 -0
- package/dist/components/table/theme/tidyTheme.js.map +1 -0
- package/dist/components/table/useTableSettings.d.ts +5 -2
- package/dist/components/table/useTableSettings.d.ts.map +1 -1
- package/dist/components/table/useTableSettings.js +11 -3
- package/dist/components/table/useTableSettings.js.map +1 -1
- package/dist/index.css +14 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/focusFirstFocusableElement.d.ts +2 -0
- package/dist/utils/focusFirstFocusableElement.d.ts.map +1 -0
- package/dist/utils/focusFirstFocusableElement.js +12 -0
- package/dist/utils/focusFirstFocusableElement.js.map +1 -0
- package/dist/utils/focusFirstFocusableElement.test.d.ts +2 -0
- package/dist/utils/focusFirstFocusableElement.test.d.ts.map +1 -0
- package/dist/utils/focusFirstFocusableElement.test.js +109 -0
- package/dist/utils/focusFirstFocusableElement.test.js.map +1 -0
- package/package.json +1 -1
- package/src/components/formField/inputs/selectDropdown/SelectDropdown.tsx +20 -14
- package/src/components/table/DSDefaultColDef.ts +37 -0
- package/src/components/table/Table.stories.tsx +284 -28
- package/src/components/table/Table.test.tsx +543 -7
- package/src/components/table/Table.tsx +55 -23
- package/src/components/table/cellColorStyles.ts +70 -0
- package/src/components/table/cellRenderers/ButtonCellRenderer.tsx +16 -2
- package/src/components/table/cellRenderers/DefaultCellRenderer.tsx +23 -0
- package/src/components/table/cellRenderers/InlineTextCellRenderer.tsx +10 -0
- package/src/components/table/cellRenderers/SelectDropdownCellEditor.tsx +43 -0
- package/src/components/table/cellRenderers/SelectDropdownCellRenderer.tsx +37 -0
- package/src/components/table/pagination/TableSettingsDropdown.tsx +5 -5
- package/src/components/table/table.scss +16 -0
- package/src/components/table/{tableTheme.ts → theme/baseThemeParams.ts} +2 -7
- package/src/components/table/theme/defaultTheme.ts +9 -0
- package/src/components/table/theme/tidyTheme.ts +10 -0
- package/src/components/table/useTableSettings.ts +15 -3
- package/src/index.ts +2 -0
- package/src/utils/focusFirstFocusableElement.test.ts +150 -0
- package/src/utils/focusFirstFocusableElement.ts +21 -0
- package/dist/components/table/tableTheme.d.ts +0 -2
- package/dist/components/table/tableTheme.d.ts.map +0 -1
- package/dist/components/table/tableTheme.js.map +0 -1
|
@@ -13,6 +13,7 @@ import { TableSettingsDropdown } from './pagination/TableSettingsDropdown';
|
|
|
13
13
|
import { ModalManager } from 'Components/modal/modalManager/ModalManager';
|
|
14
14
|
import { Modal } from 'Components/modal/Modal';
|
|
15
15
|
import { ModalUtils } from 'Utils/ModalUtils';
|
|
16
|
+
import type { SemanticColorKey } from './cellColorStyles';
|
|
16
17
|
|
|
17
18
|
type TableProps = ComponentProps<typeof Table>;
|
|
18
19
|
|
|
@@ -31,20 +32,26 @@ const meta: Meta<TableProps> = {
|
|
|
31
32
|
|
|
32
33
|
type Story = StoryObj<typeof Table>;
|
|
33
34
|
|
|
35
|
+
type CellColors = {
|
|
36
|
+
foregroundColor?: string;
|
|
37
|
+
backgroundColor?: string;
|
|
38
|
+
semanticColor?: SemanticColorKey;
|
|
39
|
+
};
|
|
40
|
+
|
|
34
41
|
interface RowData {
|
|
35
42
|
id: number;
|
|
36
|
-
name: string;
|
|
37
|
-
email: string;
|
|
38
|
-
role: string;
|
|
39
|
-
status: string;
|
|
43
|
+
name: { value: string } & CellColors;
|
|
44
|
+
email: { value: string } & CellColors;
|
|
45
|
+
role: { value: string } & CellColors;
|
|
46
|
+
status: { value: string } & CellColors;
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
const sampleData: RowData[] = [
|
|
43
|
-
{ id: 1, name: 'Alice Johnson', email: 'alice.johnson@example.com', role: 'Developer', status: 'Active' },
|
|
44
|
-
{ id: 2, name: 'Bob Smith', email: 'bob.smith@example.com', role: 'Designer', status: 'Active' },
|
|
45
|
-
{ id: 3, name: 'Charlie Brown', email: 'charlie.brown@example.com', role: 'Manager', status: 'Inactive' },
|
|
46
|
-
{ id: 4, name: 'Diana Prince', email: 'diana.prince@example.com', role: 'Developer', status: 'Active' },
|
|
47
|
-
{ id: 5, name: 'Ethan Hunt', email: 'ethan.hunt@example.com', role: 'Analyst', status: 'Active' },
|
|
50
|
+
{ id: 1, name: { value: 'Alice Johnson' }, email: { value: 'alice.johnson@example.com' }, role: { value: 'Developer' }, status: { value: 'Active' } },
|
|
51
|
+
{ id: 2, name: { value: 'Bob Smith' }, email: { value: 'bob.smith@example.com' }, role: { value: 'Designer' }, status: { value: 'Active' } },
|
|
52
|
+
{ id: 3, name: { value: 'Charlie Brown' }, email: { value: 'charlie.brown@example.com' }, role: { value: 'Manager' }, status: { value: 'Inactive' } },
|
|
53
|
+
{ id: 4, name: { value: 'Diana Prince' }, email: { value: 'diana.prince@example.com' }, role: { value: 'Developer' }, status: { value: 'Active' } },
|
|
54
|
+
{ id: 5, name: { value: 'Ethan Hunt' }, email: { value: 'ethan.hunt@example.com' }, role: { value: 'Analyst' }, status: { value: 'Active' } },
|
|
48
55
|
];
|
|
49
56
|
|
|
50
57
|
const defaultColDef: ColDef = {
|
|
@@ -68,17 +75,20 @@ const sampleColumnDefs: (ColDef | ColGroupDef)[] = [
|
|
|
68
75
|
field: 'role',
|
|
69
76
|
headerTooltip: 'The role of the user',
|
|
70
77
|
}],
|
|
78
|
+
// Value formatters from the defaultColDef are not respected for non-string value
|
|
79
|
+
// so until AG Grid fixes it we have to do it explicitly on each colDef
|
|
80
|
+
valueFormatter: Table.DefaultValueFormatter,
|
|
71
81
|
},
|
|
72
|
-
{ field: 'status' },
|
|
82
|
+
{ field: 'status', valueFormatter: Table.DefaultValueFormatter },
|
|
73
83
|
];
|
|
74
84
|
|
|
75
|
-
const
|
|
85
|
+
const footerContent = [
|
|
76
86
|
<Button key={0} variant="primary">Button 1</Button>,
|
|
77
87
|
<RowCountInfo key={3} />,
|
|
78
88
|
<Button key={2} variant="secondary">Button 2</Button>,
|
|
79
89
|
];
|
|
80
90
|
|
|
81
|
-
const
|
|
91
|
+
const headerContent = [
|
|
82
92
|
<div key={0} style={{ display: 'flex', gap: '0.5rem' }}>
|
|
83
93
|
<Button key={0} variant="secondary" size="S">Button 1</Button>
|
|
84
94
|
<Button key={1} variant="secondary" size="S">Button 2</Button>
|
|
@@ -95,7 +105,7 @@ export const Default: Story = {
|
|
|
95
105
|
args: {
|
|
96
106
|
rowData: sampleData,
|
|
97
107
|
columnDefs: sampleColumnDefs,
|
|
98
|
-
defaultColDef
|
|
108
|
+
defaultColDef,
|
|
99
109
|
domLayout: 'autoHeight',
|
|
100
110
|
rowSelection: { mode: 'multiRow', checkboxes: true },
|
|
101
111
|
initialState: {
|
|
@@ -111,7 +121,7 @@ export const WithFooter: Story = {
|
|
|
111
121
|
columnDefs: sampleColumnDefs,
|
|
112
122
|
defaultColDef: defaultColDef,
|
|
113
123
|
domLayout: 'autoHeight',
|
|
114
|
-
footerContent
|
|
124
|
+
footerContent,
|
|
115
125
|
pagination: true,
|
|
116
126
|
},
|
|
117
127
|
};
|
|
@@ -122,7 +132,7 @@ export const WithHeader: Story = {
|
|
|
122
132
|
columnDefs: sampleColumnDefs,
|
|
123
133
|
defaultColDef: defaultColDef,
|
|
124
134
|
domLayout: 'autoHeight',
|
|
125
|
-
headerContent
|
|
135
|
+
headerContent,
|
|
126
136
|
onTableSettingsChanged: (newSettings) => {
|
|
127
137
|
console.log('Settings changed', newSettings);
|
|
128
138
|
},
|
|
@@ -144,7 +154,7 @@ export const WithHeaderAndNoSearch: Story = {
|
|
|
144
154
|
columnDefs: sampleColumnDefs,
|
|
145
155
|
defaultColDef: defaultColDef,
|
|
146
156
|
domLayout: 'autoHeight',
|
|
147
|
-
headerContent
|
|
157
|
+
headerContent,
|
|
148
158
|
hasSearch: false,
|
|
149
159
|
},
|
|
150
160
|
};
|
|
@@ -155,8 +165,8 @@ export const WithHeaderAndFooter: Story = {
|
|
|
155
165
|
columnDefs: sampleColumnDefs,
|
|
156
166
|
defaultColDef: defaultColDef,
|
|
157
167
|
domLayout: 'autoHeight',
|
|
158
|
-
headerContent
|
|
159
|
-
footerContent
|
|
168
|
+
headerContent,
|
|
169
|
+
footerContent,
|
|
160
170
|
},
|
|
161
171
|
};
|
|
162
172
|
|
|
@@ -171,7 +181,7 @@ export const WithBulkActions: Story = {
|
|
|
171
181
|
args: {
|
|
172
182
|
rowData: sampleData,
|
|
173
183
|
columnDefs: sampleColumnDefs,
|
|
174
|
-
defaultColDef
|
|
184
|
+
defaultColDef,
|
|
175
185
|
domLayout: 'autoHeight',
|
|
176
186
|
headerContent: [
|
|
177
187
|
<BulkActionsDropdown
|
|
@@ -204,7 +214,7 @@ export const WithHideColumnsDropdown: Story = {
|
|
|
204
214
|
args: {
|
|
205
215
|
rowData: sampleData,
|
|
206
216
|
columnDefs: sampleColumnDefs,
|
|
207
|
-
defaultColDef
|
|
217
|
+
defaultColDef,
|
|
208
218
|
domLayout: 'autoHeight',
|
|
209
219
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
210
220
|
// @ts-ignore
|
|
@@ -249,7 +259,7 @@ export const WithRestrictedHideColumnsDropdown: Story = {
|
|
|
249
259
|
args: {
|
|
250
260
|
rowData: sampleData,
|
|
251
261
|
columnDefs: sampleColumnDefs,
|
|
252
|
-
defaultColDef
|
|
262
|
+
defaultColDef,
|
|
253
263
|
domLayout: 'autoHeight',
|
|
254
264
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
255
265
|
// @ts-ignore
|
|
@@ -301,7 +311,7 @@ export const WithClientSidePagination: StoryObj<TableProps> = {
|
|
|
301
311
|
args: {
|
|
302
312
|
rowData: sampleData,
|
|
303
313
|
columnDefs: sampleColumnDefs,
|
|
304
|
-
defaultColDef
|
|
314
|
+
defaultColDef,
|
|
305
315
|
domLayout: 'autoHeight',
|
|
306
316
|
pagination: true,
|
|
307
317
|
footerContent: <PaginationPanel availableSizes={[1, 2, 3, 4, 'All']} initialPageSize={2} />,
|
|
@@ -319,7 +329,7 @@ export const WithServerSidePagination: StoryObj<TableProps> = {
|
|
|
319
329
|
args: {
|
|
320
330
|
rowData: sampleData,
|
|
321
331
|
columnDefs: sampleColumnDefs,
|
|
322
|
-
defaultColDef
|
|
332
|
+
defaultColDef,
|
|
323
333
|
domLayout: 'autoHeight',
|
|
324
334
|
pagination: false,
|
|
325
335
|
},
|
|
@@ -366,6 +376,9 @@ const sampleColumnDefsWithButtonCellRenderer: (ColDef | ColGroupDef)[] = [
|
|
|
366
376
|
field: 'name',
|
|
367
377
|
headerTooltip: 'The name of the user',
|
|
368
378
|
cellRenderer: 'dsButtonCellRenderer',
|
|
379
|
+
cellRendererParams: {
|
|
380
|
+
supressCellFocusAndFocusFirstElement: true,
|
|
381
|
+
},
|
|
369
382
|
editable: false,
|
|
370
383
|
}, {
|
|
371
384
|
field: 'email',
|
|
@@ -392,9 +405,9 @@ export const WithButtonCellRenderer: Story = {
|
|
|
392
405
|
args: {
|
|
393
406
|
rowData: sampleDataWithButtonCellRenderer,
|
|
394
407
|
columnDefs: sampleColumnDefsWithButtonCellRenderer,
|
|
395
|
-
defaultColDef
|
|
408
|
+
defaultColDef,
|
|
396
409
|
domLayout: 'autoHeight',
|
|
397
|
-
footerContent
|
|
410
|
+
footerContent,
|
|
398
411
|
pagination: true,
|
|
399
412
|
},
|
|
400
413
|
};
|
|
@@ -403,7 +416,7 @@ export const WithButtonCellRendererThatOpensAModalWithModalManager: StoryObj<Tab
|
|
|
403
416
|
args: {
|
|
404
417
|
rowData: sampleData,
|
|
405
418
|
columnDefs: sampleColumnDefs,
|
|
406
|
-
defaultColDef
|
|
419
|
+
defaultColDef,
|
|
407
420
|
domLayout: 'autoHeight',
|
|
408
421
|
},
|
|
409
422
|
render: () => {
|
|
@@ -448,7 +461,7 @@ export const WithButtonCellRendererThatOpensAModalWithComposableModal: StoryObj<
|
|
|
448
461
|
args: {
|
|
449
462
|
rowData: sampleData,
|
|
450
463
|
columnDefs: sampleColumnDefs,
|
|
451
|
-
defaultColDef
|
|
464
|
+
defaultColDef,
|
|
452
465
|
domLayout: 'autoHeight',
|
|
453
466
|
},
|
|
454
467
|
render: () => {
|
|
@@ -652,7 +665,7 @@ const colDefsWithValidationClasses: (ColDef | ColGroupDef)[] = [
|
|
|
652
665
|
maxLength: 10,
|
|
653
666
|
},
|
|
654
667
|
cellClassRules: {
|
|
655
|
-
'ds-table__cell--invalid': params => params.value.length > 10,
|
|
668
|
+
'ds-table__cell--invalid': params => params.value.value.length > 10,
|
|
656
669
|
},
|
|
657
670
|
}, {
|
|
658
671
|
field: 'email',
|
|
@@ -683,4 +696,247 @@ export const WithValidationClassesAdded: Story = {
|
|
|
683
696
|
},
|
|
684
697
|
};
|
|
685
698
|
|
|
699
|
+
const tidyTableDefaultColDef: ColDef = {
|
|
700
|
+
...defaultColDef,
|
|
701
|
+
suppressHeaderMenuButton: true,
|
|
702
|
+
resizable: false,
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
const assessmentComponentOptions = [
|
|
706
|
+
{ value: 'comp-english-lang', label: 'English Language' },
|
|
707
|
+
{ value: 'comp-english-lit', label: 'English Literature' },
|
|
708
|
+
{ value: 'comp-maths', label: 'Maths' },
|
|
709
|
+
];
|
|
710
|
+
|
|
711
|
+
const visibilityOptions = [
|
|
712
|
+
{ value: 'show', label: 'Show' },
|
|
713
|
+
{ value: 'auto-visible', label: 'Auto-visible' },
|
|
714
|
+
{ value: 'hide', label: 'Hide' },
|
|
715
|
+
];
|
|
716
|
+
|
|
717
|
+
const marksheetTidyTableColumnDefs: (ColDef | ColGroupDef)[] = [
|
|
718
|
+
{
|
|
719
|
+
headerName: 'Assessment Component',
|
|
720
|
+
field: 'assessmentComponent',
|
|
721
|
+
cellRenderer: 'dsSelectDropdownCellRenderer',
|
|
722
|
+
cellEditor: 'dsSelectDropdownCellEditor',
|
|
723
|
+
cellRendererParams: { options: assessmentComponentOptions, placeholder: 'Select' },
|
|
724
|
+
cellEditorParams: { options: assessmentComponentOptions, placeholder: 'Select' },
|
|
725
|
+
editable: params => !params.node.group,
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
headerName: 'Visibility',
|
|
729
|
+
field: 'visibility',
|
|
730
|
+
cellRenderer: 'dsSelectDropdownCellRenderer',
|
|
731
|
+
cellEditor: 'dsSelectDropdownCellEditor',
|
|
732
|
+
cellRendererParams: { options: visibilityOptions, placeholder: 'Select' },
|
|
733
|
+
cellEditorParams: { options: visibilityOptions, placeholder: 'Select' },
|
|
734
|
+
editable: params => !params.node.group,
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
headerName: 'Editable',
|
|
738
|
+
field: 'editable',
|
|
739
|
+
editable: true,
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
headerName: 'Formatting',
|
|
743
|
+
field: 'formatting',
|
|
744
|
+
editable: false,
|
|
745
|
+
},
|
|
746
|
+
];
|
|
747
|
+
|
|
748
|
+
const marksheetTidyTableData = [
|
|
749
|
+
{
|
|
750
|
+
id: 1,
|
|
751
|
+
name: 'Student Name',
|
|
752
|
+
assessmentComponent: undefined,
|
|
753
|
+
visibility: 'show',
|
|
754
|
+
editable: true,
|
|
755
|
+
formatting: undefined,
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
id: 2,
|
|
759
|
+
name: 'Autumn',
|
|
760
|
+
children: [
|
|
761
|
+
{ id: 3, name: 'English Language', assessmentComponent: 'comp-english-lang', visibility: 'auto-visible', editable: true, formatting: undefined },
|
|
762
|
+
{ id: 4, name: 'English Literature', assessmentComponent: 'comp-english-lit', visibility: 'auto-visible', editable: true, formatting: undefined },
|
|
763
|
+
{ id: 5, name: 'Maths', assessmentComponent: 'comp-maths', visibility: 'auto-visible', editable: true, formatting: undefined },
|
|
764
|
+
],
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
id: 6,
|
|
768
|
+
name: 'Spring',
|
|
769
|
+
children: [
|
|
770
|
+
{ id: 7, name: 'English Language', assessmentComponent: 'comp-english-lang', visibility: 'auto-visible', editable: true, formatting: undefined },
|
|
771
|
+
{ id: 8, name: 'English Literature', assessmentComponent: 'comp-english-lit', visibility: 'auto-visible', editable: true, formatting: undefined },
|
|
772
|
+
{ id: 9, name: 'Maths', assessmentComponent: 'comp-maths', visibility: 'auto-visible', editable: true, formatting: undefined },
|
|
773
|
+
],
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
id: 10,
|
|
777
|
+
name: 'Summer',
|
|
778
|
+
children: [
|
|
779
|
+
{ id: 11, name: 'English Language', assessmentComponent: 'comp-english-lang', visibility: 'auto-visible', editable: true, formatting: undefined },
|
|
780
|
+
{ id: 12, name: 'English Literature', assessmentComponent: 'comp-english-lit', visibility: 'auto-visible', editable: true, formatting: undefined },
|
|
781
|
+
{ id: 13, name: 'Maths', assessmentComponent: 'comp-maths', visibility: 'auto-visible', editable: true, formatting: undefined },
|
|
782
|
+
],
|
|
783
|
+
},
|
|
784
|
+
];
|
|
785
|
+
|
|
786
|
+
export const TidyTable: Story = {
|
|
787
|
+
args: {
|
|
788
|
+
rowData: marksheetTidyTableData,
|
|
789
|
+
columnDefs: marksheetTidyTableColumnDefs,
|
|
790
|
+
defaultColDef: tidyTableDefaultColDef,
|
|
791
|
+
domLayout: 'autoHeight',
|
|
792
|
+
tableTheme: 'tidy',
|
|
793
|
+
treeData: true,
|
|
794
|
+
treeDataChildrenField: 'children',
|
|
795
|
+
singleClickEdit: true,
|
|
796
|
+
stopEditingWhenCellsLoseFocus: true,
|
|
797
|
+
groupDefaultExpanded: -1,
|
|
798
|
+
icons: {
|
|
799
|
+
groupExpanded: '',
|
|
800
|
+
groupContracted: '',
|
|
801
|
+
},
|
|
802
|
+
rowSelection: {
|
|
803
|
+
mode: 'multiRow',
|
|
804
|
+
groupSelects: 'filteredDescendants',
|
|
805
|
+
},
|
|
806
|
+
autoGroupColumnDef: {
|
|
807
|
+
field: 'name',
|
|
808
|
+
headerName: 'Marksheet Columns',
|
|
809
|
+
headerTooltip: 'Marksheet column or group name',
|
|
810
|
+
editable: true,
|
|
811
|
+
singleClickEdit: true,
|
|
812
|
+
cellRenderer: 'agGroupCellRenderer',
|
|
813
|
+
cellEditor: 'agTextCellEditor',
|
|
814
|
+
cellRendererParams: {
|
|
815
|
+
suppressCount: true,
|
|
816
|
+
suppressDoubleClickExpand: true,
|
|
817
|
+
suppressEnterExpand: true,
|
|
818
|
+
innerRenderer: 'dsInlineTextCellRenderer',
|
|
819
|
+
},
|
|
820
|
+
},
|
|
821
|
+
},
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
export const TableWithExplicitColours: Story = {
|
|
825
|
+
args: {
|
|
826
|
+
rowData: [
|
|
827
|
+
{
|
|
828
|
+
id: 1,
|
|
829
|
+
name: { value: 'Alice Johnson', backgroundColor: '#e3f2fd', foregroundColor: '#0d47a1' },
|
|
830
|
+
email: { value: 'alice.johnson@example.com' },
|
|
831
|
+
role: { value: 'Developer', backgroundColor: '#c8e6c9', foregroundColor: '#1b5e20' },
|
|
832
|
+
status: { value: 'Active', backgroundColor: '#a5d6a7', foregroundColor: '#2e7d32' },
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
id: 2,
|
|
836
|
+
name: { value: 'Bob Smith', backgroundColor: '#fff3e0', foregroundColor: '#e65100' },
|
|
837
|
+
email: { value: 'bob.smith@example.com' },
|
|
838
|
+
role: { value: 'Designer', backgroundColor: '#f3e5f5', foregroundColor: '#4a148c' },
|
|
839
|
+
status: { value: 'Active', backgroundColor: '#a5d6a7', foregroundColor: '#2e7d32' },
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
id: 3,
|
|
843
|
+
name: { value: 'Charlie Brown', backgroundColor: '#fce4ec', foregroundColor: '#880e4f' },
|
|
844
|
+
email: { value: 'charlie.brown@example.com' },
|
|
845
|
+
role: { value: 'Manager', backgroundColor: '#fff9c4', foregroundColor: '#f57f17' },
|
|
846
|
+
status: { value: 'Inactive', backgroundColor: '#ffcdd2', foregroundColor: '#b71c1c' },
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
id: 4,
|
|
850
|
+
name: { value: 'Diana Prince', backgroundColor: '#e1bee7', foregroundColor: '#6a1b9a' },
|
|
851
|
+
email: { value: 'diana.prince@example.com' },
|
|
852
|
+
role: { value: 'Developer', backgroundColor: '#c8e6c9', foregroundColor: '#1b5e20' },
|
|
853
|
+
status: { value: 'Active', backgroundColor: '#a5d6a7', foregroundColor: '#2e7d32' },
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
id: 5,
|
|
857
|
+
name: { value: 'Ethan Hunt', backgroundColor: '#b2ebf2', foregroundColor: '#006064' },
|
|
858
|
+
email: { value: 'ethan.hunt@example.com' },
|
|
859
|
+
role: { value: 'Analyst', backgroundColor: '#ffccbc', foregroundColor: '#bf360c' },
|
|
860
|
+
status: { value: 'Active', backgroundColor: '#a5d6a7', foregroundColor: '#2e7d32' },
|
|
861
|
+
},
|
|
862
|
+
],
|
|
863
|
+
columnDefs: sampleColumnDefs,
|
|
864
|
+
defaultColDef,
|
|
865
|
+
headerContent,
|
|
866
|
+
onCellValueChanged: (e) => {
|
|
867
|
+
const { node, column, oldValue, newValue } = e;
|
|
868
|
+
if (typeof oldValue === 'object' && 'value' in oldValue) {
|
|
869
|
+
node.setDataValue(column.getColId(), { ...oldValue, value: newValue });
|
|
870
|
+
}
|
|
871
|
+
},
|
|
872
|
+
domLayout: 'autoHeight',
|
|
873
|
+
},
|
|
874
|
+
parameters: {
|
|
875
|
+
docs: {
|
|
876
|
+
description: {
|
|
877
|
+
story: 'Table cells can define `foregroundColor` and `backgroundColor` fields with any valid CSS color (including ones from our tokens)',
|
|
878
|
+
},
|
|
879
|
+
},
|
|
880
|
+
},
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
export const TableWithSemanticColors: Story = {
|
|
884
|
+
args: {
|
|
885
|
+
rowData: [
|
|
886
|
+
{
|
|
887
|
+
id: 1,
|
|
888
|
+
name: { value: 'Alice Johnson' },
|
|
889
|
+
email: { value: 'alice.johnson@example.com' },
|
|
890
|
+
role: { value: 'Developer' },
|
|
891
|
+
status: { value: 'Destructive', semanticColor: 'DESTRUCTIVE' },
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
id: 2,
|
|
895
|
+
name: { value: 'Bob Smith' },
|
|
896
|
+
email: { value: 'bob.smith@example.com' },
|
|
897
|
+
role: { value: 'Designer' },
|
|
898
|
+
status: { value: 'Caution', semanticColor: 'CAUTION' },
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
id: 3,
|
|
902
|
+
name: { value: 'Charlie Brown' },
|
|
903
|
+
email: { value: 'charlie.brown@example.com' },
|
|
904
|
+
role: { value: 'Manager' },
|
|
905
|
+
status: { value: 'Info', semanticColor: 'INFO' },
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
id: 4,
|
|
909
|
+
name: { value: 'Diana Prince' },
|
|
910
|
+
email: { value: 'diana.prince@example.com' },
|
|
911
|
+
role: { value: 'Developer' },
|
|
912
|
+
status: { value: 'Success', semanticColor: 'SUCCESS' },
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
id: 5,
|
|
916
|
+
name: { value: 'Ethan Hunt' },
|
|
917
|
+
email: { value: 'ethan.hunt@example.com' },
|
|
918
|
+
role: { value: 'Analyst' },
|
|
919
|
+
status: { value: 'Warning', semanticColor: 'WARNING' },
|
|
920
|
+
},
|
|
921
|
+
],
|
|
922
|
+
columnDefs: sampleColumnDefs,
|
|
923
|
+
defaultColDef,
|
|
924
|
+
headerContent,
|
|
925
|
+
domLayout: 'autoHeight',
|
|
926
|
+
onCellValueChanged: (e) => {
|
|
927
|
+
const { node, column, oldValue, newValue } = e;
|
|
928
|
+
if (typeof oldValue === 'object' && 'value' in oldValue) {
|
|
929
|
+
node.setDataValue(column.getColId(), { ...oldValue, value: newValue });
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
},
|
|
933
|
+
parameters: {
|
|
934
|
+
docs: {
|
|
935
|
+
description: {
|
|
936
|
+
story: 'Table cells can define a `semanticColor` field with one of the following values: DESTRUCTIVE, CAUTION, INFO, SUCCESS and WARNING',
|
|
937
|
+
},
|
|
938
|
+
},
|
|
939
|
+
},
|
|
940
|
+
};
|
|
941
|
+
|
|
686
942
|
export default meta;
|