diff --git a/src/cdk/a11y/aria-describer/aria-describer.ts b/src/cdk/a11y/aria-describer/aria-describer.ts index 64166543f497..ed2cd9244e19 100644 --- a/src/cdk/a11y/aria-describer/aria-describer.ts +++ b/src/cdk/a11y/aria-describer/aria-describer.ts @@ -207,8 +207,7 @@ export class AriaDescriber implements OnDestroy { messagesContainer.classList.add(containerClassName); messagesContainer.classList.add('cdk-visually-hidden'); - // @breaking-change 14.0.0 Remove null check for `_platform`. - if (this._platform && !this._platform.isBrowser) { + if (!this._platform.isBrowser) { messagesContainer.setAttribute('platform', 'server'); } diff --git a/src/cdk/portal/dom-portal-outlet.ts b/src/cdk/portal/dom-portal-outlet.ts index aa9255d469e5..11e65cb1ad97 100644 --- a/src/cdk/portal/dom-portal-outlet.ts +++ b/src/cdk/portal/dom-portal-outlet.ts @@ -146,12 +146,6 @@ export class DomPortalOutlet extends BasePortalOutlet { * @breaking-change 10.0.0 */ override attachDomPortal = (portal: DomPortal) => { - // @breaking-change 10.0.0 Remove check and error once the - // `_document` constructor parameter is required. - if (!this._document && (typeof ngDevMode === 'undefined' || ngDevMode)) { - throw Error('Cannot attach DOM portal without _document constructor parameter'); - } - const element = portal.element; if (!element.parentNode && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw Error('DOM portal content must be attached to a parent node.'); diff --git a/src/cdk/portal/portal-directives.ts b/src/cdk/portal/portal-directives.ts index bd8f3199542f..5e685b4c8035 100644 --- a/src/cdk/portal/portal-directives.ts +++ b/src/cdk/portal/portal-directives.ts @@ -203,12 +203,6 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr * @breaking-change 10.0.0 */ override attachDomPortal = (portal: DomPortal) => { - // @breaking-change 9.0.0 Remove check and error once the - // `_document` constructor parameter is required. - if (!this._document && (typeof ngDevMode === 'undefined' || ngDevMode)) { - throw Error('Cannot attach DOM portal without _document constructor parameter'); - } - const element = portal.element; if (!element.parentNode && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw Error('DOM portal content must be attached to a parent node.'); diff --git a/src/material-date-fns-adapter/adapter/date-fns-adapter.ts b/src/material-date-fns-adapter/adapter/date-fns-adapter.ts index 727d57642677..ba4c0bfda867 100644 --- a/src/material-date-fns-adapter/adapter/date-fns-adapter.ts +++ b/src/material-date-fns-adapter/adapter/date-fns-adapter.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Inject, Injectable, Optional} from '@angular/core'; +import {Injectable, inject} from '@angular/core'; import {DateAdapter, MAT_DATE_LOCALE} from '@angular/material/core'; import { Locale, @@ -52,8 +52,11 @@ const DAY_OF_WEEK_FORMATS = { /** Adds date-fns support to Angular Material. */ @Injectable() export class DateFnsAdapter extends DateAdapter { - constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: {}) { + constructor(...args: unknown[]); + + constructor() { super(); + const matDateLocale = inject(MAT_DATE_LOCALE, {optional: true}); this.setLocale(matDateLocale as Locale); } diff --git a/src/material-luxon-adapter/adapter/luxon-date-adapter.ts b/src/material-luxon-adapter/adapter/luxon-date-adapter.ts index a4dc2e2a734a..13a66d5a4f93 100644 --- a/src/material-luxon-adapter/adapter/luxon-date-adapter.ts +++ b/src/material-luxon-adapter/adapter/luxon-date-adapter.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Inject, Injectable, Optional, InjectionToken} from '@angular/core'; +import {Injectable, InjectionToken, inject} from '@angular/core'; import {DateAdapter, MAT_DATE_LOCALE} from '@angular/material/core'; import { DateTime as LuxonDateTime, @@ -70,13 +70,16 @@ export class LuxonDateAdapter extends DateAdapter { private _firstDayOfWeek: number; private _defaultOutputCalendar: LuxonCalendarSystem; - constructor( - @Optional() @Inject(MAT_DATE_LOCALE) dateLocale: string, - @Optional() - @Inject(MAT_LUXON_DATE_ADAPTER_OPTIONS) - options?: MatLuxonDateAdapterOptions, - ) { + constructor(...args: unknown[]); + + constructor() { super(); + + const dateLocale = inject(MAT_DATE_LOCALE, {optional: true}); + const options = inject(MAT_LUXON_DATE_ADAPTER_OPTIONS, { + optional: true, + }); + this._useUTC = !!options?.useUtc; this._firstDayOfWeek = options?.firstDayOfWeek || 0; this._defaultOutputCalendar = options?.defaultOutputCalendar || 'gregory'; diff --git a/src/material-moment-adapter/adapter/moment-date-adapter.ts b/src/material-moment-adapter/adapter/moment-date-adapter.ts index 79c6e095c8cc..207fb18ef402 100644 --- a/src/material-moment-adapter/adapter/moment-date-adapter.ts +++ b/src/material-moment-adapter/adapter/moment-date-adapter.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Inject, Injectable, Optional, InjectionToken} from '@angular/core'; +import {Injectable, InjectionToken, inject} from '@angular/core'; import {DateAdapter, MAT_DATE_LOCALE} from '@angular/material/core'; // Depending on whether rollup is used, moment needs to be imported differently. // Since Moment.js doesn't have a default export, we normally need to import using the `* as` @@ -63,6 +63,10 @@ function range(length: number, valueFunction: (index: number) => T): T[] { /** Adapts Moment.js Dates for use with Angular Material. */ @Injectable() export class MomentDateAdapter extends DateAdapter { + private _options = inject(MAT_MOMENT_DATE_ADAPTER_OPTIONS, { + optional: true, + }); + // Note: all of the methods that accept a `Moment` input parameter immediately call `this.clone` // on it. This is to ensure that we're working with a `Moment` that has the correct locale setting // while avoiding mutating the original object passed to us. Just calling `.locale(...)` on the @@ -78,13 +82,11 @@ export class MomentDateAdapter extends DateAdapter { narrowDaysOfWeek: string[]; }; - constructor( - @Optional() @Inject(MAT_DATE_LOCALE) dateLocale: string, - @Optional() - @Inject(MAT_MOMENT_DATE_ADAPTER_OPTIONS) - private _options?: MatMomentDateAdapterOptions, - ) { + constructor(...args: unknown[]); + + constructor() { super(); + const dateLocale = inject(MAT_DATE_LOCALE, {optional: true}); this.setLocale(dateLocale || moment.locale()); } diff --git a/src/material/autocomplete/autocomplete-origin.ts b/src/material/autocomplete/autocomplete-origin.ts index bf6a96ad6c5f..333c1853742a 100644 --- a/src/material/autocomplete/autocomplete-origin.ts +++ b/src/material/autocomplete/autocomplete-origin.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, ElementRef} from '@angular/core'; +import {Directive, ElementRef, inject} from '@angular/core'; /** * Directive applied to an element to make it usable @@ -18,8 +18,8 @@ import {Directive, ElementRef} from '@angular/core'; standalone: true, }) export class MatAutocompleteOrigin { - constructor( - /** Reference to the element on which the directive is applied. */ - public elementRef: ElementRef, - ) {} + elementRef = inject>(ElementRef); + + constructor(...args: unknown[]); + constructor() {} } diff --git a/src/material/autocomplete/autocomplete-trigger.ts b/src/material/autocomplete/autocomplete-trigger.ts index 2652fb99a3db..6708356e3fd4 100644 --- a/src/material/autocomplete/autocomplete-trigger.ts +++ b/src/material/autocomplete/autocomplete-trigger.ts @@ -28,15 +28,12 @@ import { ChangeDetectorRef, Directive, ElementRef, - Host, - Inject, InjectionToken, Injector, Input, NgZone, OnChanges, OnDestroy, - Optional, SimpleChanges, ViewContainerRef, afterNextRender, @@ -134,10 +131,24 @@ export const MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER = { export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy { + private _element = inject>(ElementRef); + private _overlay = inject(Overlay); + private _viewContainerRef = inject(ViewContainerRef); + private _zone = inject(NgZone); + private _changeDetectorRef = inject(ChangeDetectorRef); + private _dir = inject(Directionality, {optional: true}); + private _formField = inject(MAT_FORM_FIELD, {optional: true, host: true}); + private _document = inject(DOCUMENT); + private _viewportRuler = inject(ViewportRuler); + private _defaults = inject( + MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, + {optional: true}, + ); + private _overlayRef: OverlayRef | null; private _portal: TemplatePortal; private _componentDestroyed = false; - private _scrollStrategy: () => ScrollStrategy; + private _scrollStrategy = inject(MAT_AUTOCOMPLETE_SCROLL_STRATEGY); private _keydownSubscription: Subscription | null; private _outsideClickSubscription: Subscription | null; @@ -238,23 +249,8 @@ export class MatAutocompleteTrigger private _injector = inject(Injector); - constructor( - private _element: ElementRef, - private _overlay: Overlay, - private _viewContainerRef: ViewContainerRef, - private _zone: NgZone, - private _changeDetectorRef: ChangeDetectorRef, - @Inject(MAT_AUTOCOMPLETE_SCROLL_STRATEGY) scrollStrategy: any, - @Optional() private _dir: Directionality | null, - @Optional() @Inject(MAT_FORM_FIELD) @Host() private _formField: MatFormField | null, - @Optional() @Inject(DOCUMENT) private _document: any, - private _viewportRuler: ViewportRuler, - @Optional() - @Inject(MAT_AUTOCOMPLETE_DEFAULT_OPTIONS) - private _defaults?: MatAutocompleteDefaultOptions | null, - ) { - this._scrollStrategy = scrollStrategy; - } + constructor(...args: unknown[]); + constructor() {} /** Class to apply to the panel when it's above the input. */ private _aboveClass = 'mat-mdc-autocomplete-panel-above'; diff --git a/src/material/autocomplete/autocomplete.ts b/src/material/autocomplete/autocomplete.ts index bfa8227258f5..9dc01cd86aba 100644 --- a/src/material/autocomplete/autocomplete.ts +++ b/src/material/autocomplete/autocomplete.ts @@ -14,7 +14,6 @@ import { ContentChildren, ElementRef, EventEmitter, - Inject, InjectionToken, Input, OnDestroy, @@ -24,6 +23,7 @@ import { ViewChild, ViewEncapsulation, booleanAttribute, + inject, } from '@angular/core'; import {AnimationEvent} from '@angular/animations'; import { @@ -119,6 +119,10 @@ export function MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY(): MatAutocompleteDefau standalone: true, }) export class MatAutocomplete implements AfterContentInit, OnDestroy { + private _changeDetectorRef = inject(ChangeDetectorRef); + private _elementRef = inject>(ElementRef); + protected _defaults = inject(MAT_AUTOCOMPLETE_DEFAULT_OPTIONS); + private _activeOptionChanges = Subscription.EMPTY; /** Emits when the panel animation is done. Null if the panel doesn't animate. */ @@ -252,20 +256,19 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy { */ readonly inertGroups: boolean; - constructor( - private _changeDetectorRef: ChangeDetectorRef, - private _elementRef: ElementRef, - @Inject(MAT_AUTOCOMPLETE_DEFAULT_OPTIONS) protected _defaults: MatAutocompleteDefaultOptions, - platform?: Platform, - ) { + constructor(...args: unknown[]); + + constructor() { + const platform = inject(Platform); + // TODO(crisbeto): the problem that the `inertGroups` option resolves is only present on // Safari using VoiceOver. We should occasionally check back to see whether the bug // wasn't resolved in VoiceOver, and if it has, we can remove this and the `inertGroups` // option altogether. this.inertGroups = platform?.SAFARI || false; - this.autoActiveFirstOption = !!_defaults.autoActiveFirstOption; - this.autoSelectActiveOption = !!_defaults.autoSelectActiveOption; - this.requireSelection = !!_defaults.requireSelection; + this.autoActiveFirstOption = !!this._defaults.autoActiveFirstOption; + this.autoSelectActiveOption = !!this._defaults.autoSelectActiveOption; + this.requireSelection = !!this._defaults.requireSelection; this._hideSingleSelectionIndicator = this._defaults.hideSingleSelectionIndicator ?? false; } diff --git a/src/material/badge/badge.ts b/src/material/badge/badge.ts index ebd6d16a2ab2..46050ddd50bf 100644 --- a/src/material/badge/badge.ts +++ b/src/material/badge/badge.ts @@ -15,12 +15,10 @@ import { Directive, ElementRef, inject, - Inject, Input, NgZone, OnDestroy, OnInit, - Optional, Renderer2, ViewEncapsulation, ANIMATION_MODULE_TYPE, @@ -78,6 +76,12 @@ export class _MatBadgeStyleLoader {} standalone: true, }) export class MatBadge implements OnInit, OnDestroy { + private _ngZone = inject(NgZone); + private _elementRef = inject>(ElementRef); + private _ariaDescriber = inject(AriaDescriber); + private _renderer = inject(Renderer2); + private _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + /** * Theme color of the badge. This API is supported in M2 themes only, it * has no effect in M3 themes. @@ -150,18 +154,13 @@ export class MatBadge implements OnInit, OnDestroy { private _document = inject(DOCUMENT); - constructor( - private _ngZone: NgZone, - private _elementRef: ElementRef, - private _ariaDescriber: AriaDescriber, - private _renderer: Renderer2, - @Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string, - ) { - const styleLoader = inject(_CdkPrivateStyleLoader); - styleLoader.load(_MatBadgeStyleLoader); + constructor(...args: unknown[]); + + constructor() { + inject(_CdkPrivateStyleLoader).load(_MatBadgeStyleLoader); if (typeof ngDevMode === 'undefined' || ngDevMode) { - const nativeElement = _elementRef.nativeElement; + const nativeElement = this._elementRef.nativeElement; if (nativeElement.nodeType !== nativeElement.ELEMENT_NODE) { throw Error('matBadge must be attached to an element node.'); } diff --git a/src/material/bottom-sheet/bottom-sheet-container.ts b/src/material/bottom-sheet/bottom-sheet-container.ts index 791cbe3974ed..26ce215859dd 100644 --- a/src/material/bottom-sheet/bottom-sheet-container.ts +++ b/src/material/bottom-sheet/bottom-sheet-container.ts @@ -7,21 +7,15 @@ */ import {AnimationEvent} from '@angular/animations'; -import {CdkDialogContainer, DialogConfig} from '@angular/cdk/dialog'; -import {FocusMonitor, FocusTrapFactory, InteractivityChecker} from '@angular/cdk/a11y'; +import {CdkDialogContainer} from '@angular/cdk/dialog'; import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout'; -import {OverlayRef} from '@angular/cdk/overlay'; -import {DOCUMENT} from '@angular/common'; import { ChangeDetectionStrategy, Component, - ElementRef, EventEmitter, - Inject, - NgZone, OnDestroy, - Optional, ViewEncapsulation, + inject, } from '@angular/core'; import {Subscription} from 'rxjs'; import {matBottomSheetAnimations} from './bottom-sheet-animations'; @@ -67,27 +61,12 @@ export class MatBottomSheetContainer extends CdkDialogContainer implements OnDes /** Whether the component has been destroyed. */ private _destroyed: boolean; - constructor( - elementRef: ElementRef, - focusTrapFactory: FocusTrapFactory, - @Optional() @Inject(DOCUMENT) document: any, - config: DialogConfig, - checker: InteractivityChecker, - ngZone: NgZone, - overlayRef: OverlayRef, - breakpointObserver: BreakpointObserver, - focusMonitor?: FocusMonitor, - ) { - super( - elementRef, - focusTrapFactory, - document, - config, - checker, - ngZone, - overlayRef, - focusMonitor, - ); + constructor(...args: unknown[]); + + constructor() { + super(); + + const breakpointObserver = inject(BreakpointObserver); this._breakpointSubscription = breakpointObserver .observe([Breakpoints.Medium, Breakpoints.Large, Breakpoints.XLarge]) diff --git a/src/material/bottom-sheet/bottom-sheet.spec.ts b/src/material/bottom-sheet/bottom-sheet.spec.ts index 3eb25e436bea..e21a634119a0 100644 --- a/src/material/bottom-sheet/bottom-sheet.spec.ts +++ b/src/material/bottom-sheet/bottom-sheet.spec.ts @@ -14,12 +14,12 @@ import { Component, ComponentRef, Directive, - Inject, Injector, TemplateRef, ViewChild, ViewContainerRef, ViewEncapsulation, + inject, } from '@angular/core'; import { ComponentFixture, @@ -27,7 +27,6 @@ import { fakeAsync, flush, flushMicrotasks, - inject, tick, } from '@angular/core/testing'; import {By} from '@angular/platform-browser'; @@ -63,24 +62,15 @@ describe('MatBottomSheet', () => { ], providers: [{provide: Location, useClass: SpyLocation}], }); - })); - beforeEach(inject( - [MatBottomSheet, OverlayContainer, ViewportRuler, Location], - (bs: MatBottomSheet, oc: OverlayContainer, vr: ViewportRuler, l: Location) => { - bottomSheet = bs; - viewportRuler = vr; - overlayContainerElement = oc.getContainerElement(); - mockLocation = l as SpyLocation; - }, - )); - - beforeEach(() => { + bottomSheet = TestBed.inject(MatBottomSheet); + viewportRuler = TestBed.inject(ViewportRuler); + overlayContainerElement = TestBed.inject(OverlayContainer).getContainerElement(); + mockLocation = TestBed.inject(Location) as SpyLocation; viewContainerFixture = TestBed.createComponent(ComponentWithChildViewContainer); - viewContainerFixture.detectChanges(); testViewContainerRef = viewContainerFixture.componentInstance.childViewContainer; - }); + })); it('should open a bottom sheet with a component', () => { const bottomSheetRef = bottomSheet.open(PizzaMsg, {viewContainerRef: testViewContainerRef}); @@ -873,18 +863,13 @@ describe('MatBottomSheet with parent MatBottomSheet', () => { TestBed.configureTestingModule({ imports: [MatBottomSheetModule, NoopAnimationsModule, ComponentThatProvidesMatBottomSheet], }); - })); - beforeEach(inject( - [MatBottomSheet, OverlayContainer], - (bs: MatBottomSheet, oc: OverlayContainer) => { - parentBottomSheet = bs; - overlayContainerElement = oc.getContainerElement(); - fixture = TestBed.createComponent(ComponentThatProvidesMatBottomSheet); - childBottomSheet = fixture.componentInstance.bottomSheet; - fixture.detectChanges(); - }, - )); + parentBottomSheet = TestBed.inject(MatBottomSheet); + overlayContainerElement = TestBed.inject(OverlayContainer).getContainerElement(); + fixture = TestBed.createComponent(ComponentThatProvidesMatBottomSheet); + childBottomSheet = fixture.componentInstance.bottomSheet; + fixture.detectChanges(); + })); it('should close bottom sheets opened by parent when opening from child', fakeAsync(() => { parentBottomSheet.open(PizzaMsg); @@ -964,22 +949,13 @@ describe('MatBottomSheet with default options', () => { ], providers: [{provide: MAT_BOTTOM_SHEET_DEFAULT_OPTIONS, useValue: defaultConfig}], }); - })); - - beforeEach(inject( - [MatBottomSheet, OverlayContainer], - (b: MatBottomSheet, oc: OverlayContainer) => { - bottomSheet = b; - overlayContainerElement = oc.getContainerElement(); - }, - )); - beforeEach(() => { + bottomSheet = TestBed.inject(MatBottomSheet); + overlayContainerElement = TestBed.inject(OverlayContainer).getContainerElement(); viewContainerFixture = TestBed.createComponent(ComponentWithChildViewContainer); - viewContainerFixture.detectChanges(); testViewContainerRef = viewContainerFixture.componentInstance.childViewContainer; - }); + })); it('should use the provided defaults', () => { bottomSheet.open(PizzaMsg, {viewContainerRef: testViewContainerRef}); @@ -1018,7 +994,7 @@ describe('MatBottomSheet with default options', () => { standalone: true, }) class DirectiveWithViewContainer { - constructor(public viewContainerRef: ViewContainerRef) {} + viewContainerRef = inject(ViewContainerRef); } @Component({ @@ -1057,11 +1033,9 @@ class ComponentWithTemplateRef { standalone: true, }) class PizzaMsg { - constructor( - public bottomSheetRef: MatBottomSheetRef, - public injector: Injector, - public directionality: Directionality, - ) {} + bottomSheetRef = inject>(MatBottomSheetRef); + injector = inject(Injector); + directionality = inject(Directionality); } @Component({ @@ -1086,7 +1060,7 @@ class ContentElementDialog {} imports: [MatBottomSheetModule], }) class ComponentThatProvidesMatBottomSheet { - constructor(public bottomSheet: MatBottomSheet) {} + bottomSheet = inject(MatBottomSheet); } @Component({ @@ -1094,7 +1068,7 @@ class ComponentThatProvidesMatBottomSheet { standalone: true, }) class BottomSheetWithInjectedData { - constructor(@Inject(MAT_BOTTOM_SHEET_DATA) public data: any) {} + data = inject(MAT_BOTTOM_SHEET_DATA); } @Component({ diff --git a/src/material/bottom-sheet/bottom-sheet.ts b/src/material/bottom-sheet/bottom-sheet.ts index 6fdb3522a5d7..240d5cdaa55c 100644 --- a/src/material/bottom-sheet/bottom-sheet.ts +++ b/src/material/bottom-sheet/bottom-sheet.ts @@ -9,16 +9,7 @@ import {Dialog} from '@angular/cdk/dialog'; import {Overlay} from '@angular/cdk/overlay'; import {ComponentType} from '@angular/cdk/portal'; -import { - Injectable, - Optional, - SkipSelf, - TemplateRef, - InjectionToken, - Inject, - OnDestroy, - Injector, -} from '@angular/core'; +import {Injectable, TemplateRef, InjectionToken, OnDestroy, inject} from '@angular/core'; import {MAT_BOTTOM_SHEET_DATA, MatBottomSheetConfig} from './bottom-sheet-config'; import {MatBottomSheetContainer} from './bottom-sheet-container'; import {MatBottomSheetRef} from './bottom-sheet-ref'; @@ -33,8 +24,14 @@ export const MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = new InjectionToken(MAT_BOTTOM_SHEET_DEFAULT_OPTIONS, { + optional: true, + }); + private _bottomSheetRefAtThisLevel: MatBottomSheetRef | null = null; - private _dialog: Dialog; + private _dialog = inject(Dialog); /** Reference to the currently opened bottom sheet. */ get _openedBottomSheetRef(): MatBottomSheetRef | null { @@ -50,16 +47,8 @@ export class MatBottomSheet implements OnDestroy { } } - constructor( - private _overlay: Overlay, - injector: Injector, - @Optional() @SkipSelf() private _parentBottomSheet: MatBottomSheet, - @Optional() - @Inject(MAT_BOTTOM_SHEET_DEFAULT_OPTIONS) - private _defaultOptions?: MatBottomSheetConfig, - ) { - this._dialog = injector.get(Dialog); - } + constructor(...args: unknown[]); + constructor() {} /** * Opens a bottom sheet containing the given component. diff --git a/src/material/bottom-sheet/testing/bottom-sheet-harness.spec.ts b/src/material/bottom-sheet/testing/bottom-sheet-harness.spec.ts index 9c77996ed34d..39ec594a2bda 100644 --- a/src/material/bottom-sheet/testing/bottom-sheet-harness.spec.ts +++ b/src/material/bottom-sheet/testing/bottom-sheet-harness.spec.ts @@ -1,4 +1,4 @@ -import {Component, TemplateRef, ViewChild} from '@angular/core'; +import {Component, TemplateRef, ViewChild, inject} from '@angular/core'; import {ComponentFixture, TestBed} from '@angular/core/testing'; import {HarnessLoader} from '@angular/cdk/testing'; import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed'; @@ -58,9 +58,9 @@ describe('MatBottomSheetHarness', () => { imports: [MatBottomSheetModule], }) class BottomSheetHarnessTest { - @ViewChild(TemplateRef) template: TemplateRef; + readonly bottomSheet = inject(MatBottomSheet); - constructor(readonly bottomSheet: MatBottomSheet) {} + @ViewChild(TemplateRef) template: TemplateRef; open(config?: MatBottomSheetConfig) { return this.bottomSheet.open(this.template, config); diff --git a/src/material/button-toggle/button-toggle.ts b/src/material/button-toggle/button-toggle.ts index f6ef55cd08f0..f62b42990218 100644 --- a/src/material/button-toggle/button-toggle.ts +++ b/src/material/button-toggle/button-toggle.ts @@ -11,7 +11,6 @@ import {SelectionModel} from '@angular/cdk/collections'; import {DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, UP_ARROW, SPACE, ENTER} from '@angular/cdk/keycodes'; import { AfterContentInit, - Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, @@ -23,15 +22,15 @@ import { Input, OnDestroy, OnInit, - Optional, Output, QueryList, ViewChild, ViewEncapsulation, InjectionToken, - Inject, AfterViewInit, booleanAttribute, + inject, + HostAttributeToken, } from '@angular/core'; import {Direction, Directionality} from '@angular/cdk/bidi'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; @@ -137,6 +136,9 @@ export class MatButtonToggleChange { standalone: true, }) export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, AfterContentInit { + private _changeDetector = inject(ChangeDetectorRef); + private _dir = inject(Directionality, {optional: true}); + private _multiple = false; private _disabled = false; private _disabledInteractive = false; @@ -274,13 +276,14 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After } private _hideMultipleSelectionIndicator: boolean; - constructor( - private _changeDetector: ChangeDetectorRef, - @Optional() - @Inject(MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS) - defaultOptions?: MatButtonToggleDefaultOptions, - @Optional() private _dir?: Directionality, - ) { + constructor(...args: unknown[]); + + constructor() { + const defaultOptions = inject( + MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS, + {optional: true}, + ); + this.appearance = defaultOptions && defaultOptions.appearance ? defaultOptions.appearance : 'standard'; this.hideSingleSelectionIndicator = defaultOptions?.hideSingleSelectionIndicator ?? false; @@ -557,6 +560,10 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After imports: [MatRipple, MatPseudoCheckbox], }) export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy { + private _changeDetectorRef = inject(ChangeDetectorRef); + private _elementRef = inject>(ElementRef); + private _focusMonitor = inject(FocusMonitor); + private _checked = false; /** @@ -658,16 +665,16 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy { @Output() readonly change: EventEmitter = new EventEmitter(); - constructor( - @Optional() @Inject(MAT_BUTTON_TOGGLE_GROUP) toggleGroup: MatButtonToggleGroup, - private _changeDetectorRef: ChangeDetectorRef, - private _elementRef: ElementRef, - private _focusMonitor: FocusMonitor, - @Attribute('tabindex') defaultTabIndex: string, - @Optional() - @Inject(MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS) - defaultOptions?: MatButtonToggleDefaultOptions, - ) { + constructor(...args: unknown[]); + + constructor() { + const toggleGroup = inject(MAT_BUTTON_TOGGLE_GROUP, {optional: true})!; + const defaultTabIndex = inject(new HostAttributeToken('tabindex'), {optional: true}); + const defaultOptions = inject( + MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS, + {optional: true}, + ); + const parsedTabIndex = Number(defaultTabIndex); this.tabIndex = parsedTabIndex || parsedTabIndex === 0 ? parsedTabIndex : null; this.buttonToggleGroup = toggleGroup; diff --git a/src/material/button/button-base.ts b/src/material/button/button-base.ts index da5f247c84f6..3fa05fb0f0a3 100644 --- a/src/material/button/button-base.ts +++ b/src/material/button/button-base.ts @@ -10,6 +10,7 @@ import {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; import {Platform} from '@angular/cdk/platform'; import { AfterViewInit, + ANIMATION_MODULE_TYPE, booleanAttribute, Directive, ElementRef, @@ -87,6 +88,11 @@ const HOST_SELECTOR_MDC_CLASS_PAIR: {attribute: string; mdcClasses: string[]}[] /** Base class for all buttons. */ @Directive() export class MatButtonBase implements AfterViewInit, OnDestroy { + _elementRef = inject(ElementRef); + _platform = inject(Platform); + _ngZone = inject(NgZone); + _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + private readonly _focusMonitor = inject(FocusMonitor); /** @@ -147,14 +153,11 @@ export class MatButtonBase implements AfterViewInit, OnDestroy { @Input({transform: booleanAttribute}) disabledInteractive: boolean; - constructor( - public _elementRef: ElementRef, - public _platform: Platform, - public _ngZone: NgZone, - public _animationMode?: string, - ) { + constructor(...args: unknown[]); + + constructor() { const config = inject(MAT_BUTTON_CONFIG, {optional: true}); - const element = _elementRef.nativeElement; + const element = this._elementRef.nativeElement; const classList = (element as HTMLElement).classList; this.disabledInteractive = config?.disabledInteractive ?? false; @@ -242,10 +245,6 @@ export class MatAnchorBase extends MatButtonBase implements OnInit, OnDestroy { }) tabIndex: number; - constructor(elementRef: ElementRef, platform: Platform, ngZone: NgZone, animationMode?: string) { - super(elementRef, platform, ngZone, animationMode); - } - ngOnInit(): void { this._ngZone.runOutsideAngular(() => { this._elementRef.nativeElement.addEventListener('click', this._haltDisabledEvents); diff --git a/src/material/button/button.ts b/src/material/button/button.ts index cea77a03e0e8..36b6b26da002 100644 --- a/src/material/button/button.ts +++ b/src/material/button/button.ts @@ -6,18 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Platform} from '@angular/cdk/platform'; -import { - ChangeDetectionStrategy, - Component, - ElementRef, - Inject, - NgZone, - Optional, - ViewEncapsulation, - ANIMATION_MODULE_TYPE, -} from '@angular/core'; - +import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core'; import {MAT_ANCHOR_HOST, MAT_BUTTON_HOST, MatAnchorBase, MatButtonBase} from './button-base'; /** @@ -42,16 +31,7 @@ import {MAT_ANCHOR_HOST, MAT_BUTTON_HOST, MatAnchorBase, MatButtonBase} from './ changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, }) -export class MatButton extends MatButtonBase { - constructor( - elementRef: ElementRef, - platform: Platform, - ngZone: NgZone, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { - super(elementRef, platform, ngZone, animationMode); - } -} +export class MatButton extends MatButtonBase {} /** * Material Design button component for anchor elements. Anchor elements are used to provide @@ -73,13 +53,4 @@ export class MatButton extends MatButtonBase { changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, }) -export class MatAnchor extends MatAnchorBase { - constructor( - elementRef: ElementRef, - platform: Platform, - ngZone: NgZone, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { - super(elementRef, platform, ngZone, animationMode); - } -} +export class MatAnchor extends MatAnchorBase {} diff --git a/src/material/button/fab.ts b/src/material/button/fab.ts index ae7652801284..f60d4beeaf36 100644 --- a/src/material/button/fab.ts +++ b/src/material/button/fab.ts @@ -6,19 +6,14 @@ * found in the LICENSE file at https://angular.io/license */ -import {Platform} from '@angular/cdk/platform'; import { ChangeDetectionStrategy, Component, - ElementRef, - Inject, InjectionToken, Input, - NgZone, - Optional, ViewEncapsulation, booleanAttribute, - ANIMATION_MODULE_TYPE, + inject, } from '@angular/core'; import {MatAnchor} from './button'; @@ -79,18 +74,16 @@ const defaults = MAT_FAB_DEFAULT_OPTIONS_FACTORY(); standalone: true, }) export class MatFabButton extends MatButtonBase { + private _options = inject(MAT_FAB_DEFAULT_OPTIONS, {optional: true}); + override _isFab = true; @Input({transform: booleanAttribute}) extended: boolean; - constructor( - elementRef: ElementRef, - platform: Platform, - ngZone: NgZone, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - @Optional() @Inject(MAT_FAB_DEFAULT_OPTIONS) private _options?: MatFabDefaultOptions, - ) { - super(elementRef, platform, ngZone, animationMode); + constructor(...args: unknown[]); + + constructor() { + super(); this._options = this._options || defaults; this.color = this._options!.color || defaults.color; } @@ -112,16 +105,14 @@ export class MatFabButton extends MatButtonBase { standalone: true, }) export class MatMiniFabButton extends MatButtonBase { + private _options = inject(MAT_FAB_DEFAULT_OPTIONS, {optional: true}); + override _isFab = true; - constructor( - elementRef: ElementRef, - platform: Platform, - ngZone: NgZone, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - @Optional() @Inject(MAT_FAB_DEFAULT_OPTIONS) private _options?: MatFabDefaultOptions, - ) { - super(elementRef, platform, ngZone, animationMode); + constructor(...args: unknown[]); + + constructor() { + super(); this._options = this._options || defaults; this.color = this._options!.color || defaults.color; } @@ -149,18 +140,16 @@ export class MatMiniFabButton extends MatButtonBase { standalone: true, }) export class MatFabAnchor extends MatAnchor { + private _options = inject(MAT_FAB_DEFAULT_OPTIONS, {optional: true}); + override _isFab = true; @Input({transform: booleanAttribute}) extended: boolean; - constructor( - elementRef: ElementRef, - platform: Platform, - ngZone: NgZone, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - @Optional() @Inject(MAT_FAB_DEFAULT_OPTIONS) private _options?: MatFabDefaultOptions, - ) { - super(elementRef, platform, ngZone, animationMode); + constructor(...args: unknown[]); + + constructor() { + super(); this._options = this._options || defaults; this.color = this._options!.color || defaults.color; } @@ -182,16 +171,14 @@ export class MatFabAnchor extends MatAnchor { standalone: true, }) export class MatMiniFabAnchor extends MatAnchor { + private _options = inject(MAT_FAB_DEFAULT_OPTIONS, {optional: true}); + override _isFab = true; - constructor( - elementRef: ElementRef, - platform: Platform, - ngZone: NgZone, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - @Optional() @Inject(MAT_FAB_DEFAULT_OPTIONS) private _options?: MatFabDefaultOptions, - ) { - super(elementRef, platform, ngZone, animationMode); + constructor(...args: unknown[]); + + constructor() { + super(); this._options = this._options || defaults; this.color = this._options!.color || defaults.color; } diff --git a/src/material/button/icon-button.ts b/src/material/button/icon-button.ts index 48a79cf90960..390cfa605e10 100644 --- a/src/material/button/icon-button.ts +++ b/src/material/button/icon-button.ts @@ -6,17 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Platform} from '@angular/cdk/platform'; -import { - ChangeDetectionStrategy, - Component, - ElementRef, - Inject, - NgZone, - Optional, - ViewEncapsulation, - ANIMATION_MODULE_TYPE, -} from '@angular/core'; +import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core'; import {MAT_ANCHOR_HOST, MAT_BUTTON_HOST, MatAnchorBase, MatButtonBase} from './button-base'; /** @@ -35,14 +25,10 @@ import {MAT_ANCHOR_HOST, MAT_BUTTON_HOST, MatAnchorBase, MatButtonBase} from './ standalone: true, }) export class MatIconButton extends MatButtonBase { - constructor( - elementRef: ElementRef, - platform: Platform, - ngZone: NgZone, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { - super(elementRef, platform, ngZone, animationMode); + constructor(...args: unknown[]); + constructor() { + super(); this._rippleLoader.configureRipple(this._elementRef.nativeElement, {centered: true}); } } @@ -62,13 +48,4 @@ export class MatIconButton extends MatButtonBase { changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, }) -export class MatIconAnchor extends MatAnchorBase { - constructor( - elementRef: ElementRef, - platform: Platform, - ngZone: NgZone, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { - super(elementRef, platform, ngZone, animationMode); - } -} +export class MatIconAnchor extends MatAnchorBase {} diff --git a/src/material/card/card.ts b/src/material/card/card.ts index 253a1b0cb4a6..a27d189130dc 100644 --- a/src/material/card/card.ts +++ b/src/material/card/card.ts @@ -10,11 +10,10 @@ import { ChangeDetectionStrategy, Component, Directive, - Inject, InjectionToken, Input, - Optional, ViewEncapsulation, + inject, } from '@angular/core'; export type MatCardAppearance = 'outlined' | 'raised'; @@ -51,7 +50,10 @@ export const MAT_CARD_CONFIG = new InjectionToken('MAT_CARD_CONFI export class MatCard { @Input() appearance: MatCardAppearance; - constructor(@Inject(MAT_CARD_CONFIG) @Optional() config?: MatCardConfig) { + constructor(...args: unknown[]); + + constructor() { + const config = inject(MAT_CARD_CONFIG, {optional: true}); this.appearance = config?.appearance || 'raised'; } } diff --git a/src/material/checkbox/checkbox.ts b/src/material/checkbox/checkbox.ts index b4627499dae5..a968273107bf 100644 --- a/src/material/checkbox/checkbox.ts +++ b/src/material/checkbox/checkbox.ts @@ -10,17 +10,14 @@ import {FocusableOption} from '@angular/cdk/a11y'; import { ANIMATION_MODULE_TYPE, AfterViewInit, - Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, - Inject, Input, NgZone, OnChanges, - Optional, Output, SimpleChanges, ViewChild, @@ -28,6 +25,8 @@ import { booleanAttribute, forwardRef, numberAttribute, + inject, + HostAttributeToken, } from '@angular/core'; import { AbstractControl, @@ -118,6 +117,14 @@ const defaults = MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY(); export class MatCheckbox implements AfterViewInit, OnChanges, ControlValueAccessor, Validator, FocusableOption { + _elementRef = inject>(ElementRef); + private _changeDetectorRef = inject(ChangeDetectorRef); + private _ngZone = inject(NgZone); + _animationMode? = inject(ANIMATION_MODULE_TYPE, {optional: true}); + private _options = inject(MAT_CHECKBOX_DEFAULT_OPTIONS, { + optional: true, + }); + /** Focuses the checkbox. */ focus() { this._inputElement.nativeElement.focus(); @@ -240,19 +247,15 @@ export class MatCheckbox private _controlValueAccessorChangeFn: (value: any) => void = () => {}; private _validatorChangeFn = () => {}; - constructor( - public _elementRef: ElementRef, - private _changeDetectorRef: ChangeDetectorRef, - private _ngZone: NgZone, - @Attribute('tabindex') tabIndex: string, - @Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string, - @Optional() @Inject(MAT_CHECKBOX_DEFAULT_OPTIONS) private _options?: MatCheckboxDefaultOptions, - ) { + constructor(...args: unknown[]); + + constructor() { + const tabIndex = inject(new HostAttributeToken('tabindex'), {optional: true}); this._options = this._options || defaults; this.color = this._options.color || defaults.color; - this.tabIndex = parseInt(tabIndex) || 0; + this.tabIndex = tabIndex == null ? 0 : parseInt(tabIndex) || 0; this.id = this._uniqueId = `mat-mdc-checkbox-${++nextUniqueId}`; - this.disabledInteractive = _options?.disabledInteractive ?? false; + this.disabledInteractive = this._options?.disabledInteractive ?? false; } ngOnChanges(changes: SimpleChanges) { diff --git a/src/material/chips/chip-action.ts b/src/material/chips/chip-action.ts index 8dc7e17ca98e..8eee33cf6f79 100644 --- a/src/material/chips/chip-action.ts +++ b/src/material/chips/chip-action.ts @@ -9,10 +9,10 @@ import { Directive, ElementRef, - Inject, Input, booleanAttribute, numberAttribute, + inject, } from '@angular/core'; import {ENTER, SPACE} from '@angular/cdk/keycodes'; import {MAT_CHIP} from './tokens'; @@ -37,6 +37,14 @@ import {MAT_CHIP} from './tokens'; standalone: true, }) export class MatChipAction { + _elementRef = inject>(ElementRef); + protected _parentChip = inject<{ + _handlePrimaryActionInteraction(): void; + remove(): void; + disabled: boolean; + _isEditing?: boolean; + }>(MAT_CHIP); + /** Whether the action is interactive. */ @Input() isInteractive = true; @@ -46,7 +54,7 @@ export class MatChipAction { /** Whether the action is disabled. */ @Input({transform: booleanAttribute}) get disabled(): boolean { - return this._disabled || this._parentChip.disabled; + return this._disabled || this._parentChip?.disabled || false; } set disabled(value: boolean) { this._disabled = value; @@ -83,18 +91,11 @@ export class MatChipAction { : this.tabIndex.toString(); } - constructor( - public _elementRef: ElementRef, - @Inject(MAT_CHIP) - protected _parentChip: { - _handlePrimaryActionInteraction(): void; - remove(): void; - disabled: boolean; - _isEditing?: boolean; - }, - ) { - if (_elementRef.nativeElement.nodeName === 'BUTTON') { - _elementRef.nativeElement.setAttribute('type', 'button'); + constructor(...args: unknown[]); + + constructor() { + if (this._elementRef.nativeElement.nodeName === 'BUTTON') { + this._elementRef.nativeElement.setAttribute('type', 'button'); } } diff --git a/src/material/chips/chip-edit-input.ts b/src/material/chips/chip-edit-input.ts index c308c0f87a16..215ef7c50cfd 100644 --- a/src/material/chips/chip-edit-input.ts +++ b/src/material/chips/chip-edit-input.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, ElementRef, Inject} from '@angular/core'; +import {Directive, ElementRef, inject} from '@angular/core'; import {DOCUMENT} from '@angular/common'; /** @@ -24,10 +24,11 @@ import {DOCUMENT} from '@angular/common'; standalone: true, }) export class MatChipEditInput { - constructor( - private readonly _elementRef: ElementRef, - @Inject(DOCUMENT) private readonly _document: any, - ) {} + private readonly _elementRef = inject(ElementRef); + private readonly _document = inject(DOCUMENT); + + constructor(...args: unknown[]); + constructor() {} initialize(initialValue: string) { this.getNativeElement().focus(); diff --git a/src/material/chips/chip-grid.ts b/src/material/chips/chip-grid.ts index 60cb8f6af3bd..593b18e351c9 100644 --- a/src/material/chips/chip-grid.ts +++ b/src/material/chips/chip-grid.ts @@ -6,26 +6,22 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directionality} from '@angular/cdk/bidi'; import {DOWN_ARROW, hasModifierKey, TAB, UP_ARROW} from '@angular/cdk/keycodes'; import { AfterContentInit, AfterViewInit, booleanAttribute, ChangeDetectionStrategy, - ChangeDetectorRef, Component, ContentChildren, DoCheck, - ElementRef, EventEmitter, Input, OnDestroy, - Optional, Output, QueryList, - Self, ViewEncapsulation, + inject, } from '@angular/core'; import { ControlValueAccessor, @@ -92,6 +88,8 @@ export class MatChipGrid MatFormFieldControl, OnDestroy { + ngControl = inject(NgControl, {optional: true, self: true}); + /** * Implemented as part of MatFormFieldControl. * @docs-private @@ -254,16 +252,14 @@ export class MatChipGrid this._errorStateTracker.errorState = value; } - constructor( - elementRef: ElementRef, - changeDetectorRef: ChangeDetectorRef, - @Optional() dir: Directionality, - @Optional() parentForm: NgForm, - @Optional() parentFormGroup: FormGroupDirective, - defaultErrorStateMatcher: ErrorStateMatcher, - @Optional() @Self() public ngControl: NgControl, - ) { - super(elementRef, changeDetectorRef, dir); + constructor(...args: unknown[]); + + constructor() { + super(); + + const parentForm = inject(NgForm, {optional: true}); + const parentFormGroup = inject(FormGroupDirective, {optional: true}); + const defaultErrorStateMatcher = inject(ErrorStateMatcher); if (this.ngControl) { this.ngControl.valueAccessor = this; @@ -271,7 +267,7 @@ export class MatChipGrid this._errorStateTracker = new _ErrorStateTracker( defaultErrorStateMatcher, - ngControl, + this.ngControl, parentFormGroup, parentForm, this.stateChanges, diff --git a/src/material/chips/chip-input.ts b/src/material/chips/chip-input.ts index 6f39cbdb906c..09b367ab048c 100644 --- a/src/material/chips/chip-input.ts +++ b/src/material/chips/chip-input.ts @@ -11,13 +11,12 @@ import { Directive, ElementRef, EventEmitter, - Inject, Input, OnChanges, OnDestroy, - Optional, Output, booleanAttribute, + inject, } from '@angular/core'; import {MatFormField, MAT_FORM_FIELD} from '@angular/material/form-field'; import {MatChipsDefaultOptions, MAT_CHIPS_DEFAULT_OPTIONS} from './tokens'; @@ -69,6 +68,8 @@ let nextUniqueId = 0; standalone: true, }) export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy { + protected _elementRef = inject>(ElementRef); + /** Whether the control is focused. */ focused: boolean = false; @@ -127,11 +128,12 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy { /** The native input element to which this directive is attached. */ readonly inputElement!: HTMLInputElement; - constructor( - protected _elementRef: ElementRef, - @Inject(MAT_CHIPS_DEFAULT_OPTIONS) defaultOptions: MatChipsDefaultOptions, - @Optional() @Inject(MAT_FORM_FIELD) formField?: MatFormField, - ) { + constructor(...args: unknown[]); + + constructor() { + const defaultOptions = inject(MAT_CHIPS_DEFAULT_OPTIONS); + const formField = inject(MAT_FORM_FIELD, {optional: true}); + this.inputElement = this._elementRef.nativeElement as HTMLInputElement; this.separatorKeyCodes = defaultOptions.separatorKeyCodes; diff --git a/src/material/chips/chip-row.ts b/src/material/chips/chip-row.ts index 992e2d351b2c..c1a552c299ae 100644 --- a/src/material/chips/chip-row.ts +++ b/src/material/chips/chip-row.ts @@ -6,29 +6,19 @@ * found in the LICENSE file at https://angular.io/license */ -import {FocusMonitor} from '@angular/cdk/a11y'; import {ENTER} from '@angular/cdk/keycodes'; -import {DOCUMENT} from '@angular/common'; import { - ANIMATION_MODULE_TYPE, AfterViewInit, - Attribute, ChangeDetectionStrategy, - ChangeDetectorRef, Component, ContentChild, - ElementRef, EventEmitter, - Inject, Input, - NgZone, - Optional, Output, ViewChild, ViewEncapsulation, afterNextRender, } from '@angular/core'; -import {MAT_RIPPLE_GLOBAL_OPTIONS, RippleGlobalOptions} from '@angular/material/core'; import {takeUntil} from 'rxjs/operators'; import {MatChip, MatChipEvent} from './chip'; import {MatChipAction} from './chip-action'; @@ -105,27 +95,10 @@ export class MatChipRow extends MatChip implements AfterViewInit { _isEditing = false; - constructor( - changeDetectorRef: ChangeDetectorRef, - elementRef: ElementRef, - ngZone: NgZone, - focusMonitor: FocusMonitor, - @Inject(DOCUMENT) _document: any, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - @Optional() - @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) - globalRippleOptions?: RippleGlobalOptions, - @Attribute('tabindex') tabIndex?: string, - ) { - super( - changeDetectorRef, - elementRef, - ngZone, - focusMonitor, - _document, - animationMode, - globalRippleOptions, - ); + constructor(...args: unknown[]); + + constructor() { + super(); this.role = 'row'; this._onBlur.pipe(takeUntil(this.destroyed)).subscribe(() => { diff --git a/src/material/chips/chip-set.ts b/src/material/chips/chip-set.ts index d38d1ff9a57b..65049d87d598 100644 --- a/src/material/chips/chip-set.ts +++ b/src/material/chips/chip-set.ts @@ -17,11 +17,11 @@ import { ElementRef, Input, OnDestroy, - Optional, QueryList, ViewEncapsulation, booleanAttribute, numberAttribute, + inject, } from '@angular/core'; import {Observable, Subject, merge} from 'rxjs'; import {startWith, switchMap, takeUntil} from 'rxjs/operators'; @@ -51,6 +51,10 @@ import {MatChipAction} from './chip-action'; standalone: true, }) export class MatChipSet implements AfterViewInit, OnDestroy { + protected _elementRef = inject>(ElementRef); + protected _changeDetectorRef = inject(ChangeDetectorRef); + private _dir = inject(Directionality, {optional: true}); + /** Index of the last destroyed chip that had focus. */ private _lastDestroyedFocusedChipIndex: number | null = null; @@ -131,11 +135,8 @@ export class MatChipSet implements AfterViewInit, OnDestroy { /** Flat list of all the actions contained within the chips. */ _chipActions = new QueryList(); - constructor( - protected _elementRef: ElementRef, - protected _changeDetectorRef: ChangeDetectorRef, - @Optional() private _dir: Directionality, - ) {} + constructor(...args: unknown[]); + constructor() {} ngAfterViewInit() { this._setUpFocusManagement(); diff --git a/src/material/chips/chip.ts b/src/material/chips/chip.ts index 630d22aa1c5a..6d131c70bafe 100644 --- a/src/material/chips/chip.ts +++ b/src/material/chips/chip.ts @@ -21,13 +21,11 @@ import { DoCheck, ElementRef, EventEmitter, - Inject, Injector, Input, NgZone, OnDestroy, OnInit, - Optional, Output, QueryList, ViewChild, @@ -92,7 +90,15 @@ export interface MatChipEvent { imports: [MatChipAction], }) export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck, OnDestroy { - protected _document: Document; + _changeDetectorRef = inject(ChangeDetectorRef); + _elementRef = inject>(ElementRef); + protected _ngZone = inject(NgZone); + private _focusMonitor = inject(FocusMonitor); + private _globalRippleOptions = inject(MAT_RIPPLE_GLOBAL_OPTIONS, { + optional: true, + }); + + protected _document = inject(DOCUMENT); /** Emits when the chip is focused. */ readonly _onFocus = new Subject(); @@ -226,18 +232,10 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck protected _injector = inject(Injector); - constructor( - public _changeDetectorRef: ChangeDetectorRef, - public _elementRef: ElementRef, - protected _ngZone: NgZone, - private _focusMonitor: FocusMonitor, - @Inject(DOCUMENT) _document: any, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - @Optional() - @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) - private _globalRippleOptions?: RippleGlobalOptions, - ) { - this._document = _document; + constructor(...args: unknown[]); + + constructor() { + const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); this._animationsDisabled = animationMode === 'NoopAnimations'; this._monitorFocus(); diff --git a/src/material/core/datetime/native-date-adapter.ts b/src/material/core/datetime/native-date-adapter.ts index 9934ebc43e87..092b64a697ad 100644 --- a/src/material/core/datetime/native-date-adapter.ts +++ b/src/material/core/datetime/native-date-adapter.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {inject, Inject, Injectable, Optional} from '@angular/core'; +import {inject, Injectable} from '@angular/core'; import {DateAdapter, MAT_DATE_LOCALE} from './date-adapter'; /** @@ -38,17 +38,17 @@ export class NativeDateAdapter extends DateAdapter { /** The injected locale. */ private readonly _matDateLocale = inject(MAT_DATE_LOCALE, {optional: true}); - constructor( - /** - * @deprecated Now injected via inject(), param to be removed. - * @breaking-change 18.0.0 - */ - @Optional() @Inject(MAT_DATE_LOCALE) matDateLocale?: string, - ) { + constructor(...args: unknown[]); + + constructor() { super(); + + const matDateLocale = inject(MAT_DATE_LOCALE, {optional: true}); + if (matDateLocale !== undefined) { this._matDateLocale = matDateLocale; } + super.setLocale(this._matDateLocale); } diff --git a/src/material/core/option/optgroup.ts b/src/material/core/option/optgroup.ts index dc5e75eeed6f..f50ba7ace806 100644 --- a/src/material/core/option/optgroup.ts +++ b/src/material/core/option/optgroup.ts @@ -11,10 +11,9 @@ import { ViewEncapsulation, ChangeDetectionStrategy, Input, - Inject, - Optional, InjectionToken, booleanAttribute, + inject, } from '@angular/core'; import {MatOptionParentComponent, MAT_OPTION_PARENT_COMPONENT} from './option-parent'; @@ -80,7 +79,10 @@ export class MatOptgroup { /** Whether the group is in inert a11y mode. */ _inert: boolean; - constructor(@Inject(MAT_OPTION_PARENT_COMPONENT) @Optional() parent?: MatOptionParentComponent) { + constructor(...args: unknown[]); + + constructor() { + const parent = inject(MAT_OPTION_PARENT_COMPONENT, {optional: true}); this._inert = parent?.inertGroups ?? false; } } diff --git a/src/material/core/option/option.ts b/src/material/core/option/option.ts index 9c28ddd1cf7c..02bbdbee4f7b 100644 --- a/src/material/core/option/option.ts +++ b/src/material/core/option/option.ts @@ -14,8 +14,6 @@ import { ChangeDetectionStrategy, ElementRef, ChangeDetectorRef, - Optional, - Inject, AfterViewChecked, OnDestroy, Input, @@ -24,6 +22,7 @@ import { QueryList, ViewChild, booleanAttribute, + inject, } from '@angular/core'; import {Subject} from 'rxjs'; import {MAT_OPTGROUP, MatOptgroup} from './optgroup'; @@ -83,6 +82,11 @@ export class MatOptionSelectionChange { imports: [MatPseudoCheckbox, MatRipple], }) export class MatOption implements FocusableOption, AfterViewChecked, OnDestroy { + private _element = inject>(ElementRef); + _changeDetectorRef = inject(ChangeDetectorRef); + private _parent = inject(MAT_OPTION_PARENT_COMPONENT, {optional: true}); + group = inject(MAT_OPTGROUP, {optional: true}); + private _selected = false; private _active = false; private _disabled = false; @@ -133,12 +137,8 @@ export class MatOption implements FocusableOption, AfterViewChecked, On /** Emits when the state of the option changes and any parents have to be notified. */ readonly _stateChanges = new Subject(); - constructor( - private _element: ElementRef, - public _changeDetectorRef: ChangeDetectorRef, - @Optional() @Inject(MAT_OPTION_PARENT_COMPONENT) private _parent: MatOptionParentComponent, - @Optional() @Inject(MAT_OPTGROUP) public group: MatOptgroup, - ) {} + constructor(...args: unknown[]); + constructor() {} /** * Whether or not the option is currently active and ready to be selected. diff --git a/src/material/core/ripple/ripple.ts b/src/material/core/ripple/ripple.ts index dce9aa124a86..4dad2169a77b 100644 --- a/src/material/core/ripple/ripple.ts +++ b/src/material/core/ripple/ripple.ts @@ -10,15 +10,14 @@ import {Platform} from '@angular/cdk/platform'; import { Directive, ElementRef, - Inject, InjectionToken, Input, NgZone, OnDestroy, OnInit, - Optional, ANIMATION_MODULE_TYPE, Injector, + inject, } from '@angular/core'; import {_CdkPrivateStyleLoader} from '@angular/cdk/private'; import {RippleAnimationConfig, RippleConfig, RippleRef} from './ripple-ref'; @@ -66,6 +65,9 @@ export const MAT_RIPPLE_GLOBAL_OPTIONS = new InjectionToken standalone: true, }) export class MatRipple implements OnInit, OnDestroy, RippleTarget { + private _elementRef = inject>(ElementRef); + private _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + /** Custom color for all ripples. */ @Input('matRippleColor') color: string; @@ -132,18 +134,18 @@ export class MatRipple implements OnInit, OnDestroy, RippleTarget { /** @docs-private Whether ripple directive is initialized and the input bindings are set. */ _isInitialized: boolean = false; - constructor( - private _elementRef: ElementRef, - ngZone: NgZone, - platform: Platform, - @Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalOptions?: RippleGlobalOptions, - @Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string, - injector?: Injector, - ) { + constructor(...args: unknown[]); + + constructor() { + const ngZone = inject(NgZone); + const platform = inject(Platform); + const globalOptions = inject(MAT_RIPPLE_GLOBAL_OPTIONS, {optional: true}); + const injector = inject(Injector); + // Note: cannot use `inject()` here, because this class // gets instantiated manually in the ripple loader. this._globalOptions = globalOptions || {}; - this._rippleRenderer = new RippleRenderer(this, ngZone, _elementRef, platform, injector); + this._rippleRenderer = new RippleRenderer(this, ngZone, this._elementRef, platform, injector); } ngOnInit() { diff --git a/src/material/core/selection/pseudo-checkbox/pseudo-checkbox.ts b/src/material/core/selection/pseudo-checkbox/pseudo-checkbox.ts index e925d323f43a..764fc640da70 100644 --- a/src/material/core/selection/pseudo-checkbox/pseudo-checkbox.ts +++ b/src/material/core/selection/pseudo-checkbox/pseudo-checkbox.ts @@ -11,9 +11,8 @@ import { ViewEncapsulation, Input, ChangeDetectionStrategy, - Inject, - Optional, ANIMATION_MODULE_TYPE, + inject, } from '@angular/core'; /** @@ -53,6 +52,8 @@ export type MatPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate'; standalone: true, }) export class MatPseudoCheckbox { + _animationMode? = inject(ANIMATION_MODULE_TYPE, {optional: true}); + /** Display state of the checkbox. */ @Input() state: MatPseudoCheckboxState = 'unchecked'; @@ -65,5 +66,6 @@ export class MatPseudoCheckbox { */ @Input() appearance: 'minimal' | 'full' = 'full'; - constructor(@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {} + constructor(...args: unknown[]); + constructor() {} } diff --git a/src/material/datepicker/calendar-body.ts b/src/material/datepicker/calendar-body.ts index 1e4cdadc220f..cb69316e83be 100644 --- a/src/material/datepicker/calendar-body.ts +++ b/src/material/datepicker/calendar-body.ts @@ -96,6 +96,8 @@ const passiveEventOptions = normalizePassiveListenerOptions({passive: true}); imports: [NgClass], }) export class MatCalendarBody implements OnChanges, OnDestroy, AfterViewChecked { + private _elementRef = inject>(ElementRef); + private _ngZone = inject(NgZone); private _platform = inject(Platform); /** @@ -203,12 +205,11 @@ export class MatCalendarBody implements OnChanges, OnDestroy, AfterView */ _trackRow = (row: MatCalendarCell[]) => row; - constructor( - private _elementRef: ElementRef, - private _ngZone: NgZone, - ) { - _ngZone.runOutsideAngular(() => { - const element = _elementRef.nativeElement; + constructor(...args: unknown[]); + + constructor() { + this._ngZone.runOutsideAngular(() => { + const element = this._elementRef.nativeElement; // `touchmove` is active since we need to call `preventDefault`. element.addEventListener('touchmove', this._touchmoveHandler, activeCapturingEventOptions); diff --git a/src/material/datepicker/calendar.ts b/src/material/datepicker/calendar.ts index 44aa938c3147..a9598cf7fbf1 100644 --- a/src/material/datepicker/calendar.ts +++ b/src/material/datepicker/calendar.ts @@ -14,17 +14,15 @@ import { ChangeDetectorRef, Component, EventEmitter, - forwardRef, - Inject, Input, OnChanges, OnDestroy, - Optional, Output, SimpleChange, SimpleChanges, ViewChild, ViewEncapsulation, + inject, } from '@angular/core'; import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core'; import {Subject, Subscription} from 'rxjs'; @@ -62,13 +60,15 @@ export type MatCalendarView = 'month' | 'year' | 'multi-year'; imports: [MatButton, MatIconButton], }) export class MatCalendarHeader { - constructor( - private _intl: MatDatepickerIntl, - @Inject(forwardRef(() => MatCalendar)) public calendar: MatCalendar, - @Optional() private _dateAdapter: DateAdapter, - @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats, - changeDetectorRef: ChangeDetectorRef, - ) { + private _intl = inject(MatDatepickerIntl); + calendar = inject>(MatCalendar); + private _dateAdapter = inject>(DateAdapter, {optional: true})!; + private _dateFormats = inject(MAT_DATE_FORMATS, {optional: true})!; + + constructor(...args: unknown[]); + + constructor() { + const changeDetectorRef = inject(ChangeDetectorRef); this.calendar.stateChanges.subscribe(() => changeDetectorRef.markForCheck()); } @@ -242,6 +242,10 @@ export class MatCalendarHeader { imports: [CdkPortalOutlet, CdkMonitorFocus, MatMonthView, MatYearView, MatMultiYearView], }) export class MatCalendar implements AfterContentInit, AfterViewChecked, OnDestroy, OnChanges { + private _dateAdapter = inject>(DateAdapter, {optional: true})!; + private _dateFormats = inject(MAT_DATE_FORMATS, {optional: true}); + private _changeDetectorRef = inject(ChangeDetectorRef); + /** An input indicating the type of the header component, if set. */ @Input() headerComponent: ComponentType; @@ -397,12 +401,9 @@ export class MatCalendar implements AfterContentInit, AfterViewChecked, OnDes */ readonly stateChanges = new Subject(); - constructor( - _intl: MatDatepickerIntl, - @Optional() private _dateAdapter: DateAdapter, - @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats, - private _changeDetectorRef: ChangeDetectorRef, - ) { + constructor(...args: unknown[]); + + constructor() { if (typeof ngDevMode === 'undefined' || ngDevMode) { if (!this._dateAdapter) { throw createMissingDateImplError('DateAdapter'); @@ -413,8 +414,8 @@ export class MatCalendar implements AfterContentInit, AfterViewChecked, OnDes } } - this._intlChanges = _intl.changes.subscribe(() => { - _changeDetectorRef.markForCheck(); + this._intlChanges = inject(MatDatepickerIntl).changes.subscribe(() => { + this._changeDetectorRef.markForCheck(); this.stateChanges.next(); }); } diff --git a/src/material/datepicker/date-range-input-parts.ts b/src/material/datepicker/date-range-input-parts.ts index 89aea5cb2a00..ad137398631f 100644 --- a/src/material/datepicker/date-range-input-parts.ts +++ b/src/material/datepicker/date-range-input-parts.ts @@ -12,12 +12,10 @@ import { Directive, DoCheck, ElementRef, - Inject, InjectionToken, Injector, Input, OnInit, - Optional, Signal, inject, } from '@angular/core'; @@ -32,13 +30,7 @@ import { ValidatorFn, Validators, } from '@angular/forms'; -import { - DateAdapter, - ErrorStateMatcher, - MAT_DATE_FORMATS, - MatDateFormats, - _ErrorStateTracker, -} from '@angular/material/core'; +import {ErrorStateMatcher, _ErrorStateTracker} from '@angular/material/core'; import {_computeAriaAccessibleName} from './aria-accessible-name'; import {DateRange, DateSelectionModelChange} from './date-selection-model'; import {DateFilterFn, MatDatepickerInputBase} from './datepicker-input-base'; @@ -78,6 +70,13 @@ abstract class MatDateRangeInputPartBase extends MatDatepickerInputBase> implements OnInit, DoCheck { + _rangeInput = inject>(MAT_DATE_RANGE_INPUT_PARENT); + override _elementRef = inject>(ElementRef); + _defaultErrorStateMatcher = inject(ErrorStateMatcher); + private _injector = inject(Injector); + _parentForm = inject(NgForm, {optional: true}); + _parentFormGroup = inject(FormGroupDirective, {optional: true}); + /** * Form control bound to this input part. * @docs-private @@ -107,17 +106,11 @@ abstract class MatDateRangeInputPartBase this._errorStateTracker.errorState = value; } - constructor( - @Inject(MAT_DATE_RANGE_INPUT_PARENT) public _rangeInput: MatDateRangeInputParent, - public override _elementRef: ElementRef, - public _defaultErrorStateMatcher: ErrorStateMatcher, - private _injector: Injector, - @Optional() public _parentForm: NgForm, - @Optional() public _parentFormGroup: FormGroupDirective, - @Optional() dateAdapter: DateAdapter, - @Optional() @Inject(MAT_DATE_FORMATS) dateFormats: MatDateFormats, - ) { - super(_elementRef, dateAdapter, dateFormats); + constructor(...args: unknown[]); + + constructor() { + super(); + this._errorStateTracker = new _ErrorStateTracker( this._defaultErrorStateMatcher, null, @@ -267,28 +260,6 @@ export class MatStartDate extends MatDateRangeInputPartBase { : {'matStartDateInvalid': {'end': end, 'actual': start}}; }; - constructor( - @Inject(MAT_DATE_RANGE_INPUT_PARENT) rangeInput: MatDateRangeInputParent, - elementRef: ElementRef, - defaultErrorStateMatcher: ErrorStateMatcher, - injector: Injector, - @Optional() parentForm: NgForm, - @Optional() parentFormGroup: FormGroupDirective, - @Optional() dateAdapter: DateAdapter, - @Optional() @Inject(MAT_DATE_FORMATS) dateFormats: MatDateFormats, - ) { - super( - rangeInput, - elementRef, - defaultErrorStateMatcher, - injector, - parentForm, - parentFormGroup, - dateAdapter, - dateFormats, - ); - } - protected _validator = Validators.compose([...super._getValidators(), this._startValidator]); protected _getValueFromModel(modelValue: DateRange) { @@ -380,28 +351,6 @@ export class MatEndDate extends MatDateRangeInputPartBase { : {'matEndDateInvalid': {'start': start, 'actual': end}}; }; - constructor( - @Inject(MAT_DATE_RANGE_INPUT_PARENT) rangeInput: MatDateRangeInputParent, - elementRef: ElementRef, - defaultErrorStateMatcher: ErrorStateMatcher, - injector: Injector, - @Optional() parentForm: NgForm, - @Optional() parentFormGroup: FormGroupDirective, - @Optional() dateAdapter: DateAdapter, - @Optional() @Inject(MAT_DATE_FORMATS) dateFormats: MatDateFormats, - ) { - super( - rangeInput, - elementRef, - defaultErrorStateMatcher, - injector, - parentForm, - parentFormGroup, - dateAdapter, - dateFormats, - ); - } - protected _validator = Validators.compose([...super._getValidators(), this._endValidator]); protected _getValueFromModel(modelValue: DateRange) { diff --git a/src/material/datepicker/date-range-input.ts b/src/material/datepicker/date-range-input.ts index a48fdc877739..cb3199da61b6 100644 --- a/src/material/datepicker/date-range-input.ts +++ b/src/material/datepicker/date-range-input.ts @@ -14,16 +14,14 @@ import { Component, ContentChild, ElementRef, - Inject, Input, OnChanges, OnDestroy, - Optional, - Self, SimpleChanges, ViewEncapsulation, booleanAttribute, signal, + inject, } from '@angular/core'; import {ControlContainer, NgControl, Validators} from '@angular/forms'; import {DateAdapter, ThemePalette} from '@angular/material/core'; @@ -79,6 +77,11 @@ export class MatDateRangeInput OnChanges, OnDestroy { + private _changeDetectorRef = inject(ChangeDetectorRef); + private _elementRef = inject>(ElementRef); + private _dateAdapter = inject>(DateAdapter, {optional: true})!; + private _formField = inject<_MatFormFieldPartial>(MAT_FORM_FIELD, {optional: true}); + private _closedSubscription = Subscription.EMPTY; private _openedSubscription = Subscription.EMPTY; @@ -273,21 +276,17 @@ export class MatDateRangeInput */ readonly disableAutomaticLabeling = true; - constructor( - private _changeDetectorRef: ChangeDetectorRef, - private _elementRef: ElementRef, - @Optional() @Self() control: ControlContainer, - @Optional() private _dateAdapter: DateAdapter, - @Optional() @Inject(MAT_FORM_FIELD) private _formField?: _MatFormFieldPartial, - ) { - if (!_dateAdapter && (typeof ngDevMode === 'undefined' || ngDevMode)) { + constructor(...args: unknown[]); + + constructor() { + if (!this._dateAdapter && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw createMissingDateImplError('DateAdapter'); } // The datepicker module can be used both with MDC and non-MDC form fields. We have // to conditionally add the MDC input class so that the range picker looks correctly. - if (_formField?._elementRef.nativeElement.classList.contains('mat-mdc-form-field')) { - _elementRef.nativeElement.classList.add( + if (this._formField?._elementRef.nativeElement.classList.contains('mat-mdc-form-field')) { + this._elementRef.nativeElement.classList.add( 'mat-mdc-input-element', 'mat-mdc-form-field-input-control', 'mdc-text-field__input', @@ -295,7 +294,7 @@ export class MatDateRangeInput } // TODO(crisbeto): remove `as any` after #18206 lands. - this.ngControl = control as any; + this.ngControl = inject(ControlContainer, {optional: true, self: true}) as any; } /** diff --git a/src/material/datepicker/date-range-selection-strategy.ts b/src/material/datepicker/date-range-selection-strategy.ts index 890a9ff617b4..8546af409fdc 100644 --- a/src/material/datepicker/date-range-selection-strategy.ts +++ b/src/material/datepicker/date-range-selection-strategy.ts @@ -6,7 +6,14 @@ * found in the LICENSE file at https://angular.io/license */ -import {Injectable, InjectionToken, Optional, SkipSelf, FactoryProvider} from '@angular/core'; +import { + Injectable, + InjectionToken, + Optional, + SkipSelf, + FactoryProvider, + inject, +} from '@angular/core'; import {DateAdapter} from '@angular/material/core'; import {DateRange} from './date-selection-model'; @@ -59,7 +66,10 @@ export interface MatDateRangeSelectionStrategy { /** Provides the default date range selection behavior. */ @Injectable() export class DefaultMatCalendarRangeStrategy implements MatDateRangeSelectionStrategy { - constructor(private _dateAdapter: DateAdapter) {} + private _dateAdapter = inject>(DateAdapter); + + constructor(...args: unknown[]); + constructor() {} selectionFinished(date: D, currentRange: DateRange) { let {start, end} = currentRange; diff --git a/src/material/datepicker/datepicker-actions.ts b/src/material/datepicker/datepicker-actions.ts index 0f93abaa7b2a..4821e3b42bb3 100644 --- a/src/material/datepicker/datepicker-actions.ts +++ b/src/material/datepicker/datepicker-actions.ts @@ -16,6 +16,7 @@ import { ViewChild, ViewContainerRef, ViewEncapsulation, + inject, } from '@angular/core'; import {TemplatePortal} from '@angular/cdk/portal'; import {MatDatepickerBase, MatDatepickerControl} from './datepicker-base'; @@ -27,7 +28,12 @@ import {MatDatepickerBase, MatDatepickerControl} from './datepicker-base'; standalone: true, }) export class MatDatepickerApply { - constructor(private _datepicker: MatDatepickerBase, unknown>) {} + private _datepicker = + inject, unknown>>(MatDatepickerBase); + + constructor(...args: unknown[]); + + constructor() {} _applySelection() { this._datepicker._applyPendingSelection(); @@ -42,7 +48,10 @@ export class MatDatepickerApply { standalone: true, }) export class MatDatepickerCancel { - constructor(public _datepicker: MatDatepickerBase, unknown>) {} + _datepicker = inject, unknown>>(MatDatepickerBase); + + constructor(...args: unknown[]); + constructor() {} } /** @@ -64,13 +73,15 @@ export class MatDatepickerCancel { standalone: true, }) export class MatDatepickerActions implements AfterViewInit, OnDestroy { + private _datepicker = + inject, unknown>>(MatDatepickerBase); + private _viewContainerRef = inject(ViewContainerRef); + @ViewChild(TemplateRef) _template: TemplateRef; private _portal: TemplatePortal; - constructor( - private _datepicker: MatDatepickerBase, unknown>, - private _viewContainerRef: ViewContainerRef, - ) {} + constructor(...args: unknown[]); + constructor() {} ngAfterViewInit() { this._portal = new TemplatePortal(this._template, this._viewContainerRef); diff --git a/src/material/datepicker/datepicker-base.ts b/src/material/datepicker/datepicker-base.ts index 449d08d068fc..ca3841b9415e 100644 --- a/src/material/datepicker/datepicker-base.ts +++ b/src/material/datepicker/datepicker-base.ts @@ -42,16 +42,13 @@ import { Directive, ElementRef, EventEmitter, - Inject, inject, InjectionToken, Injector, Input, - NgZone, OnChanges, OnDestroy, OnInit, - Optional, Output, SimpleChanges, ViewChild, @@ -140,6 +137,15 @@ export const MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER = { export class MatDatepickerContent> implements OnInit, AfterViewInit, OnDestroy { + protected _elementRef = inject(ElementRef); + private _changeDetectorRef = inject(ChangeDetectorRef); + private _globalModel = inject>(MatDateSelectionModel); + private _dateAdapter = inject>(DateAdapter)!; + private _rangeSelectionStrategy = inject>( + MAT_DATE_RANGE_SELECTION_STRATEGY, + {optional: true}, + ); + private _subscriptions = new Subscription(); private _model: MatDateSelectionModel; /** Reference to the internal calendar component. */ @@ -193,16 +199,11 @@ export class MatDatepickerContent> /** Id of the label for the `role="dialog"` element. */ _dialogLabelId: string | null; - constructor( - protected _elementRef: ElementRef, - private _changeDetectorRef: ChangeDetectorRef, - private _globalModel: MatDateSelectionModel, - private _dateAdapter: DateAdapter, - @Optional() - @Inject(MAT_DATE_RANGE_SELECTION_STRATEGY) - private _rangeSelectionStrategy: MatDateRangeSelectionStrategy, - intl: MatDatepickerIntl, - ) { + constructor(...args: unknown[]); + + constructor() { + const intl = inject(MatDatepickerIntl); + this._closeButtonText = intl.closeCalendarLabel; } @@ -358,7 +359,13 @@ export abstract class MatDatepickerBase< > implements MatDatepickerPanel, OnDestroy, OnChanges { - private _scrollStrategy: () => ScrollStrategy; + private _overlay = inject(Overlay); + private _viewContainerRef = inject(ViewContainerRef); + private _dateAdapter = inject>(DateAdapter, {optional: true})!; + private _dir = inject(Directionality, {optional: true}); + private _model = inject>(MatDateSelectionModel); + + private _scrollStrategy = inject(MAT_DATEPICKER_SCROLL_STRATEGY); private _inputStateChanges = Subscription.EMPTY; private _document = inject(DOCUMENT); @@ -530,25 +537,13 @@ export abstract class MatDatepickerBase< private readonly _changeDetectorRef = inject(ChangeDetectorRef); - constructor( - private _overlay: Overlay, - /** - * @deprecated parameter is unused and will be removed - * @breaking-change 19.0.0 - */ - _unusedNgZone: NgZone, - private _viewContainerRef: ViewContainerRef, - @Inject(MAT_DATEPICKER_SCROLL_STRATEGY) scrollStrategy: any, - @Optional() private _dateAdapter: DateAdapter, - @Optional() private _dir: Directionality, - private _model: MatDateSelectionModel, - ) { + constructor(...args: unknown[]); + + constructor() { if (!this._dateAdapter && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw createMissingDateImplError('DateAdapter'); } - this._scrollStrategy = scrollStrategy; - this._model.selectionChanged.subscribe(() => { this._changeDetectorRef.markForCheck(); }); @@ -741,7 +736,7 @@ export abstract class MatDatepickerBase< isDialog ? 'cdk-overlay-dark-backdrop' : 'mat-overlay-transparent-backdrop', this._backdropHarnessClass, ], - direction: this._dir, + direction: this._dir || 'ltr', scrollStrategy: isDialog ? this._overlay.scrollStrategies.block() : this._scrollStrategy(), panelClass: `mat-datepicker-${isDialog ? 'dialog' : 'popup'}`, }), diff --git a/src/material/datepicker/datepicker-input-base.ts b/src/material/datepicker/datepicker-input-base.ts index f0980c5a6c9e..63fe45f1bde6 100644 --- a/src/material/datepicker/datepicker-input-base.ts +++ b/src/material/datepicker/datepicker-input-base.ts @@ -11,15 +11,14 @@ import { Directive, ElementRef, EventEmitter, - Inject, Input, OnDestroy, - Optional, Output, AfterViewInit, OnChanges, SimpleChanges, booleanAttribute, + inject, } from '@angular/core'; import { AbstractControl, @@ -82,6 +81,10 @@ export interface _MatFormFieldPartial { export abstract class MatDatepickerInputBase> implements ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy, Validator { + protected _elementRef = inject>(ElementRef); + _dateAdapter = inject>(DateAdapter, {optional: true})!; + private _dateFormats = inject(MAT_DATE_FORMATS, {optional: true})!; + /** Whether the component has been initialized. */ private _isInitialized: boolean; @@ -242,11 +245,9 @@ export abstract class MatDatepickerInputBase, - @Optional() public _dateAdapter: DateAdapter, - @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats, - ) { + constructor(...args: unknown[]); + + constructor() { if (typeof ngDevMode === 'undefined' || ngDevMode) { if (!this._dateAdapter) { throw createMissingDateImplError('DateAdapter'); @@ -257,7 +258,7 @@ export abstract class MatDatepickerInputBase { + this._localeSubscription = this._dateAdapter.localeChanges.subscribe(() => { this._assignValueProgrammatically(this.value); }); } diff --git a/src/material/datepicker/datepicker-input.ts b/src/material/datepicker/datepicker-input.ts index 849af176df18..71b9a6864694 100644 --- a/src/material/datepicker/datepicker-input.ts +++ b/src/material/datepicker/datepicker-input.ts @@ -6,18 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import { - Directive, - ElementRef, - forwardRef, - Inject, - Input, - OnDestroy, - Optional, - signal, -} from '@angular/core'; +import {Directive, ElementRef, forwardRef, Input, OnDestroy, signal, inject} from '@angular/core'; import {NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidatorFn, Validators} from '@angular/forms'; -import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats, ThemePalette} from '@angular/material/core'; +import {ThemePalette} from '@angular/material/core'; import {MAT_FORM_FIELD} from '@angular/material/form-field'; import {MAT_INPUT_VALUE_ACCESSOR} from '@angular/material/input'; import {Subscription} from 'rxjs'; @@ -69,6 +60,7 @@ export class MatDatepickerInput extends MatDatepickerInputBase implements MatDatepickerControl, OnDestroy { + private _formField = inject<_MatFormFieldPartial>(MAT_FORM_FIELD, {optional: true}); private _closedSubscription = Subscription.EMPTY; private _openedSubscription = Subscription.EMPTY; @@ -141,13 +133,10 @@ export class MatDatepickerInput /** The combined form control validator for this input. */ protected _validator: ValidatorFn | null; - constructor( - elementRef: ElementRef, - @Optional() dateAdapter: DateAdapter, - @Optional() @Inject(MAT_DATE_FORMATS) dateFormats: MatDateFormats, - @Optional() @Inject(MAT_FORM_FIELD) private _formField?: _MatFormFieldPartial, - ) { - super(elementRef, dateAdapter, dateFormats); + constructor(...args: unknown[]); + + constructor() { + super(); this._validator = Validators.compose(super._getValidators()); } diff --git a/src/material/datepicker/datepicker-toggle.ts b/src/material/datepicker/datepicker-toggle.ts index 12690134bcef..fbe0c52a2e0f 100644 --- a/src/material/datepicker/datepicker-toggle.ts +++ b/src/material/datepicker/datepicker-toggle.ts @@ -8,7 +8,6 @@ import { AfterContentInit, - Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, @@ -21,6 +20,8 @@ import { ViewEncapsulation, ViewChild, booleanAttribute, + inject, + HostAttributeToken, } from '@angular/core'; import {MatButton, MatIconButton} from '@angular/material/button'; import {merge, Observable, of as observableOf, Subscription} from 'rxjs'; @@ -58,6 +59,8 @@ export class MatDatepickerToggleIcon {} imports: [MatIconButton], }) export class MatDatepickerToggle implements AfterContentInit, OnChanges, OnDestroy { + _intl = inject(MatDatepickerIntl); + private _changeDetectorRef = inject(ChangeDetectorRef); private _stateChanges = Subscription.EMPTY; /** Datepicker instance that the button will toggle. */ @@ -92,11 +95,10 @@ export class MatDatepickerToggle implements AfterContentInit, OnChanges, OnDe /** Underlying button element. */ @ViewChild('button') _button: MatButton; - constructor( - public _intl: MatDatepickerIntl, - private _changeDetectorRef: ChangeDetectorRef, - @Attribute('tabindex') defaultTabIndex: string, - ) { + constructor(...args: unknown[]); + + constructor() { + const defaultTabIndex = inject(new HostAttributeToken('tabindex'), {optional: true}); const parsedTabIndex = Number(defaultTabIndex); this.tabIndex = parsedTabIndex || parsedTabIndex === 0 ? parsedTabIndex : null; } diff --git a/src/material/datepicker/month-view.ts b/src/material/datepicker/month-view.ts index ee92ef19bdf5..49a7ab1f2184 100644 --- a/src/material/datepicker/month-view.ts +++ b/src/material/datepicker/month-view.ts @@ -26,15 +26,14 @@ import { ChangeDetectorRef, Component, EventEmitter, - Inject, Input, - Optional, Output, ViewEncapsulation, ViewChild, OnDestroy, SimpleChanges, OnChanges, + inject, } from '@angular/core'; import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core'; import {Directionality} from '@angular/cdk/bidi'; @@ -71,6 +70,15 @@ let uniqueIdCounter = 0; imports: [MatCalendarBody], }) export class MatMonthView implements AfterContentInit, OnChanges, OnDestroy { + readonly _changeDetectorRef = inject(ChangeDetectorRef); + private _dateFormats = inject(MAT_DATE_FORMATS, {optional: true})!; + _dateAdapter = inject>(DateAdapter, {optional: true})!; + private _dir = inject(Directionality, {optional: true}); + private _rangeStrategy = inject>( + MAT_DATE_RANGE_SELECTION_STRATEGY, + {optional: true}, + ); + private _rerenderSubscription = Subscription.EMPTY; /** Flag used to filter out space/enter keyup events that originated outside of the view. */ @@ -210,15 +218,9 @@ export class MatMonthView implements AfterContentInit, OnChanges, OnDestroy { /** The names of the weekdays. */ _weekdays: {long: string; narrow: string; id: number}[]; - constructor( - readonly _changeDetectorRef: ChangeDetectorRef, - @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats, - @Optional() public _dateAdapter: DateAdapter, - @Optional() private _dir?: Directionality, - @Inject(MAT_DATE_RANGE_SELECTION_STRATEGY) - @Optional() - private _rangeStrategy?: MatDateRangeSelectionStrategy, - ) { + constructor(...args: unknown[]); + + constructor() { if (typeof ngDevMode === 'undefined' || ngDevMode) { if (!this._dateAdapter) { throw createMissingDateImplError('DateAdapter'); diff --git a/src/material/datepicker/multi-year-view.ts b/src/material/datepicker/multi-year-view.ts index 8a1f972af033..7c47c5c2f287 100644 --- a/src/material/datepicker/multi-year-view.ts +++ b/src/material/datepicker/multi-year-view.ts @@ -25,11 +25,11 @@ import { Component, EventEmitter, Input, - Optional, Output, ViewChild, ViewEncapsulation, OnDestroy, + inject, } from '@angular/core'; import {DateAdapter} from '@angular/material/core'; import {Directionality} from '@angular/cdk/bidi'; @@ -62,6 +62,9 @@ export const yearsPerRow = 4; imports: [MatCalendarBody], }) export class MatMultiYearView implements AfterContentInit, OnDestroy { + private _changeDetectorRef = inject(ChangeDetectorRef); + _dateAdapter = inject>(DateAdapter, {optional: true})!; + private _dir = inject(Directionality, {optional: true}); private _rerenderSubscription = Subscription.EMPTY; /** Flag used to filter out space/enter keyup events that originated outside of the view. */ @@ -156,11 +159,9 @@ export class MatMultiYearView implements AfterContentInit, OnDestroy { /** The year of the selected date. Null if the selected date is null. */ _selectedYear: number | null; - constructor( - private _changeDetectorRef: ChangeDetectorRef, - @Optional() public _dateAdapter: DateAdapter, - @Optional() private _dir?: Directionality, - ) { + constructor(...args: unknown[]); + + constructor() { if (!this._dateAdapter && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw createMissingDateImplError('DateAdapter'); } diff --git a/src/material/datepicker/year-view.ts b/src/material/datepicker/year-view.ts index c1d025e47de0..960b8fb40df9 100644 --- a/src/material/datepicker/year-view.ts +++ b/src/material/datepicker/year-view.ts @@ -24,13 +24,12 @@ import { ChangeDetectorRef, Component, EventEmitter, - Inject, Input, - Optional, Output, ViewChild, ViewEncapsulation, OnDestroy, + inject, } from '@angular/core'; import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core'; import {Directionality} from '@angular/cdk/bidi'; @@ -59,6 +58,11 @@ import {DateRange} from './date-selection-model'; imports: [MatCalendarBody], }) export class MatYearView implements AfterContentInit, OnDestroy { + readonly _changeDetectorRef = inject(ChangeDetectorRef); + private _dateFormats = inject(MAT_DATE_FORMATS, {optional: true})!; + _dateAdapter = inject>(DateAdapter, {optional: true})!; + private _dir = inject(Directionality, {optional: true}); + private _rerenderSubscription = Subscription.EMPTY; /** Flag used to filter out space/enter keyup events that originated outside of the view. */ @@ -150,12 +154,9 @@ export class MatYearView implements AfterContentInit, OnDestroy { */ _selectedMonth: number | null; - constructor( - readonly _changeDetectorRef: ChangeDetectorRef, - @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats, - @Optional() public _dateAdapter: DateAdapter, - @Optional() private _dir?: Directionality, - ) { + constructor(...args: unknown[]); + + constructor() { if (typeof ngDevMode === 'undefined' || ngDevMode) { if (!this._dateAdapter) { throw createMissingDateImplError('DateAdapter'); diff --git a/src/material/dialog/dialog-container.ts b/src/material/dialog/dialog-container.ts index 30b011f437a1..6fb1f7f7a7b6 100644 --- a/src/material/dialog/dialog-container.ts +++ b/src/material/dialog/dialog-container.ts @@ -6,19 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -import {FocusMonitor, FocusTrapFactory, InteractivityChecker} from '@angular/cdk/a11y'; -import {OverlayRef} from '@angular/cdk/overlay'; -import {DOCUMENT} from '@angular/common'; import { ChangeDetectionStrategy, Component, ComponentRef, - ElementRef, EventEmitter, - Inject, - NgZone, OnDestroy, - Optional, ViewEncapsulation, ANIMATION_MODULE_TYPE, inject, @@ -97,29 +90,6 @@ export class MatDialogContainer extends CdkDialogContainer impl /** Current timer for dialog animations. */ private _animationTimer: ReturnType | null = null; - constructor( - elementRef: ElementRef, - focusTrapFactory: FocusTrapFactory, - @Optional() @Inject(DOCUMENT) _document: any, - dialogConfig: MatDialogConfig, - interactivityChecker: InteractivityChecker, - ngZone: NgZone, - overlayRef: OverlayRef, - @Optional() @Inject(ANIMATION_MODULE_TYPE) _unusedAnimationMode?: string, - focusMonitor?: FocusMonitor, - ) { - super( - elementRef, - focusTrapFactory, - _document, - dialogConfig, - interactivityChecker, - ngZone, - overlayRef, - focusMonitor, - ); - } - protected override _contentAttached(): void { // Delegate to the original dialog-container initialization (i.e. saving the // previous element, setting up the focus trap and moving focus to the container). diff --git a/src/material/dialog/dialog-content-directives.ts b/src/material/dialog/dialog-content-directives.ts index dac9c74ccf66..e6f5214aaea2 100644 --- a/src/material/dialog/dialog-content-directives.ts +++ b/src/material/dialog/dialog-content-directives.ts @@ -13,8 +13,8 @@ import { OnChanges, OnDestroy, OnInit, - Optional, SimpleChanges, + inject, } from '@angular/core'; import {CdkScrollable} from '@angular/cdk/scrolling'; @@ -38,6 +38,10 @@ let dialogElementUid = 0; }, }) export class MatDialogClose implements OnInit, OnChanges { + dialogRef = inject>(MatDialogRef, {optional: true})!; + private _elementRef = inject>(ElementRef); + private _dialog = inject(MatDialog); + /** Screen-reader label for the button. */ @Input('aria-label') ariaLabel: string; @@ -49,13 +53,8 @@ export class MatDialogClose implements OnInit, OnChanges { @Input('matDialogClose') _matDialogClose: any; - constructor( - // The dialog title directive is always used in combination with a `MatDialogRef`. - // tslint:disable-next-line: lightweight-tokens - @Optional() public dialogRef: MatDialogRef, - private _elementRef: ElementRef, - private _dialog: MatDialog, - ) {} + constructor(...args: unknown[]); + constructor() {} ngOnInit() { if (!this.dialogRef) { @@ -91,13 +90,13 @@ export class MatDialogClose implements OnInit, OnChanges { @Directive({standalone: true}) export abstract class MatDialogLayoutSection implements OnInit, OnDestroy { - constructor( - // The dialog title directive is always used in combination with a `MatDialogRef`. - // tslint:disable-next-line: lightweight-tokens - @Optional() protected _dialogRef: MatDialogRef, - private _elementRef: ElementRef, - private _dialog: MatDialog, - ) {} + protected _dialogRef = inject>(MatDialogRef, {optional: true})!; + private _elementRef = inject>(ElementRef); + private _dialog = inject(MatDialog); + + constructor(...args: unknown[]); + + constructor() {} protected abstract _onAdd(): void; protected abstract _onRemove(): void; diff --git a/src/material/dialog/dialog.spec.ts b/src/material/dialog/dialog.spec.ts index 1e64f0005486..fc65e86a47f8 100644 --- a/src/material/dialog/dialog.spec.ts +++ b/src/material/dialog/dialog.spec.ts @@ -19,7 +19,6 @@ import { ComponentFactoryResolver, ComponentRef, Directive, - Inject, Injectable, Injector, NgModule, @@ -30,6 +29,7 @@ import { createNgModuleRef, forwardRef, signal, + inject, } from '@angular/core'; import { ComponentFixture, @@ -37,7 +37,6 @@ import { fakeAsync, flush, flushMicrotasks, - inject, tick, } from '@angular/core/testing'; import {By} from '@angular/platform-browser'; @@ -93,24 +92,15 @@ describe('MatDialog', () => { }, ], }); - })); - beforeEach(inject( - [MatDialog, Location, OverlayContainer, FocusMonitor], - (d: MatDialog, l: Location, oc: OverlayContainer, fm: FocusMonitor) => { - dialog = d; - mockLocation = l as SpyLocation; - overlayContainerElement = oc.getContainerElement(); - focusMonitor = fm; - }, - )); - - beforeEach(() => { + dialog = TestBed.inject(MatDialog); + mockLocation = TestBed.inject(Location) as SpyLocation; + overlayContainerElement = TestBed.inject(OverlayContainer).getContainerElement(); + focusMonitor = TestBed.inject(FocusMonitor); viewContainerFixture = TestBed.createComponent(ComponentWithChildViewContainer); - viewContainerFixture.detectChanges(); testViewContainerRef = viewContainerFixture.componentInstance.childViewContainer; - }); + })); it('should open a dialog with a component', () => { let dialogRef = dialog.open(PizzaMsg, {viewContainerRef: testViewContainerRef}); @@ -239,30 +229,25 @@ describe('MatDialog', () => { expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeNull(); })); - it( - 'should dispatch the beforeClosed and afterClosed events when the ' + - 'overlay is detached externally', - fakeAsync( - inject([Overlay], (overlay: Overlay) => { - const dialogRef = dialog.open(PizzaMsg, { - viewContainerRef: testViewContainerRef, - scrollStrategy: overlay.scrollStrategies.close(), - }); - const beforeClosedCallback = jasmine.createSpy('beforeClosed callback'); - const afterCloseCallback = jasmine.createSpy('afterClosed callback'); + it('should dispatch the beforeClosed and afterClosed events when the overlay is detached externally', fakeAsync(() => { + const overlay = TestBed.inject(Overlay); + const dialogRef = dialog.open(PizzaMsg, { + viewContainerRef: testViewContainerRef, + scrollStrategy: overlay.scrollStrategies.close(), + }); + const beforeClosedCallback = jasmine.createSpy('beforeClosed callback'); + const afterCloseCallback = jasmine.createSpy('afterClosed callback'); - dialogRef.beforeClosed().subscribe(beforeClosedCallback); - dialogRef.afterClosed().subscribe(afterCloseCallback); + dialogRef.beforeClosed().subscribe(beforeClosedCallback); + dialogRef.afterClosed().subscribe(afterCloseCallback); - scrolledSubject.next(); - viewContainerFixture.detectChanges(); - flush(); + scrolledSubject.next(); + viewContainerFixture.detectChanges(); + flush(); - expect(beforeClosedCallback).toHaveBeenCalledTimes(1); - expect(afterCloseCallback).toHaveBeenCalledTimes(1); - }), - ), - ); + expect(beforeClosedCallback).toHaveBeenCalledTimes(1); + expect(afterCloseCallback).toHaveBeenCalledTimes(1); + })); it('should close a dialog and get back a result before it is closed', fakeAsync(() => { const dialogRef = dialog.open(PizzaMsg, {viewContainerRef: testViewContainerRef}); @@ -746,20 +731,18 @@ describe('MatDialog', () => { expect(scrollStrategy.enable).toHaveBeenCalled(); })); - it('should be able to pass in an alternate ComponentFactoryResolver', inject( - [ComponentFactoryResolver], - (resolver: ComponentFactoryResolver) => { - spyOn(resolver, 'resolveComponentFactory').and.callThrough(); + it('should be able to pass in an alternate ComponentFactoryResolver', () => { + const resolver = TestBed.inject(ComponentFactoryResolver); + spyOn(resolver, 'resolveComponentFactory').and.callThrough(); - dialog.open(PizzaMsg, { - viewContainerRef: testViewContainerRef, - componentFactoryResolver: resolver, - }); - viewContainerFixture.detectChanges(); + dialog.open(PizzaMsg, { + viewContainerRef: testViewContainerRef, + componentFactoryResolver: resolver, + }); + viewContainerFixture.detectChanges(); - expect(resolver.resolveComponentFactory).toHaveBeenCalled(); - }, - )); + expect(resolver.resolveComponentFactory).toHaveBeenCalled(); + }); describe('passing in data', () => { it('should be able to pass in data', () => { @@ -1628,12 +1611,10 @@ describe('MatDialog', () => { standalone: true, }) class Child { - dialogRef?: MatDialogRef; + readonly viewContainerRef = inject(ViewContainerRef); + readonly dialog = inject(MatDialog); - constructor( - readonly viewContainerRef: ViewContainerRef, - readonly dialog: MatDialog, - ) {} + dialogRef?: MatDialogRef; open() { this.dialogRef = this.dialog.open(DialogCmp, {viewContainerRef: this.viewContainerRef}); @@ -1910,11 +1891,8 @@ describe('MatDialog with a parent MatDialog', () => { {provide: Location, useClass: SpyLocation}, ], }); - })); - - beforeEach(inject([MatDialog], (d: MatDialog) => { - parentDialog = d; + parentDialog = TestBed.inject(MatDialog); fixture = TestBed.createComponent(ComponentThatProvidesMatDialog); childDialog = fixture.componentInstance.dialog; fixture.detectChanges(); @@ -2017,19 +1995,13 @@ describe('MatDialog with default options', () => { ], providers: [{provide: MAT_DIALOG_DEFAULT_OPTIONS, useValue: defaultConfig}], }); - })); - beforeEach(inject([MatDialog, OverlayContainer], (d: MatDialog, oc: OverlayContainer) => { - dialog = d; - overlayContainerElement = oc.getContainerElement(); - })); - - beforeEach(() => { + dialog = TestBed.inject(MatDialog); + overlayContainerElement = TestBed.inject(OverlayContainer).getContainerElement(); viewContainerFixture = TestBed.createComponent(ComponentWithChildViewContainer); - viewContainerFixture.detectChanges(); testViewContainerRef = viewContainerFixture.componentInstance.childViewContainer; - }); + })); it('should use the provided defaults', () => { dialog.open(PizzaMsg, {viewContainerRef: testViewContainerRef}); @@ -2086,11 +2058,8 @@ describe('MatDialog with animations enabled', () => { DirectiveWithViewContainer, ], }); - })); - - beforeEach(inject([MatDialog], (d: MatDialog) => { - dialog = d; + dialog = TestBed.inject(MatDialog); viewContainerFixture = TestBed.createComponent(ComponentWithChildViewContainer); viewContainerFixture.detectChanges(); testViewContainerRef = viewContainerFixture.componentInstance.childViewContainer; @@ -2143,15 +2112,10 @@ describe('MatDialog with explicit injector provided', () => { TestBed.configureTestingModule({ imports: [MatDialogModule, BrowserAnimationsModule, ModuleBoundDialogParentComponent], }); - })); - - beforeEach(inject([OverlayContainer], (oc: OverlayContainer) => { - overlayContainerElement = oc.getContainerElement(); - })); - beforeEach(() => { + overlayContainerElement = TestBed.inject(OverlayContainer).getContainerElement(); fixture = TestBed.createComponent(ModuleBoundDialogParentComponent); - }); + })); it('should use the standalone injector and render the dialog successfully', () => { fixture.componentInstance.openDialog(); @@ -2168,7 +2132,7 @@ describe('MatDialog with explicit injector provided', () => { standalone: true, }) class DirectiveWithViewContainer { - constructor(public viewContainerRef: ViewContainerRef) {} + viewContainerRef = inject(ViewContainerRef); } @Component({ @@ -2176,7 +2140,7 @@ class DirectiveWithViewContainer { template: 'hello', }) class ComponentWithOnPushViewContainer { - constructor(public viewContainerRef: ViewContainerRef) {} + viewContainerRef = inject(ViewContainerRef); } @Component({ @@ -2219,11 +2183,9 @@ class ComponentWithTemplateRef { standalone: true, }) class PizzaMsg { - constructor( - public dialogRef: MatDialogRef, - public dialogInjector: Injector, - public directionality: Directionality, - ) {} + dialogRef = inject>(MatDialogRef); + dialogInjector = inject(Injector); + directionality = inject(Directionality); } @Component({ @@ -2304,7 +2266,7 @@ class ComponentWithContentElementTemplateRef { standalone: true, }) class ComponentThatProvidesMatDialog { - constructor(public dialog: MatDialog) {} + dialog = inject(MatDialog); } /** Simple component for testing ComponentPortal. */ @@ -2313,7 +2275,7 @@ class ComponentThatProvidesMatDialog { standalone: true, }) class DialogWithInjectedData { - constructor(@Inject(MAT_DIALOG_DATA) public data: any) {} + data = inject(MAT_DIALOG_DATA); } @Component({ @@ -2333,10 +2295,8 @@ class ShadowDomComponent {} standalone: true, }) class ModuleBoundDialogParentComponent { - constructor( - private _injector: Injector, - private _dialog: MatDialog, - ) {} + private _injector = inject(Injector); + private _dialog = inject(MatDialog); openDialog(): void { const ngModuleRef = createNgModuleRef( @@ -2366,7 +2326,7 @@ class ModuleBoundDialogComponent {} standalone: true, }) class ModuleBoundDialogChildComponent { - constructor(public service: ModuleBoundDialogService) {} + service = inject(ModuleBoundDialogService); } @NgModule({ diff --git a/src/material/dialog/dialog.ts b/src/material/dialog/dialog.ts index f85a26a40055..90cfa389c9c0 100644 --- a/src/material/dialog/dialog.ts +++ b/src/material/dialog/dialog.ts @@ -6,18 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -import {ComponentType, Overlay, OverlayContainer, ScrollStrategy} from '@angular/cdk/overlay'; -import {Location} from '@angular/common'; +import {ComponentType, Overlay, ScrollStrategy} from '@angular/cdk/overlay'; import { - ANIMATION_MODULE_TYPE, ComponentRef, - Inject, Injectable, InjectionToken, - Injector, OnDestroy, - Optional, - SkipSelf, TemplateRef, Type, inject, @@ -79,10 +73,15 @@ let uniqueId = 0; */ @Injectable({providedIn: 'root'}) export class MatDialog implements OnDestroy { + private _overlay = inject(Overlay); + private _defaultOptions = inject(MAT_DIALOG_DEFAULT_OPTIONS, {optional: true}); + private _scrollStrategy = inject(MAT_DIALOG_SCROLL_STRATEGY); + private _parentDialog = inject(MatDialog, {optional: true, skipSelf: true}); + protected _dialog = inject(Dialog); + private readonly _openDialogsAtThisLevel: MatDialogRef[] = []; private readonly _afterAllClosedAtThisLevel = new Subject(); private readonly _afterOpenedAtThisLevel = new Subject>(); - protected _dialog: Dialog; protected dialogConfigClass = MatDialogConfig; private readonly _dialogRefConstructor: Type>; @@ -114,32 +113,9 @@ export class MatDialog implements OnDestroy { : this._getAfterAllClosed().pipe(startWith(undefined)), ) as Observable; - constructor( - private _overlay: Overlay, - injector: Injector, - /** - * @deprecated `_location` parameter to be removed. - * @breaking-change 10.0.0 - */ - @Optional() location: Location, - @Optional() @Inject(MAT_DIALOG_DEFAULT_OPTIONS) private _defaultOptions: MatDialogConfig, - @Inject(MAT_DIALOG_SCROLL_STRATEGY) private _scrollStrategy: any, - @Optional() @SkipSelf() private _parentDialog: MatDialog, - /** - * @deprecated No longer used. To be removed. - * @breaking-change 15.0.0 - */ - _overlayContainer: OverlayContainer, - /** - * @deprecated No longer used. To be removed. - * @breaking-change 14.0.0 - */ - @Optional() - @Inject(ANIMATION_MODULE_TYPE) - _animationMode?: 'NoopAnimations' | 'BrowserAnimations', - ) { - this._dialog = injector.get(Dialog); + constructor(...args: unknown[]); + constructor() { this._dialogRefConstructor = MatDialogRef; this._dialogContainerType = MatDialogContainer; this._dialogDataToken = MAT_DIALOG_DATA; diff --git a/src/material/dialog/dialog.zone.spec.ts b/src/material/dialog/dialog.zone.spec.ts index 0061b98f6e0b..4369949cfbe6 100644 --- a/src/material/dialog/dialog.zone.spec.ts +++ b/src/material/dialog/dialog.zone.spec.ts @@ -9,14 +9,16 @@ import { ViewChild, ViewContainerRef, provideZoneChangeDetection, + inject, } from '@angular/core'; -import {ComponentFixture, TestBed, fakeAsync, flush, inject} from '@angular/core/testing'; +import {ComponentFixture, TestBed, fakeAsync, flush} from '@angular/core/testing'; import {MatDialog, MatDialogModule, MatDialogRef} from '@angular/material/dialog'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import {Subject} from 'rxjs'; describe('MatDialog', () => { let dialog: MatDialog; + let zone: NgZone; let scrolledSubject = new Subject(); let testViewContainerRef: ViewContainerRef; @@ -44,36 +46,29 @@ describe('MatDialog', () => { }, ], }); - })); - - beforeEach(inject([MatDialog], (d: MatDialog) => { - dialog = d; - })); - beforeEach(() => { + dialog = TestBed.inject(MatDialog); + zone = TestBed.inject(NgZone); viewContainerFixture = TestBed.createComponent(ComponentWithChildViewContainer); - viewContainerFixture.detectChanges(); testViewContainerRef = viewContainerFixture.componentInstance.childViewContainer; - }); + })); - it('should invoke the afterClosed callback inside the NgZone', fakeAsync( - inject([NgZone], (zone: NgZone) => { - const dialogRef = dialog.open(PizzaMsg, {viewContainerRef: testViewContainerRef}); - const afterCloseCallback = jasmine.createSpy('afterClose callback'); + it('should invoke the afterClosed callback inside the NgZone', fakeAsync(() => { + const dialogRef = dialog.open(PizzaMsg, {viewContainerRef: testViewContainerRef}); + const afterCloseCallback = jasmine.createSpy('afterClose callback'); - dialogRef.afterClosed().subscribe(() => { - afterCloseCallback(NgZone.isInAngularZone()); - }); - zone.run(() => { - dialogRef.close(); - viewContainerFixture.detectChanges(); - flush(); - }); + dialogRef.afterClosed().subscribe(() => { + afterCloseCallback(NgZone.isInAngularZone()); + }); + zone.run(() => { + dialogRef.close(); + viewContainerFixture.detectChanges(); + flush(); + }); - expect(afterCloseCallback).toHaveBeenCalledWith(true); - }), - )); + expect(afterCloseCallback).toHaveBeenCalledWith(true); + })); }); @Directive({ @@ -81,7 +76,7 @@ describe('MatDialog', () => { standalone: true, }) class DirectiveWithViewContainer { - constructor(public viewContainerRef: ViewContainerRef) {} + viewContainerRef = inject(ViewContainerRef); } @Component({ @@ -106,9 +101,7 @@ class ComponentWithChildViewContainer { standalone: true, }) class PizzaMsg { - constructor( - public dialogRef: MatDialogRef, - public dialogInjector: Injector, - public directionality: Directionality, - ) {} + dialogRef = inject>(MatDialogRef); + dialogInjector = inject(Injector); + directionality = inject(Directionality); } diff --git a/src/material/dialog/testing/dialog-harness.spec.ts b/src/material/dialog/testing/dialog-harness.spec.ts index 28a92ec87edc..a42b30376c44 100644 --- a/src/material/dialog/testing/dialog-harness.spec.ts +++ b/src/material/dialog/testing/dialog-harness.spec.ts @@ -1,4 +1,4 @@ -import {Component, TemplateRef, ViewChild} from '@angular/core'; +import {Component, TemplateRef, ViewChild, inject} from '@angular/core'; import {ComponentFixture, TestBed} from '@angular/core/testing'; import {HarnessLoader} from '@angular/cdk/testing'; import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed'; @@ -126,9 +126,9 @@ describe('MatDialogHarness', () => { imports: [MatDialogTitle, MatDialogContent, MatDialogActions], }) class DialogHarnessTest { - @ViewChild(TemplateRef) dialogTmpl: TemplateRef; + readonly dialog = inject(MatDialog); - constructor(readonly dialog: MatDialog) {} + @ViewChild(TemplateRef) dialogTmpl: TemplateRef; open(config?: MatDialogConfig) { return this.dialog.open(this.dialogTmpl, config); diff --git a/src/material/dialog/testing/dialog-opener.spec.ts b/src/material/dialog/testing/dialog-opener.spec.ts index 34620f7ad2f7..81666539af4e 100644 --- a/src/material/dialog/testing/dialog-opener.spec.ts +++ b/src/material/dialog/testing/dialog-opener.spec.ts @@ -1,4 +1,4 @@ -import {Component, Inject} from '@angular/core'; +import {Component, inject} from '@angular/core'; import {TestBed, fakeAsync, flush} from '@angular/core/testing'; import {MAT_DIALOG_DATA, MatDialogRef, MatDialogState} from '@angular/material/dialog'; import {MatTestDialogOpener, MatTestDialogOpenerModule} from '@angular/material/dialog/testing'; @@ -64,10 +64,8 @@ interface ExampleDialogResult { standalone: true, }) class ExampleComponent { - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - ) {} + dialogRef = inject>(MatDialogRef); + data = inject(MAT_DIALOG_DATA); close() { this.dialogRef.close({reason: 'closed'}); diff --git a/src/material/dialog/testing/dialog-opener.ts b/src/material/dialog/testing/dialog-opener.ts index 561d7f755367..ae3c353bd3d5 100644 --- a/src/material/dialog/testing/dialog-opener.ts +++ b/src/material/dialog/testing/dialog-opener.ts @@ -29,6 +29,8 @@ import {Subscription} from 'rxjs'; standalone: true, }) export class MatTestDialogOpener implements OnDestroy { + dialog = inject(MatDialog); + /** Component that should be opened with the MatDialog `open` method. */ protected static component: ComponentType | undefined; @@ -55,7 +57,9 @@ export class MatTestDialogOpener implements OnDestroy return MatTestDialogOpener as ComponentType>; } - constructor(public dialog: MatDialog) { + constructor(...args: unknown[]); + + constructor() { if (!MatTestDialogOpener.component) { throw new Error(`MatTestDialogOpener does not have a component provided.`); } diff --git a/src/material/expansion/expansion-panel-content.ts b/src/material/expansion/expansion-panel-content.ts index 1bbd35064827..f2dbc1d9801e 100644 --- a/src/material/expansion/expansion-panel-content.ts +++ b/src/material/expansion/expansion-panel-content.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, TemplateRef, Inject, Optional} from '@angular/core'; +import {Directive, TemplateRef, inject} from '@angular/core'; import {MAT_EXPANSION_PANEL, MatExpansionPanelBase} from './expansion-panel-base'; /** @@ -18,8 +18,9 @@ import {MAT_EXPANSION_PANEL, MatExpansionPanelBase} from './expansion-panel-base standalone: true, }) export class MatExpansionPanelContent { - constructor( - public _template: TemplateRef, - @Inject(MAT_EXPANSION_PANEL) @Optional() public _expansionPanel?: MatExpansionPanelBase, - ) {} + _template = inject>(TemplateRef); + _expansionPanel = inject(MAT_EXPANSION_PANEL, {optional: true}); + + constructor(...args: unknown[]); + constructor() {} } diff --git a/src/material/expansion/expansion-panel-header.ts b/src/material/expansion/expansion-panel-header.ts index 5c52b8a324c4..d5e9482ca2a0 100644 --- a/src/material/expansion/expansion-panel-header.ts +++ b/src/material/expansion/expansion-panel-header.ts @@ -10,20 +10,18 @@ import {FocusableOption, FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; import {ENTER, hasModifierKey, SPACE} from '@angular/cdk/keycodes'; import { AfterViewInit, - Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, Directive, ElementRef, - Host, - Inject, Input, numberAttribute, OnDestroy, - Optional, ViewEncapsulation, ANIMATION_MODULE_TYPE, + inject, + HostAttributeToken, } from '@angular/core'; import {EMPTY, merge, Subscription} from 'rxjs'; import {filter} from 'rxjs/operators'; @@ -64,19 +62,24 @@ import { standalone: true, }) export class MatExpansionPanelHeader implements AfterViewInit, OnDestroy, FocusableOption { + panel = inject(MatExpansionPanel, {host: true}); + private _element = inject(ElementRef); + private _focusMonitor = inject(FocusMonitor); + private _changeDetectorRef = inject(ChangeDetectorRef); + _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + private _parentChangeSubscription = Subscription.EMPTY; - constructor( - @Host() public panel: MatExpansionPanel, - private _element: ElementRef, - private _focusMonitor: FocusMonitor, - private _changeDetectorRef: ChangeDetectorRef, - @Inject(MAT_EXPANSION_PANEL_DEFAULT_OPTIONS) - @Optional() - defaultOptions?: MatExpansionPanelDefaultOptions, - @Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string, - @Attribute('tabindex') tabIndex?: string, - ) { + constructor(...args: unknown[]); + + constructor() { + const panel = this.panel; + const defaultOptions = inject( + MAT_EXPANSION_PANEL_DEFAULT_OPTIONS, + {optional: true}, + ); + const tabIndex = inject(new HostAttributeToken('tabindex'), {optional: true}); + const accordionHideToggleChange = panel.accordion ? panel.accordion._stateChanges.pipe( filter(changes => !!(changes['hideToggle'] || changes['togglePosition'])), @@ -100,7 +103,7 @@ export class MatExpansionPanelHeader implements AfterViewInit, OnDestroy, Focusa // Avoids focus being lost if the panel contained the focused element and was closed. panel.closed .pipe(filter(() => panel._containsFocus())) - .subscribe(() => _focusMonitor.focusVia(_element, 'program')); + .subscribe(() => this._focusMonitor.focusVia(this._element, 'program')); if (defaultOptions) { this.expandedHeight = defaultOptions.expandedHeight; diff --git a/src/material/expansion/expansion-panel.ts b/src/material/expansion/expansion-panel.ts index 7b4c3647732b..43b516323382 100644 --- a/src/material/expansion/expansion-panel.ts +++ b/src/material/expansion/expansion-panel.ts @@ -14,26 +14,23 @@ import {DOCUMENT} from '@angular/common'; import { AfterContentInit, ChangeDetectionStrategy, - ChangeDetectorRef, Component, ContentChild, Directive, ElementRef, EventEmitter, - Inject, InjectionToken, Input, OnChanges, OnDestroy, - Optional, Output, SimpleChanges, - SkipSelf, ViewChild, ViewContainerRef, ViewEncapsulation, booleanAttribute, ANIMATION_MODULE_TYPE, + inject, } from '@angular/core'; import {Subject} from 'rxjs'; import {filter, startWith, take} from 'rxjs/operators'; @@ -101,8 +98,11 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentInit, OnChanges, OnDestroy { + private _viewContainerRef = inject(ViewContainerRef); + _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + protected _animationsDisabled: boolean; - private _document: Document; + private _document = inject(DOCUMENT); /** Whether the toggle indicator should be hidden. */ @Input({transform: booleanAttribute}) @@ -134,7 +134,7 @@ export class MatExpansionPanel readonly _inputChanges = new Subject(); /** Optionally defined accordion the expansion panel belongs to. */ - override accordion: MatAccordionBase; + override accordion = inject(MAT_ACCORDION, {optional: true, skipSelf: true})!; /** Content that will be rendered lazily. */ @ContentChild(MatExpansionPanelContent) _lazyContent: MatExpansionPanelContent; @@ -148,22 +148,18 @@ export class MatExpansionPanel /** ID for the associated header element. Used for a11y labelling. */ _headerId = `mat-expansion-panel-header-${uniqueId++}`; - constructor( - @Optional() @SkipSelf() @Inject(MAT_ACCORDION) accordion: MatAccordionBase, - _changeDetectorRef: ChangeDetectorRef, - _uniqueSelectionDispatcher: UniqueSelectionDispatcher, - private _viewContainerRef: ViewContainerRef, - @Inject(DOCUMENT) _document: any, - @Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode: string, - @Inject(MAT_EXPANSION_PANEL_DEFAULT_OPTIONS) - @Optional() - defaultOptions?: MatExpansionPanelDefaultOptions, - ) { - super(accordion, _changeDetectorRef, _uniqueSelectionDispatcher); - this._expansionDispatcher = _uniqueSelectionDispatcher; - this.accordion = accordion; - this._document = _document; - this._animationsDisabled = _animationMode === 'NoopAnimations'; + constructor(...args: unknown[]); + + constructor() { + super(); + + const defaultOptions = inject( + MAT_EXPANSION_PANEL_DEFAULT_OPTIONS, + {optional: true}, + ); + + this._expansionDispatcher = inject(UniqueSelectionDispatcher); + this._animationsDisabled = this._animationMode === 'NoopAnimations'; if (defaultOptions) { this.hideToggle = defaultOptions.hideToggle; diff --git a/src/material/form-field/directives/error.ts b/src/material/form-field/directives/error.ts index 59800fd68392..74f8de210401 100644 --- a/src/material/form-field/directives/error.ts +++ b/src/material/form-field/directives/error.ts @@ -6,7 +6,14 @@ * found in the LICENSE file at https://angular.io/license */ -import {Attribute, Directive, ElementRef, InjectionToken, Input} from '@angular/core'; +import { + Directive, + ElementRef, + InjectionToken, + Input, + HostAttributeToken, + inject, +} from '@angular/core'; let nextUniqueId = 0; @@ -31,10 +38,15 @@ export const MAT_ERROR = new InjectionToken('MatError'); export class MatError { @Input() id: string = `mat-mdc-error-${nextUniqueId++}`; - constructor(@Attribute('aria-live') ariaLive: string, elementRef: ElementRef) { + constructor(...args: unknown[]); + + constructor() { + const ariaLive = inject(new HostAttributeToken('aria-live'), {optional: true}); + // If no aria-live value is set add 'polite' as a default. This is preferred over setting // role='alert' so that screen readers do not interrupt the current task to read this aloud. if (!ariaLive) { + const elementRef = inject(ElementRef); elementRef.nativeElement.setAttribute('aria-live', 'polite'); } } diff --git a/src/material/form-field/directives/floating-label.ts b/src/material/form-field/directives/floating-label.ts index de3d239a3f7c..fd54bb3b78d4 100644 --- a/src/material/form-field/directives/floating-label.ts +++ b/src/material/form-field/directives/floating-label.ts @@ -48,6 +48,8 @@ export const FLOATING_LABEL_PARENT = new InjectionToken('Fl standalone: true, }) export class MatFormFieldFloatingLabel implements OnDestroy { + private _elementRef = inject>(ElementRef); + /** Whether the label is floating. */ @Input() get floating() { @@ -88,7 +90,8 @@ export class MatFormFieldFloatingLabel implements OnDestroy { /** The current resize event subscription. */ private _resizeSubscription = new Subscription(); - constructor(private _elementRef: ElementRef) {} + constructor(...args: unknown[]); + constructor() {} ngOnDestroy() { this._resizeSubscription.unsubscribe(); diff --git a/src/material/form-field/directives/line-ripple.ts b/src/material/form-field/directives/line-ripple.ts index 68d849894e47..be70c43482bb 100644 --- a/src/material/form-field/directives/line-ripple.ts +++ b/src/material/form-field/directives/line-ripple.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, ElementRef, NgZone, OnDestroy} from '@angular/core'; +import {Directive, ElementRef, NgZone, OnDestroy, inject} from '@angular/core'; /** Class added when the line ripple is active. */ const ACTIVATE_CLASS = 'mdc-line-ripple--active'; @@ -30,12 +30,15 @@ const DEACTIVATING_CLASS = 'mdc-line-ripple--deactivating'; standalone: true, }) export class MatFormFieldLineRipple implements OnDestroy { - constructor( - private _elementRef: ElementRef, - ngZone: NgZone, - ) { + private _elementRef = inject>(ElementRef); + + constructor(...args: unknown[]); + + constructor() { + const ngZone = inject(NgZone); + ngZone.runOutsideAngular(() => { - _elementRef.nativeElement.addEventListener('transitionend', this._handleTransitionEnd); + this._elementRef.nativeElement.addEventListener('transitionend', this._handleTransitionEnd); }); } diff --git a/src/material/form-field/directives/notched-outline.ts b/src/material/form-field/directives/notched-outline.ts index aad82e8dc06e..5529a71b0df8 100644 --- a/src/material/form-field/directives/notched-outline.ts +++ b/src/material/form-field/directives/notched-outline.ts @@ -15,6 +15,7 @@ import { NgZone, ViewChild, ViewEncapsulation, + inject, } from '@angular/core'; /** @@ -37,15 +38,16 @@ import { standalone: true, }) export class MatFormFieldNotchedOutline implements AfterViewInit { + private _elementRef = inject>(ElementRef); + private _ngZone = inject(NgZone); + /** Whether the notch should be opened. */ @Input('matFormFieldNotchedOutlineOpen') open: boolean = false; @ViewChild('notch') _notch: ElementRef; - constructor( - private _elementRef: ElementRef, - private _ngZone: NgZone, - ) {} + constructor(...args: unknown[]); + constructor() {} ngAfterViewInit(): void { const label = this._elementRef.nativeElement.querySelector('.mdc-floating-label'); diff --git a/src/material/form-field/form-field.ts b/src/material/form-field/form-field.ts index 00ae130f1399..cb666451c0d5 100644 --- a/src/material/form-field/form-field.ts +++ b/src/material/form-field/form-field.ts @@ -8,7 +8,7 @@ import {Directionality} from '@angular/cdk/bidi'; import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; import {Platform} from '@angular/cdk/platform'; -import {DOCUMENT, NgTemplateOutlet} from '@angular/common'; +import {NgTemplateOutlet} from '@angular/common'; import { ANIMATION_MODULE_TYPE, AfterContentChecked, @@ -20,13 +20,10 @@ import { ContentChild, ContentChildren, ElementRef, - Inject, InjectionToken, Injector, Input, - NgZone, OnDestroy, - Optional, QueryList, ViewChild, ViewEncapsulation, @@ -191,6 +188,15 @@ interface MatFormFieldControl extends _MatFormFieldControl {} export class MatFormField implements FloatingLabelParent, AfterContentInit, AfterContentChecked, AfterViewInit, OnDestroy { + _elementRef = inject(ElementRef); + private _changeDetectorRef = inject(ChangeDetectorRef); + private _dir = inject(Directionality); + private _platform = inject(Platform); + private _defaults = inject(MAT_FORM_FIELD_DEFAULT_OPTIONS, { + optional: true, + }); + _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + @ViewChild('textField') _textField: ElementRef; @ViewChild('iconPrefixContainer') _iconPrefixContainer: ElementRef; @ViewChild('textPrefixContainer') _textPrefixContainer: ElementRef; @@ -326,33 +332,18 @@ export class MatFormField private _injector = inject(Injector); - constructor( - public _elementRef: ElementRef, - private _changeDetectorRef: ChangeDetectorRef, - /** - * @deprecated not needed, to be removed. - * @breaking-change 19.0.0 remove this param - */ - _unusedNgZone: NgZone, - private _dir: Directionality, - private _platform: Platform, - @Optional() - @Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS) - private _defaults?: MatFormFieldDefaultOptions, - @Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string, - /** - * @deprecated not needed, to be removed. - * @breaking-change 17.0.0 remove this param - */ - @Inject(DOCUMENT) _unusedDocument?: any, - ) { - if (_defaults) { - if (_defaults.appearance) { - this.appearance = _defaults.appearance; + constructor(...args: unknown[]); + + constructor() { + const defaults = this._defaults; + + if (defaults) { + if (defaults.appearance) { + this.appearance = defaults.appearance; } - this._hideRequiredMarker = Boolean(_defaults?.hideRequiredMarker); - if (_defaults.color) { - this.color = _defaults.color; + this._hideRequiredMarker = Boolean(defaults?.hideRequiredMarker); + if (defaults.color) { + this.color = defaults.color; } } } diff --git a/src/material/grid-list/grid-list.ts b/src/material/grid-list/grid-list.ts index 63aa820d6395..6325f42004b9 100644 --- a/src/material/grid-list/grid-list.ts +++ b/src/material/grid-list/grid-list.ts @@ -15,8 +15,8 @@ import { ContentChildren, QueryList, ElementRef, - Optional, ChangeDetectionStrategy, + inject, } from '@angular/core'; import {MatGridTile} from './grid-tile'; import {TileCoordinator} from './tile-coordinator'; @@ -59,6 +59,9 @@ const MAT_FIT_MODE = 'fit'; standalone: true, }) export class MatGridList implements MatGridListBase, OnInit, AfterContentChecked, TileStyleTarget { + private _element = inject>(ElementRef); + private _dir = inject(Directionality, {optional: true}); + /** Number of columns being rendered. */ private _cols: number; @@ -82,10 +85,8 @@ export class MatGridList implements MatGridListBase, OnInit, AfterContentChecked /** Query list of tiles that are being rendered. */ @ContentChildren(MatGridTile, {descendants: true}) _tiles: QueryList; - constructor( - private _element: ElementRef, - @Optional() private _dir: Directionality, - ) {} + constructor(...args: unknown[]); + constructor() {} /** Amount of columns in the grid list. */ @Input() diff --git a/src/material/grid-list/grid-tile.ts b/src/material/grid-list/grid-tile.ts index f1e59f0050d6..bc80c3ff72b5 100644 --- a/src/material/grid-list/grid-tile.ts +++ b/src/material/grid-list/grid-tile.ts @@ -11,13 +11,12 @@ import { ViewEncapsulation, ElementRef, Input, - Optional, ContentChildren, QueryList, AfterContentInit, Directive, ChangeDetectionStrategy, - Inject, + inject, } from '@angular/core'; import {MatLine, setLines} from '@angular/material/core'; import {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion'; @@ -40,13 +39,14 @@ import {MAT_GRID_LIST, MatGridListBase} from './grid-list-base'; standalone: true, }) export class MatGridTile { + private _element = inject>(ElementRef); + _gridList? = inject(MAT_GRID_LIST, {optional: true}); + _rowspan: number = 1; _colspan: number = 1; - constructor( - private _element: ElementRef, - @Optional() @Inject(MAT_GRID_LIST) public _gridList?: MatGridListBase, - ) {} + constructor(...args: unknown[]); + constructor() {} /** Amount of rows that the grid tile takes up. */ @Input() @@ -83,9 +83,12 @@ export class MatGridTile { standalone: true, }) export class MatGridTileText implements AfterContentInit { + private _element = inject>(ElementRef); + @ContentChildren(MatLine, {descendants: true}) _lines: QueryList; - constructor(private _element: ElementRef) {} + constructor(...args: unknown[]); + constructor() {} ngAfterContentInit() { setLines(this._lines, this._element); diff --git a/src/material/icon/icon-registry.ts b/src/material/icon/icon-registry.ts index e70ce5e8c107..349df604fd94 100644 --- a/src/material/icon/icon-registry.ts +++ b/src/material/icon/icon-registry.ts @@ -10,13 +10,13 @@ import {DOCUMENT} from '@angular/common'; import {HttpClient, HttpErrorResponse} from '@angular/common/http'; import { ErrorHandler, - Inject, Injectable, InjectionToken, OnDestroy, Optional, SecurityContext, SkipSelf, + inject, } from '@angular/core'; import {DomSanitizer, SafeHtml, SafeResourceUrl} from '@angular/platform-browser'; import {forkJoin, Observable, of as observableOf, throwError as observableThrow} from 'rxjs'; @@ -118,7 +118,10 @@ type LoadedSvgIconConfig = SvgIconConfig & {svgText: TrustedHTML}; */ @Injectable({providedIn: 'root'}) export class MatIconRegistry implements OnDestroy { - private _document: Document; + private _httpClient = inject(HttpClient, {optional: true}); + private _sanitizer = inject(DomSanitizer); + private readonly _errorHandler = inject(ErrorHandler); + private _document = inject(DOCUMENT, {optional: true})!; /** * URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]". @@ -150,14 +153,9 @@ export class MatIconRegistry implements OnDestroy { */ private _defaultFontSetClass = ['material-icons', 'mat-ligature-font']; - constructor( - @Optional() private _httpClient: HttpClient, - private _sanitizer: DomSanitizer, - @Optional() @Inject(DOCUMENT) document: any, - private readonly _errorHandler: ErrorHandler, - ) { - this._document = document; - } + constructor(...args: unknown[]); + + constructor() {} /** * Registers an icon by URL in the default namespace. diff --git a/src/material/icon/icon.ts b/src/material/icon/icon.ts index 4e5408b758d9..375e80d4cb21 100644 --- a/src/material/icon/icon.ts +++ b/src/material/icon/icon.ts @@ -9,20 +9,18 @@ import {DOCUMENT} from '@angular/common'; import { AfterViewChecked, - Attribute, booleanAttribute, ChangeDetectionStrategy, Component, ElementRef, ErrorHandler, inject, - Inject, InjectionToken, Input, OnDestroy, OnInit, - Optional, ViewEncapsulation, + HostAttributeToken, } from '@angular/core'; import {ThemePalette} from '@angular/material/core'; import {Subscription} from 'rxjs'; @@ -154,6 +152,10 @@ const funcIriPattern = /^url\(['"]?#(.*?)['"]?\)$/; standalone: true, }) export class MatIcon implements OnInit, AfterViewChecked, OnDestroy { + readonly _elementRef = inject>(ElementRef); + private _iconRegistry = inject(MatIconRegistry); + private _location = inject(MAT_ICON_LOCATION); + private readonly _errorHandler = inject(ErrorHandler); private _defaultColor: ThemePalette; /** @@ -241,16 +243,12 @@ export class MatIcon implements OnInit, AfterViewChecked, OnDestroy { /** Subscription to the current in-progress SVG icon request. */ private _currentIconFetch = Subscription.EMPTY; - constructor( - readonly _elementRef: ElementRef, - private _iconRegistry: MatIconRegistry, - @Attribute('aria-hidden') ariaHidden: string, - @Inject(MAT_ICON_LOCATION) private _location: MatIconLocation, - private readonly _errorHandler: ErrorHandler, - @Optional() - @Inject(MAT_ICON_DEFAULT_OPTIONS) - defaults?: MatIconDefaultOptions, - ) { + constructor(...args: unknown[]); + + constructor() { + const ariaHidden = inject(new HostAttributeToken('aria-hidden'), {optional: true}); + const defaults = inject(MAT_ICON_DEFAULT_OPTIONS, {optional: true}); + if (defaults) { if (defaults.color) { this.color = this._defaultColor = defaults.color; @@ -264,7 +262,7 @@ export class MatIcon implements OnInit, AfterViewChecked, OnDestroy { // If the user has not explicitly set aria-hidden, mark the icon as hidden, as this is // the right thing to do for the majority of icon use-cases. if (!ariaHidden) { - _elementRef.nativeElement.setAttribute('aria-hidden', 'true'); + this._elementRef.nativeElement.setAttribute('aria-hidden', 'true'); } } diff --git a/src/material/input/input.ts b/src/material/input/input.ts index a34705997a2c..a2706f2b7471 100644 --- a/src/material/input/input.ts +++ b/src/material/input/input.ts @@ -16,14 +16,11 @@ import { DoCheck, ElementRef, inject, - Inject, InjectionToken, Input, NgZone, OnChanges, OnDestroy, - Optional, - Self, } from '@angular/core'; import {FormGroupDirective, NgControl, NgForm, Validators} from '@angular/forms'; import {ErrorStateMatcher, _ErrorStateTracker} from '@angular/material/core'; @@ -96,6 +93,14 @@ export const MAT_INPUT_CONFIG = new InjectionToken('MAT_INPUT_CO export class MatInput implements MatFormFieldControl, OnChanges, OnDestroy, AfterViewInit, DoCheck { + protected _elementRef = + inject>(ElementRef); + protected _platform = inject(Platform); + ngControl = inject(NgControl, {optional: true, self: true}); + private _autofillMonitor = inject(AutofillMonitor); + private _ngZone = inject(NgZone); + protected _formField? = inject(MAT_FORM_FIELD, {optional: true}); + protected _uid = `mat-input-${nextUniqueId++}`; protected _previousNativeValue: any; private _inputValueAccessor: {value: any}; @@ -279,20 +284,14 @@ export class MatInput 'week', ].filter(t => getSupportedInputTypes().has(t)); - constructor( - protected _elementRef: ElementRef, - protected _platform: Platform, - @Optional() @Self() public ngControl: NgControl, - @Optional() parentForm: NgForm, - @Optional() parentFormGroup: FormGroupDirective, - defaultErrorStateMatcher: ErrorStateMatcher, - @Optional() @Self() @Inject(MAT_INPUT_VALUE_ACCESSOR) inputValueAccessor: any, - private _autofillMonitor: AutofillMonitor, - private _ngZone: NgZone, - // TODO: Remove this once the legacy appearance has been removed. We only need - // to inject the form field for determining whether the placeholder has been promoted. - @Optional() @Inject(MAT_FORM_FIELD) protected _formField?: MatFormField, - ) { + constructor(...args: unknown[]); + + constructor() { + const parentForm = inject(NgForm, {optional: true}); + const parentFormGroup = inject(FormGroupDirective, {optional: true}); + const defaultErrorStateMatcher = inject(ErrorStateMatcher); + const inputValueAccessor = inject(MAT_INPUT_VALUE_ACCESSOR, {optional: true, self: true}); + const element = this._elementRef.nativeElement; const nodeName = element.nodeName.toLowerCase(); @@ -308,15 +307,15 @@ export class MatInput // On some versions of iOS the caret gets stuck in the wrong place when holding down the delete // key. In order to get around this we need to "jiggle" the caret loose. Since this bug only // exists on iOS, we only bother to install the listener on iOS. - if (_platform.IOS) { - _ngZone.runOutsideAngular(() => { - _elementRef.nativeElement.addEventListener('keyup', this._iOSKeyupListener); + if (this._platform.IOS) { + this._ngZone.runOutsideAngular(() => { + element.addEventListener('keyup', this._iOSKeyupListener); }); } this._errorStateTracker = new _ErrorStateTracker( defaultErrorStateMatcher, - ngControl, + this.ngControl, parentFormGroup, parentForm, this.stateChanges, @@ -324,7 +323,7 @@ export class MatInput this._isServer = !this._platform.isBrowser; this._isNativeSelect = nodeName === 'select'; this._isTextarea = nodeName === 'textarea'; - this._isInFormField = !!_formField; + this._isInFormField = !!this._formField; this.disabledInteractive = this._config?.disabledInteractive || false; if (this._isNativeSelect) { diff --git a/src/material/list/list-base.ts b/src/material/list/list-base.ts index 2f42bbfb05e9..15aa46510d25 100644 --- a/src/material/list/list-base.ts +++ b/src/material/list/list-base.ts @@ -14,11 +14,9 @@ import { Directive, ElementRef, inject, - Inject, Input, NgZone, OnDestroy, - Optional, QueryList, ANIMATION_MODULE_TYPE, Injector, @@ -86,6 +84,11 @@ export abstract class MatListBase { }) /** @docs-private */ export abstract class MatListItemBase implements AfterViewInit, OnDestroy, RippleTarget { + _elementRef = inject>(ElementRef); + protected _ngZone = inject(NgZone); + private _listBase = inject(MatListBase, {optional: true}); + private _platform = inject(Platform); + /** Query list matching list-item line elements. */ abstract _lines: QueryList | undefined; @@ -174,22 +177,20 @@ export abstract class MatListItemBase implements AfterViewInit, OnDestroy, Rippl return this.disableRipple || !!this.rippleConfig.disabled; } - constructor( - public _elementRef: ElementRef, - protected _ngZone: NgZone, - @Optional() private _listBase: MatListBase | null, - private _platform: Platform, - @Optional() - @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) - globalRippleOptions?: RippleGlobalOptions, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { + constructor(...args: unknown[]); + + constructor() { + const globalRippleOptions = inject(MAT_RIPPLE_GLOBAL_OPTIONS, { + optional: true, + }); + const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + this.rippleConfig = globalRippleOptions || {}; this._hostElement = this._elementRef.nativeElement; this._isButtonElement = this._hostElement.nodeName.toLowerCase() === 'button'; this._noopAnimations = animationMode === 'NoopAnimations'; - if (_listBase && !_listBase._isNonInteractive) { + if (this._listBase && !this._listBase._isNonInteractive) { this._initInteractiveListItem(); } diff --git a/src/material/list/list-item-sections.ts b/src/material/list/list-item-sections.ts index 0ca18e781fec..87df93cbe437 100644 --- a/src/material/list/list-item-sections.ts +++ b/src/material/list/list-item-sections.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, ElementRef, Inject, Optional} from '@angular/core'; +import {Directive, ElementRef, inject} from '@angular/core'; import {LIST_OPTION, ListOption} from './list-option-types'; /** @@ -21,7 +21,10 @@ import {LIST_OPTION, ListOption} from './list-option-types'; standalone: true, }) export class MatListItemTitle { - constructor(public _elementRef: ElementRef) {} + _elementRef = inject>(ElementRef); + + constructor(...args: unknown[]); + constructor() {} } /** @@ -36,7 +39,10 @@ export class MatListItemTitle { standalone: true, }) export class MatListItemLine { - constructor(public _elementRef: ElementRef) {} + _elementRef = inject>(ElementRef); + + constructor(...args: unknown[]); + constructor() {} } /** @@ -72,7 +78,10 @@ export class MatListItemMeta {} standalone: true, }) export class _MatListItemGraphicBase { - constructor(@Optional() @Inject(LIST_OPTION) public _listOption: ListOption) {} + _listOption = inject(LIST_OPTION, {optional: true}); + + constructor(...args: unknown[]); + constructor() {} _isAlignedAtStart() { // By default, in all list items the graphic is aligned at start. In list options, diff --git a/src/material/list/list-option.ts b/src/material/list/list-option.ts index a790aed5a2c8..cbc14c2eca99 100644 --- a/src/material/list/list-option.ts +++ b/src/material/list/list-option.ts @@ -9,30 +9,26 @@ import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; import {SelectionModel} from '@angular/cdk/collections'; import { - ANIMATION_MODULE_TYPE, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, ElementRef, EventEmitter, - Inject, InjectionToken, Input, - NgZone, OnDestroy, OnInit, - Optional, Output, QueryList, ViewChild, ViewEncapsulation, + inject, } from '@angular/core'; -import {MAT_RIPPLE_GLOBAL_OPTIONS, RippleGlobalOptions, ThemePalette} from '@angular/material/core'; +import {ThemePalette} from '@angular/material/core'; import {MatListBase, MatListItemBase} from './list-base'; import {LIST_OPTION, ListOption, MatListOptionTogglePosition} from './list-option-types'; import {MatListItemLine, MatListItemTitle} from './list-item-sections'; -import {Platform} from '@angular/cdk/platform'; import {NgTemplateOutlet} from '@angular/common'; import {CdkObserveContent} from '@angular/cdk/observers'; @@ -105,6 +101,9 @@ export interface SelectionList extends MatListBase { imports: [NgTemplateOutlet, CdkObserveContent], }) export class MatListOption extends MatListItemBase implements ListOption, OnInit, OnDestroy { + private _selectionList = inject(SELECTION_LIST); + private _changeDetectorRef = inject(ChangeDetectorRef); + @ContentChildren(MatListItemLine, {descendants: true}) _lines: QueryList; @ContentChildren(MatListItemTitle, {descendants: true}) _titles: QueryList; @ViewChild('unscopedContent') _unscopedContent: ElementRef; @@ -187,20 +186,6 @@ export class MatListOption extends MatListItemBase implements ListOption, OnInit */ private _inputsInitialized = false; - constructor( - elementRef: ElementRef, - ngZone: NgZone, - @Inject(SELECTION_LIST) private _selectionList: SelectionList, - platform: Platform, - private _changeDetectorRef: ChangeDetectorRef, - @Optional() - @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) - globalRippleOptions?: RippleGlobalOptions, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { - super(elementRef, ngZone, _selectionList, platform, globalRippleOptions, animationMode); - } - ngOnInit() { const list = this._selectionList; diff --git a/src/material/list/list.ts b/src/material/list/list.ts index fd6662d4a468..da937ec3bd2d 100644 --- a/src/material/list/list.ts +++ b/src/material/list/list.ts @@ -6,23 +6,17 @@ * found in the LICENSE file at https://angular.io/license */ -import {Platform} from '@angular/cdk/platform'; import { ChangeDetectionStrategy, Component, Input, ContentChildren, ElementRef, - Inject, - NgZone, - Optional, QueryList, ViewChild, ViewEncapsulation, InjectionToken, - ANIMATION_MODULE_TYPE, } from '@angular/core'; -import {MAT_RIPPLE_GLOBAL_OPTIONS, RippleGlobalOptions} from '@angular/material/core'; import {MatListBase, MatListItemBase} from './list-base'; import {MatListItemLine, MatListItemMeta, MatListItemTitle} from './list-item-sections'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; @@ -88,17 +82,6 @@ export class MatListItem extends MatListItemBase { } _activated = false; - constructor( - element: ElementRef, - ngZone: NgZone, - @Optional() listBase: MatListBase | null, - platform: Platform, - @Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalRippleOptions?: RippleGlobalOptions, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { - super(element, ngZone, listBase, platform, globalRippleOptions, animationMode); - } - /** * Determine the value of `aria-current`. Return 'page' if this item is an activated anchor tag. * Otherwise, return `null`. This method is safe to use with server-side rendering. diff --git a/src/material/list/selection-list.ts b/src/material/list/selection-list.ts index 566a62401f86..59f43aa537e9 100644 --- a/src/material/list/selection-list.ts +++ b/src/material/list/selection-list.ts @@ -77,6 +77,9 @@ export class MatSelectionList extends MatListBase implements SelectionList, ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy { + _element = inject>(ElementRef); + private _ngZone = inject(NgZone); + private _initialized = false; private _keyManager: FocusKeyManager; @@ -155,10 +158,9 @@ export class MatSelectionList private readonly _changeDetectorRef = inject(ChangeDetectorRef); - constructor( - public _element: ElementRef, - private _ngZone: NgZone, - ) { + constructor(...args: unknown[]); + + constructor() { super(); this._isNonInteractive = false; } diff --git a/src/material/menu/menu-content.ts b/src/material/menu/menu-content.ts index 0c9426dda717..a4995351b36f 100644 --- a/src/material/menu/menu-content.ts +++ b/src/material/menu/menu-content.ts @@ -13,12 +13,12 @@ import { ChangeDetectorRef, ComponentFactoryResolver, Directive, - Inject, InjectionToken, Injector, OnDestroy, TemplateRef, ViewContainerRef, + inject, } from '@angular/core'; import {Subject} from 'rxjs'; @@ -36,45 +36,23 @@ export const MAT_MENU_CONTENT = new InjectionToken('MatMenuConte standalone: true, }) export class MatMenuContent implements OnDestroy { + private _template = inject>(TemplateRef); + private _componentFactoryResolver = inject(ComponentFactoryResolver); + private _appRef = inject(ApplicationRef); + private _injector = inject(Injector); + private _viewContainerRef = inject(ViewContainerRef); + private _document = inject(DOCUMENT); + private _changeDetectorRef = inject(ChangeDetectorRef); + private _portal: TemplatePortal; private _outlet: DomPortalOutlet; /** Emits when the menu content has been attached. */ readonly _attached = new Subject(); - constructor( - template: TemplateRef, - componentFactoryResolver: ComponentFactoryResolver, - appRef: ApplicationRef, - injector: Injector, - viewContainerRef: ViewContainerRef, - document: any, - changeDetectorRef: ChangeDetectorRef, - ); - - /** - * @deprecated `changeDetectorRef` is now a required parameter. - * @breaking-change 9.0.0 - */ - constructor( - template: TemplateRef, - componentFactoryResolver: ComponentFactoryResolver, - appRef: ApplicationRef, - injector: Injector, - viewContainerRef: ViewContainerRef, - document: any, - changeDetectorRef?: ChangeDetectorRef, - ); + constructor(...args: unknown[]); - constructor( - private _template: TemplateRef, - private _componentFactoryResolver: ComponentFactoryResolver, - private _appRef: ApplicationRef, - private _injector: Injector, - private _viewContainerRef: ViewContainerRef, - @Inject(DOCUMENT) private _document: any, - private _changeDetectorRef?: ChangeDetectorRef, - ) {} + constructor() {} /** * Attaches the content with a particular context. @@ -108,8 +86,7 @@ export class MatMenuContent implements OnDestroy { // by Angular. This causes the `@ContentChildren` for menu items within the menu to // not be updated by Angular. By explicitly marking for check here, we tell Angular that // it needs to check for new menu items and update the `@ContentChild` in `MatMenu`. - // @breaking-change 9.0.0 Make change detector ref required - this._changeDetectorRef?.markForCheck(); + this._changeDetectorRef.markForCheck(); this._portal.attach(this._outlet, context); this._attached.next(); } diff --git a/src/material/menu/menu-item.ts b/src/material/menu/menu-item.ts index f274212e2676..d6f54b1f9854 100644 --- a/src/material/menu/menu-item.ts +++ b/src/material/menu/menu-item.ts @@ -12,12 +12,11 @@ import { ElementRef, OnDestroy, ViewEncapsulation, - Inject, - Optional, Input, AfterViewInit, ChangeDetectorRef, booleanAttribute, + inject, } from '@angular/core'; import {FocusableOption, FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; import {Subject} from 'rxjs'; @@ -49,6 +48,12 @@ import {MatRipple} from '@angular/material/core'; imports: [MatRipple], }) export class MatMenuItem implements FocusableOption, AfterViewInit, OnDestroy { + private _elementRef = inject>(ElementRef); + private _document = inject(DOCUMENT); + private _focusMonitor = inject(FocusMonitor); + _parentMenu? = inject>(MAT_MENU_PANEL, {optional: true}); + private _changeDetectorRef = inject(ChangeDetectorRef); + /** ARIA role for the menu item. */ @Input() role: 'menuitem' | 'menuitemradio' | 'menuitemcheckbox' = 'menuitem'; @@ -70,34 +75,10 @@ export class MatMenuItem implements FocusableOption, AfterViewInit, OnDestroy { /** Whether the menu item acts as a trigger for a sub-menu. */ _triggersSubmenu: boolean = false; - constructor( - elementRef: ElementRef, - document: any, - focusMonitor: FocusMonitor, - parentMenu: MatMenuPanel | undefined, - changeDetectorRef: ChangeDetectorRef, - ); - - /** - * @deprecated `document`, `changeDetectorRef` and `focusMonitor` to become required. - * @breaking-change 12.0.0 - */ - constructor( - elementRef: ElementRef, - document?: any, - focusMonitor?: FocusMonitor, - parentMenu?: MatMenuPanel, - changeDetectorRef?: ChangeDetectorRef, - ); - - constructor( - private _elementRef: ElementRef, - @Inject(DOCUMENT) private _document?: any, - private _focusMonitor?: FocusMonitor, - @Inject(MAT_MENU_PANEL) @Optional() public _parentMenu?: MatMenuPanel, - private _changeDetectorRef?: ChangeDetectorRef, - ) { - _parentMenu?.addItem?.(this); + constructor(...args: unknown[]); + + constructor() { + this._parentMenu?.addItem?.(this); } /** Focuses the menu item. */ @@ -173,15 +154,13 @@ export class MatMenuItem implements FocusableOption, AfterViewInit, OnDestroy { // We need to mark this for check for the case where the content is coming from a // `matMenuContent` whose change detection tree is at the declaration position, // not the insertion position. See #23175. - // @breaking-change 12.0.0 Remove null check for `_changeDetectorRef`. this._highlighted = isHighlighted; - this._changeDetectorRef?.markForCheck(); + this._changeDetectorRef.markForCheck(); } _setTriggersSubmenu(triggersSubmenu: boolean) { - // @breaking-change 12.0.0 Remove null check for `_changeDetectorRef`. this._triggersSubmenu = triggersSubmenu; - this._changeDetectorRef?.markForCheck(); + this._changeDetectorRef.markForCheck(); } _hasFocus(): boolean { diff --git a/src/material/menu/menu-trigger.ts b/src/material/menu/menu-trigger.ts index 13b9c3ea7c09..1218bfce7268 100644 --- a/src/material/menu/menu-trigger.ts +++ b/src/material/menu/menu-trigger.ts @@ -31,14 +31,11 @@ import { ElementRef, EventEmitter, inject, - Inject, InjectionToken, Input, NgZone, OnDestroy, - Optional, Output, - Self, ViewContainerRef, } from '@angular/core'; import {normalizePassiveListenerOptions} from '@angular/cdk/platform'; @@ -100,14 +97,22 @@ export const MENU_PANEL_TOP_PADDING = 8; standalone: true, }) export class MatMenuTrigger implements AfterContentInit, OnDestroy { + private _overlay = inject(Overlay); + private _element = inject>(ElementRef); + private _viewContainerRef = inject(ViewContainerRef); + private _menuItemInstance = inject(MatMenuItem, {optional: true, self: true})!; + private _dir = inject(Directionality, {optional: true}); + private _focusMonitor = inject(FocusMonitor); + private _ngZone = inject(NgZone); + private _scrollStrategy = inject(MAT_MENU_SCROLL_STRATEGY); + private _changeDetectorRef = inject(ChangeDetectorRef); + private _portal: TemplatePortal; private _overlayRef: OverlayRef | null = null; private _menuOpen: boolean = false; private _closingActionsSubscription = Subscription.EMPTY; private _hoverSubscription = Subscription.EMPTY; private _menuCloseSubscription = Subscription.EMPTY; - private _scrollStrategy: () => ScrollStrategy; - private _changeDetectorRef = inject(ChangeDetectorRef); /** * We're specifically looking for a `MatMenu` here since the generic `MatMenuPanel` @@ -211,65 +216,14 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy { // tslint:disable-next-line:no-output-on-prefix @Output() readonly onMenuClose: EventEmitter = this.menuClosed; - constructor( - overlay: Overlay, - element: ElementRef, - viewContainerRef: ViewContainerRef, - scrollStrategy: any, - parentMenu: MatMenuPanel, - menuItemInstance: MatMenuItem, - dir: Directionality, - focusMonitor: FocusMonitor, - ngZone: NgZone, - ); + constructor(...args: unknown[]); - /** - * @deprecated `focusMonitor` will become a required parameter. - * @breaking-change 8.0.0 - */ - constructor( - overlay: Overlay, - element: ElementRef, - viewContainerRef: ViewContainerRef, - scrollStrategy: any, - parentMenu: MatMenuPanel, - menuItemInstance: MatMenuItem, - dir: Directionality, - focusMonitor?: FocusMonitor | null, - ); + constructor() { + const parentMenu = inject(MAT_MENU_PANEL, {optional: true}); - /** - * @deprecated `ngZone` will become a required parameter. - * @breaking-change 15.0.0 - */ - constructor( - overlay: Overlay, - element: ElementRef, - viewContainerRef: ViewContainerRef, - scrollStrategy: any, - parentMenu: MatMenuPanel, - menuItemInstance: MatMenuItem, - dir: Directionality, - focusMonitor: FocusMonitor, - ); - - constructor( - private _overlay: Overlay, - private _element: ElementRef, - private _viewContainerRef: ViewContainerRef, - @Inject(MAT_MENU_SCROLL_STRATEGY) scrollStrategy: any, - @Inject(MAT_MENU_PANEL) @Optional() parentMenu: MatMenuPanel, - // `MatMenuTrigger` is commonly used in combination with a `MatMenuItem`. - // tslint:disable-next-line: lightweight-tokens - @Optional() @Self() private _menuItemInstance: MatMenuItem, - @Optional() private _dir: Directionality, - private _focusMonitor: FocusMonitor | null, - private _ngZone?: NgZone, - ) { - this._scrollStrategy = scrollStrategy; this._parentMaterialMenu = parentMenu instanceof MatMenu ? parentMenu : undefined; - _element.nativeElement.addEventListener( + this._element.nativeElement.addEventListener( 'touchstart', this._handleTouchStart, passiveEventListenerOptions, @@ -500,7 +454,7 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy { backdropClass: menu.backdropClass || 'cdk-overlay-transparent-backdrop', panelClass: menu.overlayPanelClass, scrollStrategy: this._scrollStrategy(), - direction: this._dir, + direction: this._dir || 'ltr', }); } @@ -512,17 +466,12 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy { private _subscribeToPositions(menu: MatMenuPanel, position: FlexibleConnectedPositionStrategy) { if (menu.setPositionClasses) { position.positionChanges.subscribe(change => { - const posX: MenuPositionX = change.connectionPair.overlayX === 'start' ? 'after' : 'before'; - const posY: MenuPositionY = change.connectionPair.overlayY === 'top' ? 'below' : 'above'; - - // @breaking-change 15.0.0 Remove null check for `ngZone`. - // `positionChanges` fires outside of the `ngZone` and `setPositionClasses` might be - // updating something in the view so we need to bring it back in. - if (this._ngZone) { - this._ngZone.run(() => menu.setPositionClasses!(posX, posY)); - } else { + this._ngZone.run(() => { + const posX: MenuPositionX = + change.connectionPair.overlayX === 'start' ? 'after' : 'before'; + const posY: MenuPositionY = change.connectionPair.overlayY === 'top' ? 'below' : 'above'; menu.setPositionClasses!(posX, posY); - } + }); }); } } diff --git a/src/material/menu/menu.ts b/src/material/menu/menu.ts index b625f64727e2..15b89359791f 100644 --- a/src/material/menu/menu.ts +++ b/src/material/menu/menu.ts @@ -14,10 +14,8 @@ import { ContentChildren, ElementRef, EventEmitter, - Inject, InjectionToken, Input, - NgZone, OnDestroy, Output, TemplateRef, @@ -114,6 +112,9 @@ export function MAT_MENU_DEFAULT_OPTIONS_FACTORY(): MatMenuDefaultOptions { standalone: true, }) export class MatMenu implements AfterContentInit, MatMenuPanel, OnInit, OnDestroy { + private _elementRef = inject>(ElementRef); + private _changeDetectorRef = inject(ChangeDetectorRef); + private _keyManager: FocusKeyManager; private _xPosition: MenuPositionX; private _yPosition: MenuPositionY; @@ -274,35 +275,10 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnI private _injector = inject(Injector); - constructor( - elementRef: ElementRef, - ngZone: NgZone, - defaultOptions: MatMenuDefaultOptions, - changeDetectorRef: ChangeDetectorRef, - ); + constructor(...args: unknown[]); - /** - * @deprecated `_changeDetectorRef` to become a required parameter. - * @breaking-change 15.0.0 - */ - constructor( - elementRef: ElementRef, - ngZone: NgZone, - defaultOptions: MatMenuDefaultOptions, - changeDetectorRef?: ChangeDetectorRef, - ); - - constructor( - private _elementRef: ElementRef, - /** - * @deprecated Unused param, will be removed. - * @breaking-change 19.0.0 - */ - _unusedNgZone: NgZone, - @Inject(MAT_MENU_DEFAULT_OPTIONS) defaultOptions: MatMenuDefaultOptions, - // @breaking-change 15.0.0 `_changeDetectorRef` to become a required parameter. - private _changeDetectorRef?: ChangeDetectorRef, - ) { + constructor() { + const defaultOptions = inject(MAT_MENU_DEFAULT_OPTIONS); this.overlayPanelClass = defaultOptions.overlayPanelClass || ''; this._xPosition = defaultOptions.xPosition; this._yPosition = defaultOptions.yPosition; @@ -518,8 +494,7 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnI ['mat-menu-below']: posY === 'below', }; - // @breaking-change 15.0.0 Remove null check for `_changeDetectorRef`. - this._changeDetectorRef?.markForCheck(); + this._changeDetectorRef.markForCheck(); } /** Starts the enter animation. */ diff --git a/src/material/paginator/paginator.ts b/src/material/paginator/paginator.ts index 0e589fdb4b5d..85a4dc9da56a 100644 --- a/src/material/paginator/paginator.ts +++ b/src/material/paginator/paginator.ts @@ -11,16 +11,15 @@ import { ChangeDetectorRef, Component, EventEmitter, - Inject, InjectionToken, Input, OnDestroy, OnInit, - Optional, Output, ViewEncapsulation, booleanAttribute, numberAttribute, + inject, } from '@angular/core'; import {MatOption, ThemePalette} from '@angular/material/core'; import {MatSelect} from '@angular/material/select'; @@ -112,6 +111,9 @@ let nextUniqueId = 0; imports: [MatFormField, MatSelect, MatOption, MatIconButton, MatTooltip], }) export class MatPaginator implements OnInit, OnDestroy { + _intl = inject(MatPaginatorIntl); + private _changeDetectorRef = inject(ChangeDetectorRef); + /** If set, styles the "page size" form field with the designated style. */ _formFieldAppearance?: MatFormFieldAppearance; @@ -199,12 +201,14 @@ export class MatPaginator implements OnInit, OnDestroy { /** Emits when the paginator is initialized. */ initialized: Observable = this._initializedStream; - constructor( - public _intl: MatPaginatorIntl, - private _changeDetectorRef: ChangeDetectorRef, - @Optional() @Inject(MAT_PAGINATOR_DEFAULT_OPTIONS) defaults?: MatPaginatorDefaultOptions, - ) { - this._intlChanges = _intl.changes.subscribe(() => this._changeDetectorRef.markForCheck()); + constructor(...args: unknown[]); + + constructor() { + const defaults = inject(MAT_PAGINATOR_DEFAULT_OPTIONS, { + optional: true, + }); + + this._intlChanges = this._intl.changes.subscribe(() => this._changeDetectorRef.markForCheck()); if (defaults) { const {pageSize, pageSizeOptions, hidePageSize, showFirstLastButtons} = defaults; diff --git a/src/material/progress-bar/progress-bar.ts b/src/material/progress-bar/progress-bar.ts index 8a4788b43be9..84b9df7f13c3 100644 --- a/src/material/progress-bar/progress-bar.ts +++ b/src/material/progress-bar/progress-bar.ts @@ -12,8 +12,6 @@ import { ViewEncapsulation, ElementRef, NgZone, - Optional, - Inject, Input, Output, EventEmitter, @@ -110,16 +108,19 @@ export type ProgressBarMode = 'determinate' | 'indeterminate' | 'buffer' | 'quer standalone: true, }) export class MatProgressBar implements AfterViewInit, OnDestroy { - constructor( - readonly _elementRef: ElementRef, - private _ngZone: NgZone, - private _changeDetectorRef: ChangeDetectorRef, - @Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string, - @Optional() - @Inject(MAT_PROGRESS_BAR_DEFAULT_OPTIONS) - defaults?: MatProgressBarDefaultOptions, - ) { - this._isNoopAnimation = _animationMode === 'NoopAnimations'; + readonly _elementRef = inject>(ElementRef); + private _ngZone = inject(NgZone); + private _changeDetectorRef = inject(ChangeDetectorRef); + _animationMode? = inject(ANIMATION_MODULE_TYPE, {optional: true}); + + constructor(...args: unknown[]); + + constructor() { + const defaults = inject(MAT_PROGRESS_BAR_DEFAULT_OPTIONS, { + optional: true, + }); + + this._isNoopAnimation = this._animationMode === 'NoopAnimations'; if (defaults) { if (defaults.color) { diff --git a/src/material/progress-spinner/progress-spinner.ts b/src/material/progress-spinner/progress-spinner.ts index d6e425267559..8e2484bcfa81 100644 --- a/src/material/progress-spinner/progress-spinner.ts +++ b/src/material/progress-spinner/progress-spinner.ts @@ -10,14 +10,13 @@ import { ChangeDetectionStrategy, Component, ElementRef, - Inject, InjectionToken, Input, - Optional, ViewChild, ViewEncapsulation, numberAttribute, ANIMATION_MODULE_TYPE, + inject, } from '@angular/core'; import {ThemePalette} from '@angular/material/core'; import {NgTemplateOutlet} from '@angular/common'; @@ -97,6 +96,8 @@ const BASE_STROKE_WIDTH = 10; imports: [NgTemplateOutlet], }) export class MatProgressSpinner { + readonly _elementRef = inject>(ElementRef); + /** Whether the _mat-animation-noopable class should be applied, disabling animations. */ _noopAnimations: boolean; @@ -121,16 +122,16 @@ export class MatProgressSpinner { /** The element of the determinate spinner. */ @ViewChild('determinateSpinner') _determinateCircle: ElementRef; - constructor( - readonly _elementRef: ElementRef, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode: string, - @Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS) - defaults?: MatProgressSpinnerDefaultOptions, - ) { + constructor(...args: unknown[]); + + constructor() { + const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + const defaults = inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS); + this._noopAnimations = animationMode === 'NoopAnimations' && !!defaults && !defaults._forceAnimations; this.mode = - _elementRef.nativeElement.nodeName.toLowerCase() === 'mat-spinner' + this._elementRef.nativeElement.nodeName.toLowerCase() === 'mat-spinner' ? 'indeterminate' : 'determinate'; diff --git a/src/material/radio/radio.ts b/src/material/radio/radio.ts index e4720df85265..7c64ca81e912 100644 --- a/src/material/radio/radio.ts +++ b/src/material/radio/radio.ts @@ -12,7 +12,6 @@ import { ANIMATION_MODULE_TYPE, AfterContentInit, AfterViewInit, - Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, @@ -21,14 +20,12 @@ import { DoCheck, ElementRef, EventEmitter, - Inject, InjectionToken, Injector, Input, NgZone, OnDestroy, OnInit, - Optional, Output, QueryList, ViewChild, @@ -38,6 +35,7 @@ import { forwardRef, inject, numberAttribute, + HostAttributeToken, } from '@angular/core'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; import {MatRipple, ThemePalette, _MatInternalFormField} from '@angular/material/core'; @@ -120,6 +118,8 @@ export function MAT_RADIO_DEFAULT_OPTIONS_FACTORY(): MatRadioDefaultOptions { standalone: true, }) export class MatRadioGroup implements AfterContentInit, OnDestroy, ControlValueAccessor { + private _changeDetector = inject(ChangeDetectorRef); + /** Selected value for the radio group. */ private _value: any = null; @@ -264,7 +264,9 @@ export class MatRadioGroup implements AfterContentInit, OnDestroy, ControlValueA } private _disabledInteractive = false; - constructor(private _changeDetector: ChangeDetectorRef) {} + constructor(...args: unknown[]); + + constructor() {} /** * Initialize properties once content children are available. @@ -407,6 +409,14 @@ export class MatRadioGroup implements AfterContentInit, OnDestroy, ControlValueA imports: [MatRipple, _MatInternalFormField], }) export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy { + protected _elementRef = inject(ElementRef); + private _changeDetector = inject(ChangeDetectorRef); + private _focusMonitor = inject(FocusMonitor); + private _radioDispatcher = inject(UniqueSelectionDispatcher); + private _defaultOptions = inject(MAT_RADIO_DEFAULT_OPTIONS, { + optional: true, + }); + private _ngZone = inject(NgZone); private _uniqueId: string = `mat-radio-${++nextUniqueId}`; @@ -587,23 +597,18 @@ export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy private _injector = inject(Injector); - constructor( - @Optional() @Inject(MAT_RADIO_GROUP) radioGroup: MatRadioGroup, - protected _elementRef: ElementRef, - private _changeDetector: ChangeDetectorRef, - private _focusMonitor: FocusMonitor, - private _radioDispatcher: UniqueSelectionDispatcher, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - @Optional() - @Inject(MAT_RADIO_DEFAULT_OPTIONS) - private _defaultOptions?: MatRadioDefaultOptions, - @Attribute('tabindex') tabIndex?: string, - ) { + constructor(...args: unknown[]); + + constructor() { + const radioGroup = inject(MAT_RADIO_GROUP, {optional: true})!; + const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + const tabIndex = inject(new HostAttributeToken('tabindex'), {optional: true}); + // Assertions. Ideally these should be stripped out by the compiler. // TODO(jelbourn): Assert that there's no name binding AND a parent radio group. this.radioGroup = radioGroup; this._noopAnimations = animationMode === 'NoopAnimations'; - this._disabledInteractive = _defaultOptions?.disabledInteractive ?? false; + this._disabledInteractive = this._defaultOptions?.disabledInteractive ?? false; if (tabIndex) { this.tabIndex = numberAttribute(tabIndex, 0); diff --git a/src/material/select/select.spec.ts b/src/material/select/select.spec.ts index c0a5dc64cec7..553742d83f3e 100644 --- a/src/material/select/select.spec.ts +++ b/src/material/select/select.spec.ts @@ -5520,12 +5520,14 @@ class SelectInNgContainer {} `, }) class SelectInsideDynamicFormGroup { + private _formBuilder = inject(FormBuilder); + @ViewChild(MatSelect) select: MatSelect; form: FormGroup; private readonly _changeDetectorRef = inject(ChangeDetectorRef); - constructor(private _formBuilder: FormBuilder) { + constructor() { this.assignGroup(false); } diff --git a/src/material/select/select.ts b/src/material/select/select.ts index e78fbf0c13a1..b68a6268b976 100644 --- a/src/material/select/select.ts +++ b/src/material/select/select.ts @@ -34,7 +34,6 @@ import { import {ViewportRuler} from '@angular/cdk/scrolling'; import { AfterContentInit, - Attribute, booleanAttribute, ChangeDetectionStrategy, ChangeDetectorRef, @@ -45,22 +44,19 @@ import { DoCheck, ElementRef, EventEmitter, - Inject, inject, InjectionToken, Input, - NgZone, numberAttribute, OnChanges, OnDestroy, OnInit, - Optional, Output, QueryList, - Self, SimpleChanges, ViewChild, ViewEncapsulation, + HostAttributeToken, } from '@angular/core'; import { AbstractControl, @@ -217,6 +213,14 @@ export class MatSelect ControlValueAccessor, MatFormFieldControl { + protected _viewportRuler = inject(ViewportRuler); + protected _changeDetectorRef = inject(ChangeDetectorRef); + readonly _elementRef = inject(ElementRef); + private _dir = inject(Directionality, {optional: true}); + protected _parentFormField = inject(MAT_FORM_FIELD, {optional: true}); + ngControl = inject(NgControl, {self: true, optional: true}); + private _liveAnnouncer = inject(LiveAnnouncer); + protected _defaultOptions = inject(MAT_SELECT_CONFIG, {optional: true}); /** All of the defined select options. */ @@ -301,7 +305,7 @@ export class MatSelect } /** Factory function used to create a scroll strategy for this select. */ - private _scrollStrategyFactory: () => ScrollStrategy; + private _scrollStrategyFactory = inject(MAT_SELECT_SCROLL_STRATEGY); /** Whether or not the overlay panel is open. */ private _panelOpen = false; @@ -591,26 +595,14 @@ export class MatSelect */ @Output() readonly valueChange: EventEmitter = new EventEmitter(); - constructor( - protected _viewportRuler: ViewportRuler, - protected _changeDetectorRef: ChangeDetectorRef, - /** - * @deprecated Unused param, will be removed. - * @breaking-change 19.0.0 - */ - _unusedNgZone: NgZone, - defaultErrorStateMatcher: ErrorStateMatcher, - readonly _elementRef: ElementRef, - @Optional() private _dir: Directionality, - @Optional() parentForm: NgForm, - @Optional() parentFormGroup: FormGroupDirective, - @Optional() @Inject(MAT_FORM_FIELD) protected _parentFormField: MatFormField, - @Self() @Optional() public ngControl: NgControl, - @Attribute('tabindex') tabIndex: string, - @Inject(MAT_SELECT_SCROLL_STRATEGY) scrollStrategyFactory: any, - private _liveAnnouncer: LiveAnnouncer, - @Optional() @Inject(MAT_SELECT_CONFIG) _unusedDefaultOptions?: unknown, - ) { + constructor(...args: unknown[]); + + constructor() { + const defaultErrorStateMatcher = inject(ErrorStateMatcher); + const parentForm = inject(NgForm, {optional: true}); + const parentFormGroup = inject(FormGroupDirective, {optional: true}); + const tabIndex = inject(new HostAttributeToken('tabindex'), {optional: true}); + if (this.ngControl) { // Note: we provide the value accessor through here, instead of // the `providers` to avoid running into a circular import. @@ -625,14 +617,13 @@ export class MatSelect this._errorStateTracker = new _ErrorStateTracker( defaultErrorStateMatcher, - ngControl, + this.ngControl, parentFormGroup, parentForm, this.stateChanges, ); - this._scrollStrategyFactory = scrollStrategyFactory; this._scrollStrategy = this._scrollStrategyFactory(); - this.tabIndex = parseInt(tabIndex) || 0; + this.tabIndex = tabIndex == null ? 0 : parseInt(tabIndex) || 0; // Force setter to be called in case id was not specified. this.id = this.id; @@ -1365,7 +1356,7 @@ export class MatSelect return null; } - const labelId = this._parentFormField?.getLabelId(); + const labelId = this._parentFormField?.getLabelId() || null; const labelExpression = labelId ? labelId + ' ' : ''; return this.ariaLabelledby ? labelExpression + this.ariaLabelledby : labelId; } diff --git a/src/material/sidenav/drawer.ts b/src/material/sidenav/drawer.ts index fcd9588e697c..cf1bae387a9d 100644 --- a/src/material/sidenav/drawer.ts +++ b/src/material/sidenav/drawer.ts @@ -34,15 +34,12 @@ import { DoCheck, ElementRef, EventEmitter, - forwardRef, inject, - Inject, InjectionToken, Injector, Input, NgZone, OnDestroy, - Optional, Output, QueryList, ViewChild, @@ -117,13 +114,16 @@ export function MAT_DRAWER_DEFAULT_AUTOSIZE_FACTORY(): boolean { standalone: true, }) export class MatDrawerContent extends CdkScrollable implements AfterContentInit { - constructor( - private _changeDetectorRef: ChangeDetectorRef, - @Inject(forwardRef(() => MatDrawerContainer)) public _container: MatDrawerContainer, - elementRef: ElementRef, - scrollDispatcher: ScrollDispatcher, - ngZone: NgZone, - ) { + private _changeDetectorRef = inject(ChangeDetectorRef); + _container = inject(MatDrawerContainer); + + constructor(...args: unknown[]); + + constructor() { + const elementRef = inject>(ElementRef); + const scrollDispatcher = inject(ScrollDispatcher); + const ngZone = inject(NgZone); + super(elementRef, scrollDispatcher, ngZone); } @@ -162,6 +162,15 @@ export class MatDrawerContent extends CdkScrollable implements AfterContentInit imports: [CdkScrollable], }) export class MatDrawer implements AfterViewInit, AfterContentChecked, OnDestroy { + private _elementRef = inject>(ElementRef); + private _focusTrapFactory = inject(FocusTrapFactory); + private _focusMonitor = inject(FocusMonitor); + private _platform = inject(Platform); + private _ngZone = inject(NgZone); + private readonly _interactivityChecker = inject(InteractivityChecker); + private _doc = inject(DOCUMENT, {optional: true})!; + _container? = inject(MAT_DRAWER_CONTAINER, {optional: true}); + private _focusTrap: FocusTrap | null = null; private _elementFocusedBeforeDrawerWasOpened: HTMLElement | null = null; @@ -324,16 +333,9 @@ export class MatDrawer implements AfterViewInit, AfterContentChecked, OnDestroy private _injector = inject(Injector); private _changeDetectorRef = inject(ChangeDetectorRef); - constructor( - private _elementRef: ElementRef, - private _focusTrapFactory: FocusTrapFactory, - private _focusMonitor: FocusMonitor, - private _platform: Platform, - private _ngZone: NgZone, - private readonly _interactivityChecker: InteractivityChecker, - @Optional() @Inject(DOCUMENT) private _doc: any, - @Optional() @Inject(MAT_DRAWER_CONTAINER) public _container?: MatDrawerContainer, - ) { + constructor(...args: unknown[]); + + constructor() { this.openedChange.pipe(takeUntil(this._destroyed)).subscribe((opened: boolean) => { if (opened) { if (this._doc) { @@ -671,6 +673,12 @@ export class MatDrawer implements AfterViewInit, AfterContentChecked, OnDestroy imports: [MatDrawerContent], }) export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy { + private _dir = inject(Directionality, {optional: true}); + private _element = inject>(ElementRef); + private _ngZone = inject(NgZone); + private _changeDetectorRef = inject(ChangeDetectorRef); + private _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + /** All drawers in the container. Includes drawers from inside nested containers. */ @ContentChildren(MatDrawer, { // We need to use `descendants: true`, because Ivy will no longer match @@ -710,7 +718,7 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy set autosize(value: BooleanInput) { this._autosize = coerceBooleanProperty(value); } - private _autosize: boolean; + private _autosize = inject(MAT_DRAWER_DEFAULT_AUTOSIZE); /** * Whether the drawer container should have a backdrop while one of the sidenavs is open. @@ -764,23 +772,17 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy private _injector = inject(Injector); - constructor( - @Optional() private _dir: Directionality, - private _element: ElementRef, - private _ngZone: NgZone, - private _changeDetectorRef: ChangeDetectorRef, - viewportRuler: ViewportRuler, - @Inject(MAT_DRAWER_DEFAULT_AUTOSIZE) defaultAutosize = false, - @Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string, - ) { + constructor(...args: unknown[]); + + constructor() { + const viewportRuler = inject(ViewportRuler); + // If a `Dir` directive exists up the tree, listen direction changes // and update the left/right properties to point to the proper start/end. - if (_dir) { - _dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => { - this._validateDrawers(); - this.updateContentMargins(); - }); - } + this._dir?.change.pipe(takeUntil(this._destroyed)).subscribe(() => { + this._validateDrawers(); + this.updateContentMargins(); + }); // Since the minimum width of the sidenav depends on the viewport width, // we need to recompute the margins if the viewport changes. @@ -788,8 +790,6 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy .change() .pipe(takeUntil(this._destroyed)) .subscribe(() => this.updateContentMargins()); - - this._autosize = defaultAutosize; } ngAfterContentInit() { diff --git a/src/material/sidenav/sidenav.ts b/src/material/sidenav/sidenav.ts index 4f1b5a5f8f58..2e75b80c78c0 100644 --- a/src/material/sidenav/sidenav.ts +++ b/src/material/sidenav/sidenav.ts @@ -8,17 +8,12 @@ import { ChangeDetectionStrategy, - ChangeDetectorRef, Component, ContentChild, ContentChildren, - forwardRef, - Inject, Input, ViewEncapsulation, QueryList, - ElementRef, - NgZone, } from '@angular/core'; import {MatDrawer, MatDrawerContainer, MatDrawerContent, MAT_DRAWER_CONTAINER} from './drawer'; import {matDrawerAnimations} from './drawer-animations'; @@ -28,7 +23,7 @@ import { coerceNumberProperty, NumberInput, } from '@angular/cdk/coercion'; -import {ScrollDispatcher, CdkScrollable} from '@angular/cdk/scrolling'; +import {CdkScrollable} from '@angular/cdk/scrolling'; @Component({ selector: 'mat-sidenav-content', @@ -48,17 +43,7 @@ import {ScrollDispatcher, CdkScrollable} from '@angular/cdk/scrolling'; ], standalone: true, }) -export class MatSidenavContent extends MatDrawerContent { - constructor( - changeDetectorRef: ChangeDetectorRef, - @Inject(forwardRef(() => MatSidenavContainer)) container: MatSidenavContainer, - elementRef: ElementRef, - scrollDispatcher: ScrollDispatcher, - ngZone: NgZone, - ) { - super(changeDetectorRef, container, elementRef, scrollDispatcher, ngZone); - } -} +export class MatSidenavContent extends MatDrawerContent {} @Component({ selector: 'mat-sidenav', @@ -83,6 +68,7 @@ export class MatSidenavContent extends MatDrawerContent { encapsulation: ViewEncapsulation.None, standalone: true, imports: [CdkScrollable], + providers: [{provide: MatDrawer, useExisting: MatSidenav}], }) export class MatSidenav extends MatDrawer { /** Whether the sidenav is fixed in the viewport. */ @@ -138,6 +124,10 @@ export class MatSidenav extends MatDrawer { provide: MAT_DRAWER_CONTAINER, useExisting: MatSidenavContainer, }, + { + provide: MatDrawerContainer, + useExisting: MatSidenavContainer, + }, ], standalone: true, imports: [MatSidenavContent], diff --git a/src/material/slide-toggle/slide-toggle.ts b/src/material/slide-toggle/slide-toggle.ts index 28837bcf85c9..d747c765db99 100644 --- a/src/material/slide-toggle/slide-toggle.ts +++ b/src/material/slide-toggle/slide-toggle.ts @@ -8,7 +8,6 @@ import { AfterContentInit, - Attribute, booleanAttribute, ChangeDetectionStrategy, ChangeDetectorRef, @@ -16,17 +15,17 @@ import { ElementRef, EventEmitter, forwardRef, - Inject, Input, numberAttribute, OnChanges, OnDestroy, - Optional, Output, SimpleChanges, ViewChild, ViewEncapsulation, ANIMATION_MODULE_TYPE, + inject, + HostAttributeToken, } from '@angular/core'; import { AbstractControl, @@ -100,6 +99,11 @@ let nextUniqueId = 0; export class MatSlideToggle implements OnDestroy, AfterContentInit, OnChanges, ControlValueAccessor, Validator { + private _elementRef = inject(ElementRef); + protected _focusMonitor = inject(FocusMonitor); + protected _changeDetectorRef = inject(ChangeDetectorRef); + defaults = inject(MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS); + private _onChange = (_: any) => {}; private _onTouched = () => {}; private _validatorOnChange = () => {}; @@ -205,15 +209,14 @@ export class MatSlideToggle return `${this.id || this._uniqueId}-input`; } - constructor( - private _elementRef: ElementRef, - protected _focusMonitor: FocusMonitor, - protected _changeDetectorRef: ChangeDetectorRef, - @Attribute('tabindex') tabIndex: string, - @Inject(MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS) public defaults: MatSlideToggleDefaultOptions, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { - this.tabIndex = parseInt(tabIndex) || 0; + constructor(...args: unknown[]); + + constructor() { + const tabIndex = inject(new HostAttributeToken('tabindex'), {optional: true}); + const defaults = this.defaults; + const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + + this.tabIndex = tabIndex == null ? 0 : parseInt(tabIndex) || 0; this.color = defaults.color || 'accent'; this._noopAnimations = animationMode === 'NoopAnimations'; this.id = this._uniqueId = `mat-mdc-slide-toggle-${++nextUniqueId}`; diff --git a/src/material/slider/slider-input.ts b/src/material/slider/slider-input.ts index a0d840d93b00..1327c8e0d9b4 100644 --- a/src/material/slider/slider-input.ts +++ b/src/material/slider/slider-input.ts @@ -14,7 +14,6 @@ import { EventEmitter, forwardRef, inject, - Inject, Input, NgZone, numberAttribute, @@ -85,6 +84,11 @@ export const MAT_SLIDER_RANGE_THUMB_VALUE_ACCESSOR: any = { standalone: true, }) export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueAccessor { + readonly _ngZone = inject(NgZone); + readonly _elementRef = inject>(ElementRef); + readonly _cdr = inject(ChangeDetectorRef); + protected _slider = inject<_MatSlider>(MAT_SLIDER); + @Input({transform: numberAttribute}) get value(): number { return numberAttribute(this._hostElement.value, 0); @@ -209,7 +213,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA } /** The host native HTML input element. */ - _hostElement: HTMLInputElement; + _hostElement = this._elementRef.nativeElement; /** The aria-valuetext string representation of the input's value. */ _valuetext = signal(''); @@ -274,13 +278,9 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA private _platform = inject(Platform); - constructor( - readonly _ngZone: NgZone, - readonly _elementRef: ElementRef, - readonly _cdr: ChangeDetectorRef, - @Inject(MAT_SLIDER) protected _slider: _MatSlider, - ) { - this._hostElement = _elementRef.nativeElement; + constructor(...args: unknown[]); + + constructor() { this._ngZone.runOutsideAngular(() => { this._hostElement.addEventListener('pointerdown', this._onPointerDown.bind(this)); this._hostElement.addEventListener('pointermove', this._onPointerMove.bind(this)); @@ -609,6 +609,8 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA standalone: true, }) export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRangeThumb { + override readonly _cdr = inject(ChangeDetectorRef); + /** @docs-private */ getSibling(): _MatSliderRangeThumb | undefined { if (!this._sibling) { @@ -655,13 +657,11 @@ export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRan /** Whether this slider corresponds to the input with greater value. */ _isEndThumb: boolean; - constructor( - _ngZone: NgZone, - @Inject(MAT_SLIDER) _slider: _MatSlider, - _elementRef: ElementRef, - override readonly _cdr: ChangeDetectorRef, - ) { - super(_ngZone, _elementRef, _cdr, _slider); + constructor(...args: unknown[]); + + constructor() { + super(); + this._isEndThumb = this._hostElement.hasAttribute('matSliderEndThumb'); this._setIsLeftThumb(); this.thumbPosition = this._isEndThumb ? _MatThumb.END : _MatThumb.START; diff --git a/src/material/slider/slider-interface.ts b/src/material/slider/slider-interface.ts index b728af803fe3..2319fb603dc9 100644 --- a/src/material/slider/slider-interface.ts +++ b/src/material/slider/slider-interface.ts @@ -125,7 +125,7 @@ export interface _MatSlider { _rippleRadius: number; /** The global configuration for `matRipple` instances. */ - readonly _globalRippleOptions?: RippleGlobalOptions; + readonly _globalRippleOptions: RippleGlobalOptions | null; /** Whether animations have been disabled. */ _noopAnimations: boolean; diff --git a/src/material/slider/slider-thumb.ts b/src/material/slider/slider-thumb.ts index 774ed77371d5..858821fb516d 100644 --- a/src/material/slider/slider-thumb.ts +++ b/src/material/slider/slider-thumb.ts @@ -12,7 +12,6 @@ import { ChangeDetectorRef, Component, ElementRef, - Inject, Input, NgZone, OnDestroy, @@ -52,6 +51,10 @@ import {Platform} from '@angular/cdk/platform'; imports: [MatRipple], }) export class MatSliderVisualThumb implements _MatSliderVisualThumb, AfterViewInit, OnDestroy { + readonly _cdr = inject(ChangeDetectorRef); + private readonly _ngZone = inject(NgZone); + private _slider = inject<_MatSlider>(MAT_SLIDER); + /** Whether the slider displays a numeric value label upon pressing the thumb. */ @Input() discrete: boolean; @@ -96,18 +99,12 @@ export class MatSliderVisualThumb implements _MatSliderVisualThumb, AfterViewIni _isValueIndicatorVisible: boolean = false; /** The host native HTML input element. */ - _hostElement: HTMLElement; + _hostElement = inject>(ElementRef).nativeElement; private _platform = inject(Platform); - constructor( - readonly _cdr: ChangeDetectorRef, - private readonly _ngZone: NgZone, - _elementRef: ElementRef, - @Inject(MAT_SLIDER) private _slider: _MatSlider, - ) { - this._hostElement = _elementRef.nativeElement; - } + constructor(...args: unknown[]); + constructor() {} ngAfterViewInit() { this._ripple.radius = 24; diff --git a/src/material/slider/slider.ts b/src/material/slider/slider.ts index ad9f252fc3f0..6903b9f90246 100644 --- a/src/material/slider/slider.ts +++ b/src/material/slider/slider.ts @@ -18,12 +18,10 @@ import { ContentChildren, ElementRef, inject, - Inject, Input, NgZone, numberAttribute, OnDestroy, - Optional, QueryList, ViewChild, ViewChildren, @@ -76,6 +74,14 @@ import {MatSliderVisualThumb} from './slider-thumb'; imports: [MatSliderVisualThumb], }) export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider { + readonly _ngZone = inject(NgZone); + readonly _cdr = inject(ChangeDetectorRef); + readonly _elementRef = inject>(ElementRef); + readonly _dir = inject(Directionality, {optional: true}); + readonly _globalRippleOptions = inject(MAT_RIPPLE_GLOBAL_OPTIONS, { + optional: true, + }); + /** The active portion of the slider track. */ @ViewChild('trackActive') _trackActive: ElementRef; @@ -395,19 +401,16 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider { private _platform = inject(Platform); - constructor( - readonly _ngZone: NgZone, - readonly _cdr: ChangeDetectorRef, - readonly _elementRef: ElementRef, - @Optional() readonly _dir: Directionality, - @Optional() - @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) - readonly _globalRippleOptions?: RippleGlobalOptions, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { + constructor(...args: unknown[]); + + constructor() { + const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); this._noopAnimations = animationMode === 'NoopAnimations'; - this._dirChangeSubscription = this._dir.change.subscribe(() => this._onDirChange()); - this._isRtl = this._dir.value === 'rtl'; + + if (this._dir) { + this._dirChangeSubscription = this._dir.change.subscribe(() => this._onDirChange()); + this._isRtl = this._dir.value === 'rtl'; + } } /** The radius of the native slider's knob. AFAIK there is no way to avoid hardcoding this. */ @@ -488,7 +491,7 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider { /** Handles updating the slider ui after a dir change. */ private _onDirChange(): void { - this._isRtl = this._dir.value === 'rtl'; + this._isRtl = this._dir?.value === 'rtl'; this._isRange ? this._onDirChangeRange() : this._onDirChangeNonRange(); this._updateTickMarkUI(); } diff --git a/src/material/snack-bar/simple-snack-bar.ts b/src/material/snack-bar/simple-snack-bar.ts index a2865aac94f2..0bcde81a1aad 100644 --- a/src/material/snack-bar/simple-snack-bar.ts +++ b/src/material/snack-bar/simple-snack-bar.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {ChangeDetectionStrategy, Component, Inject, ViewEncapsulation} from '@angular/core'; +import {ChangeDetectionStrategy, Component, ViewEncapsulation, inject} from '@angular/core'; import {MatButton} from '@angular/material/button'; import {MatSnackBarRef} from './snack-bar-ref'; import {MAT_SNACK_BAR_DATA} from './snack-bar-config'; @@ -36,10 +36,11 @@ export interface TextOnlySnackBar { }, }) export class SimpleSnackBar implements TextOnlySnackBar { - constructor( - public snackBarRef: MatSnackBarRef, - @Inject(MAT_SNACK_BAR_DATA) public data: {message: string; action: string}, - ) {} + snackBarRef = inject>(MatSnackBarRef); + data = inject(MAT_SNACK_BAR_DATA); + + constructor(...args: unknown[]); + constructor() {} /** Performs the action on the snack bar. */ action(): void { diff --git a/src/material/snack-bar/snack-bar-container.ts b/src/material/snack-bar/snack-bar-container.ts index 163b2969f4c2..14ec64973b78 100644 --- a/src/material/snack-bar/snack-bar-container.ts +++ b/src/material/snack-bar/snack-bar-container.ts @@ -60,6 +60,12 @@ let uniqueId = 0; }, }) export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy { + private _ngZone = inject(NgZone); + private _elementRef = inject>(ElementRef); + private _changeDetectorRef = inject(ChangeDetectorRef); + private _platform = inject(Platform); + snackBarConfig = inject(MatSnackBarConfig); + private _document = inject(DOCUMENT); private _trackedModals = new Set(); @@ -106,21 +112,17 @@ export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy /** Unique ID of the aria-live element. */ readonly _liveElementId = `mat-snack-bar-container-live-${uniqueId++}`; - constructor( - private _ngZone: NgZone, - private _elementRef: ElementRef, - private _changeDetectorRef: ChangeDetectorRef, - private _platform: Platform, - /** The snack bar configuration. */ - public snackBarConfig: MatSnackBarConfig, - ) { + constructor(...args: unknown[]); + + constructor() { super(); + const config = this.snackBarConfig; // Use aria-live rather than a live role like 'alert' or 'status' // because NVDA and JAWS have show inconsistent behavior with live roles. - if (snackBarConfig.politeness === 'assertive' && !snackBarConfig.announcementMessage) { + if (config.politeness === 'assertive' && !config.announcementMessage) { this._live = 'assertive'; - } else if (snackBarConfig.politeness === 'off') { + } else if (config.politeness === 'off') { this._live = 'off'; } else { this._live = 'polite'; diff --git a/src/material/snack-bar/snack-bar.spec.ts b/src/material/snack-bar/snack-bar.spec.ts index 3fdff3f77c7a..28a54c2fd5bb 100644 --- a/src/material/snack-bar/snack-bar.spec.ts +++ b/src/material/snack-bar/snack-bar.spec.ts @@ -5,13 +5,13 @@ import { ChangeDetectionStrategy, Component, Directive, - Inject, TemplateRef, ViewChild, ViewContainerRef, signal, + inject, } from '@angular/core'; -import {ComponentFixture, TestBed, fakeAsync, flush, inject, tick} from '@angular/core/testing'; +import {ComponentFixture, TestBed, fakeAsync, flush, tick} from '@angular/core/testing'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import { MAT_SNACK_BAR_DATA, @@ -48,23 +48,14 @@ describe('MatSnackBar', () => { DirectiveWithViewContainer, ], }); - })); - - beforeEach(inject( - [MatSnackBar, LiveAnnouncer, OverlayContainer], - (sb: MatSnackBar, la: LiveAnnouncer, oc: OverlayContainer) => { - snackBar = sb; - liveAnnouncer = la; - overlayContainerElement = oc.getContainerElement(); - }, - )); - beforeEach(() => { + snackBar = TestBed.inject(MatSnackBar); + liveAnnouncer = TestBed.inject(LiveAnnouncer); + overlayContainerElement = TestBed.inject(OverlayContainer).getContainerElement(); viewContainerFixture = TestBed.createComponent(ComponentWithChildViewContainer); - viewContainerFixture.detectChanges(); testViewContainerRef = viewContainerFixture.componentInstance.childViewContainer; - }); + })); it('should open with content first in the inert region', () => { snackBar.open('Snack time!', 'Chew'); @@ -593,10 +584,8 @@ describe('MatSnackBar', () => { }) .configureTestingModule({imports: [MatSnackBarModule, NoopAnimationsModule]}); - inject([MatSnackBar, OverlayContainer], (sb: MatSnackBar, oc: OverlayContainer) => { - snackBar = sb; - overlayContainerElement = oc.getContainerElement(); - })(); + snackBar = TestBed.inject(MatSnackBar); + overlayContainerElement = TestBed.inject(OverlayContainer).getContainerElement(); snackBar.open(simpleMessage); flush(); @@ -754,12 +743,9 @@ describe('MatSnackBar with parent MatSnackBar', () => { DirectiveWithViewContainer, ], }); - })); - - beforeEach(inject([MatSnackBar, OverlayContainer], (sb: MatSnackBar, oc: OverlayContainer) => { - parentSnackBar = sb; - overlayContainerElement = oc.getContainerElement(); + parentSnackBar = TestBed.inject(MatSnackBar); + overlayContainerElement = TestBed.inject(OverlayContainer).getContainerElement(); fixture = TestBed.createComponent(ComponentThatProvidesMatSnackBar); childSnackBar = fixture.componentInstance.snackBar; fixture.detectChanges(); @@ -832,17 +818,12 @@ describe('MatSnackBar Positioning', () => { DirectiveWithViewContainer, ], }); - })); - - beforeEach(inject([MatSnackBar, OverlayContainer], (sb: MatSnackBar, oc: OverlayContainer) => { - snackBar = sb; - overlayContainerEl = oc.getContainerElement(); - })); - beforeEach(() => { + snackBar = TestBed.inject(MatSnackBar); + overlayContainerEl = TestBed.inject(OverlayContainer).getContainerElement(); viewContainerFixture = TestBed.createComponent(ComponentWithChildViewContainer); viewContainerFixture.detectChanges(); - }); + })); it('should default to bottom center', fakeAsync(() => { snackBar.open(simpleMessage, simpleActionLabel); @@ -1079,7 +1060,7 @@ describe('MatSnackBar Positioning', () => { standalone: true, }) class DirectiveWithViewContainer { - constructor(public viewContainerRef: ViewContainerRef) {} + viewContainerRef = inject(ViewContainerRef); } @Component({ @@ -1119,10 +1100,8 @@ class ComponentWithTemplateRef { standalone: true, }) class BurritosNotification { - constructor( - public snackBarRef: MatSnackBarRef, - @Inject(MAT_SNACK_BAR_DATA) public data: any, - ) {} + snackBarRef = inject>(MatSnackBarRef); + data = inject(MAT_SNACK_BAR_DATA); } @Component({ @@ -1131,5 +1110,5 @@ class BurritosNotification { standalone: true, }) class ComponentThatProvidesMatSnackBar { - constructor(public snackBar: MatSnackBar) {} + snackBar = inject(MatSnackBar); } diff --git a/src/material/snack-bar/snack-bar.ts b/src/material/snack-bar/snack-bar.ts index 2cd1632357dd..e0c03359df3f 100644 --- a/src/material/snack-bar/snack-bar.ts +++ b/src/material/snack-bar/snack-bar.ts @@ -12,14 +12,12 @@ import {ComponentType, Overlay, OverlayConfig, OverlayRef} from '@angular/cdk/ov import { ComponentRef, EmbeddedViewRef, - Inject, Injectable, InjectionToken, Injector, OnDestroy, - Optional, - SkipSelf, TemplateRef, + inject, } from '@angular/core'; import {SimpleSnackBar, TextOnlySnackBar} from './simple-snack-bar'; import {MatSnackBarContainer} from './snack-bar-container'; @@ -47,6 +45,13 @@ export const MAT_SNACK_BAR_DEFAULT_OPTIONS = new InjectionToken(MAT_SNACK_BAR_DEFAULT_OPTIONS); + /** * Reference to the current snack bar in the view *at this level* (in the Angular injector tree). * If there is a parent snack-bar service, all operations should delegate to that parent @@ -77,14 +82,8 @@ export class MatSnackBar implements OnDestroy { } } - constructor( - private _overlay: Overlay, - private _live: LiveAnnouncer, - private _injector: Injector, - private _breakpointObserver: BreakpointObserver, - @Optional() @SkipSelf() private _parentSnackBar: MatSnackBar, - @Inject(MAT_SNACK_BAR_DEFAULT_OPTIONS) private _defaultConfig: MatSnackBarConfig, - ) {} + constructor(...args: unknown[]); + constructor() {} /** * Creates and dispatches a snack bar with a custom component for the content, removing any diff --git a/src/material/snack-bar/snack-bar.zone.spec.ts b/src/material/snack-bar/snack-bar.zone.spec.ts index c344b38eb69f..403cdf9be9e9 100644 --- a/src/material/snack-bar/snack-bar.zone.spec.ts +++ b/src/material/snack-bar/snack-bar.zone.spec.ts @@ -6,8 +6,9 @@ import { ViewContainerRef, provideZoneChangeDetection, signal, + inject, } from '@angular/core'; -import {ComponentFixture, TestBed, fakeAsync, flush, inject, tick} from '@angular/core/testing'; +import {ComponentFixture, TestBed, fakeAsync, flush, tick} from '@angular/core/testing'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import {MatSnackBarModule} from './module'; import {MatSnackBar} from './snack-bar'; @@ -15,7 +16,6 @@ import {MatSnackBarConfig} from './snack-bar-config'; describe('MatSnackBar Zone.js integration', () => { let snackBar: MatSnackBar; - let viewContainerFixture: ComponentFixture; beforeEach(fakeAsync(() => { @@ -28,17 +28,11 @@ describe('MatSnackBar Zone.js integration', () => { ], providers: [provideZoneChangeDetection()], }); - })); - - beforeEach(inject([MatSnackBar], (sb: MatSnackBar) => { - snackBar = sb; - })); - beforeEach(() => { + snackBar = TestBed.inject(MatSnackBar); viewContainerFixture = TestBed.createComponent(ComponentWithChildViewContainer); - viewContainerFixture.detectChanges(); - }); + })); it('should clear the dismiss timeout when dismissed before timeout expiration', fakeAsync(() => { let config = new MatSnackBarConfig(); @@ -73,7 +67,7 @@ describe('MatSnackBar Zone.js integration', () => { standalone: true, }) class DirectiveWithViewContainer { - constructor(public viewContainerRef: ViewContainerRef) {} + viewContainerRef = inject(ViewContainerRef); } @Component({ diff --git a/src/material/snack-bar/testing/snack-bar-harness.spec.ts b/src/material/snack-bar/testing/snack-bar-harness.spec.ts index 7f61a48733bf..869e0e8f719a 100644 --- a/src/material/snack-bar/testing/snack-bar-harness.spec.ts +++ b/src/material/snack-bar/testing/snack-bar-harness.spec.ts @@ -1,4 +1,4 @@ -import {Component, TemplateRef, ViewChild} from '@angular/core'; +import {Component, TemplateRef, ViewChild, inject} from '@angular/core'; import {ComponentFixture, TestBed} from '@angular/core/testing'; import {HarnessLoader} from '@angular/cdk/testing'; import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed'; @@ -175,11 +175,11 @@ describe('MatSnackBarHarness', () => { imports: [MatSnackBarLabel, MatSnackBarActions, MatSnackBarAction], }) class SnackbarHarnessTest { + snackBar = inject(MatSnackBar); + @ViewChild('custom') customTmpl: TemplateRef; @ViewChild('customWithAction') customWithActionTmpl: TemplateRef; - constructor(public snackBar: MatSnackBar) {} - openSimple(message: string, action = '', config?: MatSnackBarConfig) { return this.snackBar.open(message, action, config); } diff --git a/src/material/sort/sort-header.ts b/src/material/sort/sort-header.ts index 1406c9072704..d3c877b1851a 100644 --- a/src/material/sort/sort-header.ts +++ b/src/material/sort/sort-header.ts @@ -14,13 +14,12 @@ import { ChangeDetectorRef, Component, ElementRef, - Inject, Input, OnDestroy, OnInit, - Optional, ViewEncapsulation, booleanAttribute, + inject, } from '@angular/core'; import {merge, Subscription} from 'rxjs'; import { @@ -96,6 +95,16 @@ interface MatSortHeaderColumnDef { standalone: true, }) export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewInit { + _intl = inject(MatSortHeaderIntl); + private _changeDetectorRef = inject(ChangeDetectorRef); + _sort = inject(MatSort, {optional: true})!; + _columnDef = inject('MAT_SORT_HEADER_COLUMN_DEF' as any, { + optional: true, + }); + private _focusMonitor = inject(FocusMonitor); + private _elementRef = inject>(ElementRef); + private _ariaDescriber = inject(AriaDescriber, {optional: true}); + private _rerenderSubscription: Subscription; /** @@ -161,32 +170,18 @@ export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewI @Input({transform: booleanAttribute}) disableClear: boolean; - constructor( - /** - * @deprecated `_intl` parameter isn't being used anymore and it'll be removed. - * @breaking-change 13.0.0 - */ - public _intl: MatSortHeaderIntl, - private _changeDetectorRef: ChangeDetectorRef, - // `MatSort` is not optionally injected, but just asserted manually w/ better error. - // tslint:disable-next-line: lightweight-tokens - @Optional() public _sort: MatSort, - @Inject('MAT_SORT_HEADER_COLUMN_DEF') - @Optional() - public _columnDef: MatSortHeaderColumnDef, - private _focusMonitor: FocusMonitor, - private _elementRef: ElementRef, - /** @breaking-change 14.0.0 _ariaDescriber will be required. */ - @Optional() private _ariaDescriber?: AriaDescriber | null, - @Optional() - @Inject(MAT_SORT_DEFAULT_OPTIONS) - defaultOptions?: MatSortDefaultOptions, - ) { + constructor(...args: unknown[]); + + constructor() { + const defaultOptions = inject(MAT_SORT_DEFAULT_OPTIONS, { + optional: true, + }); + // Note that we use a string token for the `_columnDef`, because the value is provided both by // `material/table` and `cdk/table` and we can't have the CDK depending on Material, // and we want to avoid having the sort header depending on the CDK table because // of this single reference. - if (!_sort && (typeof ngDevMode === 'undefined' || ngDevMode)) { + if (!this._sort && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw getSortHeaderNotContainedWithinSortError(); } diff --git a/src/material/sort/sort.spec.ts b/src/material/sort/sort.spec.ts index 1bb9fc45f483..08bf17a48219 100644 --- a/src/material/sort/sort.spec.ts +++ b/src/material/sort/sort.spec.ts @@ -6,7 +6,7 @@ import { dispatchMouseEvent, wrappedErrorMessage, } from '@angular/cdk/testing/private'; -import {Component, ElementRef, ViewChild} from '@angular/core'; +import {Component, ElementRef, ViewChild, inject} from '@angular/core'; import {ComponentFixture, TestBed, fakeAsync, tick, waitForAsync} from '@angular/core/testing'; import {MatTableModule} from '@angular/material/table'; import {By} from '@angular/platform-browser'; @@ -677,8 +677,8 @@ type SimpleMatSortAppColumnIds = 'defaultA' | 'defaultB' | 'overrideStart' | 'ov imports: [MatSortModule, MatTableModule, CdkTableModule], }) class SimpleMatSortApp { + elementRef = inject>(ElementRef); latestSortEvent: Sort; - active: string; start: SortDirection = 'asc'; direction: SortDirection = ''; @@ -693,8 +693,6 @@ class SimpleMatSortApp { @ViewChild('overrideStart') overrideStart: MatSortHeader; @ViewChild('overrideDisableClear') overrideDisableClear: MatSortHeader; - constructor(public elementRef: ElementRef) {} - sort(id: SimpleMatSortAppColumnIds) { this.dispatchMouseEvent(id, 'click'); } @@ -853,16 +851,14 @@ class MatSortableInvalidDirection {} imports: [MatSortModule, MatTableModule, CdkTableModule], }) class MatSortWithoutExplicitInputs { + elementRef = inject>(ElementRef); latestSortEvent: Sort; - active: string; start: SortDirection = 'asc'; @ViewChild(MatSort) matSort: MatSort; @ViewChild('defaultA') defaultA: MatSortHeader; - constructor(public elementRef: ElementRef) {} - sort(id: SimpleMatSortAppColumnIds) { this.dispatchMouseEvent(id, 'click'); } diff --git a/src/material/sort/sort.ts b/src/material/sort/sort.ts index fdaf80111d0f..e5de04ef70f0 100644 --- a/src/material/sort/sort.ts +++ b/src/material/sort/sort.ts @@ -9,15 +9,14 @@ import { Directive, EventEmitter, - Inject, InjectionToken, Input, OnChanges, OnDestroy, OnInit, - Optional, Output, booleanAttribute, + inject, } from '@angular/core'; import {Observable, ReplaySubject, Subject} from 'rxjs'; import {SortDirection} from './sort-direction'; @@ -74,6 +73,10 @@ export const MAT_SORT_DEFAULT_OPTIONS = new InjectionToken(MAT_SORT_DEFAULT_OPTIONS, { + optional: true, + }); + private _initializedStream = new ReplaySubject(1); /** Collection of all registered sortables that this directive manages. */ @@ -126,11 +129,8 @@ export class MatSort implements OnChanges, OnDestroy, OnInit { /** Emits when the paginator is initialized. */ initialized: Observable = this._initializedStream; - constructor( - @Optional() - @Inject(MAT_SORT_DEFAULT_OPTIONS) - private _defaultOptions?: MatSortDefaultOptions, - ) {} + constructor(...args: unknown[]); + constructor() {} /** * Register function to be used by the contained MatSortables. Adds the MatSortable to the diff --git a/src/material/stepper/step-content.ts b/src/material/stepper/step-content.ts index d92238a3168b..322caa1e92c2 100644 --- a/src/material/stepper/step-content.ts +++ b/src/material/stepper/step-content.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, TemplateRef} from '@angular/core'; +import {Directive, TemplateRef, inject} from '@angular/core'; /** * Content for a `mat-step` that will be rendered lazily. @@ -16,5 +16,8 @@ import {Directive, TemplateRef} from '@angular/core'; standalone: true, }) export class MatStepContent { - constructor(public _template: TemplateRef) {} + _template = inject>(TemplateRef); + + constructor(...args: unknown[]); + constructor() {} } diff --git a/src/material/stepper/step-header.ts b/src/material/stepper/step-header.ts index 37535f17cc03..1cd3a91e1f41 100644 --- a/src/material/stepper/step-header.ts +++ b/src/material/stepper/step-header.ts @@ -11,12 +11,12 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, - ElementRef, Input, OnDestroy, ViewEncapsulation, TemplateRef, AfterViewInit, + inject, } from '@angular/core'; import {Subscription} from 'rxjs'; import {MatStepLabel} from './step-label'; @@ -42,6 +42,9 @@ import {NgTemplateOutlet} from '@angular/common'; imports: [MatRipple, NgTemplateOutlet, MatIcon], }) export class MatStepHeader extends CdkStepHeader implements AfterViewInit, OnDestroy { + _intl = inject(MatStepperIntl); + private _focusMonitor = inject(FocusMonitor); + private _intlSubscription: Subscription; /** State of the given step. */ @@ -80,14 +83,13 @@ export class MatStepHeader extends CdkStepHeader implements AfterViewInit, OnDes */ @Input() color: ThemePalette; - constructor( - public _intl: MatStepperIntl, - private _focusMonitor: FocusMonitor, - _elementRef: ElementRef, - changeDetectorRef: ChangeDetectorRef, - ) { - super(_elementRef); - this._intlSubscription = _intl.changes.subscribe(() => changeDetectorRef.markForCheck()); + constructor(...args: unknown[]); + + constructor() { + super(); + + const changeDetectorRef = inject(ChangeDetectorRef); + this._intlSubscription = this._intl.changes.subscribe(() => changeDetectorRef.markForCheck()); } ngAfterViewInit() { diff --git a/src/material/stepper/stepper-icon.ts b/src/material/stepper/stepper-icon.ts index 98c53b066b2a..cba0475a7b28 100644 --- a/src/material/stepper/stepper-icon.ts +++ b/src/material/stepper/stepper-icon.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, Input, TemplateRef} from '@angular/core'; +import {Directive, Input, TemplateRef, inject} from '@angular/core'; import {StepState} from '@angular/cdk/stepper'; /** Template context available to an attached `matStepperIcon`. */ @@ -27,8 +27,11 @@ export interface MatStepperIconContext { standalone: true, }) export class MatStepperIcon { + templateRef = inject>(TemplateRef); + /** Name of the icon to be overridden. */ @Input('matStepperIcon') name: StepState; - constructor(public templateRef: TemplateRef) {} + constructor(...args: unknown[]); + constructor() {} } diff --git a/src/material/stepper/stepper.ts b/src/material/stepper/stepper.ts index dc22c14afa7a..b97938bfbf31 100644 --- a/src/material/stepper/stepper.ts +++ b/src/material/stepper/stepper.ts @@ -6,33 +6,21 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directionality} from '@angular/cdk/bidi'; -import { - CdkStep, - CdkStepper, - StepContentPositionState, - STEPPER_GLOBAL_OPTIONS, - StepperOptions, -} from '@angular/cdk/stepper'; +import {CdkStep, CdkStepper, StepContentPositionState} from '@angular/cdk/stepper'; import {AnimationEvent} from '@angular/animations'; import { AfterContentInit, ChangeDetectionStrategy, - ChangeDetectorRef, Component, ContentChild, ContentChildren, ElementRef, EventEmitter, - forwardRef, inject, - Inject, Input, OnDestroy, - Optional, Output, QueryList, - SkipSelf, TemplateRef, ViewChildren, ViewContainerRef, @@ -73,6 +61,8 @@ import {Platform} from '@angular/cdk/platform'; }, }) export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentInit, OnDestroy { + private _errorStateMatcher = inject(ErrorStateMatcher, {skipSelf: true}); + private _viewContainerRef = inject(ViewContainerRef); private _isSelected = Subscription.EMPTY; /** Content for step label given by ``. */ @@ -94,15 +84,6 @@ export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentI /** Currently-attached portal containing the lazy content. */ _portal: TemplatePortal; - constructor( - @Inject(forwardRef(() => MatStepper)) stepper: MatStepper, - @SkipSelf() private _errorStateMatcher: ErrorStateMatcher, - private _viewContainerRef: ViewContainerRef, - @Optional() @Inject(STEPPER_GLOBAL_OPTIONS) stepperOptions?: StepperOptions, - ) { - super(stepper, stepperOptions); - } - ngAfterContentInit() { this._isSelected = this._stepper.steps.changes .pipe( @@ -228,12 +209,12 @@ export class MatStepper extends CdkStepper implements AfterContentInit { /** Whether the stepper is rendering on the server. */ protected _isServer: boolean = !inject(Platform).isBrowser; - constructor( - @Optional() dir: Directionality, - changeDetectorRef: ChangeDetectorRef, - elementRef: ElementRef, - ) { - super(dir, changeDetectorRef, elementRef); + constructor(...args: unknown[]); + + constructor() { + super(); + + const elementRef = inject>(ElementRef); const nodeName = elementRef.nativeElement.nodeName.toLowerCase(); this.orientation = nodeName === 'mat-vertical-stepper' ? 'vertical' : 'horizontal'; } diff --git a/src/material/tabs/paginated-tab-header.ts b/src/material/tabs/paginated-tab-header.ts index 7c6f2264b2f6..63f77bf004b6 100644 --- a/src/material/tabs/paginated-tab-header.ts +++ b/src/material/tabs/paginated-tab-header.ts @@ -21,12 +21,10 @@ import { Directive, ElementRef, EventEmitter, - Inject, Injector, Input, NgZone, OnDestroy, - Optional, Output, QueryList, afterNextRender, @@ -81,6 +79,14 @@ export type MatPaginatedTabHeaderItem = FocusableOption & {elementRef: ElementRe export abstract class MatPaginatedTabHeader implements AfterContentChecked, AfterContentInit, AfterViewInit, OnDestroy { + protected _elementRef = inject>(ElementRef); + protected _changeDetectorRef = inject(ChangeDetectorRef); + private _viewportRuler = inject(ViewportRuler); + private _dir = inject(Directionality, {optional: true}); + private _ngZone = inject(NgZone); + private _platform = inject(Platform); + _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + abstract _items: QueryList; abstract _inkBar: {hide: () => void; alignToElement: (element: HTMLElement) => void}; abstract _tabListContainer: ElementRef; @@ -161,22 +167,14 @@ export abstract class MatPaginatedTabHeader private _injector = inject(Injector); - constructor( - protected _elementRef: ElementRef, - protected _changeDetectorRef: ChangeDetectorRef, - private _viewportRuler: ViewportRuler, - @Optional() private _dir: Directionality, - private _ngZone: NgZone, - private _platform: Platform, - @Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string, - ) { + constructor(...args: unknown[]); + + constructor() { // Bind the `mouseleave` event on the outside since it doesn't change anything in the view. - _ngZone.runOutsideAngular(() => { - fromEvent(_elementRef.nativeElement, 'mouseleave') + this._ngZone.runOutsideAngular(() => { + fromEvent(this._elementRef.nativeElement, 'mouseleave') .pipe(takeUntil(this._destroyed)) - .subscribe(() => { - this._stopInterval(); - }); + .subscribe(() => this._stopInterval()); }); } diff --git a/src/material/tabs/tab-body.ts b/src/material/tabs/tab-body.ts index 2e285078106f..aa8305279cc1 100644 --- a/src/material/tabs/tab-body.ts +++ b/src/material/tabs/tab-body.ts @@ -19,16 +19,14 @@ import { Directive, ElementRef, EventEmitter, - forwardRef, - Inject, Input, OnDestroy, OnInit, - Optional, Output, ViewChild, ViewContainerRef, ViewEncapsulation, + inject, } from '@angular/core'; import {Subject, Subscription} from 'rxjs'; import {distinctUntilChanged, startWith} from 'rxjs/operators'; @@ -43,17 +41,20 @@ import {matTabsAnimations} from './tabs-animations'; standalone: true, }) export class MatTabBodyPortal extends CdkPortalOutlet implements OnInit, OnDestroy { + private _host = inject(MatTabBody); + /** Subscription to events for when the tab body begins centering. */ private _centeringSub = Subscription.EMPTY; /** Subscription to events for when the tab body finishes leaving from center position. */ private _leavingSub = Subscription.EMPTY; - constructor( - componentFactoryResolver: ComponentFactoryResolver, - viewContainerRef: ViewContainerRef, - @Inject(forwardRef(() => MatTabBody)) private _host: MatTabBody, - @Inject(DOCUMENT) _document: any, - ) { + constructor(...args: unknown[]); + + constructor() { + const componentFactoryResolver = inject(ComponentFactoryResolver); + const viewContainerRef = inject(ViewContainerRef); + const _document = inject(DOCUMENT); + super(componentFactoryResolver, viewContainerRef, _document); } @@ -120,6 +121,9 @@ export type MatTabBodyPositionState = imports: [MatTabBodyPortal, CdkScrollable], }) export class MatTabBody implements OnInit, OnDestroy { + private _elementRef = inject>(ElementRef); + private _dir = inject(Directionality, {optional: true}); + /** Current position of the tab-body in the tab-group. Zero means that the tab is visible. */ private _positionIndex: number; @@ -168,13 +172,12 @@ export class MatTabBody implements OnInit, OnDestroy { this._computePositionAnimationState(); } - constructor( - private _elementRef: ElementRef, - @Optional() private _dir: Directionality, - changeDetectorRef: ChangeDetectorRef, - ) { - if (_dir) { - this._dirChangeSubscription = _dir.change.subscribe((dir: Direction) => { + constructor(...args: unknown[]); + + constructor() { + if (this._dir) { + const changeDetectorRef = inject(ChangeDetectorRef); + this._dirChangeSubscription = this._dir.change.subscribe((dir: Direction) => { this._computePositionAnimationState(dir); changeDetectorRef.markForCheck(); }); diff --git a/src/material/tabs/tab-content.ts b/src/material/tabs/tab-content.ts index 71a0ab867080..27ac762ae746 100644 --- a/src/material/tabs/tab-content.ts +++ b/src/material/tabs/tab-content.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, InjectionToken, TemplateRef} from '@angular/core'; +import {Directive, InjectionToken, TemplateRef, inject} from '@angular/core'; /** * Injection token that can be used to reference instances of `MatTabContent`. It serves as @@ -22,5 +22,8 @@ export const MAT_TAB_CONTENT = new InjectionToken('MatTabContent' standalone: true, }) export class MatTabContent { - constructor(/** Content for the tab. */ public template: TemplateRef) {} + template = inject>(TemplateRef); + + constructor(...args: unknown[]); + constructor() {} } diff --git a/src/material/tabs/tab-group.ts b/src/material/tabs/tab-group.ts index 84c7695ca30d..63ec9a22c8f7 100644 --- a/src/material/tabs/tab-group.ts +++ b/src/material/tabs/tab-group.ts @@ -15,10 +15,8 @@ import { ContentChildren, ElementRef, EventEmitter, - Inject, Input, OnDestroy, - Optional, Output, QueryList, ViewChild, @@ -94,6 +92,10 @@ const ENABLE_BACKGROUND_INPUT = true; ], }) export class MatTabGroup implements AfterContentInit, AfterContentChecked, OnDestroy { + readonly _elementRef = inject(ElementRef); + private _changeDetectorRef = inject(ChangeDetectorRef); + _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + /** * All tabs inside the tab group. This includes tabs that belong to groups that are nested * inside the current one. We filter out only the tabs that belong to this group in `_tabs`. @@ -267,12 +269,11 @@ export class MatTabGroup implements AfterContentInit, AfterContentChecked, OnDes /** Whether the tab group is rendered on the server. */ protected _isServer: boolean = !inject(Platform).isBrowser; - constructor( - readonly _elementRef: ElementRef, - private _changeDetectorRef: ChangeDetectorRef, - @Inject(MAT_TABS_CONFIG) @Optional() defaultConfig?: MatTabsConfig, - @Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string, - ) { + constructor(...args: unknown[]); + + constructor() { + const defaultConfig = inject(MAT_TABS_CONFIG, {optional: true}); + this._groupId = nextId++; this.animationDuration = defaultConfig && defaultConfig.animationDuration ? defaultConfig.animationDuration : '500ms'; diff --git a/src/material/tabs/tab-header.ts b/src/material/tabs/tab-header.ts index d262948ac661..8650f21597aa 100644 --- a/src/material/tabs/tab-header.ts +++ b/src/material/tabs/tab-header.ts @@ -11,24 +11,16 @@ import { AfterContentInit, AfterViewInit, ChangeDetectionStrategy, - ChangeDetectorRef, Component, ContentChildren, ElementRef, - Inject, Input, - NgZone, OnDestroy, - Optional, QueryList, ViewChild, ViewEncapsulation, booleanAttribute, - ANIMATION_MODULE_TYPE, } from '@angular/core'; -import {ViewportRuler} from '@angular/cdk/scrolling'; -import {Platform} from '@angular/cdk/platform'; -import {Directionality} from '@angular/cdk/bidi'; import {MatTabLabelWrapper} from './tab-label-wrapper'; import {MatInkBar} from './ink-bar'; import {MatPaginatedTabHeader} from './paginated-tab-header'; @@ -79,18 +71,6 @@ export class MatTabHeader @Input({transform: booleanAttribute}) disableRipple: boolean = false; - constructor( - elementRef: ElementRef, - changeDetectorRef: ChangeDetectorRef, - viewportRuler: ViewportRuler, - @Optional() dir: Directionality, - ngZone: NgZone, - platform: Platform, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { - super(elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform, animationMode); - } - override ngAfterContentInit() { this._inkBar = new MatInkBar(this._items); super.ngAfterContentInit(); diff --git a/src/material/tabs/tab-label-wrapper.ts b/src/material/tabs/tab-label-wrapper.ts index 4a5bb7625f53..ba1474a7c1f3 100644 --- a/src/material/tabs/tab-label-wrapper.ts +++ b/src/material/tabs/tab-label-wrapper.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, ElementRef, Input, booleanAttribute} from '@angular/core'; +import {Directive, ElementRef, Input, booleanAttribute, inject} from '@angular/core'; import {InkBarItem} from './ink-bar'; /** @@ -22,14 +22,12 @@ import {InkBarItem} from './ink-bar'; standalone: true, }) export class MatTabLabelWrapper extends InkBarItem { + elementRef = inject(ElementRef); + /** Whether the tab is disabled. */ @Input({transform: booleanAttribute}) disabled: boolean = false; - constructor(public elementRef: ElementRef) { - super(); - } - /** Sets focus on the wrapper element */ focus(): void { this.elementRef.nativeElement.focus(); diff --git a/src/material/tabs/tab-label.ts b/src/material/tabs/tab-label.ts index a5e457ef157a..da6861eb6a49 100644 --- a/src/material/tabs/tab-label.ts +++ b/src/material/tabs/tab-label.ts @@ -6,14 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import { - Directive, - Inject, - InjectionToken, - Optional, - TemplateRef, - ViewContainerRef, -} from '@angular/core'; +import {Directive, InjectionToken, inject} from '@angular/core'; import {CdkPortal} from '@angular/cdk/portal'; /** @@ -36,11 +29,5 @@ export const MAT_TAB = new InjectionToken('MAT_TAB'); standalone: true, }) export class MatTabLabel extends CdkPortal { - constructor( - templateRef: TemplateRef, - viewContainerRef: ViewContainerRef, - @Inject(MAT_TAB) @Optional() public _closestTab: any, - ) { - super(templateRef, viewContainerRef); - } + _closestTab = inject(MAT_TAB, {optional: true}); } diff --git a/src/material/tabs/tab-nav-bar/tab-nav-bar.ts b/src/material/tabs/tab-nav-bar/tab-nav-bar.ts index 23013019b3f6..eb994bdd3b6f 100644 --- a/src/material/tabs/tab-nav-bar/tab-nav-bar.ts +++ b/src/material/tabs/tab-nav-bar/tab-nav-bar.ts @@ -9,7 +9,6 @@ import { AfterContentChecked, AfterContentInit, AfterViewInit, - Attribute, booleanAttribute, ChangeDetectionStrategy, ChangeDetectorRef, @@ -17,16 +16,16 @@ import { ContentChildren, ElementRef, forwardRef, - Inject, Input, NgZone, numberAttribute, OnDestroy, - Optional, QueryList, ViewChild, ViewEncapsulation, ANIMATION_MODULE_TYPE, + inject, + HostAttributeToken, } from '@angular/core'; import { MAT_RIPPLE_GLOBAL_OPTIONS, @@ -164,16 +163,18 @@ export class MatTabNav @ViewChild('previousPaginator') _previousPaginator: ElementRef; _inkBar: MatInkBar; - constructor( - elementRef: ElementRef, - @Optional() dir: Directionality, - ngZone: NgZone, - changeDetectorRef: ChangeDetectorRef, - viewportRuler: ViewportRuler, - platform: Platform, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - @Optional() @Inject(MAT_TABS_CONFIG) defaultConfig?: MatTabsConfig, - ) { + constructor(...args: unknown[]); + + constructor() { + const elementRef = inject(ElementRef); + const dir = inject(Directionality, {optional: true}); + const ngZone = inject(NgZone); + const changeDetectorRef = inject(ChangeDetectorRef); + const viewportRuler = inject(ViewportRuler); + const platform = inject(Platform); + const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + const defaultConfig = inject(MAT_TABS_CONFIG, {optional: true}); + super(elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform, animationMode); this.disablePagination = defaultConfig && defaultConfig.disablePagination != null @@ -271,6 +272,10 @@ export class MatTabLink extends InkBarItem implements AfterViewInit, OnDestroy, RippleTarget, FocusableOption { + private _tabNavBar = inject(MatTabNav); + elementRef = inject(ElementRef); + private _focusMonitor = inject(FocusMonitor); + private readonly _destroyed = new Subject(); /** Whether the tab link is active or not. */ @@ -326,24 +331,25 @@ export class MatTabLink /** Unique id for the tab. */ @Input() id = `mat-tab-link-${nextUniqueId++}`; - constructor( - private _tabNavBar: MatTabNav, - /** @docs-private */ public elementRef: ElementRef, - @Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalRippleOptions: RippleGlobalOptions | null, - @Attribute('tabindex') tabIndex: string, - private _focusMonitor: FocusMonitor, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { + constructor(...args: unknown[]); + + constructor() { super(); + const globalRippleOptions = inject(MAT_RIPPLE_GLOBAL_OPTIONS, { + optional: true, + }); + const tabIndex = inject(new HostAttributeToken('tabindex'), {optional: true}); + const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); + this.rippleConfig = globalRippleOptions || {}; - this.tabIndex = parseInt(tabIndex) || 0; + this.tabIndex = tabIndex == null ? 0 : parseInt(tabIndex) || 0; if (animationMode === 'NoopAnimations') { this.rippleConfig.animation = {enterDuration: 0, exitDuration: 0}; } - _tabNavBar._fitInkBarToContent + this._tabNavBar._fitInkBarToContent .pipe(takeUntil(this._destroyed)) .subscribe(fitInkBarToContent => { this.fitInkBarToContent = fitInkBarToContent; diff --git a/src/material/tabs/tab.ts b/src/material/tabs/tab.ts index 2419cf8f5e83..ba1e08638a1c 100644 --- a/src/material/tabs/tab.ts +++ b/src/material/tabs/tab.ts @@ -10,19 +10,18 @@ import { ChangeDetectionStrategy, Component, ContentChild, - Inject, InjectionToken, Input, OnChanges, OnDestroy, OnInit, - Optional, SimpleChanges, TemplateRef, ViewChild, ViewContainerRef, ViewEncapsulation, booleanAttribute, + inject, } from '@angular/core'; import {MatTabContent} from './tab-content'; import {MAT_TAB, MatTabLabel} from './tab-label'; @@ -54,6 +53,9 @@ export const MAT_TAB_GROUP = new InjectionToken('MAT_TAB_GROUP'); }, }) export class MatTab implements OnInit, OnChanges, OnDestroy { + private _viewContainerRef = inject(ViewContainerRef); + _closestTabGroup = inject(MAT_TAB_GROUP, {optional: true}); + /** whether the tab is disabled. */ @Input({transform: booleanAttribute}) disabled: boolean = false; @@ -124,10 +126,8 @@ export class MatTab implements OnInit, OnChanges, OnDestroy { */ isActive = false; - constructor( - private _viewContainerRef: ViewContainerRef, - @Inject(MAT_TAB_GROUP) @Optional() public _closestTabGroup: any, - ) {} + constructor(...args: unknown[]); + constructor() {} ngOnChanges(changes: SimpleChanges): void { if (changes.hasOwnProperty('textLabel') || changes.hasOwnProperty('disabled')) { diff --git a/src/material/toolbar/toolbar.ts b/src/material/toolbar/toolbar.ts index 4eedd4bc7c55..811c4eeafcd3 100644 --- a/src/material/toolbar/toolbar.ts +++ b/src/material/toolbar/toolbar.ts @@ -15,10 +15,10 @@ import { ContentChildren, Directive, ElementRef, - Inject, Input, QueryList, ViewEncapsulation, + inject, } from '@angular/core'; @Directive({ @@ -45,6 +45,10 @@ export class MatToolbarRow {} standalone: true, }) export class MatToolbar implements AfterViewInit { + protected _elementRef = inject(ElementRef); + private _platform = inject(Platform); + private _document = inject(DOCUMENT); + // TODO: should be typed as `ThemePalette` but internal apps pass in arbitrary strings. /** * Theme color of the toolbar. This API is supported in M2 themes only, it has @@ -55,19 +59,11 @@ export class MatToolbar implements AfterViewInit { */ @Input() color?: string | null; - private _document: Document; - /** Reference to all toolbar row elements that have been projected. */ @ContentChildren(MatToolbarRow, {descendants: true}) _toolbarRows: QueryList; - constructor( - protected _elementRef: ElementRef, - private _platform: Platform, - @Inject(DOCUMENT) document?: any, - ) { - // TODO: make the document a required param when doing breaking changes. - this._document = document; - } + constructor(...args: unknown[]); + constructor() {} ngAfterViewInit() { if (this._platform.isBrowser) { diff --git a/src/material/tooltip/tooltip.ts b/src/material/tooltip/tooltip.ts index 47ec824f100d..0b25b74fb785 100644 --- a/src/material/tooltip/tooltip.ts +++ b/src/material/tooltip/tooltip.ts @@ -20,12 +20,10 @@ import { Component, Directive, ElementRef, - Inject, InjectionToken, Input, NgZone, OnDestroy, - Optional, ViewChild, ViewContainerRef, ViewEncapsulation, @@ -190,6 +188,20 @@ const MAX_WIDTH = 200; standalone: true, }) export class MatTooltip implements OnDestroy, AfterViewInit { + private _overlay = inject(Overlay); + private _elementRef = inject>(ElementRef); + private _scrollDispatcher = inject(ScrollDispatcher); + private _viewContainerRef = inject(ViewContainerRef); + private _ngZone = inject(NgZone); + private _platform = inject(Platform); + private _ariaDescriber = inject(AriaDescriber); + private _focusMonitor = inject(FocusMonitor); + protected _dir = inject(Directionality); + private _injector = inject(Injector); + private _defaultOptions = inject(MAT_TOOLTIP_DEFAULT_OPTIONS, { + optional: true, + }); + _overlayRef: OverlayRef | null; _tooltipInstance: TooltipComponent | null; @@ -198,7 +210,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit { private _positionAtOrigin: boolean = false; private _disabled: boolean = false; private _tooltipClass: string | string[] | Set | {[key: string]: any}; - private _scrollStrategy: () => ScrollStrategy; + private _scrollStrategy = inject(MAT_TOOLTIP_SCROLL_STRATEGY); private _viewInitialized = false; private _pointerExitEventsInitialized = false; private readonly _tooltipComponent = TooltipComponent; @@ -351,7 +363,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit { []; /** Reference to the current document. */ - private _document: Document; + private _document = inject(DOCUMENT); /** Timer started at the last `touchstart` event. */ private _touchstartTimeout: null | ReturnType = null; @@ -359,49 +371,33 @@ export class MatTooltip implements OnDestroy, AfterViewInit { /** Emits when the component is destroyed. */ private readonly _destroyed = new Subject(); - private _injector = inject(Injector); + constructor(...args: unknown[]); + + constructor() { + const defaultOptions = this._defaultOptions; - constructor( - private _overlay: Overlay, - private _elementRef: ElementRef, - private _scrollDispatcher: ScrollDispatcher, - private _viewContainerRef: ViewContainerRef, - private _ngZone: NgZone, - private _platform: Platform, - private _ariaDescriber: AriaDescriber, - private _focusMonitor: FocusMonitor, - @Inject(MAT_TOOLTIP_SCROLL_STRATEGY) scrollStrategy: any, - protected _dir: Directionality, - @Optional() - @Inject(MAT_TOOLTIP_DEFAULT_OPTIONS) - private _defaultOptions: MatTooltipDefaultOptions, - @Inject(DOCUMENT) _document: any, - ) { - this._scrollStrategy = scrollStrategy; - this._document = _document; - - if (_defaultOptions) { - this._showDelay = _defaultOptions.showDelay; - this._hideDelay = _defaultOptions.hideDelay; - - if (_defaultOptions.position) { - this.position = _defaultOptions.position; + if (defaultOptions) { + this._showDelay = defaultOptions.showDelay; + this._hideDelay = defaultOptions.hideDelay; + + if (defaultOptions.position) { + this.position = defaultOptions.position; } - if (_defaultOptions.positionAtOrigin) { - this.positionAtOrigin = _defaultOptions.positionAtOrigin; + if (defaultOptions.positionAtOrigin) { + this.positionAtOrigin = defaultOptions.positionAtOrigin; } - if (_defaultOptions.touchGestures) { - this.touchGestures = _defaultOptions.touchGestures; + if (defaultOptions.touchGestures) { + this.touchGestures = defaultOptions.touchGestures; } - if (_defaultOptions.tooltipClass) { - this.tooltipClass = _defaultOptions.tooltipClass; + if (defaultOptions.tooltipClass) { + this.tooltipClass = defaultOptions.tooltipClass; } } - _dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => { + this._dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => { if (this._overlayRef) { this._updatePosition(this._overlayRef); } @@ -813,7 +809,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit { this._touchstartTimeout = setTimeout(() => { this._touchstartTimeout = null; this.show(undefined, origin); - }, this._defaultOptions.touchLongPressShowDelay ?? DEFAULT_LONGPRESS_DELAY); + }, this._defaultOptions?.touchLongPressShowDelay ?? DEFAULT_LONGPRESS_DELAY); }, ]); } @@ -847,7 +843,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit { if (this._touchstartTimeout) { clearTimeout(this._touchstartTimeout); } - this.hide(this._defaultOptions.touchendHideDelay); + this.hide(this._defaultOptions?.touchendHideDelay); }; exitListeners.push(['touchend', touchendListener], ['touchcancel', touchendListener]); @@ -955,6 +951,9 @@ export class MatTooltip implements OnDestroy, AfterViewInit { imports: [NgClass], }) export class TooltipComponent implements OnDestroy { + private _changeDetectorRef = inject(ChangeDetectorRef); + protected _elementRef = inject>(ElementRef); + /* Whether the tooltip text overflows to multiple lines */ _isMultiline = false; @@ -1002,11 +1001,10 @@ export class TooltipComponent implements OnDestroy { /** Name of the hide animation and the class that toggles it. */ private readonly _hideAnimation = 'mat-mdc-tooltip-hide'; - constructor( - private _changeDetectorRef: ChangeDetectorRef, - protected _elementRef: ElementRef, - @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - ) { + constructor(...args: unknown[]); + + constructor() { + const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true}); this._animationsDisabled = animationMode === 'NoopAnimations'; } diff --git a/src/material/tree/node.ts b/src/material/tree/node.ts index b9ebf968c0e2..f4d79466f007 100644 --- a/src/material/tree/node.ts +++ b/src/material/tree/node.ts @@ -9,21 +9,19 @@ import { CDK_TREE_NODE_OUTLET_NODE, CdkNestedTreeNode, - CdkTree, CdkTreeNode, CdkTreeNodeDef, } from '@angular/cdk/tree'; import { AfterContentInit, - Attribute, Directive, - ElementRef, Input, - IterableDiffers, OnDestroy, OnInit, booleanAttribute, numberAttribute, + inject, + HostAttributeToken, } from '@angular/core'; import {NoopTreeKeyManager, TreeKeyManagerItem, TreeKeyManagerStrategy} from '@angular/cdk/a11y'; @@ -108,21 +106,12 @@ export class MatTreeNode extends CdkTreeNode implements OnInit, this.isDisabled = value; } - constructor( - elementRef: ElementRef, - tree: CdkTree, - /** - * The tabindex of the tree node. - * - * @deprecated By default MatTreeNode manages focus using TreeKeyManager instead of tabIndex. - * Recommend to avoid setting tabIndex directly to prevent TreeKeyManager form getting into - * an unexpected state. Tabindex to be removed in a future version. - * @breaking-change 21.0.0 Remove this attribute. - */ - @Attribute('tabindex') tabIndex: string, - ) { - super(elementRef, tree); + constructor(...args: unknown[]); + constructor() { + super(); + + const tabIndex = inject(new HostAttributeToken('tabindex'), {optional: true}); this.tabIndexInputBinding = Number(tabIndex) || this.defaultTabIndex; } @@ -201,18 +190,6 @@ export class MatNestedTreeNode } private _tabIndex: number; - constructor( - elementRef: ElementRef, - tree: CdkTree, - differs: IterableDiffers, - // Ignore tabindex attribute. MatTree manages its own active state using TreeKeyManager. - // Keeping tabIndex in constructor for backwards compatibility with trees created before - // introducing TreeKeyManager. - @Attribute('tabindex') tabIndex: string, - ) { - super(elementRef, tree, differs); - } - // This is a workaround for https://github.com/angular/angular/issues/19145 // In aot mode, the lifecycle hooks from parent class are not called. // TODO(tinayuangao): Remove when the angular issue #19145 is fixed diff --git a/src/material/tree/outlet.ts b/src/material/tree/outlet.ts index d69f1ba26fc5..54710a9bc780 100644 --- a/src/material/tree/outlet.ts +++ b/src/material/tree/outlet.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ import {CDK_TREE_NODE_OUTLET_NODE, CdkTreeNodeOutlet} from '@angular/cdk/tree'; -import {Directive, Inject, Optional, ViewContainerRef} from '@angular/core'; +import {Directive, ViewContainerRef, inject} from '@angular/core'; /** * Outlet for nested CdkNode. Put `[matTreeNodeOutlet]` on a tag to place children dataNodes @@ -23,8 +23,6 @@ import {Directive, Inject, Optional, ViewContainerRef} from '@angular/core'; standalone: true, }) export class MatTreeNodeOutlet implements CdkTreeNodeOutlet { - constructor( - public viewContainer: ViewContainerRef, - @Inject(CDK_TREE_NODE_OUTLET_NODE) @Optional() public _node?: any, - ) {} + viewContainer = inject(ViewContainerRef); + _node = inject(CDK_TREE_NODE_OUTLET_NODE, {optional: true}); } diff --git a/tools/public_api_guard/material/autocomplete.md b/tools/public_api_guard/material/autocomplete.md index 3f134f3b7562..4949ce629f4c 100644 --- a/tools/public_api_guard/material/autocomplete.md +++ b/tools/public_api_guard/material/autocomplete.md @@ -8,9 +8,7 @@ import { ActiveDescendantKeyManager } from '@angular/cdk/a11y'; import { AfterContentInit } from '@angular/core'; import { AfterViewInit } from '@angular/core'; import { AnimationEvent as AnimationEvent_2 } from '@angular/animations'; -import { ChangeDetectorRef } from '@angular/core'; import { ControlValueAccessor } from '@angular/forms'; -import { Directionality } from '@angular/cdk/bidi'; import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; import * as i0 from '@angular/core'; @@ -19,23 +17,18 @@ import * as i2 from '@angular/material/core'; import * as i3 from '@angular/common'; import * as i7 from '@angular/cdk/scrolling'; import { InjectionToken } from '@angular/core'; -import { MatFormField } from '@angular/material/form-field'; import { MatOptgroup } from '@angular/material/core'; import { MatOption } from '@angular/material/core'; import { MatOptionSelectionChange } from '@angular/material/core'; -import { NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { Overlay } from '@angular/cdk/overlay'; -import { Platform } from '@angular/cdk/platform'; import { QueryList } from '@angular/core'; import { ScrollStrategy } from '@angular/cdk/overlay'; import { SimpleChanges } from '@angular/core'; import { TemplateRef } from '@angular/core'; import { ThemePalette } from '@angular/material/core'; -import { ViewContainerRef } from '@angular/core'; -import { ViewportRuler } from '@angular/cdk/scrolling'; // @public export function getMatAutocompleteMissingPanelError(): Error; @@ -64,7 +57,7 @@ export const MAT_AUTOCOMPLETE_VALUE_ACCESSOR: any; // @public export class MatAutocomplete implements AfterContentInit, OnDestroy { - constructor(_changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef, _defaults: MatAutocompleteDefaultOptions, platform?: Platform); + constructor(...args: unknown[]); _animationDone: EventEmitter; ariaLabel: string; ariaLabelledby: string; @@ -154,8 +147,8 @@ export class MatAutocompleteModule { // @public export class MatAutocompleteOrigin { - constructor( - elementRef: ElementRef); + constructor(...args: unknown[]); + // (undocumented) elementRef: ElementRef; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; @@ -174,7 +167,7 @@ export class MatAutocompleteSelectedEvent { // @public export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy { - constructor(_element: ElementRef, _overlay: Overlay, _viewContainerRef: ViewContainerRef, _zone: NgZone, _changeDetectorRef: ChangeDetectorRef, scrollStrategy: any, _dir: Directionality | null, _formField: MatFormField | null, _document: any, _viewportRuler: ViewportRuler, _defaults?: (MatAutocompleteDefaultOptions | null) | undefined); + constructor(...args: unknown[]); get activeOption(): MatOption | null; autocomplete: MatAutocomplete; autocompleteAttribute: string; @@ -216,7 +209,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewIn // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } export { MatOptgroup } diff --git a/tools/public_api_guard/material/badge.md b/tools/public_api_guard/material/badge.md index 0d606e736d11..85c9f45e0869 100644 --- a/tools/public_api_guard/material/badge.md +++ b/tools/public_api_guard/material/badge.md @@ -4,20 +4,16 @@ ```ts -import { AriaDescriber } from '@angular/cdk/a11y'; -import { ElementRef } from '@angular/core'; import * as i0 from '@angular/core'; import * as i1 from '@angular/cdk/a11y'; import * as i2 from '@angular/material/core'; -import { NgZone } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; -import { Renderer2 } from '@angular/core'; import { ThemePalette } from '@angular/material/core'; // @public export class MatBadge implements OnInit, OnDestroy { - constructor(_ngZone: NgZone, _elementRef: ElementRef, _ariaDescriber: AriaDescriber, _renderer: Renderer2, _animationMode?: string | undefined); + constructor(...args: unknown[]); get color(): ThemePalette; set color(value: ThemePalette); get content(): string | number | undefined | null; @@ -46,7 +42,7 @@ export class MatBadge implements OnInit, OnDestroy { // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) diff --git a/tools/public_api_guard/material/bottom-sheet.md b/tools/public_api_guard/material/bottom-sheet.md index e8eae6db0ae2..586bbde9a9c7 100644 --- a/tools/public_api_guard/material/bottom-sheet.md +++ b/tools/public_api_guard/material/bottom-sheet.md @@ -6,29 +6,19 @@ import { AnimationEvent as AnimationEvent_2 } from '@angular/animations'; import { AnimationTriggerMetadata } from '@angular/animations'; -import { BreakpointObserver } from '@angular/cdk/layout'; import { CdkDialogContainer } from '@angular/cdk/dialog'; import { ComponentRef } from '@angular/core'; import { ComponentType } from '@angular/cdk/portal'; -import { DialogConfig } from '@angular/cdk/dialog'; import { DialogRef } from '@angular/cdk/dialog'; import { Direction } from '@angular/cdk/bidi'; -import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; -import { FocusMonitor } from '@angular/cdk/a11y'; -import { FocusTrapFactory } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i1 from '@angular/cdk/dialog'; import * as i2 from '@angular/material/core'; import * as i3 from '@angular/cdk/portal'; import { InjectionToken } from '@angular/core'; -import { Injector } from '@angular/core'; -import { InteractivityChecker } from '@angular/cdk/a11y'; -import { NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { OnDestroy } from '@angular/core'; -import { Overlay } from '@angular/cdk/overlay'; -import { OverlayRef } from '@angular/cdk/overlay'; import { ScrollStrategy } from '@angular/cdk/overlay'; import { TemplateRef } from '@angular/core'; import { ViewContainerRef } from '@angular/core'; @@ -44,7 +34,7 @@ export const MAT_BOTTOM_SHEET_DEFAULT_OPTIONS: InjectionToken(result?: R): void; // (undocumented) ngOnDestroy(): void; @@ -53,7 +43,7 @@ export class MatBottomSheet implements OnDestroy { get _openedBottomSheetRef(): MatBottomSheetRef | null; set _openedBottomSheetRef(value: MatBottomSheetRef | null); // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; // (undocumented) static ɵprov: i0.ɵɵInjectableDeclaration; } @@ -82,7 +72,7 @@ export class MatBottomSheetConfig { // @public export class MatBottomSheetContainer extends CdkDialogContainer implements OnDestroy { - constructor(elementRef: ElementRef, focusTrapFactory: FocusTrapFactory, document: any, config: DialogConfig, checker: InteractivityChecker, ngZone: NgZone, overlayRef: OverlayRef, breakpointObserver: BreakpointObserver, focusMonitor?: FocusMonitor); + constructor(...args: unknown[]); _animationState: 'void' | 'visible' | 'hidden'; _animationStateChanged: EventEmitter; // (undocumented) @@ -98,7 +88,7 @@ export class MatBottomSheetContainer extends CdkDialogContainer implements OnDes // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) diff --git a/tools/public_api_guard/material/button-toggle.md b/tools/public_api_guard/material/button-toggle.md index 90c7615e5090..65c4ca8ee072 100644 --- a/tools/public_api_guard/material/button-toggle.md +++ b/tools/public_api_guard/material/button-toggle.md @@ -6,13 +6,10 @@ import { AfterContentInit } from '@angular/core'; import { AfterViewInit } from '@angular/core'; -import { ChangeDetectorRef } from '@angular/core'; import { ControlValueAccessor } from '@angular/forms'; import { Direction } from '@angular/cdk/bidi'; -import { Directionality } from '@angular/cdk/bidi'; import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; -import { FocusMonitor } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; import { InjectionToken } from '@angular/core'; @@ -34,7 +31,7 @@ export const MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR: any; // @public export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy { - constructor(toggleGroup: MatButtonToggleGroup, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef, _focusMonitor: FocusMonitor, defaultTabIndex: string, defaultOptions?: MatButtonToggleDefaultOptions); + constructor(...args: unknown[]); get appearance(): MatButtonToggleAppearance; set appearance(value: MatButtonToggleAppearance); ariaLabel: string; @@ -77,7 +74,7 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -102,7 +99,7 @@ export interface MatButtonToggleDefaultOptions { // @public export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, AfterContentInit { - constructor(_changeDetector: ChangeDetectorRef, defaultOptions?: MatButtonToggleDefaultOptions, _dir?: Directionality | undefined); + constructor(...args: unknown[]); appearance: MatButtonToggleAppearance; _buttonToggles: QueryList; readonly change: EventEmitter; @@ -157,7 +154,7 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) diff --git a/tools/public_api_guard/material/button.md b/tools/public_api_guard/material/button.md index 34449374d5a9..3c9326f8311c 100644 --- a/tools/public_api_guard/material/button.md +++ b/tools/public_api_guard/material/button.md @@ -28,20 +28,18 @@ export function MAT_FAB_DEFAULT_OPTIONS_FACTORY(): MatFabDefaultOptions; // @public export class MatAnchor extends MatAnchorBase { - constructor(elementRef: ElementRef, platform: Platform, ngZone: NgZone, animationMode?: string); // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatButton extends MatButtonBase { - constructor(elementRef: ElementRef, platform: Platform, ngZone: NgZone, animationMode?: string); // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -62,7 +60,7 @@ export class MatButtonModule { // @public export class MatFabAnchor extends MatAnchor { - constructor(elementRef: ElementRef, platform: Platform, ngZone: NgZone, animationMode?: string, _options?: MatFabDefaultOptions | undefined); + constructor(...args: unknown[]); // (undocumented) extended: boolean; // (undocumented) @@ -72,12 +70,12 @@ export class MatFabAnchor extends MatAnchor { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatFabButton extends MatButtonBase { - constructor(elementRef: ElementRef, platform: Platform, ngZone: NgZone, animationMode?: string, _options?: MatFabDefaultOptions | undefined); + constructor(...args: unknown[]); // (undocumented) extended: boolean; // (undocumented) @@ -87,7 +85,7 @@ export class MatFabButton extends MatButtonBase { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -97,42 +95,41 @@ export interface MatFabDefaultOptions { // @public export class MatIconAnchor extends MatAnchorBase { - constructor(elementRef: ElementRef, platform: Platform, ngZone: NgZone, animationMode?: string); // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatIconButton extends MatButtonBase { - constructor(elementRef: ElementRef, platform: Platform, ngZone: NgZone, animationMode?: string); + constructor(...args: unknown[]); // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatMiniFabAnchor extends MatAnchor { - constructor(elementRef: ElementRef, platform: Platform, ngZone: NgZone, animationMode?: string, _options?: MatFabDefaultOptions | undefined); + constructor(...args: unknown[]); // (undocumented) _isFab: boolean; // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatMiniFabButton extends MatButtonBase { - constructor(elementRef: ElementRef, platform: Platform, ngZone: NgZone, animationMode?: string, _options?: MatFabDefaultOptions | undefined); + constructor(...args: unknown[]); // (undocumented) _isFab: boolean; // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // (No @packageDocumentation comment for this package) diff --git a/tools/public_api_guard/material/card.md b/tools/public_api_guard/material/card.md index 7015d29fa8ed..576c88722df2 100644 --- a/tools/public_api_guard/material/card.md +++ b/tools/public_api_guard/material/card.md @@ -14,13 +14,13 @@ export const MAT_CARD_CONFIG: InjectionToken; // @public export class MatCard { - constructor(config?: MatCardConfig); + constructor(...args: unknown[]); // (undocumented) appearance: MatCardAppearance; // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/checkbox.md b/tools/public_api_guard/material/checkbox.md index e1b0acd3cf25..e717cbd4fea5 100644 --- a/tools/public_api_guard/material/checkbox.md +++ b/tools/public_api_guard/material/checkbox.md @@ -6,7 +6,6 @@ import { AbstractControl } from '@angular/forms'; import { AfterViewInit } from '@angular/core'; -import { ChangeDetectorRef } from '@angular/core'; import { CheckboxRequiredValidator } from '@angular/forms'; import { ControlValueAccessor } from '@angular/forms'; import { ElementRef } from '@angular/core'; @@ -15,7 +14,6 @@ import { FocusableOption } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i3 from '@angular/material/core'; import { InjectionToken } from '@angular/core'; -import { NgZone } from '@angular/core'; import { OnChanges } from '@angular/core'; import { Provider } from '@angular/core'; import { SimpleChanges } from '@angular/core'; @@ -37,7 +35,7 @@ export const MAT_CHECKBOX_REQUIRED_VALIDATOR: Provider; // @public (undocumented) export class MatCheckbox implements AfterViewInit, OnChanges, ControlValueAccessor, Validator, FocusableOption { - constructor(_elementRef: ElementRef, _changeDetectorRef: ChangeDetectorRef, _ngZone: NgZone, tabIndex: string, _animationMode?: string | undefined, _options?: MatCheckboxDefaultOptions | undefined); + constructor(...args: unknown[]); protected _animationClasses: { uncheckedToChecked: string; uncheckedToIndeterminate: string; @@ -47,7 +45,7 @@ export class MatCheckbox implements AfterViewInit, OnChanges, ControlValueAccess indeterminateToUnchecked: string; }; // (undocumented) - _animationMode?: string | undefined; + _animationMode?: "NoopAnimations" | "BrowserAnimations" | null | undefined; ariaControls: string; ariaDescribedby: string; ariaExpanded: boolean; @@ -130,7 +128,7 @@ export class MatCheckbox implements AfterViewInit, OnChanges, ControlValueAccess // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/chips.md b/tools/public_api_guard/material/chips.md index 82e20ca5d178..d14e5409aab1 100644 --- a/tools/public_api_guard/material/chips.md +++ b/tools/public_api_guard/material/chips.md @@ -8,29 +8,23 @@ import { AfterContentInit } from '@angular/core'; import { AfterViewInit } from '@angular/core'; import { ChangeDetectorRef } from '@angular/core'; import { ControlValueAccessor } from '@angular/forms'; -import { Directionality } from '@angular/cdk/bidi'; import { DoCheck } from '@angular/core'; import { ElementRef } from '@angular/core'; import { ErrorStateMatcher } from '@angular/material/core'; import { EventEmitter } from '@angular/core'; import { FocusKeyManager } from '@angular/cdk/a11y'; -import { FocusMonitor } from '@angular/cdk/a11y'; -import { FormGroupDirective } from '@angular/forms'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; import { InjectionToken } from '@angular/core'; import { Injector } from '@angular/core'; -import { MatFormField } from '@angular/material/form-field'; import { MatFormFieldControl } from '@angular/material/form-field'; import { NgControl } from '@angular/forms'; -import { NgForm } from '@angular/forms'; import { NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; import { QueryList } from '@angular/core'; -import { RippleGlobalOptions } from '@angular/material/core'; import { Subject } from 'rxjs'; // @public @@ -53,7 +47,7 @@ export const MAT_CHIPS_DEFAULT_OPTIONS: InjectionToken; // @public export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck, OnDestroy { - constructor(_changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef, _ngZone: NgZone, _focusMonitor: FocusMonitor, _document: any, animationMode?: string, _globalRippleOptions?: RippleGlobalOptions | undefined); + constructor(...args: unknown[]); protected _allLeadingIcons: QueryList; protected _allRemoveIcons: QueryList; protected _allTrailingIcons: QueryList; @@ -123,7 +117,7 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -141,7 +135,7 @@ export interface MatChipEditedEvent extends MatChipEvent { // @public export class MatChipEditInput { - constructor(_elementRef: ElementRef, _document: any); + constructor(...args: unknown[]); // (undocumented) getNativeElement(): HTMLElement; // (undocumented) @@ -163,7 +157,7 @@ export interface MatChipEvent { // @public export class MatChipGrid extends MatChipSet implements AfterContentInit, AfterViewInit, ControlValueAccessor, DoCheck, MatFormFieldControl, OnDestroy { - constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, dir: Directionality, parentForm: NgForm, parentFormGroup: FormGroupDirective, defaultErrorStateMatcher: ErrorStateMatcher, ngControl: NgControl); + constructor(...args: unknown[]); protected _allowFocusEscape(): void; _blur(): void; readonly change: EventEmitter; @@ -196,7 +190,7 @@ export class MatChipGrid extends MatChipSet implements AfterContentInit, AfterVi // (undocumented) ngAfterViewInit(): void; // (undocumented) - ngControl: NgControl; + ngControl: NgControl | null; // (undocumented) ngDoCheck(): void; // (undocumented) @@ -229,7 +223,7 @@ export class MatChipGrid extends MatChipSet implements AfterContentInit, AfterVi // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -243,7 +237,7 @@ export class MatChipGridChange { // @public export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy { - constructor(_elementRef: ElementRef, defaultOptions: MatChipsDefaultOptions, formField?: MatFormField); + constructor(...args: unknown[]); addOnBlur: boolean; _blur(): void; readonly chipEnd: EventEmitter; @@ -280,7 +274,7 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy { // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -405,7 +399,7 @@ export class MatChipRemove extends MatChipAction { // @public export class MatChipRow extends MatChip implements AfterViewInit { - constructor(changeDetectorRef: ChangeDetectorRef, elementRef: ElementRef, ngZone: NgZone, focusMonitor: FocusMonitor, _document: any, animationMode?: string, globalRippleOptions?: RippleGlobalOptions, tabIndex?: string); + constructor(...args: unknown[]); // (undocumented) protected basicChipAttrName: string; contentEditInput?: MatChipEditInput; @@ -427,7 +421,7 @@ export class MatChipRow extends MatChip implements AfterViewInit { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -449,7 +443,7 @@ export class MatChipSelectionChange { // @public export class MatChipSet implements AfterViewInit, OnDestroy { - constructor(_elementRef: ElementRef, _changeDetectorRef: ChangeDetectorRef, _dir: Directionality); + constructor(...args: unknown[]); protected _allowFocusEscape(): void; // (undocumented) protected _changeDetectorRef: ChangeDetectorRef; @@ -491,7 +485,7 @@ export class MatChipSet implements AfterViewInit, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) diff --git a/tools/public_api_guard/material/core.md b/tools/public_api_guard/material/core.md index 5c38679b0099..d1e887327553 100644 --- a/tools/public_api_guard/material/core.md +++ b/tools/public_api_guard/material/core.md @@ -216,7 +216,7 @@ export class MatNativeDateModule { // @public export class MatOptgroup { - constructor(parent?: MatOptionParentComponent); + constructor(...args: unknown[]); disabled: boolean; _inert: boolean; label: string; @@ -226,12 +226,12 @@ export class MatOptgroup { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatOption implements FocusableOption, AfterViewChecked, OnDestroy { - constructor(_element: ElementRef, _changeDetectorRef: ChangeDetectorRef, _parent: MatOptionParentComponent, group: MatOptgroup); + constructor(...args: unknown[]); get active(): boolean; // (undocumented) _changeDetectorRef: ChangeDetectorRef; @@ -244,11 +244,11 @@ export class MatOption implements FocusableOption, AfterViewChecked, On getLabel(): string; _getTabIndex(): string; // (undocumented) - group: MatOptgroup; + group: MatOptgroup | null; _handleKeydown(event: KeyboardEvent): void; get hideSingleSelectionIndicator(): boolean; id: string; - get multiple(): boolean | undefined; + get multiple(): boolean | null | undefined; // (undocumented) static ngAcceptInputType_disabled: unknown; // (undocumented) @@ -268,7 +268,7 @@ export class MatOption implements FocusableOption, AfterViewChecked, On // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration, "mat-option", ["matOption"], { "value": { "alias": "value"; "required": false; }; "id": { "alias": "id"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "onSelectionChange": "onSelectionChange"; }, never, ["mat-icon", "*"], true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, null, { optional: true; }, { optional: true; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public (undocumented) @@ -304,16 +304,16 @@ export class MatOptionSelectionChange { // @public export class MatPseudoCheckbox { - constructor(_animationMode?: string | undefined); + constructor(...args: unknown[]); // (undocumented) - _animationMode?: string | undefined; + _animationMode?: "NoopAnimations" | "BrowserAnimations" | null | undefined; appearance: 'minimal' | 'full'; disabled: boolean; state: MatPseudoCheckboxState; // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) @@ -331,7 +331,7 @@ export type MatPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate'; // @public (undocumented) export class MatRipple implements OnInit, OnDestroy, RippleTarget { - constructor(_elementRef: ElementRef, ngZone: NgZone, platform: Platform, globalOptions?: RippleGlobalOptions, _animationMode?: string | undefined, injector?: Injector); + constructor(...args: unknown[]); animation: RippleAnimationConfig; centered: boolean; color: string; @@ -355,7 +355,7 @@ export class MatRipple implements OnInit, OnDestroy, RippleTarget { // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -389,8 +389,7 @@ export class MatRippleModule { // @public export class NativeDateAdapter extends DateAdapter { - constructor( - matDateLocale?: string); + constructor(...args: unknown[]); // (undocumented) addCalendarDays(date: Date, days: number): Date; // (undocumented) @@ -439,7 +438,7 @@ export class NativeDateAdapter extends DateAdapter { // @deprecated (undocumented) useUtcForDisplay: boolean; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; // (undocumented) static ɵprov: i0.ɵɵInjectableDeclaration; } diff --git a/tools/public_api_guard/material/datepicker.md b/tools/public_api_guard/material/datepicker.md index 8b1ed1385618..0744cc4ece3b 100644 --- a/tools/public_api_guard/material/datepicker.md +++ b/tools/public_api_guard/material/datepicker.md @@ -12,7 +12,6 @@ import { AnimationEvent as AnimationEvent_2 } from '@angular/animations'; import { AnimationTriggerMetadata } from '@angular/animations'; import { ChangeDetectorRef } from '@angular/core'; import { ComponentType } from '@angular/cdk/portal'; -import { ControlContainer } from '@angular/forms'; import { ControlValueAccessor } from '@angular/forms'; import { DateAdapter } from '@angular/material/core'; import { Directionality } from '@angular/cdk/bidi'; @@ -32,13 +31,10 @@ import * as i4 from '@angular/cdk/a11y'; import * as i5 from '@angular/cdk/portal'; import * as i6 from '@angular/material/core'; import { InjectionToken } from '@angular/core'; -import { Injector } from '@angular/core'; import { MatButton } from '@angular/material/button'; -import { MatDateFormats } from '@angular/material/core'; import { MatFormFieldControl } from '@angular/material/form-field'; import { NgControl } from '@angular/forms'; import { NgForm } from '@angular/forms'; -import { NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; @@ -55,7 +51,6 @@ import { ThemePalette } from '@angular/material/core'; import { ValidationErrors } from '@angular/forms'; import { Validator } from '@angular/forms'; import { ValidatorFn } from '@angular/forms'; -import { ViewContainerRef } from '@angular/core'; import { WritableSignal } from '@angular/core'; // @public @@ -85,7 +80,7 @@ export interface DateSelectionModelChange { // @public export class DefaultMatCalendarRangeStrategy implements MatDateRangeSelectionStrategy { - constructor(_dateAdapter: DateAdapter); + constructor(...args: unknown[]); // (undocumented) createDrag(dragOrigin: D, originalRange: DateRange, newDate: D): DateRange | null; // (undocumented) @@ -137,7 +132,7 @@ export const MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER: FactoryProvider; // @public export class MatCalendar implements AfterContentInit, AfterViewChecked, OnDestroy, OnChanges { - constructor(_intl: MatDatepickerIntl, _dateAdapter: DateAdapter, _dateFormats: MatDateFormats, _changeDetectorRef: ChangeDetectorRef); + constructor(...args: unknown[]); get activeDate(): D; set activeDate(value: D); protected _activeDrag: MatCalendarUserEvent | null; @@ -189,12 +184,12 @@ export class MatCalendar implements AfterContentInit, AfterViewChecked, OnDes // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration, "mat-calendar", ["matCalendar"], { "headerComponent": { "alias": "headerComponent"; "required": false; }; "startAt": { "alias": "startAt"; "required": false; }; "startView": { "alias": "startView"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "maxDate": { "alias": "maxDate"; "required": false; }; "dateFilter": { "alias": "dateFilter"; "required": false; }; "dateClass": { "alias": "dateClass"; "required": false; }; "comparisonStart": { "alias": "comparisonStart"; "required": false; }; "comparisonEnd": { "alias": "comparisonEnd"; "required": false; }; "startDateAccessibleName": { "alias": "startDateAccessibleName"; "required": false; }; "endDateAccessibleName": { "alias": "endDateAccessibleName"; "required": false; }; }, { "selectedChange": "selectedChange"; "yearSelected": "yearSelected"; "monthSelected": "monthSelected"; "viewChanged": "viewChanged"; "_userSelection": "_userSelection"; "_userDragDrop": "_userDragDrop"; }, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, { optional: true; }, { optional: true; }, null]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public export class MatCalendarBody implements OnChanges, OnDestroy, AfterViewChecked { - constructor(_elementRef: ElementRef, _ngZone: NgZone); + constructor(...args: unknown[]); activeCell: number; // (undocumented) readonly activeDateChange: EventEmitter>; @@ -288,7 +283,7 @@ export type MatCalendarCellCssClasses = string | string[] | Set | { // @public export class MatCalendarHeader { - constructor(_intl: MatDatepickerIntl, calendar: MatCalendar, _dateAdapter: DateAdapter, _dateFormats: MatDateFormats, changeDetectorRef: ChangeDetectorRef); + constructor(...args: unknown[]); // (undocumented) calendar: MatCalendar; currentPeriodClicked(): void; @@ -306,7 +301,7 @@ export class MatCalendarHeader { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration, "mat-calendar-header", ["matCalendarHeader"], {}, {}, never, ["*"], true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, null, { optional: true; }, { optional: true; }, null]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public @@ -330,7 +325,7 @@ export class MatDatepicker extends MatDatepickerBase, // @public export class MatDatepickerActions implements AfterViewInit, OnDestroy { - constructor(_datepicker: MatDatepickerBase, unknown>, _viewContainerRef: ViewContainerRef); + constructor(...args: unknown[]); // (undocumented) ngAfterViewInit(): void; // (undocumented) @@ -351,7 +346,7 @@ export const matDatepickerAnimations: { // @public export class MatDatepickerApply { - constructor(_datepicker: MatDatepickerBase, unknown>); + constructor(...args: unknown[]); // (undocumented) _applySelection(): void; // (undocumented) @@ -362,9 +357,9 @@ export class MatDatepickerApply { // @public export class MatDatepickerCancel { - constructor(_datepicker: MatDatepickerBase, unknown>); + constructor(...args: unknown[]); // (undocumented) - _datepicker: MatDatepickerBase, unknown>; + _datepicker: MatDatepickerBase, unknown, {}>; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) @@ -373,7 +368,7 @@ export class MatDatepickerCancel { // @public export class MatDatepickerContent> implements OnInit, AfterViewInit, OnDestroy { - constructor(_elementRef: ElementRef, _changeDetectorRef: ChangeDetectorRef, _globalModel: MatDateSelectionModel, _dateAdapter: DateAdapter, _rangeSelectionStrategy: MatDateRangeSelectionStrategy, intl: MatDatepickerIntl); + constructor(...args: unknown[]); _actionsPortal: TemplatePortal | null; readonly _animationDone: Subject; _animationState: 'enter-dropdown' | 'enter-dialog' | 'void'; @@ -388,7 +383,7 @@ export class MatDatepickerContent> implem datepicker: MatDatepickerBase; _dialogLabelId: string | null; // (undocumented) - protected _elementRef: ElementRef; + protected _elementRef: ElementRef; endDateAccessibleName: string | null; // (undocumented) _getSelected(): D | DateRange | null; @@ -412,7 +407,7 @@ export class MatDatepickerContent> implem // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration, "mat-datepicker-content", ["matDatepickerContent"], { "color": { "alias": "color"; "required": false; }; }, {}, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, null, null, null, { optional: true; }, null]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public @@ -439,7 +434,7 @@ export interface MatDatepickerControl { // @public export class MatDatepickerInput extends MatDatepickerInputBase implements MatDatepickerControl, OnDestroy { - constructor(elementRef: ElementRef, dateAdapter: DateAdapter, dateFormats: MatDateFormats, _formField?: _MatFormFieldPartial | undefined); + constructor(...args: unknown[]); protected _ariaOwns: WritableSignal; // (undocumented) protected _assignValueToModel(value: D | null): void; @@ -470,7 +465,7 @@ export class MatDatepickerInput extends MatDatepickerInputBase i // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration, "input[matDatepicker]", ["matDatepickerInput"], { "matDatepicker": { "alias": "matDatepicker"; "required": false; }; "min": { "alias": "min"; "required": false; }; "max": { "alias": "max"; "required": false; }; "dateFilter": { "alias": "matDatepickerFilter"; "required": false; }; }, {}, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, { optional: true; }, { optional: true; }, { optional: true; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public @@ -535,7 +530,7 @@ export interface MatDatepickerPanel, S, D = Ex // @public (undocumented) export class MatDatepickerToggle implements AfterContentInit, OnChanges, OnDestroy { - constructor(_intl: MatDatepickerIntl, _changeDetectorRef: ChangeDetectorRef, defaultTabIndex: string); + constructor(...args: unknown[]); ariaLabel: string; _button: MatButton; _customIcon: MatDatepickerToggleIcon; @@ -559,7 +554,7 @@ export class MatDatepickerToggle implements AfterContentInit, OnChanges, OnDe // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration, "mat-datepicker-toggle", ["matDatepickerToggle"], { "datepicker": { "alias": "for"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "disableRipple": { "alias": "disableRipple"; "required": false; }; }, {}, ["_customIcon"], ["[matDatepickerToggleIcon]"], true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, null, { attribute: "tabindex"; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public @@ -572,7 +567,7 @@ export class MatDatepickerToggleIcon { // @public (undocumented) export class MatDateRangeInput implements MatFormFieldControl>, MatDatepickerControl, MatDateRangeInputParent, MatDateRangePickerInput, AfterContentInit, OnChanges, OnDestroy { - constructor(_changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef, control: ControlContainer, _dateAdapter: DateAdapter, _formField?: _MatFormFieldPartial | undefined); + constructor(...args: unknown[]); _ariaDescribedBy: string | null; _ariaOwns: WritableSignal; comparisonEnd: D | null; @@ -637,7 +632,7 @@ export class MatDateRangeInput implements MatFormFieldControl>, // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration, "mat-date-range-input", ["matDateRangeInput"], { "rangePicker": { "alias": "rangePicker"; "required": false; }; "required": { "alias": "required"; "required": false; }; "dateFilter": { "alias": "dateFilter"; "required": false; }; "min": { "alias": "min"; "required": false; }; "max": { "alias": "max"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "separator": { "alias": "separator"; "required": false; }; "comparisonStart": { "alias": "comparisonStart"; "required": false; }; "comparisonEnd": { "alias": "comparisonEnd"; "required": false; }; }, {}, ["_startInput", "_endInput"], ["input[matStartDate]", "input[matEndDate]"], true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, null, { optional: true; self: true; }, { optional: true; }, { optional: true; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public @@ -682,7 +677,6 @@ export abstract class MatDateSelectionModel extends MatDateRangeInputPartBase { - constructor(rangeInput: MatDateRangeInputParent, elementRef: ElementRef, defaultErrorStateMatcher: ErrorStateMatcher, injector: Injector, parentForm: NgForm, parentFormGroup: FormGroupDirective, dateAdapter: DateAdapter, dateFormats: MatDateFormats); // (undocumented) protected _assignValueToModel(value: D | null): void; // (undocumented) @@ -696,12 +690,12 @@ export class MatEndDate extends MatDateRangeInputPartBase { // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration, "input[matEndDate]", never, {}, { "dateChange": "dateChange"; "dateInput": "dateInput"; }, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, null, null, null, { optional: true; }, { optional: true; }, { optional: true; }, { optional: true; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public export class MatMonthView implements AfterContentInit, OnChanges, OnDestroy { - constructor(_changeDetectorRef: ChangeDetectorRef, _dateFormats: MatDateFormats, _dateAdapter: DateAdapter, _dir?: Directionality | undefined, _rangeStrategy?: MatDateRangeSelectionStrategy | undefined); + constructor(...args: unknown[]); get activeDate(): D; set activeDate(value: D); readonly activeDateChange: EventEmitter; @@ -713,7 +707,7 @@ export class MatMonthView implements AfterContentInit, OnChanges, OnDestroy { _comparisonRangeStart: number | null; comparisonStart: D | null; // (undocumented) - _dateAdapter: DateAdapter; + _dateAdapter: DateAdapter; dateClass: MatCalendarCellClassFunction; dateFilter: (date: D) => boolean; _dateSelected(event: MatCalendarUserEvent): void; @@ -761,17 +755,17 @@ export class MatMonthView implements AfterContentInit, OnChanges, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration, "mat-month-view", ["matMonthView"], { "activeDate": { "alias": "activeDate"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "maxDate": { "alias": "maxDate"; "required": false; }; "dateFilter": { "alias": "dateFilter"; "required": false; }; "dateClass": { "alias": "dateClass"; "required": false; }; "comparisonStart": { "alias": "comparisonStart"; "required": false; }; "comparisonEnd": { "alias": "comparisonEnd"; "required": false; }; "startDateAccessibleName": { "alias": "startDateAccessibleName"; "required": false; }; "endDateAccessibleName": { "alias": "endDateAccessibleName"; "required": false; }; "activeDrag": { "alias": "activeDrag"; "required": false; }; }, { "selectedChange": "selectedChange"; "_userSelection": "_userSelection"; "dragStarted": "dragStarted"; "dragEnded": "dragEnded"; "activeDateChange": "activeDateChange"; }, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, { optional: true; }, { optional: true; }, { optional: true; }, { optional: true; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public export class MatMultiYearView implements AfterContentInit, OnDestroy { - constructor(_changeDetectorRef: ChangeDetectorRef, _dateAdapter: DateAdapter, _dir?: Directionality | undefined); + constructor(...args: unknown[]); get activeDate(): D; set activeDate(value: D); readonly activeDateChange: EventEmitter; // (undocumented) - _dateAdapter: DateAdapter; + _dateAdapter: DateAdapter; dateClass: MatCalendarCellClassFunction; dateFilter: (date: D) => boolean; _focusActiveCell(): void; @@ -802,7 +796,7 @@ export class MatMultiYearView implements AfterContentInit, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration, "mat-multi-year-view", ["matMultiYearView"], { "activeDate": { "alias": "activeDate"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "maxDate": { "alias": "maxDate"; "required": false; }; "dateFilter": { "alias": "dateFilter"; "required": false; }; "dateClass": { "alias": "dateClass"; "required": false; }; }, { "selectedChange": "selectedChange"; "yearSelected": "yearSelected"; "activeDateChange": "activeDateChange"; }, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, { optional: true; }, { optional: true; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public @@ -833,7 +827,6 @@ export class MatSingleDateSelectionModel extends MatDateSelectionModel extends MatDateRangeInputPartBase { - constructor(rangeInput: MatDateRangeInputParent, elementRef: ElementRef, defaultErrorStateMatcher: ErrorStateMatcher, injector: Injector, parentForm: NgForm, parentFormGroup: FormGroupDirective, dateAdapter: DateAdapter, dateFormats: MatDateFormats); // (undocumented) protected _assignValueToModel(value: D | null): void; // (undocumented) @@ -849,19 +842,19 @@ export class MatStartDate extends MatDateRangeInputPartBase { // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration, "input[matStartDate]", never, {}, { "dateChange": "dateChange"; "dateInput": "dateInput"; }, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, null, null, null, { optional: true; }, { optional: true; }, { optional: true; }, { optional: true; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public export class MatYearView implements AfterContentInit, OnDestroy { - constructor(_changeDetectorRef: ChangeDetectorRef, _dateFormats: MatDateFormats, _dateAdapter: DateAdapter, _dir?: Directionality | undefined); + constructor(...args: unknown[]); get activeDate(): D; set activeDate(value: D); readonly activeDateChange: EventEmitter; // (undocumented) readonly _changeDetectorRef: ChangeDetectorRef; // (undocumented) - _dateAdapter: DateAdapter; + _dateAdapter: DateAdapter; dateClass: MatCalendarCellClassFunction; dateFilter: (date: D) => boolean; _focusActiveCell(): void; @@ -891,7 +884,7 @@ export class MatYearView implements AfterContentInit, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration, "mat-year-view", ["matYearView"], { "activeDate": { "alias": "activeDate"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "minDate": { "alias": "minDate"; "required": false; }; "maxDate": { "alias": "maxDate"; "required": false; }; "dateFilter": { "alias": "dateFilter"; "required": false; }; "dateClass": { "alias": "dateClass"; "required": false; }; }, { "selectedChange": "selectedChange"; "monthSelected": "monthSelected"; "activeDateChange": "activeDateChange"; }, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, { optional: true; }, { optional: true; }, { optional: true; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public (undocumented) diff --git a/tools/public_api_guard/material/dialog-testing.md b/tools/public_api_guard/material/dialog-testing.md index 317a912fc96a..600104df7283 100644 --- a/tools/public_api_guard/material/dialog-testing.md +++ b/tools/public_api_guard/material/dialog-testing.md @@ -55,7 +55,7 @@ export enum MatDialogSection { // @public export class MatTestDialogOpener implements OnDestroy { - constructor(dialog: MatDialog); + constructor(...args: unknown[]); closedResult: R | undefined; protected static component: ComponentType | undefined; protected static config: MatDialogConfig | undefined; diff --git a/tools/public_api_guard/material/dialog.md b/tools/public_api_guard/material/dialog.md index 5c9c9fcb2f04..4fa7693bb0e7 100644 --- a/tools/public_api_guard/material/dialog.md +++ b/tools/public_api_guard/material/dialog.md @@ -13,11 +13,8 @@ import { ComponentType } from '@angular/cdk/overlay'; import { Dialog } from '@angular/cdk/dialog'; import { DialogRef } from '@angular/cdk/dialog'; import { Direction } from '@angular/cdk/bidi'; -import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; -import { FocusMonitor } from '@angular/cdk/a11y'; import { FocusOrigin } from '@angular/cdk/a11y'; -import { FocusTrapFactory } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i1 from '@angular/cdk/scrolling'; import * as i1_2 from '@angular/cdk/dialog'; @@ -26,16 +23,11 @@ import * as i3 from '@angular/cdk/portal'; import * as i4 from '@angular/material/core'; import { InjectionToken } from '@angular/core'; import { Injector } from '@angular/core'; -import { InteractivityChecker } from '@angular/cdk/a11y'; -import { Location as Location_2 } from '@angular/common'; -import { NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; import { Overlay } from '@angular/cdk/overlay'; -import { OverlayContainer } from '@angular/cdk/overlay'; -import { OverlayRef } from '@angular/cdk/overlay'; import { ScrollStrategy } from '@angular/cdk/overlay'; import { SimpleChanges } from '@angular/core'; import { Subject } from 'rxjs'; @@ -88,10 +80,7 @@ export function MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): ( // @public export class MatDialog implements OnDestroy { - constructor(_overlay: Overlay, injector: Injector, - location: Location_2, _defaultOptions: MatDialogConfig, _scrollStrategy: any, _parentDialog: MatDialog, - _overlayContainer: OverlayContainer, - _animationMode?: 'NoopAnimations' | 'BrowserAnimations'); + constructor(...args: unknown[]); readonly afterAllClosed: Observable; get afterOpened(): Subject>; closeAll(): void; @@ -108,7 +97,7 @@ export class MatDialog implements OnDestroy { open(template: ComponentType | TemplateRef, config?: MatDialogConfig): MatDialogRef; get openDialogs(): MatDialogRef[]; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; // (undocumented) static ɵprov: i0.ɵɵInjectableDeclaration; } @@ -133,10 +122,10 @@ export const matDialogAnimations: { // @public export class MatDialogClose implements OnInit, OnChanges { - constructor(dialogRef: MatDialogRef, _elementRef: ElementRef, _dialog: MatDialog); + constructor(...args: unknown[]); ariaLabel: string; // (undocumented) - dialogRef: MatDialogRef; + dialogRef: MatDialogRef; dialogResult: any; // (undocumented) _matDialogClose: any; @@ -150,7 +139,7 @@ export class MatDialogClose implements OnInit, OnChanges { // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -188,7 +177,6 @@ export class MatDialogConfig { // @public (undocumented) export class MatDialogContainer extends CdkDialogContainer implements OnDestroy { - constructor(elementRef: ElementRef, focusTrapFactory: FocusTrapFactory, _document: any, dialogConfig: MatDialogConfig, interactivityChecker: InteractivityChecker, ngZone: NgZone, overlayRef: OverlayRef, _unusedAnimationMode?: string, focusMonitor?: FocusMonitor); protected _actionSectionCount: number; _animationsEnabled: boolean; _animationStateChanged: EventEmitter; @@ -206,7 +194,7 @@ export class MatDialogContainer extends CdkDialogContainer impl // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/expansion.md b/tools/public_api_guard/material/expansion.md index a265d9d922dd..e4c2339ae2c2 100644 --- a/tools/public_api_guard/material/expansion.md +++ b/tools/public_api_guard/material/expansion.md @@ -10,11 +10,9 @@ import { AnimationEvent as AnimationEvent_2 } from '@angular/animations'; import { AnimationTriggerMetadata } from '@angular/animations'; import { CdkAccordion } from '@angular/cdk/accordion'; import { CdkAccordionItem } from '@angular/cdk/accordion'; -import { ChangeDetectorRef } from '@angular/core'; import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; import { FocusableOption } from '@angular/cdk/a11y'; -import { FocusMonitor } from '@angular/cdk/a11y'; import { FocusOrigin } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; @@ -28,8 +26,6 @@ import { SimpleChanges } from '@angular/core'; import { Subject } from 'rxjs'; import { TemplatePortal } from '@angular/cdk/portal'; import { TemplateRef } from '@angular/core'; -import { UniqueSelectionDispatcher } from '@angular/cdk/collections'; -import { ViewContainerRef } from '@angular/core'; // @public export const EXPANSION_PANEL_ANIMATION_TIMING = "225ms cubic-bezier(0.4,0.0,0.2,1)"; @@ -97,13 +93,13 @@ export class MatExpansionModule { // @public export class MatExpansionPanel extends CdkAccordionItem implements AfterContentInit, OnChanges, OnDestroy { - constructor(accordion: MatAccordionBase, _changeDetectorRef: ChangeDetectorRef, _uniqueSelectionDispatcher: UniqueSelectionDispatcher, _viewContainerRef: ViewContainerRef, _document: any, _animationMode: string, defaultOptions?: MatExpansionPanelDefaultOptions); + constructor(...args: unknown[]); accordion: MatAccordionBase; readonly afterCollapse: EventEmitter; readonly afterExpand: EventEmitter; protected _animationDone(event: AnimationEvent_2): void; // (undocumented) - _animationMode: string; + _animationMode: "NoopAnimations" | "BrowserAnimations" | null; // (undocumented) protected _animationsDisabled: boolean; protected _animationStarted(event: AnimationEvent_2): void; @@ -133,7 +129,7 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -146,15 +142,15 @@ export class MatExpansionPanelActionRow { // @public export class MatExpansionPanelContent { - constructor(_template: TemplateRef, _expansionPanel?: MatExpansionPanelBase | undefined); + constructor(...args: unknown[]); // (undocumented) - _expansionPanel?: MatExpansionPanelBase | undefined; + _expansionPanel: MatExpansionPanelBase | null; // (undocumented) _template: TemplateRef; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -174,9 +170,9 @@ export class MatExpansionPanelDescription { // @public export class MatExpansionPanelHeader implements AfterViewInit, OnDestroy, FocusableOption { - constructor(panel: MatExpansionPanel, _element: ElementRef, _focusMonitor: FocusMonitor, _changeDetectorRef: ChangeDetectorRef, defaultOptions?: MatExpansionPanelDefaultOptions, _animationMode?: string | undefined, tabIndex?: string); + constructor(...args: unknown[]); // (undocumented) - _animationMode?: string | undefined; + _animationMode: "NoopAnimations" | "BrowserAnimations" | null; collapsedHeight: string; get disabled(): boolean; expandedHeight: string; @@ -201,7 +197,7 @@ export class MatExpansionPanelHeader implements AfterViewInit, OnDestroy, Focusa // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/form-field.md b/tools/public_api_guard/material/form-field.md index 48d9c7798264..8fb0711000e7 100644 --- a/tools/public_api_guard/material/form-field.md +++ b/tools/public_api_guard/material/form-field.md @@ -10,8 +10,6 @@ import { AfterContentInit } from '@angular/core'; import { AfterViewInit } from '@angular/core'; import { AnimationTriggerMetadata } from '@angular/animations'; import { BooleanInput } from '@angular/cdk/coercion'; -import { ChangeDetectorRef } from '@angular/core'; -import { Directionality } from '@angular/cdk/bidi'; import { ElementRef } from '@angular/core'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; @@ -19,10 +17,8 @@ import * as i2 from '@angular/common'; import * as i3 from '@angular/cdk/observers'; import { InjectionToken } from '@angular/core'; import { NgControl } from '@angular/forms'; -import { NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { OnDestroy } from '@angular/core'; -import { Platform } from '@angular/cdk/platform'; import { QueryList } from '@angular/core'; import { Signal } from '@angular/core'; import { ThemePalette } from '@angular/material/core'; @@ -56,30 +52,28 @@ export const MAT_SUFFIX: InjectionToken; // @public export class MatError { - constructor(ariaLive: string, elementRef: ElementRef); + constructor(...args: unknown[]); // (undocumented) id: string; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatFormField implements FloatingLabelParent, AfterContentInit, AfterContentChecked, AfterViewInit, OnDestroy { - constructor(_elementRef: ElementRef, _changeDetectorRef: ChangeDetectorRef, - _unusedNgZone: NgZone, _dir: Directionality, _platform: Platform, _defaults?: MatFormFieldDefaultOptions | undefined, _animationMode?: string | undefined, - _unusedDocument?: any); + constructor(...args: unknown[]); _animateAndLockLabel(): void; // (undocumented) - _animationMode?: string | undefined; + _animationMode: "NoopAnimations" | "BrowserAnimations" | null; get appearance(): MatFormFieldAppearance; set appearance(value: MatFormFieldAppearance); color: ThemePalette; get _control(): MatFormFieldControl_2; set _control(value: MatFormFieldControl_2); // (undocumented) - _elementRef: ElementRef; + _elementRef: ElementRef; // (undocumented) _errorChildren: QueryList; // (undocumented) @@ -152,7 +146,7 @@ export class MatFormField implements FloatingLabelParent, AfterContentInit, Afte // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/grid-list.md b/tools/public_api_guard/material/grid-list.md index c056cefc401e..151710ca5458 100644 --- a/tools/public_api_guard/material/grid-list.md +++ b/tools/public_api_guard/material/grid-list.md @@ -6,8 +6,6 @@ import { AfterContentChecked } from '@angular/core'; import { AfterContentInit } from '@angular/core'; -import { Directionality } from '@angular/cdk/bidi'; -import { ElementRef } from '@angular/core'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; import { MatLine } from '@angular/material/core'; @@ -25,7 +23,7 @@ export class MatGridAvatarCssMatStyler { // @public (undocumented) export class MatGridList implements MatGridListBase, OnInit, AfterContentChecked, TileStyleTarget { - constructor(_element: ElementRef, _dir: Directionality); + constructor(...args: unknown[]); get cols(): number; set cols(value: NumberInput); get gutterSize(): string; @@ -40,7 +38,7 @@ export class MatGridList implements MatGridListBase, OnInit, AfterContentChecked // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) @@ -55,13 +53,13 @@ export class MatGridListModule { // @public (undocumented) export class MatGridTile { - constructor(_element: ElementRef, _gridList?: MatGridListBase | undefined); + constructor(...args: unknown[]); get colspan(): number; set colspan(value: NumberInput); // (undocumented) _colspan: number; // (undocumented) - _gridList?: MatGridListBase | undefined; + _gridList?: MatGridListBase | null | undefined; get rowspan(): number; set rowspan(value: NumberInput); // (undocumented) @@ -70,7 +68,7 @@ export class MatGridTile { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -91,7 +89,7 @@ export class MatGridTileHeaderCssMatStyler { // @public (undocumented) export class MatGridTileText implements AfterContentInit { - constructor(_element: ElementRef); + constructor(...args: unknown[]); // (undocumented) _lines: QueryList; // (undocumented) diff --git a/tools/public_api_guard/material/icon.md b/tools/public_api_guard/material/icon.md index a80cb3aae9a3..6739034004fb 100644 --- a/tools/public_api_guard/material/icon.md +++ b/tools/public_api_guard/material/icon.md @@ -35,7 +35,7 @@ export function getMatIconNoHttpProviderError(): Error; // @public export const ICON_REGISTRY_PROVIDER: { provide: typeof MatIconRegistry; - deps: (Optional[] | typeof DomSanitizer | typeof ErrorHandler)[]; + deps: (typeof DomSanitizer | typeof ErrorHandler | Optional[])[]; useFactory: typeof ICON_REGISTRY_PROVIDER_FACTORY; }; @@ -62,7 +62,7 @@ export function MAT_ICON_LOCATION_FACTORY(): MatIconLocation; // @public export class MatIcon implements OnInit, AfterViewChecked, OnDestroy { - constructor(_elementRef: ElementRef, _iconRegistry: MatIconRegistry, ariaHidden: string, _location: MatIconLocation, _errorHandler: ErrorHandler, defaults?: MatIconDefaultOptions); + constructor(...args: unknown[]); get color(): string | null | undefined; set color(value: string | null | undefined); // (undocumented) @@ -91,7 +91,7 @@ export class MatIcon implements OnInit, AfterViewChecked, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -118,7 +118,7 @@ export class MatIconModule { // @public export class MatIconRegistry implements OnDestroy { - constructor(_httpClient: HttpClient, _sanitizer: DomSanitizer, document: any, _errorHandler: ErrorHandler); + constructor(...args: unknown[]); addSvgIcon(iconName: string, url: SafeResourceUrl, options?: IconOptions): this; addSvgIconInNamespace(namespace: string, iconName: string, url: SafeResourceUrl, options?: IconOptions): this; addSvgIconLiteral(iconName: string, literal: SafeHtml, options?: IconOptions): this; @@ -137,7 +137,7 @@ export class MatIconRegistry implements OnDestroy { registerFontClassAlias(alias: string, classNames?: string): this; setDefaultFontSetClass(...classNames: string[]): this; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; // (undocumented) static ɵprov: i0.ɵɵInjectableDeclaration; } diff --git a/tools/public_api_guard/material/input.md b/tools/public_api_guard/material/input.md index 296715879191..8dd0b845a094 100644 --- a/tools/public_api_guard/material/input.md +++ b/tools/public_api_guard/material/input.md @@ -5,12 +5,10 @@ ```ts import { AfterViewInit } from '@angular/core'; -import { AutofillMonitor } from '@angular/cdk/text-field'; import { BooleanInput } from '@angular/cdk/coercion'; import { DoCheck } from '@angular/core'; import { ElementRef } from '@angular/core'; import { ErrorStateMatcher } from '@angular/material/core'; -import { FormGroupDirective } from '@angular/forms'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; import * as i2 from '@angular/material/form-field'; @@ -24,8 +22,6 @@ import { MatLabel } from '@angular/material/form-field'; import { MatPrefix } from '@angular/material/form-field'; import { MatSuffix } from '@angular/material/form-field'; import { NgControl } from '@angular/forms'; -import { NgForm } from '@angular/forms'; -import { NgZone } from '@angular/core'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { Platform } from '@angular/cdk/platform'; @@ -50,7 +46,7 @@ export { MatHint } // @public (undocumented) export class MatInput implements MatFormFieldControl, OnChanges, OnDestroy, AfterViewInit, DoCheck { - constructor(_elementRef: ElementRef, _platform: Platform, ngControl: NgControl, parentForm: NgForm, parentFormGroup: FormGroupDirective, defaultErrorStateMatcher: ErrorStateMatcher, inputValueAccessor: any, _autofillMonitor: AutofillMonitor, _ngZone: NgZone, _formField?: MatFormField | undefined); + constructor(...args: unknown[]); autofilled: boolean; controlType: string; protected _dirtyCheckNativeValue(): void; @@ -70,7 +66,7 @@ export class MatInput implements MatFormFieldControl, OnChanges, OnDestroy, _focusChanged(isFocused: boolean): void; focused: boolean; // (undocumented) - protected _formField?: MatFormField | undefined; + protected _formField?: MatFormField | null | undefined; protected _getPlaceholder(): string | null; protected _getReadonlyAttribute(): string | null; get id(): string; @@ -92,7 +88,7 @@ export class MatInput implements MatFormFieldControl, OnChanges, OnDestroy, // (undocumented) ngAfterViewInit(): void; // (undocumented) - ngControl: NgControl; + ngControl: NgControl | null; // (undocumented) ngDoCheck(): void; // (undocumented) @@ -130,7 +126,7 @@ export class MatInput implements MatFormFieldControl, OnChanges, OnDestroy, // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/list.md b/tools/public_api_guard/material/list.md index da4aad970fa1..a9a2eafe9a27 100644 --- a/tools/public_api_guard/material/list.md +++ b/tools/public_api_guard/material/list.md @@ -6,7 +6,6 @@ import { AfterViewInit } from '@angular/core'; import { BooleanInput } from '@angular/cdk/coercion'; -import { ChangeDetectorRef } from '@angular/core'; import { ControlValueAccessor } from '@angular/forms'; import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; @@ -20,7 +19,6 @@ import { NgZone } from '@angular/core'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; -import { Platform } from '@angular/cdk/platform'; import { QueryList } from '@angular/core'; import { RippleConfig } from '@angular/material/core'; import { RippleGlobalOptions } from '@angular/material/core'; @@ -66,7 +64,6 @@ export interface MatListConfig { // @public (undocumented) export class MatListItem extends MatListItemBase { - constructor(element: ElementRef, ngZone: NgZone, listBase: MatListBase | null, platform: Platform, globalRippleOptions?: RippleGlobalOptions, animationMode?: string); get activated(): boolean; set activated(activated: boolean); // (undocumented) @@ -87,7 +84,7 @@ export class MatListItem extends MatListItemBase { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -100,15 +97,15 @@ export class MatListItemAvatar extends _MatListItemGraphicBase { // @public export class _MatListItemGraphicBase { - constructor(_listOption: ListOption); + constructor(...args: unknown[]); // (undocumented) _isAlignedAtStart(): boolean; // (undocumented) - _listOption: ListOption; + _listOption: ListOption | null; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration<_MatListItemGraphicBase, never, never, {}, {}, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration<_MatListItemGraphicBase, [{ optional: true; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration<_MatListItemGraphicBase, never>; } // @public @@ -121,7 +118,7 @@ export class MatListItemIcon extends _MatListItemGraphicBase { // @public export class MatListItemLine { - constructor(_elementRef: ElementRef); + constructor(...args: unknown[]); // (undocumented) _elementRef: ElementRef; // (undocumented) @@ -140,7 +137,7 @@ export class MatListItemMeta { // @public export class MatListItemTitle { - constructor(_elementRef: ElementRef); + constructor(...args: unknown[]); // (undocumented) _elementRef: ElementRef; // (undocumented) @@ -161,7 +158,6 @@ export class MatListModule { // @public (undocumented) export class MatListOption extends MatListItemBase implements ListOption, OnInit, OnDestroy { - constructor(elementRef: ElementRef, ngZone: NgZone, _selectionList: SelectionList, platform: Platform, _changeDetectorRef: ChangeDetectorRef, globalRippleOptions?: RippleGlobalOptions, animationMode?: string); // @deprecated get checkboxPosition(): MatListOptionTogglePosition; set checkboxPosition(value: MatListOptionTogglePosition); @@ -202,7 +198,7 @@ export class MatListOption extends MatListItemBase implements ListOption, OnInit // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -230,7 +226,7 @@ export class MatNavList extends MatListBase { // @public (undocumented) export class MatSelectionList extends MatListBase implements SelectionList, ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy { - constructor(_element: ElementRef, _ngZone: NgZone); + constructor(...args: unknown[]); color: ThemePalette; compareWith: (o1: any, o2: any) => boolean; deselectAll(): MatListOption[]; diff --git a/tools/public_api_guard/material/menu.md b/tools/public_api_guard/material/menu.md index 20744fc6a6b2..d52575110cd7 100644 --- a/tools/public_api_guard/material/menu.md +++ b/tools/public_api_guard/material/menu.md @@ -8,15 +8,9 @@ import { AfterContentInit } from '@angular/core'; import { AfterViewInit } from '@angular/core'; import { AnimationEvent as AnimationEvent_2 } from '@angular/animations'; import { AnimationTriggerMetadata } from '@angular/animations'; -import { ApplicationRef } from '@angular/core'; -import { ChangeDetectorRef } from '@angular/core'; -import { ComponentFactoryResolver } from '@angular/core'; import { Direction } from '@angular/cdk/bidi'; -import { Directionality } from '@angular/cdk/bidi'; -import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; import { FocusableOption } from '@angular/cdk/a11y'; -import { FocusMonitor } from '@angular/cdk/a11y'; import { FocusOrigin } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i1 from '@angular/common'; @@ -24,8 +18,6 @@ import * as i2 from '@angular/material/core'; import * as i3 from '@angular/cdk/overlay'; import * as i8 from '@angular/cdk/scrolling'; import { InjectionToken } from '@angular/core'; -import { Injector } from '@angular/core'; -import { NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; @@ -34,7 +26,6 @@ import { QueryList } from '@angular/core'; import { ScrollStrategy } from '@angular/cdk/overlay'; import { Subject } from 'rxjs'; import { TemplateRef } from '@angular/core'; -import { ViewContainerRef } from '@angular/core'; // @public @deprecated (undocumented) export const fadeInItems: AnimationTriggerMetadata; @@ -60,9 +51,7 @@ export const MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER: { // @public (undocumented) export class MatMenu implements AfterContentInit, MatMenuPanel, OnInit, OnDestroy { - constructor(elementRef: ElementRef, ngZone: NgZone, defaultOptions: MatMenuDefaultOptions, changeDetectorRef: ChangeDetectorRef); - // @deprecated - constructor(elementRef: ElementRef, ngZone: NgZone, defaultOptions: MatMenuDefaultOptions, changeDetectorRef?: ChangeDetectorRef); + constructor(...args: unknown[]); // (undocumented) addItem(_item: MatMenuItem): void; _allItems: QueryList; @@ -136,9 +125,7 @@ export const matMenuAnimations: { // @public export class MatMenuContent implements OnDestroy { - constructor(template: TemplateRef, componentFactoryResolver: ComponentFactoryResolver, appRef: ApplicationRef, injector: Injector, viewContainerRef: ViewContainerRef, document: any, changeDetectorRef: ChangeDetectorRef); - // @deprecated - constructor(template: TemplateRef, componentFactoryResolver: ComponentFactoryResolver, appRef: ApplicationRef, injector: Injector, viewContainerRef: ViewContainerRef, document: any, changeDetectorRef?: ChangeDetectorRef); + constructor(...args: unknown[]); attach(context?: any): void; readonly _attached: Subject; detach(): void; @@ -162,9 +149,7 @@ export interface MatMenuDefaultOptions { // @public export class MatMenuItem implements FocusableOption, AfterViewInit, OnDestroy { - constructor(elementRef: ElementRef, document: any, focusMonitor: FocusMonitor, parentMenu: MatMenuPanel | undefined, changeDetectorRef: ChangeDetectorRef); - // @deprecated - constructor(elementRef: ElementRef, document?: any, focusMonitor?: FocusMonitor, parentMenu?: MatMenuPanel, changeDetectorRef?: ChangeDetectorRef); + constructor(...args: unknown[]); _checkDisabled(event: Event): void; disabled: boolean; disableRipple: boolean; @@ -187,7 +172,7 @@ export class MatMenuItem implements FocusableOption, AfterViewInit, OnDestroy { // (undocumented) ngOnDestroy(): void; // (undocumented) - _parentMenu?: MatMenuPanel | undefined; + _parentMenu?: MatMenuPanel | null | undefined; role: 'menuitem' | 'menuitemradio' | 'menuitemcheckbox'; // (undocumented) _setHighlighted(isHighlighted: boolean): void; @@ -197,7 +182,7 @@ export class MatMenuItem implements FocusableOption, AfterViewInit, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) @@ -252,11 +237,7 @@ export interface MatMenuPanel { // @public export class MatMenuTrigger implements AfterContentInit, OnDestroy { - constructor(overlay: Overlay, element: ElementRef, viewContainerRef: ViewContainerRef, scrollStrategy: any, parentMenu: MatMenuPanel, menuItemInstance: MatMenuItem, dir: Directionality, focusMonitor: FocusMonitor, ngZone: NgZone); - // @deprecated - constructor(overlay: Overlay, element: ElementRef, viewContainerRef: ViewContainerRef, scrollStrategy: any, parentMenu: MatMenuPanel, menuItemInstance: MatMenuItem, dir: Directionality, focusMonitor?: FocusMonitor | null); - // @deprecated - constructor(overlay: Overlay, element: ElementRef, viewContainerRef: ViewContainerRef, scrollStrategy: any, parentMenu: MatMenuPanel, menuItemInstance: MatMenuItem, dir: Directionality, focusMonitor: FocusMonitor); + constructor(...args: unknown[]); closeMenu(): void; // @deprecated (undocumented) get _deprecatedMatMenuTriggerFor(): MatMenuPanel | null; @@ -290,7 +271,7 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy { // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @deprecated diff --git a/tools/public_api_guard/material/paginator.md b/tools/public_api_guard/material/paginator.md index 7fb1f2751433..2188aeb1ce33 100644 --- a/tools/public_api_guard/material/paginator.md +++ b/tools/public_api_guard/material/paginator.md @@ -4,7 +4,6 @@ ```ts -import { ChangeDetectorRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/button'; @@ -34,7 +33,7 @@ export function MAT_PAGINATOR_INTL_PROVIDER_FACTORY(parentIntl: MatPaginatorIntl // @public export class MatPaginator implements OnInit, OnDestroy { - constructor(_intl: MatPaginatorIntl, _changeDetectorRef: ChangeDetectorRef, defaults?: MatPaginatorDefaultOptions); + constructor(...args: unknown[]); _changePageSize(pageSize: number): void; color: ThemePalette; disabled: boolean; @@ -84,7 +83,7 @@ export class MatPaginator implements OnInit, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/progress-bar.md b/tools/public_api_guard/material/progress-bar.md index 7cb34a64da1e..3005307de1c0 100644 --- a/tools/public_api_guard/material/progress-bar.md +++ b/tools/public_api_guard/material/progress-bar.md @@ -5,13 +5,11 @@ ```ts import { AfterViewInit } from '@angular/core'; -import { ChangeDetectorRef } from '@angular/core'; import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; import * as i0 from '@angular/core'; import * as i2 from '@angular/material/core'; import { InjectionToken } from '@angular/core'; -import { NgZone } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { ThemePalette } from '@angular/material/core'; @@ -26,10 +24,10 @@ export function MAT_PROGRESS_BAR_LOCATION_FACTORY(): MatProgressBarLocation; // @public (undocumented) export class MatProgressBar implements AfterViewInit, OnDestroy { - constructor(_elementRef: ElementRef, _ngZone: NgZone, _changeDetectorRef: ChangeDetectorRef, _animationMode?: string | undefined, defaults?: MatProgressBarDefaultOptions); + constructor(...args: unknown[]); readonly animationEnd: EventEmitter; // (undocumented) - _animationMode?: string | undefined; + _animationMode?: "NoopAnimations" | "BrowserAnimations" | null | undefined; get bufferValue(): number; set bufferValue(v: number); get color(): string | null | undefined; @@ -55,7 +53,7 @@ export class MatProgressBar implements AfterViewInit, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/progress-spinner.md b/tools/public_api_guard/material/progress-spinner.md index 18dc439c601d..bae5cac27552 100644 --- a/tools/public_api_guard/material/progress-spinner.md +++ b/tools/public_api_guard/material/progress-spinner.md @@ -19,7 +19,7 @@ export function MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY(): MatProgressSpinn // @public (undocumented) export class MatProgressSpinner { - constructor(_elementRef: ElementRef, animationMode: string, defaults?: MatProgressSpinnerDefaultOptions); + constructor(...args: unknown[]); _circleRadius(): number; _circleStrokeWidth(): number; get color(): string | null | undefined; @@ -47,7 +47,7 @@ export class MatProgressSpinner { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/radio.md b/tools/public_api_guard/material/radio.md index 3abddd72015d..5ef2f429d2b0 100644 --- a/tools/public_api_guard/material/radio.md +++ b/tools/public_api_guard/material/radio.md @@ -6,12 +6,10 @@ import { AfterContentInit } from '@angular/core'; import { AfterViewInit } from '@angular/core'; -import { ChangeDetectorRef } from '@angular/core'; import { ControlValueAccessor } from '@angular/forms'; import { DoCheck } from '@angular/core'; import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; -import { FocusMonitor } from '@angular/cdk/a11y'; import { FocusOrigin } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; @@ -21,7 +19,6 @@ import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; import { QueryList } from '@angular/core'; import { ThemePalette } from '@angular/material/core'; -import { UniqueSelectionDispatcher } from '@angular/cdk/collections'; // @public (undocumented) export const MAT_RADIO_DEFAULT_OPTIONS: InjectionToken; @@ -37,7 +34,7 @@ export const MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any; // @public (undocumented) export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy { - constructor(radioGroup: MatRadioGroup, _elementRef: ElementRef, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor, _radioDispatcher: UniqueSelectionDispatcher, animationMode?: string, _defaultOptions?: MatRadioDefaultOptions | undefined, tabIndex?: string); + constructor(...args: unknown[]); ariaDescribedby: string; ariaLabel: string; ariaLabelledby: string; @@ -52,7 +49,7 @@ export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy set disabledInteractive(value: boolean); disableRipple: boolean; // (undocumented) - protected _elementRef: ElementRef; + protected _elementRef: ElementRef; focus(options?: FocusOptions, origin?: FocusOrigin): void; id: string; _inputElement: ElementRef; @@ -97,7 +94,7 @@ export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -117,7 +114,7 @@ export interface MatRadioDefaultOptions { // @public export class MatRadioGroup implements AfterContentInit, OnDestroy, ControlValueAccessor { - constructor(_changeDetector: ChangeDetectorRef); + constructor(...args: unknown[]); readonly change: EventEmitter; // (undocumented) _checkSelectedRadioButton(): void; diff --git a/tools/public_api_guard/material/select.md b/tools/public_api_guard/material/select.md index b2dab171a73f..ec4c1101cbe3 100644 --- a/tools/public_api_guard/material/select.md +++ b/tools/public_api_guard/material/select.md @@ -12,12 +12,10 @@ import { CdkOverlayOrigin } from '@angular/cdk/overlay'; import { ChangeDetectorRef } from '@angular/core'; import { ConnectedPosition } from '@angular/cdk/overlay'; import { ControlValueAccessor } from '@angular/forms'; -import { Directionality } from '@angular/cdk/bidi'; import { DoCheck } from '@angular/core'; import { ElementRef } from '@angular/core'; import { ErrorStateMatcher } from '@angular/material/core'; import { EventEmitter } from '@angular/core'; -import { FormGroupDirective } from '@angular/forms'; import * as i0 from '@angular/core'; import * as i1 from '@angular/common'; import * as i2 from '@angular/cdk/overlay'; @@ -25,7 +23,6 @@ import * as i3 from '@angular/material/core'; import * as i5 from '@angular/cdk/scrolling'; import * as i6 from '@angular/material/form-field'; import { InjectionToken } from '@angular/core'; -import { LiveAnnouncer } from '@angular/cdk/a11y'; import { MatError } from '@angular/material/form-field'; import { MatFormField } from '@angular/material/form-field'; import { MatFormFieldControl } from '@angular/material/form-field'; @@ -37,8 +34,6 @@ import { MatOptionSelectionChange } from '@angular/material/core'; import { MatPrefix } from '@angular/material/form-field'; import { MatSuffix } from '@angular/material/form-field'; import { NgControl } from '@angular/forms'; -import { NgForm } from '@angular/forms'; -import { NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; @@ -86,8 +81,7 @@ export { MatPrefix } // @public (undocumented) export class MatSelect implements AfterContentInit, OnChanges, OnDestroy, OnInit, DoCheck, ControlValueAccessor, MatFormFieldControl { - constructor(_viewportRuler: ViewportRuler, _changeDetectorRef: ChangeDetectorRef, - _unusedNgZone: NgZone, defaultErrorStateMatcher: ErrorStateMatcher, _elementRef: ElementRef, _dir: Directionality, parentForm: NgForm, parentFormGroup: FormGroupDirective, _parentFormField: MatFormField, ngControl: NgControl, tabIndex: string, scrollStrategyFactory: any, _liveAnnouncer: LiveAnnouncer, _unusedDefaultOptions?: unknown); + constructor(...args: unknown[]); ariaLabel: string; ariaLabelledby: string; protected _canOpen(): boolean; @@ -107,7 +101,7 @@ export class MatSelect implements AfterContentInit, OnChanges, OnDestroy, OnInit disableOptionCentering: boolean; disableRipple: boolean; // (undocumented) - readonly _elementRef: ElementRef; + readonly _elementRef: ElementRef; get empty(): boolean; get errorState(): boolean; set errorState(value: boolean); @@ -146,7 +140,7 @@ export class MatSelect implements AfterContentInit, OnChanges, OnDestroy, OnInit // (undocumented) ngAfterContentInit(): void; // (undocumented) - ngControl: NgControl; + ngControl: NgControl | null; // (undocumented) ngDoCheck(): void; // (undocumented) @@ -181,7 +175,7 @@ export class MatSelect implements AfterContentInit, OnChanges, OnDestroy, OnInit get panelOpen(): boolean; panelWidth: string | number | null; // (undocumented) - protected _parentFormField: MatFormField; + protected _parentFormField: MatFormField | null; get placeholder(): string; set placeholder(value: string); _positions: ConnectedPosition[]; @@ -218,7 +212,7 @@ export class MatSelect implements AfterContentInit, OnChanges, OnDestroy, OnInit // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/sidenav.md b/tools/public_api_guard/material/sidenav.md index 7b614e5c8f2e..062c2ddddf52 100644 --- a/tools/public_api_guard/material/sidenav.md +++ b/tools/public_api_guard/material/sidenav.md @@ -11,28 +11,19 @@ import { AnimationEvent as AnimationEvent_2 } from '@angular/animations'; import { AnimationTriggerMetadata } from '@angular/animations'; import { BooleanInput } from '@angular/cdk/coercion'; import { CdkScrollable } from '@angular/cdk/scrolling'; -import { ChangeDetectorRef } from '@angular/core'; -import { Directionality } from '@angular/cdk/bidi'; import { DoCheck } from '@angular/core'; import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; -import { FocusMonitor } from '@angular/cdk/a11y'; import { FocusOrigin } from '@angular/cdk/a11y'; -import { FocusTrapFactory } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; import * as i2 from '@angular/cdk/scrolling'; import { InjectionToken } from '@angular/core'; -import { InteractivityChecker } from '@angular/cdk/a11y'; -import { NgZone } from '@angular/core'; import { NumberInput } from '@angular/cdk/coercion'; import { Observable } from 'rxjs'; import { OnDestroy } from '@angular/core'; -import { Platform } from '@angular/cdk/platform'; import { QueryList } from '@angular/core'; -import { ScrollDispatcher } from '@angular/cdk/scrolling'; import { Subject } from 'rxjs'; -import { ViewportRuler } from '@angular/cdk/scrolling'; // @public export const MAT_DRAWER_DEFAULT_AUTOSIZE: InjectionToken; @@ -42,7 +33,7 @@ export function MAT_DRAWER_DEFAULT_AUTOSIZE_FACTORY(): boolean; // @public export class MatDrawer implements AfterViewInit, AfterContentChecked, OnDestroy { - constructor(_elementRef: ElementRef, _focusTrapFactory: FocusTrapFactory, _focusMonitor: FocusMonitor, _platform: Platform, _ngZone: NgZone, _interactivityChecker: InteractivityChecker, _doc: any, _container?: MatDrawerContainer | undefined); + constructor(...args: unknown[]); readonly _animationEnd: Subject; readonly _animationStarted: Subject; _animationState: 'open-instant' | 'open' | 'void'; @@ -53,7 +44,7 @@ export class MatDrawer implements AfterViewInit, AfterContentChecked, OnDestroy readonly _closedStream: Observable; _closeViaBackdropClick(): Promise; // (undocumented) - _container?: MatDrawerContainer | undefined; + _container?: MatDrawerContainer | null | undefined; _content: ElementRef; get disableClose(): boolean; set disableClose(value: BooleanInput); @@ -81,7 +72,7 @@ export class MatDrawer implements AfterViewInit, AfterContentChecked, OnDestroy // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -91,7 +82,7 @@ export const matDrawerAnimations: { // @public export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy { - constructor(_dir: Directionality, _element: ElementRef, _ngZone: NgZone, _changeDetectorRef: ChangeDetectorRef, viewportRuler: ViewportRuler, defaultAutosize?: boolean, _animationMode?: string | undefined); + constructor(...args: unknown[]); _allDrawers: QueryList; get autosize(): boolean; set autosize(value: BooleanInput); @@ -135,12 +126,12 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) export class MatDrawerContent extends CdkScrollable implements AfterContentInit { - constructor(_changeDetectorRef: ChangeDetectorRef, _container: MatDrawerContainer, elementRef: ElementRef, scrollDispatcher: ScrollDispatcher, ngZone: NgZone); + constructor(...args: unknown[]); // (undocumented) _container: MatDrawerContainer; // (undocumented) @@ -185,7 +176,6 @@ export class MatSidenavContainer extends MatDrawerContainer { // @public (undocumented) export class MatSidenavContent extends MatDrawerContent { - constructor(changeDetectorRef: ChangeDetectorRef, container: MatSidenavContainer, elementRef: ElementRef, scrollDispatcher: ScrollDispatcher, ngZone: NgZone); // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) diff --git a/tools/public_api_guard/material/slide-toggle.md b/tools/public_api_guard/material/slide-toggle.md index 1e14c8840e4a..e8a125f3d01e 100644 --- a/tools/public_api_guard/material/slide-toggle.md +++ b/tools/public_api_guard/material/slide-toggle.md @@ -39,7 +39,7 @@ export const MAT_SLIDE_TOGGLE_VALUE_ACCESSOR: { // @public (undocumented) export class MatSlideToggle implements OnDestroy, AfterContentInit, OnChanges, ControlValueAccessor, Validator { - constructor(_elementRef: ElementRef, _focusMonitor: FocusMonitor, _changeDetectorRef: ChangeDetectorRef, tabIndex: string, defaults: MatSlideToggleDefaultOptions, animationMode?: string); + constructor(...args: unknown[]); ariaDescribedby: string; ariaLabel: string | null; ariaLabelledby: string | null; @@ -104,7 +104,7 @@ export class MatSlideToggle implements OnDestroy, AfterContentInit, OnChanges, C // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/slider.md b/tools/public_api_guard/material/slider.md index 4f48a3b3c369..3ef7b8ab020b 100644 --- a/tools/public_api_guard/material/slider.md +++ b/tools/public_api_guard/material/slider.md @@ -23,7 +23,7 @@ import { WritableSignal } from '@angular/core'; // @public export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider { - constructor(_ngZone: NgZone, _cdr: ChangeDetectorRef, _elementRef: ElementRef, _dir: Directionality, _globalRippleOptions?: RippleGlobalOptions | undefined, animationMode?: string); + constructor(...args: unknown[]); // (undocumented) _cachedLeft: number; // (undocumented) @@ -33,7 +33,7 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider { readonly _cdr: ChangeDetectorRef; color: ThemePalette; // (undocumented) - readonly _dir: Directionality; + readonly _dir: Directionality | null; get disabled(): boolean; set disabled(v: boolean); disableRipple: boolean; @@ -48,7 +48,7 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider { _getInput(thumbPosition: _MatThumb): _MatSliderThumb | _MatSliderRangeThumb | undefined; _getThumb(thumbPosition: _MatThumb): _MatSliderVisualThumb; // (undocumented) - readonly _globalRippleOptions?: RippleGlobalOptions | undefined; + readonly _globalRippleOptions: RippleGlobalOptions | null; // (undocumented) _hasAnimation: boolean; _input: _MatSliderThumb; @@ -123,7 +123,7 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @deprecated @@ -152,7 +152,7 @@ export class MatSliderModule { // @public (undocumented) export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRangeThumb { - constructor(_ngZone: NgZone, _slider: _MatSlider, _elementRef: ElementRef, _cdr: ChangeDetectorRef); + constructor(...args: unknown[]); // (undocumented) readonly _cdr: ChangeDetectorRef; // (undocumented) @@ -197,7 +197,7 @@ export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRan // @public export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueAccessor { - constructor(_ngZone: NgZone, _elementRef: ElementRef, _cdr: ChangeDetectorRef, _slider: _MatSlider); + constructor(...args: unknown[]); // (undocumented) blur(): void; // (undocumented) @@ -301,7 +301,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA // @public export class MatSliderVisualThumb implements _MatSliderVisualThumb, AfterViewInit, OnDestroy { - constructor(_cdr: ChangeDetectorRef, _ngZone: NgZone, _elementRef: ElementRef, _slider: _MatSlider); + constructor(...args: unknown[]); // (undocumented) readonly _cdr: ChangeDetectorRef; discrete: boolean; diff --git a/tools/public_api_guard/material/snack-bar.md b/tools/public_api_guard/material/snack-bar.md index 954a958d9a92..b42922741409 100644 --- a/tools/public_api_guard/material/snack-bar.md +++ b/tools/public_api_guard/material/snack-bar.md @@ -8,9 +8,7 @@ import { AnimationEvent as AnimationEvent_2 } from '@angular/animations'; import { AnimationTriggerMetadata } from '@angular/animations'; import { AriaLivePoliteness } from '@angular/cdk/a11y'; import { BasePortalOutlet } from '@angular/cdk/portal'; -import { BreakpointObserver } from '@angular/cdk/layout'; import { CdkPortalOutlet } from '@angular/cdk/portal'; -import { ChangeDetectorRef } from '@angular/core'; import { ComponentPortal } from '@angular/cdk/portal'; import { ComponentRef } from '@angular/core'; import { ComponentType } from '@angular/cdk/overlay'; @@ -24,14 +22,9 @@ import * as i2 from '@angular/cdk/portal'; import * as i3 from '@angular/material/button'; import * as i4 from '@angular/material/core'; import { InjectionToken } from '@angular/core'; -import { Injector } from '@angular/core'; -import { LiveAnnouncer } from '@angular/cdk/a11y'; -import { NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { OnDestroy } from '@angular/core'; -import { Overlay } from '@angular/cdk/overlay'; import { OverlayRef } from '@angular/cdk/overlay'; -import { Platform } from '@angular/cdk/platform'; import { Subject } from 'rxjs'; import { TemplatePortal } from '@angular/cdk/portal'; import { TemplateRef } from '@angular/core'; @@ -48,7 +41,7 @@ export function MAT_SNACK_BAR_DEFAULT_OPTIONS_FACTORY(): MatSnackBarConfig; // @public export class MatSnackBar implements OnDestroy { - constructor(_overlay: Overlay, _live: LiveAnnouncer, _injector: Injector, _breakpointObserver: BreakpointObserver, _parentSnackBar: MatSnackBar, _defaultConfig: MatSnackBarConfig); + constructor(...args: unknown[]); dismiss(): void; handsetCssClass: string; // (undocumented) @@ -61,7 +54,7 @@ export class MatSnackBar implements OnDestroy { simpleSnackBarComponent: typeof SimpleSnackBar; snackBarContainerComponent: typeof MatSnackBarContainer; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; // (undocumented) static ɵprov: i0.ɵɵInjectableDeclaration; } @@ -102,8 +95,7 @@ export class MatSnackBarConfig { // @public export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy { - constructor(_ngZone: NgZone, _elementRef: ElementRef, _changeDetectorRef: ChangeDetectorRef, _platform: Platform, - snackBarConfig: MatSnackBarConfig); + constructor(...args: unknown[]); _animationState: string; attachComponentPortal(portal: ComponentPortal): ComponentRef; // @deprecated @@ -121,7 +113,8 @@ export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy readonly _onExit: Subject; _portalOutlet: CdkPortalOutlet; _role?: 'status' | 'alert'; - snackBarConfig: MatSnackBarConfig; + // (undocumented) + snackBarConfig: MatSnackBarConfig; // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) @@ -175,16 +168,10 @@ export type MatSnackBarVerticalPosition = 'top' | 'bottom'; // @public (undocumented) export class SimpleSnackBar implements TextOnlySnackBar { - constructor(snackBarRef: MatSnackBarRef, data: { - message: string; - action: string; - }); + constructor(...args: unknown[]); action(): void; // (undocumented) - data: { - message: string; - action: string; - }; + data: any; get hasAction(): boolean; // (undocumented) snackBarRef: MatSnackBarRef; diff --git a/tools/public_api_guard/material/sort.md b/tools/public_api_guard/material/sort.md index 574afd649dcd..58cfeafa754e 100644 --- a/tools/public_api_guard/material/sort.md +++ b/tools/public_api_guard/material/sort.md @@ -6,11 +6,7 @@ import { AfterViewInit } from '@angular/core'; import { AnimationTriggerMetadata } from '@angular/animations'; -import { AriaDescriber } from '@angular/cdk/a11y'; -import { ChangeDetectorRef } from '@angular/core'; -import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; -import { FocusMonitor } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; import { InjectionToken } from '@angular/core'; @@ -47,7 +43,7 @@ export function MAT_SORT_HEADER_INTL_PROVIDER_FACTORY(parentIntl: MatSortHeaderI // @public export class MatSort implements OnChanges, OnDestroy, OnInit { - constructor(_defaultOptions?: MatSortDefaultOptions | undefined); + constructor(...args: unknown[]); active: string; deregister(sortable: MatSortable): void; get direction(): SortDirection; @@ -75,7 +71,7 @@ export class MatSort implements OnChanges, OnDestroy, OnInit { // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -103,13 +99,11 @@ export interface MatSortDefaultOptions { // @public export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewInit { - constructor( - _intl: MatSortHeaderIntl, _changeDetectorRef: ChangeDetectorRef, _sort: MatSort, _columnDef: MatSortHeaderColumnDef, _focusMonitor: FocusMonitor, _elementRef: ElementRef, - _ariaDescriber?: (AriaDescriber | null) | undefined, defaultOptions?: MatSortDefaultOptions); + constructor(...args: unknown[]); _arrowDirection: SortDirection; arrowPosition: SortHeaderArrowPosition; // (undocumented) - _columnDef: MatSortHeaderColumnDef; + _columnDef: MatSortHeaderColumnDef | null; disableClear: boolean; disabled: boolean; _disableViewStateAnimation: boolean; @@ -121,7 +115,7 @@ export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewI // (undocumented) _handleKeydown(event: KeyboardEvent): void; id: string; - // @deprecated (undocumented) + // (undocumented) _intl: MatSortHeaderIntl; // (undocumented) _isDisabled(): boolean; @@ -151,7 +145,7 @@ export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewI // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/stepper.md b/tools/public_api_guard/material/stepper.md index 79ff114c69a2..a989ec6117cf 100644 --- a/tools/public_api_guard/material/stepper.md +++ b/tools/public_api_guard/material/stepper.md @@ -15,12 +15,8 @@ import { CdkStepLabel } from '@angular/cdk/stepper'; import { CdkStepper } from '@angular/cdk/stepper'; import { CdkStepperNext } from '@angular/cdk/stepper'; import { CdkStepperPrevious } from '@angular/cdk/stepper'; -import { ChangeDetectorRef } from '@angular/core'; -import { Directionality } from '@angular/cdk/bidi'; -import { ElementRef } from '@angular/core'; import { ErrorStateMatcher } from '@angular/material/core'; import { EventEmitter } from '@angular/core'; -import { FocusMonitor } from '@angular/cdk/a11y'; import { FocusOrigin } from '@angular/cdk/a11y'; import { FormGroupDirective } from '@angular/forms'; import * as i0 from '@angular/core'; @@ -33,14 +29,12 @@ import { NgForm } from '@angular/forms'; import { OnDestroy } from '@angular/core'; import { Optional } from '@angular/core'; import { QueryList } from '@angular/core'; -import { StepperOptions } from '@angular/cdk/stepper'; import { StepperOrientation } from '@angular/cdk/stepper'; import { StepState } from '@angular/cdk/stepper'; import { Subject } from 'rxjs'; import { TemplatePortal } from '@angular/cdk/portal'; import { TemplateRef } from '@angular/core'; import { ThemePalette } from '@angular/material/core'; -import { ViewContainerRef } from '@angular/core'; // @public export const MAT_STEPPER_INTL_PROVIDER: { @@ -54,7 +48,6 @@ export function MAT_STEPPER_INTL_PROVIDER_FACTORY(parentIntl: MatStepperIntl): M // @public (undocumented) export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentInit, OnDestroy { - constructor(stepper: MatStepper, _errorStateMatcher: ErrorStateMatcher, _viewContainerRef: ViewContainerRef, stepperOptions?: StepperOptions); color: ThemePalette; isErrorState(control: AbstractControl | null, form: FormGroupDirective | NgForm | null): boolean; _lazyContent: MatStepContent; @@ -67,12 +60,12 @@ export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentI // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatStepContent { - constructor(_template: TemplateRef); + constructor(...args: unknown[]); // (undocumented) _template: TemplateRef; // (undocumented) @@ -83,7 +76,7 @@ export class MatStepContent { // @public (undocumented) export class MatStepHeader extends CdkStepHeader implements AfterViewInit, OnDestroy { - constructor(_intl: MatStepperIntl, _focusMonitor: FocusMonitor, _elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef); + constructor(...args: unknown[]); active: boolean; color: ThemePalette; disableRipple: boolean; @@ -125,7 +118,7 @@ export class MatStepLabel extends CdkStepLabel { // @public (undocumented) export class MatStepper extends CdkStepper implements AfterContentInit { - constructor(dir: Directionality, changeDetectorRef: ChangeDetectorRef, elementRef: ElementRef); + constructor(...args: unknown[]); readonly animationDone: EventEmitter; readonly _animationDone: Subject; get animationDuration(): string; @@ -149,7 +142,7 @@ export class MatStepper extends CdkStepper implements AfterContentInit { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -160,7 +153,7 @@ export const matStepperAnimations: { // @public export class MatStepperIcon { - constructor(templateRef: TemplateRef); + constructor(...args: unknown[]); name: StepState; // (undocumented) templateRef: TemplateRef; diff --git a/tools/public_api_guard/material/tabs.md b/tools/public_api_guard/material/tabs.md index 5b542f8c44bb..ea6ed4eb6606 100644 --- a/tools/public_api_guard/material/tabs.md +++ b/tools/public_api_guard/material/tabs.md @@ -13,22 +13,17 @@ import { BehaviorSubject } from 'rxjs'; import { CdkPortal } from '@angular/cdk/portal'; import { CdkPortalOutlet } from '@angular/cdk/portal'; import { ChangeDetectorRef } from '@angular/core'; -import { ComponentFactoryResolver } from '@angular/core'; import { Direction } from '@angular/cdk/bidi'; -import { Directionality } from '@angular/cdk/bidi'; import { ElementRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; import { FocusableOption } from '@angular/cdk/a11y'; -import { FocusMonitor } from '@angular/cdk/a11y'; import { FocusOrigin } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; import { InjectionToken } from '@angular/core'; -import { NgZone } from '@angular/core'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; -import { Platform } from '@angular/cdk/platform'; import { QueryList } from '@angular/core'; import { RippleConfig } from '@angular/material/core'; import { RippleGlobalOptions } from '@angular/material/core'; @@ -38,8 +33,6 @@ import { Subject } from 'rxjs'; import { TemplatePortal } from '@angular/cdk/portal'; import { TemplateRef } from '@angular/core'; import { ThemePalette } from '@angular/material/core'; -import { ViewContainerRef } from '@angular/core'; -import { ViewportRuler } from '@angular/cdk/scrolling'; // @public export const _MAT_INK_BAR_POSITIONER: InjectionToken<_MatInkBarPositioner>; @@ -80,10 +73,10 @@ export interface _MatInkBarPositioner { // @public export abstract class MatPaginatedTabHeader implements AfterContentChecked, AfterContentInit, AfterViewInit, OnDestroy { - constructor(_elementRef: ElementRef, _changeDetectorRef: ChangeDetectorRef, _viewportRuler: ViewportRuler, _dir: Directionality, _ngZone: NgZone, _platform: Platform, _animationMode?: string | undefined); + constructor(...args: unknown[]); _alignInkBarToSelectedTab(): void; // (undocumented) - _animationMode?: string | undefined; + _animationMode: "NoopAnimations" | "BrowserAnimations" | null; // (undocumented) protected _changeDetectorRef: ChangeDetectorRef; _checkPaginationEnabled(): void; @@ -152,12 +145,12 @@ export abstract class MatPaginatedTabHeader implements AfterContentChecked, Afte // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) export class MatTab implements OnInit, OnChanges, OnDestroy { - constructor(_viewContainerRef: ViewContainerRef, _closestTabGroup: any); + constructor(...args: unknown[]); ariaLabel: string; ariaLabelledby: string; bodyClass: string | string[]; @@ -185,12 +178,12 @@ export class MatTab implements OnInit, OnChanges, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatTabBody implements OnInit, OnDestroy { - constructor(_elementRef: ElementRef, _dir: Directionality, changeDetectorRef: ChangeDetectorRef); + constructor(...args: unknown[]); readonly _afterLeavingCenter: EventEmitter; animationDuration: string; readonly _beforeCentering: EventEmitter; @@ -213,7 +206,7 @@ export class MatTabBody implements OnInit, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -221,7 +214,7 @@ export type MatTabBodyOriginState = 'left' | 'right'; // @public export class MatTabBodyPortal extends CdkPortalOutlet implements OnInit, OnDestroy { - constructor(componentFactoryResolver: ComponentFactoryResolver, viewContainerRef: ViewContainerRef, _host: MatTabBody, _document: any); + constructor(...args: unknown[]); ngOnDestroy(): void; ngOnInit(): void; // (undocumented) @@ -241,7 +234,7 @@ export class MatTabChangeEvent { // @public export class MatTabContent { - constructor(template: TemplateRef); + constructor(...args: unknown[]); // (undocumented) template: TemplateRef; // (undocumented) @@ -252,13 +245,13 @@ export class MatTabContent { // @public export class MatTabGroup implements AfterContentInit, AfterContentChecked, OnDestroy { - constructor(_elementRef: ElementRef, _changeDetectorRef: ChangeDetectorRef, defaultConfig?: MatTabsConfig, _animationMode?: string | undefined); + constructor(...args: unknown[]); _allTabs: QueryList; readonly animationDone: EventEmitter; get animationDuration(): string; set animationDuration(value: string | number); // (undocumented) - _animationMode?: string | undefined; + _animationMode: "NoopAnimations" | "BrowserAnimations" | null; ariaLabel: string; ariaLabelledby: string; // @deprecated @@ -271,7 +264,7 @@ export class MatTabGroup implements AfterContentInit, AfterContentChecked, OnDes disableRipple: boolean; dynamicHeight: boolean; // (undocumented) - readonly _elementRef: ElementRef; + readonly _elementRef: ElementRef; get fitInkBarToContent(): boolean; set fitInkBarToContent(value: boolean); readonly focusChange: EventEmitter; @@ -324,7 +317,7 @@ export class MatTabGroup implements AfterContentInit, AfterContentChecked, OnDes // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -339,7 +332,6 @@ export interface MatTabGroupBaseHeader { // @public export class MatTabHeader extends MatPaginatedTabHeader implements AfterContentChecked, AfterContentInit, AfterViewInit, OnDestroy { - constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, viewportRuler: ViewportRuler, dir: Directionality, ngZone: NgZone, platform: Platform, animationMode?: string); ariaLabel: string; ariaLabelledby: string; disableRipple: boolean; @@ -366,7 +358,7 @@ export class MatTabHeader extends MatPaginatedTabHeader implements AfterContentC // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -374,21 +366,19 @@ export type MatTabHeaderPosition = 'above' | 'below'; // @public export class MatTabLabel extends CdkPortal { - constructor(templateRef: TemplateRef, viewContainerRef: ViewContainerRef, _closestTab: any); // (undocumented) _closestTab: any; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatTabLabelWrapper extends InkBarItem { - constructor(elementRef: ElementRef); disabled: boolean; // (undocumented) - elementRef: ElementRef; + elementRef: ElementRef; focus(): void; // (undocumented) getOffsetLeft(): number; @@ -404,13 +394,13 @@ export class MatTabLabelWrapper extends InkBarItem { // @public export class MatTabLink extends InkBarItem implements AfterViewInit, OnDestroy, RippleTarget, FocusableOption { - constructor(_tabNavBar: MatTabNav, - elementRef: ElementRef, globalRippleOptions: RippleGlobalOptions | null, tabIndex: string, _focusMonitor: FocusMonitor, animationMode?: string); + constructor(...args: unknown[]); get active(): boolean; set active(value: boolean); disabled: boolean; disableRipple: boolean; - elementRef: ElementRef; + // (undocumented) + elementRef: ElementRef; focus(): void; // (undocumented) _getAriaControls(): string | null; @@ -447,12 +437,12 @@ export class MatTabLink extends InkBarItem implements AfterViewInit, OnDestroy, // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public export class MatTabNav extends MatPaginatedTabHeader implements AfterContentChecked, AfterContentInit, OnDestroy, AfterViewInit { - constructor(elementRef: ElementRef, dir: Directionality, ngZone: NgZone, changeDetectorRef: ChangeDetectorRef, viewportRuler: ViewportRuler, platform: Platform, animationMode?: string, defaultConfig?: MatTabsConfig); + constructor(...args: unknown[]); // (undocumented) get animationDuration(): string; set animationDuration(value: string | number); @@ -497,7 +487,7 @@ export class MatTabNav extends MatPaginatedTabHeader implements AfterContentChec // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/toolbar.md b/tools/public_api_guard/material/toolbar.md index 34b6cb9ca0c0..8031848e3fe8 100644 --- a/tools/public_api_guard/material/toolbar.md +++ b/tools/public_api_guard/material/toolbar.md @@ -8,15 +8,14 @@ import { AfterViewInit } from '@angular/core'; import { ElementRef } from '@angular/core'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/core'; -import { Platform } from '@angular/cdk/platform'; import { QueryList } from '@angular/core'; // @public (undocumented) export class MatToolbar implements AfterViewInit { - constructor(_elementRef: ElementRef, _platform: Platform, document?: any); + constructor(...args: unknown[]); color?: string | null; // (undocumented) - protected _elementRef: ElementRef; + protected _elementRef: ElementRef; // (undocumented) ngAfterViewInit(): void; _toolbarRows: QueryList; diff --git a/tools/public_api_guard/material/tooltip.md b/tools/public_api_guard/material/tooltip.md index 5920a5dfc5ac..1c83fa4db149 100644 --- a/tools/public_api_guard/material/tooltip.md +++ b/tools/public_api_guard/material/tooltip.md @@ -6,13 +6,10 @@ import { AfterViewInit } from '@angular/core'; import { AnimationTriggerMetadata } from '@angular/animations'; -import { AriaDescriber } from '@angular/cdk/a11y'; import { BooleanInput } from '@angular/cdk/coercion'; -import { ChangeDetectorRef } from '@angular/core'; import { ConnectedPosition } from '@angular/cdk/overlay'; import { Directionality } from '@angular/cdk/bidi'; import { ElementRef } from '@angular/core'; -import { FocusMonitor } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import * as i1 from '@angular/cdk/a11y'; import * as i2 from '@angular/common'; @@ -20,7 +17,6 @@ import * as i3 from '@angular/cdk/overlay'; import * as i4 from '@angular/material/core'; import * as i6 from '@angular/cdk/scrolling'; import { InjectionToken } from '@angular/core'; -import { NgZone } from '@angular/core'; import { NumberInput } from '@angular/cdk/coercion'; import { Observable } from 'rxjs'; import { OnDestroy } from '@angular/core'; @@ -28,10 +24,7 @@ import { OriginConnectionPosition } from '@angular/cdk/overlay'; import { Overlay } from '@angular/cdk/overlay'; import { OverlayConnectionPosition } from '@angular/cdk/overlay'; import { OverlayRef } from '@angular/cdk/overlay'; -import { Platform } from '@angular/cdk/platform'; -import { ScrollDispatcher } from '@angular/cdk/overlay'; import { ScrollStrategy } from '@angular/cdk/overlay'; -import { ViewContainerRef } from '@angular/core'; // @public export function getMatTooltipInvalidPositionError(position: string): Error; @@ -57,7 +50,7 @@ export const MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER: { // @public export class MatTooltip implements OnDestroy, AfterViewInit { - constructor(_overlay: Overlay, _elementRef: ElementRef, _scrollDispatcher: ScrollDispatcher, _viewContainerRef: ViewContainerRef, _ngZone: NgZone, _platform: Platform, _ariaDescriber: AriaDescriber, _focusMonitor: FocusMonitor, scrollStrategy: any, _dir: Directionality, _defaultOptions: MatTooltipDefaultOptions, _document: any); + constructor(...args: unknown[]); protected _addOffset(position: ConnectedPosition): ConnectedPosition; // (undocumented) protected _dir: Directionality; @@ -108,7 +101,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit { // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public @@ -147,7 +140,7 @@ export const TOOLTIP_PANEL_CLASS = "mat-mdc-tooltip-panel"; // @public export class TooltipComponent implements OnDestroy { - constructor(_changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef, animationMode?: string); + constructor(...args: unknown[]); afterHidden(): Observable; _cancelPendingAnimations(): void; // (undocumented) @@ -175,7 +168,7 @@ export class TooltipComponent implements OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public diff --git a/tools/public_api_guard/material/tree.md b/tools/public_api_guard/material/tree.md index 5844b80b21e7..d63d1c0ee9ca 100644 --- a/tools/public_api_guard/material/tree.md +++ b/tools/public_api_guard/material/tree.md @@ -14,12 +14,10 @@ import { CdkTreeNodePadding } from '@angular/cdk/tree'; import { CdkTreeNodeToggle } from '@angular/cdk/tree'; import { CollectionViewer } from '@angular/cdk/collections'; import { DataSource } from '@angular/cdk/collections'; -import { ElementRef } from '@angular/core'; import { FlatTreeControl } from '@angular/cdk/tree'; import * as i0 from '@angular/core'; import * as i1 from '@angular/cdk/tree'; import * as i2 from '@angular/material/core'; -import { IterableDiffers } from '@angular/core'; import { Observable } from 'rxjs'; import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; @@ -28,7 +26,6 @@ import { ViewContainerRef } from '@angular/core'; // @public export class MatNestedTreeNode extends CdkNestedTreeNode implements AfterContentInit, OnDestroy, OnInit { - constructor(elementRef: ElementRef, tree: CdkTree, differs: IterableDiffers, tabIndex: string); // @deprecated get disabled(): boolean; set disabled(value: boolean); @@ -49,7 +46,7 @@ export class MatNestedTreeNode extends CdkNestedTreeNode impleme // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration, "mat-nested-tree-node", ["matNestedTreeNode"], { "node": { "alias": "matNestedTreeNode"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; }, { "activation": "activation"; "expandedChange": "expandedChange"; }, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, null, null, { attribute: "tabindex"; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public @@ -115,8 +112,7 @@ export class MatTreeNestedDataSource extends DataSource { // @public export class MatTreeNode extends CdkTreeNode implements OnInit, OnDestroy { - constructor(elementRef: ElementRef, tree: CdkTree, - tabIndex: string); + constructor(...args: unknown[]); // @deprecated defaultTabIndex: number; // @deprecated @@ -138,7 +134,7 @@ export class MatTreeNode extends CdkTreeNode implements OnInit, // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration, "mat-tree-node", ["matTreeNode"], { "tabIndexInputBinding": { "alias": "tabIndex"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "activation": "activation"; "expandedChange": "expandedChange"; }, never, never, true, never>; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration, [null, null, { attribute: "tabindex"; }]>; + static ɵfac: i0.ɵɵFactoryDeclaration, never>; } // @public @@ -153,15 +149,14 @@ export class MatTreeNodeDef extends CdkTreeNodeDef { // @public export class MatTreeNodeOutlet implements CdkTreeNodeOutlet { - constructor(viewContainer: ViewContainerRef, _node?: any); // (undocumented) - _node?: any; + _node: {} | null; // (undocumented) viewContainer: ViewContainerRef; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public