Skip to content

Commit 05f1fee

Browse files
vanessatran-ddichrisolsen
authored andcommitted
feat(#2802): upgrade the repo with angular 20
1 parent 8e3e0c0 commit 05f1fee

File tree

160 files changed

+9350
-5210
lines changed

Some content is hidden

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

160 files changed

+9350
-5210
lines changed

libs/angular-components/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
},
1919
"peerDependencies": {
2020
"@abgov/ui-components-common": "^0.0.0 || ^1.0.0",
21-
"@angular/forms": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
22-
"@angular/common": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
23-
"@angular/core": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
21+
"@angular/forms": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
22+
"@angular/common": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
23+
"@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0"
2424
},
2525
"sideEffects": false
2626
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from "@angular/core";
2+
import { CommonModule } from "@angular/common";
23
import { ValueDirective, ValueListDirective } from "./value-directive";
34
import { CheckedDirective } from "./checked-directive";
45

56
@NgModule({
6-
declarations: [ValueDirective, ValueListDirective, CheckedDirective],
7+
imports: [CommonModule, ValueDirective, ValueListDirective, CheckedDirective],
78
exports: [ValueDirective, ValueListDirective, CheckedDirective],
89
schemas: [CUSTOM_ELEMENTS_SCHEMA],
910
})

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Component } from "@angular/core";
2-
import { CommonModule } from "@angular/common";
2+
33

44
@Component({
55
selector: "goab-lib-angular-components",
66
standalone: true,
7-
imports: [CommonModule],
7+
imports: [],
88
templateUrl: "./angular-components.component.html",
99
styleUrl: "./angular-components.component.css",
1010
})

libs/angular-components/src/lib/checked-directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212

