Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 0b9a906

Browse files
authored
refactor: migrate to signal inputs using automated migration (#1270)
* refactor: migrate to signal inputs using automated migration Migrates all compatible inputs to signal inputs.
1 parent 36fa0d2 commit 0b9a906

File tree

8 files changed

+21
-18
lines changed

8 files changed

+21
-18
lines changed

src/app/pages/component-sidenav/component-nav.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="docs-component-viewer-nav">
2-
@if ((params | async)?.section; as section) {
2+
@if ((params() | async)?.section; as section) {
33
<div class="docs-component-viewer-nav-content">
44
<mat-nav-list>
55
@for (component of docItems.getItems(section); track component) {

src/app/pages/component-sidenav/component-sidenav.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import {Component,
2-
Input,
1+
import {
2+
Component,
33
NgModule,
44
NgZone,
55
OnDestroy,
66
OnInit,
77
ViewChild,
88
ViewEncapsulation,
9-
forwardRef
9+
forwardRef,
10+
input
1011
} from '@angular/core';
1112
import {animate, state, style, transition, trigger} from '@angular/animations';
1213
import {CdkAccordionModule} from '@angular/cdk/accordion';
@@ -142,7 +143,7 @@ export class ComponentSidenav implements OnInit, OnDestroy {
142143
],
143144
})
144145
export class ComponentNav {
145-
@Input() params: Observable<Params> | undefined;
146+
readonly params = input<Observable<Params>>();
146147
currentItemId: string | undefined;
147148

148149
constructor(public docItems: DocumentationItems) {}

src/app/shared/carousel/carousel.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import {
66
ElementRef,
77
HostBinding,
88
Inject,
9-
Input,
109
Optional,
1110
QueryList,
1211
ViewChild,
1312
ViewEncapsulation,
13+
input
1414
} from '@angular/core';
1515
import {FocusableOption, FocusKeyManager} from '@angular/cdk/a11y';
1616
import {LEFT_ARROW, RIGHT_ARROW, TAB} from '@angular/cdk/keycodes';
@@ -42,7 +42,7 @@ export class CarouselItem implements FocusableOption {
4242
imports: [MatButtonModule, MatIconModule],
4343
})
4444
export class Carousel implements AfterContentInit {
45-
@Input('aria-label') ariaLabel: string | undefined;
45+
readonly ariaLabel = input<string|undefined>(undefined, { alias: 'aria-label' });
4646
@ContentChildren(CarouselItem) items!: QueryList<CarouselItem>;
4747
@ViewChild('list') list!: ElementRef<HTMLElement>;
4848
@HostBinding('class.animations-disabled') readonly animationsDisabled: boolean;

src/app/shared/doc-viewer/doc-viewer.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Output,
1616
SecurityContext,
1717
ViewContainerRef,
18+
input
1819
} from '@angular/core';
1920
import {Observable, Subscription} from 'rxjs';
2021
import {shareReplay, take, tap} from 'rxjs/operators';
@@ -46,7 +47,7 @@ export class DocViewer implements OnDestroy {
4647
private _portalHosts: DomPortalOutlet[] = [];
4748
private _documentFetchSubscription: Subscription | undefined;
4849

49-
@Input() name: string | undefined;
50+
readonly name = input<string>();
5051

5152
/** The URL of the document to display. */
5253
@Input()

src/app/shared/doc-viewer/header-link.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Input} from '@angular/core';
1+
import {Component} from '@angular/core';
22
import {Router} from '@angular/router';
33
import {MatIconModule} from '@angular/material/icon';
44

@@ -32,7 +32,7 @@ export class HeaderLink {
3232
* Id of the anchor element. Note that is uses "example" because we instantiate the
3333
* header link components through the ComponentPortal.
3434
*/
35-
@Input() example: string | undefined;
35+
example: string = '';
3636

3737
/** Base URL that is used to build an absolute fragment URL. */
3838
private _baseUrl: string;
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div class="docs-example-source-wrapper">
2-
<pre class="docs-example-source"><doc-viewer #viewer [documentUrl]="source"></doc-viewer></pre>
2+
<pre class="docs-example-source"><doc-viewer #viewer [documentUrl]="source()"></doc-viewer></pre>
33
</div>

src/app/shared/example-viewer/code-snippet.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
22
ChangeDetectionStrategy,
33
Component,
4-
Input,
54
ViewChild,
6-
forwardRef
5+
forwardRef,
6+
input
77
} from '@angular/core';
88
import {DocViewer} from '../doc-viewer/doc-viewer';
99

@@ -16,6 +16,6 @@ import {DocViewer} from '../doc-viewer/doc-viewer';
1616
imports: [forwardRef(() => DocViewer)]
1717
})
1818
export class CodeSnippet {
19-
@Input() source: string | undefined;
19+
readonly source = input<string>();
2020
@ViewChild('viewer') viewer!: DocViewer;
2121
}

src/app/shared/table-of-contents/table-of-contents.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import {
33
Component,
44
ElementRef,
55
Inject,
6-
Input,
76
OnDestroy,
87
OnInit,
98
NgZone,
109
ChangeDetectorRef,
10+
input
1111
} from '@angular/core';
1212
import {DOCUMENT} from '@angular/common';
1313
import {ActivatedRoute, Router} from '@angular/router';
@@ -44,7 +44,7 @@ interface Link {
4444
standalone: true
4545
})
4646
export class TableOfContents implements OnInit, AfterViewInit, OnDestroy {
47-
@Input() container: string | undefined;
47+
readonly container = input<string>();
4848

4949
_linkSections: LinkSection[] = [];
5050
_links: Link[] = [];
@@ -87,8 +87,9 @@ export class TableOfContents implements OnInit, AfterViewInit, OnDestroy {
8787
// to subscribe to its scroll event until next tick (when it does exist).
8888
this._ngZone.runOutsideAngular(() => {
8989
Promise.resolve().then(() => {
90-
this._scrollContainer = this.container ?
91-
this._document.querySelector(this.container) as HTMLElement :
90+
const container = this.container();
91+
this._scrollContainer = container ?
92+
this._document.querySelector(container) as HTMLElement :
9293
window;
9394

9495
if (this._scrollContainer) {

0 commit comments

Comments
 (0)