Skip to content

Commit 7fce4c9

Browse files
feat(#2609): add data-grid component
1 parent 14a6673 commit 7fce4c9

File tree

57 files changed

+1347
-679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1347
-679
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { CUSTOM_ELEMENTS_SCHEMA, Component } from "@angular/core";
2+
3+
@Component({
4+
standalone: true,
5+
selector: "goab-data-grid",
6+
template: `
7+
<goa-data-grid>
8+
<ng-content></ng-content>
9+
</goa-data-grid>
10+
`,
11+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
12+
})
13+
export class GoabDataGrid {}

libs/angular-components/src/lib/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export * from "./chip/chip";
1313
export * from "./circular-progress/circular-progress";
1414
export * from "./column-layout/column-layout";
1515
export * from "./container/container";
16+
export * from "./data-grid/data-grid";
1617
export * from "./date-picker/date-picker";
1718
export * from "./details/details";
1819
export * from "./divider/divider";

libs/react-components/specs/dropdown.browser.spec.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,11 @@ describe("Dropdown Component", () => {
434434
await option2.click();
435435
});
436436

437-
// Result
438-
expect(onChange).toHaveBeenCalledTimes(1);
437+
// Result - Wait for onChange to be called
438+
await vi.waitFor(() => {
439+
expect(onChange).toHaveBeenCalledTimes(1);
440+
});
441+
439442
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({
440443
name: "options",
441444
value: 2

libs/react-components/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export * from "./lib/checkbox/checkbox";
1212
export * from "./lib/chip/chip";
1313
export * from "./lib/circular-progress/circular-progress";
1414
export * from "./lib/container/container";
15+
export * from "./lib/data-grid/data-grid";
1516
export * from "./lib/date-picker/date-picker";
1617
export * from "./lib/details/details";
1718
export * from "./lib/divider/divider";

libs/react-components/src/lib/accordion/accordion.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
GoabAccordionIconPosition,
66
Margins,
77
} from "@abgov/ui-components-common";
8+
import { DataGridProps, useDataGridProps } from "../common/data-props";
89

910
interface WCProps extends Margins {
1011
ref: React.RefObject<HTMLElement | null>;
@@ -27,7 +28,7 @@ declare module "react" {
2728
}
2829
}
2930

30-
export interface GoabAccordionProps extends Margins {
31+
export interface GoabAccordionProps extends Margins, DataGridProps {
3132
open?: boolean;
3233
headingSize?: GoabAccordionHeadingSize;
3334
secondaryText?: string;
@@ -40,23 +41,23 @@ export interface GoabAccordionProps extends Margins {
4041
children?: ReactNode;
4142
}
4243

43-
export function GoabAccordion({
44-
open,
45-
heading,
46-
headingSize,
47-
secondaryText,
48-
headingContent,
49-
iconPosition,
50-
maxWidth,
51-
testId,
52-
onChange,
53-
children,
54-
mt,
55-
mr,
56-
mb,
57-
ml,
58-
}: GoabAccordionProps): JSX.Element {
44+
export function GoabAccordion(props: GoabAccordionProps): JSX.Element {
5945
const ref = useRef<HTMLElement>(null);
46+
const [dataGridProps, {
47+
open,
48+
heading,
49+
headingSize,
50+
secondaryText,
51+
headingContent,
52+
iconPosition,
53+
maxWidth,
54+
testId,
55+
onChange,
56+
children,
57+
mt,
58+
mr,
59+
mb,
60+
ml}] = useDataGridProps(props);
6061

6162
useEffect(() => {
6263
const element = ref.current;
@@ -85,6 +86,7 @@ export function GoabAccordion({
8586
mr={mr}
8687
mb={mb}
8788
ml={ml}
89+
{...dataGridProps}
8890
>
8991
{headingContent && <div slot="headingcontent">{headingContent}</div>}
9092
{children}

libs/react-components/src/lib/app-header-menu/app-header-menu.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ReactNode } from "react";
22
import { GoabIconType } from "@abgov/ui-components-common";
3+
import { DataGridProps, useDataGridProps } from "../common/data-props";
34

45
interface WCProps {
56
heading: string;
@@ -8,7 +9,7 @@ interface WCProps {
89
}
910

1011
/* eslint-disable-next-line */
11-
export interface GoabAppHeaderMenuProps {
12+
export interface GoabAppHeaderMenuProps extends DataGridProps {
1213
heading: string;
1314
leadingIcon?: GoabIconType;
1415
testId?: string;
@@ -25,13 +26,15 @@ declare module "react" {
2526
}
2627

2728
export function GoabAppHeaderMenu(props: GoabAppHeaderMenuProps) {
29+
const [dataGridProps, { heading, leadingIcon, testId, children }] = useDataGridProps(props);
2830
return (
2931
<goa-app-header-menu
30-
heading={props.heading}
31-
leadingicon={props.leadingIcon}
32-
testid={props.testId}
32+
heading={heading}
33+
leadingicon={leadingIcon}
34+
testid={testId}
35+
{...dataGridProps}
3336
>
34-
{props.children}
37+
{children}
3538
</goa-app-header-menu>
3639
);
3740
}

libs/react-components/src/lib/app-header/app-header.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect, useRef, type JSX } from "react";
2+
import { DataGridProps, useDataGridProps } from "../common/data-props";
23

34
interface WCProps {
45
heading?: string;
@@ -19,7 +20,7 @@ declare module "react" {
1920
}
2021
}
2122

22-
export interface GoabAppHeaderProps {
23+
export interface GoabAppHeaderProps extends DataGridProps {
2324
heading?: string;
2425
url?: string;
2526
maxContentWidth?: string;
@@ -29,16 +30,17 @@ export interface GoabAppHeaderProps {
2930
testId?: string;
3031
}
3132

32-
export function GoabAppHeader({
33-
heading,
34-
url,
35-
maxContentWidth,
36-
fullMenuBreakpoint,
37-
testId,
38-
children,
39-
onMenuClick,
40-
}: GoabAppHeaderProps): JSX.Element {
33+
export function GoabAppHeader(props: GoabAppHeaderProps): JSX.Element {
4134
const el = useRef<HTMLElement>(null);
35+
const [dataGridProps, {
36+
heading,
37+
url,
38+
maxContentWidth,
39+
fullMenuBreakpoint,
40+
testId,
41+
children,
42+
onMenuClick
43+
}] = useDataGridProps(props);
4244

4345
useEffect(() => {
4446
if (!el.current) {
@@ -66,6 +68,7 @@ export function GoabAppHeader({
6668
maxcontentwidth={maxContentWidth}
6769
testid={testId}
6870
hasmenuclickhandler={onMenuClick ? "true" : "false"}
71+
{...dataGridProps}
6972
>
7073
{children}
7174
</goa-app-header>

libs/react-components/src/lib/badge/badge.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { GoabBadgeType, Margins } from "@abgov/ui-components-common";
22
import type { JSX } from "react";
3+
import { DataGridProps, useDataGridProps } from "../common/data-props";
34

45
interface WCProps extends Margins {
56
type: GoabBadgeType;
@@ -18,25 +19,27 @@ declare module "react" {
1819
}
1920
}
2021

21-
export interface GoabBadgeProps extends Margins {
22+
export interface GoabBadgeProps extends Margins, DataGridProps {
2223
type: GoabBadgeType;
2324
icon?: boolean;
2425
content?: string;
2526
testId?: string;
2627
ariaLabel?: string;
2728
}
2829

29-
export function GoabBadge({
30-
type,
31-
content,
32-
icon,
33-
testId,
34-
mt,
35-
mr,
36-
mb,
37-
ml,
38-
ariaLabel,
39-
}: GoabBadgeProps): JSX.Element {
30+
export function GoabBadge(props: GoabBadgeProps): JSX.Element {
31+
const [dataGridProps, {
32+
type,
33+
content,
34+
icon,
35+
testId,
36+
mt,
37+
mr,
38+
mb,
39+
ml,
40+
ariaLabel,
41+
}] = useDataGridProps(props);
42+
4043
return (
4144
<goa-badge
4245
type={type}
@@ -48,6 +51,7 @@ export function GoabBadge({
4851
mr={mr}
4952
mb={mb}
5053
ml={ml}
54+
{...dataGridProps}
5155
/>
5256
);
5357
}

libs/react-components/src/lib/block/block.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Spacing,
66
} from "@abgov/ui-components-common";
77
import { ReactNode } from "react";
8+
import { DataGridProps, useDataGridProps } from "../common/data-props";
89

910
export interface WCProps extends Margins {
1011
gap?: Spacing;
@@ -23,7 +24,7 @@ declare module "react" {
2324
}
2425

2526
/* eslint-disable-next-line */
26-
export interface GoabBlockProps extends Margins {
27+
export interface GoabBlockProps extends Margins, DataGridProps {
2728
gap?: Spacing;
2829
direction?: GoabBlockDirection;
2930
alignment?: GoabBlockAlignment;
@@ -32,18 +33,21 @@ export interface GoabBlockProps extends Margins {
3233
}
3334

3435
export function GoabBlock(props: GoabBlockProps) {
36+
const [dataGridProps, { gap, direction, alignment, mt, mr, mb, ml, testId, children}] = useDataGridProps(props);
37+
3538
return (
3639
<goa-block
37-
gap={props.gap}
38-
direction={props.direction}
39-
alignment={props.alignment}
40-
mt={props.mt}
41-
mr={props.mr}
42-
mb={props.mb}
43-
ml={props.ml}
44-
testid={props.testId}
40+
gap={gap}
41+
direction={direction}
42+
alignment={alignment}
43+
mt={mt}
44+
mr={mr}
45+
mb={mb}
46+
ml={ml}
47+
testid={testId}
48+
{...dataGridProps}
4549
>
46-
{props.children}
50+
{children}
4751
</goa-block>
4852
);
4953
}

libs/react-components/src/lib/button-group/button-group.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from "@abgov/ui-components-common";
66

77
import type { JSX } from "react";
8+
import { DataGridProps, useDataGridProps } from "../common/data-props";
89

910
interface WCProps extends Margins {
1011
alignment: GoabButtonGroupAlignment;
@@ -21,23 +22,26 @@ declare module "react" {
2122
}
2223
}
2324

24-
export interface GoabButtonGroupProps extends Margins {
25+
export interface GoabButtonGroupProps extends Margins, DataGridProps {
2526
alignment: GoabButtonGroupAlignment;
2627
gap?: GoabButtonGroupGap;
2728
testId?: string;
2829
children?: React.ReactNode;
30+
[key: `data-grid${string}`]: string | boolean | undefined;
2931
}
3032

31-
export function GoabButtonGroup({
32-
alignment,
33-
gap,
34-
testId,
35-
children,
36-
mt,
37-
mr,
38-
mb,
39-
ml,
40-
}: GoabButtonGroupProps): JSX.Element {
33+
export function GoabButtonGroup(props: GoabButtonGroupProps): JSX.Element {
34+
const [dataGridProps, {
35+
alignment,
36+
gap,
37+
testId,
38+
children,
39+
mt,
40+
mr,
41+
mb,
42+
ml
43+
}] = useDataGridProps(props);
44+
4145
return (
4246
<goa-button-group
4347
alignment={alignment}
@@ -47,6 +51,7 @@ export function GoabButtonGroup({
4751
mb={mb}
4852
ml={ml}
4953
testid={testId}
54+
{...dataGridProps}
5055
>
5156
{children}
5257
</goa-button-group>

0 commit comments

Comments
 (0)