@arbor-education/design-system.components 0.16.0 → 0.17.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/.gather/instructions/project-overview.md +0 -4
- package/.gather/skills/aroo-hunni/SKILL.md +58 -0
- package/CHANGELOG.md +31 -0
- package/CONTRIBUTING.md +1 -0
- package/dist/components/arborLogo/ArborLogo.d.ts +9 -0
- package/dist/components/arborLogo/ArborLogo.d.ts.map +1 -0
- package/dist/components/arborLogo/ArborLogo.js +17 -0
- package/dist/components/arborLogo/ArborLogo.js.map +1 -0
- package/dist/components/arborLogo/ArborLogo.stories.d.ts +94 -0
- package/dist/components/arborLogo/ArborLogo.stories.d.ts.map +1 -0
- package/dist/components/arborLogo/ArborLogo.stories.js +418 -0
- package/dist/components/arborLogo/ArborLogo.stories.js.map +1 -0
- package/dist/components/arborLogo/ArborLogo.test.d.ts +2 -0
- package/dist/components/arborLogo/ArborLogo.test.d.ts.map +1 -0
- package/dist/components/arborLogo/ArborLogo.test.js +32 -0
- package/dist/components/arborLogo/ArborLogo.test.js.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.d.ts +19 -0
- package/dist/components/dataViewCard/DataViewCard.d.ts.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.js +13 -0
- package/dist/components/dataViewCard/DataViewCard.js.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.stories.d.ts +100 -0
- package/dist/components/dataViewCard/DataViewCard.stories.d.ts.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.stories.js +317 -0
- package/dist/components/dataViewCard/DataViewCard.stories.js.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.test.d.ts +2 -0
- package/dist/components/dataViewCard/DataViewCard.test.d.ts.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.test.js +67 -0
- package/dist/components/dataViewCard/DataViewCard.test.js.map +1 -0
- package/dist/components/row/Row.d.ts +2 -1
- package/dist/components/row/Row.d.ts.map +1 -1
- package/dist/components/row/Row.js +2 -2
- package/dist/components/row/Row.js.map +1 -1
- package/dist/components/table/Table.stories.d.ts +1 -0
- package/dist/components/table/Table.stories.d.ts.map +1 -1
- package/dist/components/table/Table.stories.js +27 -2
- package/dist/components/table/Table.stories.js.map +1 -1
- package/dist/components/table/Table.test.js +30 -0
- package/dist/components/table/Table.test.js.map +1 -1
- package/dist/components/table/tableControls/HideColumnsDropdown.d.ts.map +1 -1
- package/dist/components/table/tableControls/HideColumnsDropdown.js +9 -3
- package/dist/components/table/tableControls/HideColumnsDropdown.js.map +1 -1
- package/dist/components/treeRow/TreeRow.d.ts +32 -0
- package/dist/components/treeRow/TreeRow.d.ts.map +1 -0
- package/dist/components/treeRow/TreeRow.js +19 -0
- package/dist/components/treeRow/TreeRow.js.map +1 -0
- package/dist/components/treeRow/TreeRow.stories.d.ts +13 -0
- package/dist/components/treeRow/TreeRow.stories.d.ts.map +1 -0
- package/dist/components/treeRow/TreeRow.stories.js +774 -0
- package/dist/components/treeRow/TreeRow.stories.js.map +1 -0
- package/dist/components/treeRow/TreeRow.test.d.ts +2 -0
- package/dist/components/treeRow/TreeRow.test.d.ts.map +1 -0
- package/dist/components/treeRow/TreeRow.test.js +262 -0
- package/dist/components/treeRow/TreeRow.test.js.map +1 -0
- package/dist/components/treeRow/TreeRowSection.d.ts +12 -0
- package/dist/components/treeRow/TreeRowSection.d.ts.map +1 -0
- package/dist/components/treeRow/TreeRowSection.js +20 -0
- package/dist/components/treeRow/TreeRowSection.js.map +1 -0
- package/dist/index.css +146 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/arborLogo/ArborLogo.stories.tsx +663 -0
- package/src/components/arborLogo/ArborLogo.test.tsx +36 -0
- package/src/components/arborLogo/ArborLogo.tsx +92 -0
- package/src/components/arborLogo/__snapshots__/ArborLogo.test.tsx.snap +424 -0
- package/src/components/dataViewCard/DataViewCard.stories.tsx +464 -0
- package/src/components/dataViewCard/DataViewCard.test.tsx +127 -0
- package/src/components/dataViewCard/DataViewCard.tsx +62 -0
- package/src/components/dataViewCard/dataViewCard.scss +25 -0
- package/src/components/row/Row.tsx +4 -1
- package/src/components/row/row.scss +9 -1
- package/src/components/table/Table.stories.tsx +49 -2
- package/src/components/table/Table.test.tsx +53 -0
- package/src/components/table/tableControls/HideColumnsDropdown.tsx +11 -2
- package/src/components/treeRow/TreeRow.stories.tsx +870 -0
- package/src/components/treeRow/TreeRow.test.tsx +371 -0
- package/src/components/treeRow/TreeRow.tsx +85 -0
- package/src/components/treeRow/TreeRowSection.tsx +56 -0
- package/src/components/treeRow/treeRow.scss +134 -0
- package/src/docs/Contributing.mdx +1 -0
- package/src/index.scss +2 -0
- package/src/index.ts +4 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { Icon } from 'Components/icon/Icon';
|
|
3
|
-
import type { MouseEvent, MouseEventHandler } from 'react';
|
|
3
|
+
import type { CSSProperties, MouseEvent, MouseEventHandler } from 'react';
|
|
4
4
|
import { ENTER_KEY, SPACE_KEY } from 'Utils/keyboardConstants';
|
|
5
5
|
|
|
6
6
|
export type RowProps = {
|
|
7
7
|
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
8
9
|
label?: string;
|
|
9
10
|
value?: string;
|
|
10
11
|
note?: string;
|
|
@@ -14,6 +15,7 @@ export type RowProps = {
|
|
|
14
15
|
export const Row = (props: RowProps) => {
|
|
15
16
|
const {
|
|
16
17
|
className,
|
|
18
|
+
style,
|
|
17
19
|
label,
|
|
18
20
|
value,
|
|
19
21
|
note,
|
|
@@ -31,6 +33,7 @@ export const Row = (props: RowProps) => {
|
|
|
31
33
|
},
|
|
32
34
|
className,
|
|
33
35
|
)}
|
|
36
|
+
style={style}
|
|
34
37
|
onClick={onClick}
|
|
35
38
|
onKeyDown={(e) => {
|
|
36
39
|
if (isClickable && [ENTER_KEY, SPACE_KEY].includes(e.key)) {
|
|
@@ -47,15 +47,23 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
&__label {
|
|
50
|
-
|
|
50
|
+
flex-basis: 30%;
|
|
51
|
+
max-width: 190px;
|
|
51
52
|
font-weight: var(--font-weight-semi-bold);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
&__value {
|
|
55
56
|
flex-grow: 1;
|
|
57
|
+
flex-basis: 70%;
|
|
58
|
+
|
|
59
|
+
&:has(+ .ds-row__note) {
|
|
60
|
+
flex-basis: 50%;
|
|
61
|
+
}
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
&__note {
|
|
59
65
|
font-style: italic;
|
|
66
|
+
flex-basis: 20%;
|
|
67
|
+
text-align: right;
|
|
60
68
|
}
|
|
61
69
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { fn } from '@storybook/test';
|
|
2
3
|
import {
|
|
3
4
|
Controls,
|
|
4
5
|
Heading as DocHeading,
|
|
@@ -843,7 +844,53 @@ export const WithHideColumnsDropdown: Story = {
|
|
|
843
844
|
headerContent={(
|
|
844
845
|
<HideColumnsDropdown
|
|
845
846
|
overrideColumnHiding={overrideColumnHiding}
|
|
846
|
-
onSelectionChanged={
|
|
847
|
+
onSelectionChanged={fn()}
|
|
848
|
+
/>
|
|
849
|
+
)}
|
|
850
|
+
/>
|
|
851
|
+
);
|
|
852
|
+
},
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
export const WithInitiallyHiddenColumns: Story = {
|
|
856
|
+
parameters: {
|
|
857
|
+
docs: {
|
|
858
|
+
description: {
|
|
859
|
+
story:
|
|
860
|
+
'Use AG Grid initial state to start with selected columns hidden. This example hides the email and role columns on first render.',
|
|
861
|
+
},
|
|
862
|
+
},
|
|
863
|
+
},
|
|
864
|
+
args: {
|
|
865
|
+
rowData: sampleData,
|
|
866
|
+
columnDefs: sampleColumnDefs,
|
|
867
|
+
defaultColDef,
|
|
868
|
+
domLayout: 'autoHeight',
|
|
869
|
+
initialState: {
|
|
870
|
+
columnVisibility: {
|
|
871
|
+
hiddenColIds: ['email', 'role'],
|
|
872
|
+
},
|
|
873
|
+
},
|
|
874
|
+
},
|
|
875
|
+
render: (args) => {
|
|
876
|
+
const {
|
|
877
|
+
rowData,
|
|
878
|
+
columnDefs,
|
|
879
|
+
defaultColDef,
|
|
880
|
+
domLayout,
|
|
881
|
+
initialState,
|
|
882
|
+
} = args;
|
|
883
|
+
|
|
884
|
+
return (
|
|
885
|
+
<Table
|
|
886
|
+
rowData={rowData}
|
|
887
|
+
columnDefs={columnDefs}
|
|
888
|
+
defaultColDef={defaultColDef}
|
|
889
|
+
domLayout={domLayout}
|
|
890
|
+
initialState={initialState}
|
|
891
|
+
headerContent={(
|
|
892
|
+
<HideColumnsDropdown
|
|
893
|
+
onSelectionChanged={fn()}
|
|
847
894
|
/>
|
|
848
895
|
)}
|
|
849
896
|
/>
|
|
@@ -895,7 +942,7 @@ export const WithRestrictedHideColumnsDropdown: Story = {
|
|
|
895
942
|
headerContent={(
|
|
896
943
|
<HideColumnsDropdown
|
|
897
944
|
overrideColumnHiding={overrideColumnHiding}
|
|
898
|
-
onSelectionChanged={
|
|
945
|
+
onSelectionChanged={fn()}
|
|
899
946
|
columns={columns}
|
|
900
947
|
/>
|
|
901
948
|
)}
|
|
@@ -7,6 +7,7 @@ import { HideColumnsDropdown } from 'Components/table/tableControls/HideColumnsD
|
|
|
7
7
|
import { TableSettingsDropdown } from './tableControls/TableSettingsDropdown';
|
|
8
8
|
import userEvent from '@testing-library/user-event';
|
|
9
9
|
import type { GridApi } from 'ag-grid-enterprise';
|
|
10
|
+
import type { Column } from 'ag-grid-community';
|
|
10
11
|
import * as focusFirstFocusableElementModule from 'Utils/focusFirstFocusableElement';
|
|
11
12
|
|
|
12
13
|
describe('Table', () => {
|
|
@@ -385,6 +386,25 @@ describe('Table', () => {
|
|
|
385
386
|
});
|
|
386
387
|
});
|
|
387
388
|
|
|
389
|
+
test('reflects initially hidden columns in dropdown text', async () => {
|
|
390
|
+
render(
|
|
391
|
+
<Table
|
|
392
|
+
columnDefs={columnDefs}
|
|
393
|
+
rowData={rowData}
|
|
394
|
+
initialState={{
|
|
395
|
+
columnVisibility: {
|
|
396
|
+
hiddenColIds: ['email'],
|
|
397
|
+
},
|
|
398
|
+
}}
|
|
399
|
+
headerContent={<HideColumnsDropdown />}
|
|
400
|
+
/>,
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
await waitFor(() => {
|
|
404
|
+
expect(screen.getByText('Hide (1)')).toBeInTheDocument();
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
|
|
388
408
|
test('works with custom columns prop', async () => {
|
|
389
409
|
const mockColumn = {
|
|
390
410
|
getColDef: () => ({ headerName: 'Custom Column' }),
|
|
@@ -417,6 +437,39 @@ describe('Table', () => {
|
|
|
417
437
|
expect(menuItems[0]).toHaveTextContent('Custom Column');
|
|
418
438
|
});
|
|
419
439
|
|
|
440
|
+
test('reflects initially hidden state when using custom columns prop', async () => {
|
|
441
|
+
const visibleColumn = {
|
|
442
|
+
getColDef: () => ({ headerName: 'Visible Column' }),
|
|
443
|
+
isVisible: () => true,
|
|
444
|
+
getColId: () => 'visible',
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
const hiddenColumn = {
|
|
448
|
+
getColDef: () => ({ headerName: 'Hidden Column' }),
|
|
449
|
+
isVisible: () => false,
|
|
450
|
+
getColId: () => 'hidden',
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
render(
|
|
454
|
+
<div>
|
|
455
|
+
<HideColumnsDropdown
|
|
456
|
+
columns={[visibleColumn, hiddenColumn] as unknown as Column[]}
|
|
457
|
+
overrideColumnHiding
|
|
458
|
+
/>
|
|
459
|
+
</div>,
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
await waitFor(() => expect(screen.getByText('Hide (1)')).toBeInTheDocument());
|
|
463
|
+
await userEvent.click(screen.getByText('Hide (1)'));
|
|
464
|
+
|
|
465
|
+
const menuItems = await screen.findAllByRole('menuitemcheckbox');
|
|
466
|
+
const visibleColumnItem = menuItems.find(item => item.textContent === 'Visible Column');
|
|
467
|
+
const hiddenColumnItem = menuItems.find(item => item.textContent === 'Hidden Column');
|
|
468
|
+
|
|
469
|
+
expect(visibleColumnItem).toHaveAttribute('aria-checked', 'false');
|
|
470
|
+
expect(hiddenColumnItem).toHaveAttribute('aria-checked', 'true');
|
|
471
|
+
});
|
|
472
|
+
|
|
420
473
|
test('returns null when no columns are available', () => {
|
|
421
474
|
const { container } = render(
|
|
422
475
|
<div><HideColumnsDropdown columns={[]} /></div>,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SelectDropdown } from 'Components/formField/inputs/selectDropdown/SelectDropdown';
|
|
2
|
-
import { useContext, useState } from 'react';
|
|
2
|
+
import { useContext, useEffect, useState } from 'react';
|
|
3
3
|
import { GridApiContext } from '../GridApiContext';
|
|
4
4
|
import type { Column } from 'ag-grid-community';
|
|
5
5
|
|
|
@@ -9,6 +9,10 @@ export type HideColumnsDropdownProps = {
|
|
|
9
9
|
overrideColumnHiding?: boolean;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
const getHiddenColumnIds = (columns?: Column[] | null) => columns
|
|
13
|
+
?.filter(column => !column.isVisible())
|
|
14
|
+
.map(column => column.getColId()) ?? [];
|
|
15
|
+
|
|
12
16
|
export const HideColumnsDropdown = (props: HideColumnsDropdownProps) => {
|
|
13
17
|
const {
|
|
14
18
|
columns: rawColumns,
|
|
@@ -18,7 +22,11 @@ export const HideColumnsDropdown = (props: HideColumnsDropdownProps) => {
|
|
|
18
22
|
|
|
19
23
|
const gridApi = useContext(GridApiContext);
|
|
20
24
|
const currentColumns = rawColumns || gridApi?.getColumns();
|
|
21
|
-
const [hiddenColumns, setHiddenColumns] = useState<string[]>(
|
|
25
|
+
const [hiddenColumns, setHiddenColumns] = useState<string[]>(() => getHiddenColumnIds(rawColumns));
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setHiddenColumns(getHiddenColumnIds(currentColumns));
|
|
29
|
+
}, [currentColumns]);
|
|
22
30
|
|
|
23
31
|
if (!currentColumns || currentColumns.length === 0) return null;
|
|
24
32
|
|
|
@@ -50,6 +58,7 @@ export const HideColumnsDropdown = (props: HideColumnsDropdownProps) => {
|
|
|
50
58
|
multiple
|
|
51
59
|
placeholder={placeholderText}
|
|
52
60
|
options={options}
|
|
61
|
+
selectedValues={hiddenColumns}
|
|
53
62
|
onSelectionChange={handleVisibilityChange}
|
|
54
63
|
alwaysShowPlaceholder
|
|
55
64
|
/>
|