Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
ChangeDetectionStrategy,
Component,
EventEmitter,
Input,
Output,
inject,
input,
} from '@angular/core';
import {NavigationItem} from '../../interfaces/index';
import {NavigationState} from '../../services/index';
Expand All @@ -30,11 +30,11 @@ import {IsActiveNavigationItem} from '../../pipes/is-active-navigation-item.pipe
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NavigationList {
@Input({required: true}) navigationItems: NavigationItem[] = [];
@Input() displayItemsToLevel: number = 2;
@Input() collapsableLevel: number | undefined = undefined;
@Input() expandableLevel: number = 2;
@Input() isDropdownView = false;
readonly navigationItems = input.required<NavigationItem[]>();
readonly displayItemsToLevel = input<number>(2);
readonly collapsableLevel = input<number>();
readonly expandableLevel = input<number>(2);
readonly isDropdownView = input(false);

@Output() linkClicked = new EventEmitter<void>();

Expand All @@ -46,8 +46,8 @@ export class NavigationList {
toggle(item: NavigationItem): void {
if (
item.level === 1 &&
item.level !== this.expandableLevel &&
item.level !== this.collapsableLevel
item.level !== this.expandableLevel() &&
item.level !== this.collapsableLevel()
) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions adev/shared-docs/components/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {ControlValueAccessor, NG_VALUE_ACCESSOR, FormsModule} from '@angular/forms';
import {ChangeDetectionStrategy, Component, Input, forwardRef, signal} from '@angular/core';
import {ChangeDetectionStrategy, Component, Input, forwardRef, signal, input} from '@angular/core';
import {CommonModule} from '@angular/common';

type SelectOptionValue = string | number | boolean;
Expand Down Expand Up @@ -36,9 +36,9 @@ export interface SelectOption {
},
})
export class Select implements ControlValueAccessor {
@Input({required: true, alias: 'selectId'}) id!: string;
@Input({required: true}) name!: string;
@Input({required: true}) options!: SelectOption[];
readonly id = input.required<string>({alias: 'selectId'});
readonly name = input.required<string>();
readonly options = input.required<SelectOption[]>();
@Input() disabled = false;

// Implemented as part of ControlValueAccessor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {ChangeDetectionStrategy, Component, Input, forwardRef, signal} from '@angular/core';
import {ChangeDetectionStrategy, Component, Input, forwardRef, signal, input} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';

Expand All @@ -26,8 +26,8 @@ import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
],
})
export class SlideToggle implements ControlValueAccessor {
@Input({required: true}) buttonId!: string;
@Input({required: true}) label!: string;
readonly buttonId = input.required<string>();
readonly label = input.required<string>();
@Input() disabled = false;

// Implemented as part of ControlValueAccessor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
ChangeDetectionStrategy,
Component,
DestroyRef,
Input,
computed,
inject,
input,
} from '@angular/core';
import {RouterLink} from '@angular/router';
import {TableOfContentsLevel} from '../../interfaces/index';
Expand All @@ -30,7 +30,7 @@ import {IconComponent} from '../icon/icon.component';
})
export class TableOfContents {
// Element that contains the content from which the Table of Contents is built
@Input({required: true}) contentSourceElement!: HTMLElement;
readonly contentSourceElement = input.required<HTMLElement>();

private readonly scrollSpy = inject(TableOfContentsScrollSpy);
private readonly tableOfContentsLoader = inject(TableOfContentsLoader);
Expand All @@ -43,8 +43,9 @@ export class TableOfContents {
TableOfContentsLevel = TableOfContentsLevel;

ngAfterViewInit() {
this.tableOfContentsLoader.buildTableOfContent(this.contentSourceElement);
this.scrollSpy.startListeningToScroll(this.contentSourceElement, this.destroyRef);
const contentSourceElement = this.contentSourceElement();
this.tableOfContentsLoader.buildTableOfContent(contentSourceElement);
this.scrollSpy.startListeningToScroll(contentSourceElement, this.destroyRef);
}

scrollToTop(): void {
Expand Down
11 changes: 6 additions & 5 deletions adev/shared-docs/components/text-field/text-field.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
afterNextRender,
forwardRef,
signal,
input,
} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR} from '@angular/forms';
Expand All @@ -41,11 +42,11 @@ import {IconComponent} from '../icon/icon.component';
export class TextField implements ControlValueAccessor {
@ViewChild('inputRef') private input?: ElementRef<HTMLInputElement>;

@Input() name: string | null = null;
@Input() placeholder: string | null = null;
readonly name = input<string | null>(null);
readonly placeholder = input<string | null>(null);
@Input() disabled = false;
@Input() hideIcon = false;
@Input() autofocus = false;
readonly hideIcon = input(false);
readonly autofocus = input(false);

// Implemented as part of ControlValueAccessor.
private onChange: (value: string) => void = (_: string) => {};
Expand All @@ -55,7 +56,7 @@ export class TextField implements ControlValueAccessor {

constructor() {
afterNextRender(() => {
if (this.autofocus) {
if (this.autofocus()) {
this.input?.nativeElement.focus();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
EnvironmentInjector,
inject,
Injector,
Input,
OnChanges,
PLATFORM_ID,
SimpleChanges,
Expand All @@ -28,6 +27,7 @@ import {
ɵPendingTasks as PendingTasks,
EventEmitter,
Output,
input,
} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {TOC_SKIP_CONTENT_MARKER, NavigationState} from '../../../services/index';
Expand Down Expand Up @@ -66,8 +66,8 @@ export const GITHUB_CONTENT_URL =
},
})
export class DocViewer implements OnChanges {
@Input() docContent?: string;
@Input() hasToc = false;
readonly docContent = input<string>();
readonly hasToc = input(false);
@Output() contentLoaded = new EventEmitter<void>();

private readonly destroyRef = inject(DestroyRef);
Expand All @@ -92,7 +92,7 @@ export class DocViewer implements OnChanges {
async ngOnChanges(changes: SimpleChanges): Promise<void> {
const taskId = this.pendingTasks.add();
if ('docContent' in changes) {
await this.renderContentsAndRunClientSetup(this.docContent!);
await this.renderContentsAndRunClientSetup(this.docContent()!);
}
this.pendingTasks.remove(taskId);
}
Expand Down Expand Up @@ -166,7 +166,7 @@ export class DocViewer implements OnChanges {
}

private renderTableOfContents(element: HTMLElement): void {
if (!this.hasToc) {
if (!this.hasToc()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
signal,
ElementRef,
forwardRef,
input,
} from '@angular/core';
import {CommonModule, DOCUMENT} from '@angular/common';
import {MatTabGroup, MatTabsModule} from '@angular/material/tabs';
Expand Down Expand Up @@ -53,8 +54,8 @@ export class ExampleViewer {
this.exampleMetadata.set(value);
}

@Input() githubUrl: string | null = null;
@Input() stackblitzUrl: string | null = null;
readonly githubUrl = input<string | null>(null);
readonly stackblitzUrl = input<string | null>(null);
@ViewChild('codeTabs') matTabGroup?: MatTabGroup;

private readonly changeDetector = inject(ChangeDetectorRef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {DOCUMENT} from '@angular/common';
import {Directive, ElementRef, EventEmitter, Input, Output, inject} from '@angular/core';
import {Directive, ElementRef, EventEmitter, Output, inject, input} from '@angular/core';

@Directive({
selector: '[docsClickOutside]',
Expand All @@ -17,7 +17,7 @@ import {Directive, ElementRef, EventEmitter, Input, Output, inject} from '@angul
},
})
export class ClickOutside {
@Input('docsClickOutsideIgnore') public ignoredElementsIds: string[] = [];
public readonly ignoredElementsIds = input<string[]>([], {alias: 'docsClickOutsideIgnore'});
@Output('docsClickOutside') public clickOutside = new EventEmitter<void>();

private readonly document = inject(DOCUMENT);
Expand All @@ -33,11 +33,12 @@ export class ClickOutside {
}

private wasClickedOnIgnoredElement($event: PointerEvent): boolean {
if (this.ignoredElementsIds.length === 0) {
const ignoredElementsIds = this.ignoredElementsIds();
if (ignoredElementsIds.length === 0) {
return false;
}

return this.ignoredElementsIds.some((elementId) => {
return ignoredElementsIds.some((elementId) => {
const element = this.document.getElementById(elementId);
const target = $event.target as Node;
const contains = element?.contains(target);
Expand Down
11 changes: 6 additions & 5 deletions adev/shared-docs/directives/search-item/search-item.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {Directive, ElementRef, Input, inject, signal} from '@angular/core';
import {Directive, ElementRef, inject, signal, input} from '@angular/core';
import {Highlightable} from '@angular/cdk/a11y';
import {SearchResult} from '../../interfaces/search-results';

Expand All @@ -18,8 +18,8 @@ import {SearchResult} from '../../interfaces/search-results';
},
})
export class SearchItem implements Highlightable {
@Input() item?: SearchResult;
@Input() disabled = false;
readonly item = input<SearchResult>();
readonly disabled = input(false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually breaking because disabled is overriding the definition of Highlightable


private readonly elementRef = inject(ElementRef<HTMLLIElement>);

Expand All @@ -38,10 +38,11 @@ export class SearchItem implements Highlightable {
}

getLabel(): string {
if (!this.item?.hierarchy) {
const item = this.item();
if (!item?.hierarchy) {
return '';
}
const {hierarchy} = this.item;
const {hierarchy} = item;
return `${hierarchy.lvl0}${hierarchy.lvl1}${hierarchy.lvl2}`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
Component,
EnvironmentInjector,
inject,
Input,
OnInit,
input,
} from '@angular/core';

import {injectAsync} from '../../../core/services/inject-async';
Expand All @@ -33,7 +33,7 @@ export class CodeEditorComponent implements OnInit {
private readonly environmentInjector = inject(EnvironmentInjector);
private readonly embeddedTutorialManager = inject(EmbeddedTutorialManager);

@Input({required: true}) tutorialFiles!: string;
readonly tutorialFiles = input.required<string>();

ngOnInit(): void {
this.loadEmbeddedEditor();
Expand All @@ -44,7 +44,7 @@ export class CodeEditorComponent implements OnInit {
import('../../../editor/index').then((c) => c.NodeRuntimeSandbox),
);

await this.embeddedTutorialManager.fetchAndSetTutorialFiles(this.tutorialFiles);
await this.embeddedTutorialManager.fetchAndSetTutorialFiles(this.tutorialFiles());

this.cdRef.markForCheck();

Expand Down
4 changes: 2 additions & 2 deletions adev/src/app/features/tutorial/tutorial.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import {DOCS_VIEWER_SELECTOR, DocViewer, WINDOW} from '@angular/docs';

import {Component, Input, signal} from '@angular/core';
import {Component, signal, input} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {RouterTestingModule} from '@angular/router/testing';
Expand Down Expand Up @@ -38,7 +38,7 @@ class FakeEmbeddedEditor {}
standalone: true,
})
class FakeDocViewer {
@Input('documentFilePath') documentFilePath: string | undefined;
readonly documentFilePath = input<string>();
}

// TODO: export this class, it's a helpful mock we could you on other tests.
Expand Down