1313
// @deprecated: Use the new <goab-checkbox .. /> component
1414
@Directive({
15+
standalone: true,
1516
selector: "[goaChecked]",
1617
providers: [
1718
{

libs/angular-components/src/lib/components/accordion/accordion.spec.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { GoabAccordion } from "./accordion";
2-
import { ComponentFixture, TestBed } from "@angular/core/testing";
2+
import { ComponentFixture, TestBed, fakeAsync, tick } from "@angular/core/testing";
33
import { CUSTOM_ELEMENTS_SCHEMA, Component } from "@angular/core";
44
import { By } from "@angular/platform-browser";
55
import { GoabAccordionHeadingSize, GoabAccordionIconPosition } from "@abgov/ui-components-common";
66

77
@Component({
8+
standalone: true,
9+
imports: [GoabAccordion],
810
template: `
911
<goab-accordion
1012
[heading]="heading"
@@ -31,11 +33,10 @@ describe("GoabAccordion", () => {
3133
let fixture: ComponentFixture<TestAccordionComponent>;
3234
let component: TestAccordionComponent;
3335

34-
beforeEach(async () => {
35-
await TestBed.configureTestingModule({
36-
imports: [GoabAccordion],
36+
beforeEach(fakeAsync(() => {
37+
TestBed.configureTestingModule({
38+
imports: [GoabAccordion, TestAccordionComponent],
3739
schemas: [CUSTOM_ELEMENTS_SCHEMA],
38-
declarations: [TestAccordionComponent],
3940
}).compileComponents();
4041

4142
fixture = TestBed.createComponent(TestAccordionComponent);
@@ -47,7 +48,9 @@ describe("GoabAccordion", () => {
4748
component.iconPosition = "right" as GoabAccordionIconPosition;
4849

4950
fixture.detectChanges();
50-
});
51+
tick();
52+
fixture.detectChanges();
53+
}));
5154

5255
it("should render and set the props correctly", () => {
5356
const accordionElement = fixture.debugElement.query(

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@ import {
1010
Output,
1111
EventEmitter,
1212
booleanAttribute,
13+
OnInit,
14+
ChangeDetectorRef,
1315
} from "@angular/core";
14-
import { NgTemplateOutlet } from "@angular/common";
16+
import { NgTemplateOutlet, CommonModule } from "@angular/common";
1517
import { GoabBaseComponent } from "../base.component";
1618

1719
@Component({
1820
standalone: true,
1921
selector: "goab-accordion",
20-
imports: [NgTemplateOutlet],
22+
imports: [NgTemplateOutlet, CommonModule],
2123
template: `
2224
<goa-accordion
25+
*ngIf="isReady"
2326
[attr.heading]="heading"
2427
[attr.secondarytext]="secondaryText"
2528
[attr.open]="open"
@@ -41,7 +44,7 @@ import { GoabBaseComponent } from "../base.component";
4144
`,
4245
schemas: [CUSTOM_ELEMENTS_SCHEMA],
4346
})
44-
export class GoabAccordion extends GoabBaseComponent {
47+
export class GoabAccordion extends GoabBaseComponent implements OnInit {
4548
@Input() heading?: string;
4649
@Input() secondaryText?: string;
4750
@Input({ transform: booleanAttribute }) open?: boolean;
@@ -52,6 +55,21 @@ export class GoabAccordion extends GoabBaseComponent {
5255

5356
@Output() onChange = new EventEmitter<boolean>();
5457

58+
isReady = false;
59+
60+
constructor(private cdr: ChangeDetectorRef) {
61+
super();
62+
}
63+
64+
ngOnInit(): void {
65+
// For Angular 20, we need to delay rendering the web component
66+
// to ensure all attributes are properly bound before the component initializes
67+
setTimeout(() => {
68+
this.isReady = true;
69+
this.cdr.detectChanges();
70+
}, 0);
71+
}
72+
5573
_onChange(e: Event) {
5674
const detail = (e as CustomEvent).detail;
5775
this.onChange.emit(detail.open as boolean);

libs/angular-components/src/lib/components/badge/badge.spec.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { ComponentFixture, TestBed } from "@angular/core/testing";
1+
import { ComponentFixture, TestBed, fakeAsync, tick } from "@angular/core/testing";
22
import { GoabBadge } from "./badge";
33
import { Component, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
44
import { GoabBadgeType, Spacing } from "@abgov/ui-components-common";
55
import { By } from "@angular/platform-browser";
66

77
@Component({
8+
standalone: true,
9+
imports: [GoabBadge],
810
template: `
911
<goab-badge
1012
[type]="type"
@@ -35,10 +37,9 @@ describe("GoABBadge", () => {
3537
let fixture: ComponentFixture<TestBadgeComponent>;
3638
let component: TestBadgeComponent;
3739

38-
beforeEach(async () => {
39-
await TestBed.configureTestingModule({
40-
imports: [GoabBadge],
41-
declarations: [TestBadgeComponent],
40+
beforeEach(fakeAsync(() => {
41+
TestBed.configureTestingModule({
42+
imports: [GoabBadge, TestBadgeComponent],
4243
schemas: [CUSTOM_ELEMENTS_SCHEMA],
4344
}).compileComponents();
4445

@@ -55,7 +56,9 @@ describe("GoABBadge", () => {
5556
component.mr = "xl" as Spacing;
5657

5758
fixture.detectChanges();
58-
});
59+
tick();
60+
fixture.detectChanges();
61+
}));
5962

6063
it("should render and set the props correctly", () => {
6164
const badgeElement = fixture.debugElement.query(By.css("goa-badge")).nativeElement;

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ import {
44
Component,
55
Input,
66
booleanAttribute,
7+
OnInit,
8+
ChangeDetectorRef,
79
} from "@angular/core";
10+
import { CommonModule } from "@angular/common";
811
import { GoabBaseComponent } from "../base.component";
912

1013
@Component({
1114
standalone: true,
1215
selector: "goab-badge",
1316
template: `
1417
<goa-badge
18+
*ngIf="isReady"
1519
[attr.type]="type"
1620
[attr.icon]="icon"
1721
[attr.icontype]="iconType"
@@ -26,6 +30,7 @@ import { GoabBaseComponent } from "../base.component";
2630
</goa-badge>
2731
`,
2832
schemas: [CUSTOM_ELEMENTS_SCHEMA],
33+
imports: [CommonModule],
2934
styles: [
3035
`
3136
:host {
@@ -34,10 +39,25 @@ import { GoabBaseComponent } from "../base.component";
3439
`,
3540
],
3641
})
37-
export class GoabBadge extends GoabBaseComponent {
42+
export class GoabBadge extends GoabBaseComponent implements OnInit {
3843
@Input() type?: GoabBadgeType;
3944
@Input() content?: string;
4045
@Input({ transform: booleanAttribute }) icon?: boolean;
4146
@Input() iconType?: GoabIconType;
4247
@Input() ariaLabel?: string;
48+
49+
isReady = false;
50+
51+
constructor(private cdr: ChangeDetectorRef) {
52+
super();
53+
}
54+
55+
ngOnInit(): void {
56+
// For Angular 20, we need to delay rendering the web component
57+
// to ensure all attributes are properly bound before the component initializes
58+
setTimeout(() => {
59+
this.isReady = true;
60+
this.cdr.detectChanges();
61+
}, 0);
62+
}
4363
}

libs/angular-components/src/lib/components/block/block.spec.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ComponentFixture, TestBed } from "@angular/core/testing";
1+
import { ComponentFixture, TestBed, fakeAsync, tick } from "@angular/core/testing";
22
import { GoabBlock } from "./block";
33
import { Component, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
44
import {
@@ -9,6 +9,8 @@ import {
99
import { By } from "@angular/platform-browser";
1010

1111
@Component({
12+
standalone: true,
13+
imports: [GoabBlock],
1214
template: `
1315
<goab-block
1416
[gap]="gap"
@@ -39,11 +41,10 @@ describe("GoABBlock", () => {
3941
let fixture: ComponentFixture<TestBlockComponent>;
4042
let component: TestBlockComponent;
4143

42-
beforeEach(async () => {
43-
await TestBed.configureTestingModule({
44-
imports: [GoabBlock],
44+
beforeEach(fakeAsync(() => {
45+
TestBed.configureTestingModule({
46+
imports: [GoabBlock, TestBlockComponent],
4547
schemas: [CUSTOM_ELEMENTS_SCHEMA],
46-
declarations: [TestBlockComponent],
4748
}).compileComponents();
4849

4950
fixture = TestBed.createComponent(TestBlockComponent);
@@ -57,7 +58,9 @@ describe("GoABBlock", () => {
5758
component.ml = "l" as Spacing;
5859
component.mr = "xl" as Spacing;
5960
fixture.detectChanges();
60-
});
61+
tick();
62+
fixture.detectChanges();
63+
}));
6164

6265
it("should render", () => {
6366
const blockElement = fixture.debugElement.query(By.css("goa-block")).nativeElement;

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,23 @@ import {
33
GoabBlockDirection,
44
Spacing,
55
} from "@abgov/ui-components-common";
6-
import { CUSTOM_ELEMENTS_SCHEMA, Component, Input } from "@angular/core";
6+
import {
7+
CUSTOM_ELEMENTS_SCHEMA,
8+
Component,
9+
Input,
10+
OnInit,
11+
ChangeDetectorRef,
12+
} from "@angular/core";
13+
import { CommonModule } from "@angular/common";
714
import { GoabBaseComponent } from "../base.component";
815

916
@Component({
1017
standalone: true,
1118
selector: "goab-block",
19+
imports: [CommonModule],
1220
template: `
1321
<goa-block
22+
*ngIf="isReady"
1423
[attr.gap]="gap"
1524
[attr.direction]="direction"
1625
[attr.alignment]="alignment"
@@ -25,8 +34,23 @@ import { GoabBaseComponent } from "../base.component";
2534
`,
2635
schemas: [CUSTOM_ELEMENTS_SCHEMA],
2736
})
28-
export class GoabBlock extends GoabBaseComponent {
37+
export class GoabBlock extends GoabBaseComponent implements OnInit {
2938
@Input() gap?: Spacing;
3039
@Input() direction?: GoabBlockDirection;
3140
@Input() alignment?: GoabBlockAlignment;
41+
42+
isReady = false;
43+
44+
constructor(private cdr: ChangeDetectorRef) {
45+
super();
46+
}
47+
48+
ngOnInit(): void {
49+
// For Angular 20, we need to delay rendering the web component
50+
// to ensure all attributes are properly bound before the component initializes
51+
setTimeout(() => {
52+
this.isReady = true;
53+
this.cdr.detectChanges();
54+
}, 0);
55+
}
3256
}

0 commit comments

Comments
 (0)