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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions goldens/material/snack-bar/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import { TemplateRef } from '@angular/core';
import { ViewContainerRef } from '@angular/core';

// @public
export const MAT_SNACK_BAR_DATA: InjectionToken<any>;
export const MAT_SNACK_BAR_DATA: InjectionToken<unknown>;

// @public
export const MAT_SNACK_BAR_DEFAULT_OPTIONS: InjectionToken<MatSnackBarConfig<any>>;
export const MAT_SNACK_BAR_DEFAULT_OPTIONS: InjectionToken<MatSnackBarConfig<unknown>>;

// @public
export class MatSnackBar implements OnDestroy {
Expand All @@ -45,10 +45,10 @@ export class MatSnackBar implements OnDestroy {
// (undocumented)
ngOnDestroy(): void;
open(message: string, action?: string, config?: MatSnackBarConfig): MatSnackBarRef<TextOnlySnackBar>;
get _openedSnackBarRef(): MatSnackBarRef<any> | null;
set _openedSnackBarRef(value: MatSnackBarRef<any> | null);
openFromComponent<T, D = any>(component: ComponentType<T>, config?: MatSnackBarConfig<D>): MatSnackBarRef<T>;
openFromTemplate(template: TemplateRef<any>, config?: MatSnackBarConfig): MatSnackBarRef<EmbeddedViewRef<any>>;
get _openedSnackBarRef(): MatSnackBarRef<unknown> | null;
set _openedSnackBarRef(value: MatSnackBarRef<unknown> | null);
openFromComponent<T, D = unknown>(component: ComponentType<T>, config?: MatSnackBarConfig<D>): MatSnackBarRef<T>;
openFromTemplate<C = unknown>(template: TemplateRef<C>, config?: MatSnackBarConfig): MatSnackBarRef<EmbeddedViewRef<C>>;
simpleSnackBarComponent: typeof SimpleSnackBar;
snackBarContainerComponent: typeof MatSnackBarContainer;
// (undocumented)
Expand All @@ -74,7 +74,7 @@ export class MatSnackBarActions {
}

// @public
export class MatSnackBarConfig<D = any> {
export class MatSnackBarConfig<D = unknown> {
announcementMessage?: string;
data?: D | null;
direction?: Direction;
Expand Down Expand Up @@ -168,7 +168,7 @@ export class SimpleSnackBar implements TextOnlySnackBar {
constructor(...args: unknown[]);
action(): void;
// (undocumented)
data: any;
data: TextOnlySnackBarData;
get hasAction(): boolean;
// (undocumented)
snackBarRef: MatSnackBarRef<SimpleSnackBar>;
Expand All @@ -183,16 +183,21 @@ export interface TextOnlySnackBar {
// (undocumented)
action: () => void;
// (undocumented)
data: {
message: string;
action: string;
};
data: TextOnlySnackBarData;
// (undocumented)
hasAction: boolean;
// (undocumented)
snackBarRef: MatSnackBarRef<TextOnlySnackBar>;
}

// @public
export interface TextOnlySnackBarData {
// (undocumented)
action: string;
// (undocumented)
message: string;
}

// (No @packageDocumentation comment for this package)

```
8 changes: 4 additions & 4 deletions goldens/material/stepper/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentI
}

// @public
export class MatStepContent {
export class MatStepContent<C = unknown> {
constructor(...args: unknown[]);
// (undocumented)
_template: TemplateRef<any>;
_template: TemplateRef<C>;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<MatStepContent, "ng-template[matStepContent]", never, {}, {}, never, never, true, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<MatStepContent<any>, "ng-template[matStepContent]", never, {}, {}, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatStepContent, never>;
static ɵfac: i0.ɵɵFactoryDeclaration<MatStepContent<any>, never>;
}

// @public (undocumented)
Expand Down
4 changes: 2 additions & 2 deletions goldens/material/timepicker/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ export class MatTimepickerInput<D> implements MatTimepickerConnectedInput<D>, Co
// (undocumented)
ngOnDestroy(): void;
readonly openOnClick: InputSignalWithTransform<boolean, unknown>;
registerOnChange(fn: (value: any) => void): void;
registerOnChange(fn: (value: unknown) => void): void;
registerOnTouched(fn: () => void): void;
registerOnValidatorChange(fn: () => void): void;
setDisabledState(isDisabled: boolean): void;
readonly timepicker: InputSignal<MatTimepicker<D>>;
timepickerValueAssigned(value: D | null): void;
validate(control: AbstractControl): ValidationErrors | null;
readonly value: ModelSignal<D | null>;
writeValue(value: any): void;
writeValue(value: unknown): void;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<MatTimepickerInput<any>, "input[matTimepicker]", ["matTimepickerInput"], { "value": { "alias": "value"; "required": false; "isSignal": true; }; "timepicker": { "alias": "matTimepicker"; "required": true; "isSignal": true; }; "min": { "alias": "matTimepickerMin"; "required": false; "isSignal": true; }; "max": { "alias": "matTimepickerMax"; "required": false; "isSignal": true; }; "openOnClick": { "alias": "matTimepickerOpenOnClick"; "required": false; "isSignal": true; }; "disabledInput": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; }, never, never, true, never>;
// (undocumented)
Expand Down
6 changes: 3 additions & 3 deletions goldens/material/tooltip/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
y: number;
}): void;
get tooltipClass(): string | string[] | Set<string> | {
[key: string]: any;
[key: string]: unknown;
};
set tooltipClass(value: string | string[] | Set<string> | {
[key: string]: any;
[key: string]: unknown;
});
// (undocumented)
_tooltipInstance: TooltipComponent | null;
Expand Down Expand Up @@ -143,7 +143,7 @@ export class TooltipComponent implements OnDestroy {
show(delay: number): void;
_tooltip: ElementRef<HTMLElement>;
tooltipClass: string | string[] | Set<string> | {
[key: string]: any;
[key: string]: unknown;
};
_triggerElement: HTMLElement;
// (undocumented)
Expand Down
14 changes: 10 additions & 4 deletions src/material/snack-bar/simple-snack-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ import {MatSnackBarRef} from './snack-bar-ref';
import {MAT_SNACK_BAR_DATA} from './snack-bar-config';
import {MatSnackBarAction, MatSnackBarActions, MatSnackBarLabel} from './snack-bar-content';

/** Input data for a simple snack bar component that has a message and a single action. */
export interface TextOnlySnackBarData {
message: string;
action: string;
}

/**
* Interface for a simple snack bar component that has a message and a single action.
*/
export interface TextOnlySnackBar {
data: {message: string; action: string};
snackBarRef: MatSnackBarRef<TextOnlySnackBar>;
data: TextOnlySnackBarData;
snackBarRef: MatSnackBarRef<TextOnlySnackBar, TextOnlySnackBarData>;
action: () => void;
hasAction: boolean;
}
Expand All @@ -35,8 +41,8 @@ export interface TextOnlySnackBar {
},
})
export class SimpleSnackBar implements TextOnlySnackBar {
snackBarRef = inject<MatSnackBarRef<SimpleSnackBar>>(MatSnackBarRef);
data = inject(MAT_SNACK_BAR_DATA);
snackBarRef = inject<MatSnackBarRef<SimpleSnackBar, TextOnlySnackBarData>>(MatSnackBarRef);
data = inject<TextOnlySnackBarData>(MAT_SNACK_BAR_DATA);

constructor(...args: unknown[]);
constructor() {}
Expand Down
4 changes: 2 additions & 2 deletions src/material/snack-bar/snack-bar-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {AriaLivePoliteness} from '@angular/cdk/a11y';
import {Direction} from '@angular/cdk/bidi';

/** Injection token that can be used to access the data that was passed in to a snack bar. */
export const MAT_SNACK_BAR_DATA = new InjectionToken<any>('MatSnackBarData');
export const MAT_SNACK_BAR_DATA = new InjectionToken<unknown>('MatSnackBarData');

/** Possible values for horizontalPosition on MatSnackBarConfig. */
export type MatSnackBarHorizontalPosition = 'start' | 'center' | 'end' | 'left' | 'right';
Expand All @@ -22,7 +22,7 @@ export type MatSnackBarVerticalPosition = 'top' | 'bottom';
/**
* Configuration used when opening a snack-bar.
*/
export class MatSnackBarConfig<D = any> {
export class MatSnackBarConfig<D = unknown> {
/** The politeness level for the MatAriaLiveAnnouncer announcement. */
politeness?: AriaLivePoliteness = 'polite';

Expand Down
4 changes: 2 additions & 2 deletions src/material/snack-bar/snack-bar-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ const EXIT_ANIMATION = '_mat-snack-bar-exit';
'(animationcancel)': 'onAnimationEnd($event.animationName)',
},
})
export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy {
export class MatSnackBarContainer<D = unknown> extends BasePortalOutlet implements OnDestroy {
private _ngZone = inject(NgZone);
readonly _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
private _changeDetectorRef = inject(ChangeDetectorRef);
private _platform = inject(Platform);
protected _animationsDisabled = _animationsDisabled();
snackBarConfig = inject(MatSnackBarConfig);
snackBarConfig = inject<MatSnackBarConfig<D>>(MatSnackBarConfig);

private _document = inject(DOCUMENT);
private _trackedModals = new Set<Element>();
Expand Down
6 changes: 3 additions & 3 deletions src/material/snack-bar/snack-bar-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const MAX_TIMEOUT = Math.pow(2, 31) - 1;
/**
* Reference to a snack bar dispatched from the snack bar service.
*/
export class MatSnackBarRef<T> {
export class MatSnackBarRef<T, D = unknown> {
/** The instance of the component making up the content of the snack bar. */
instance: T;

/**
* The instance of the component making up the content of the snack bar.
* @docs-private
*/
containerInstance: MatSnackBarContainer;
containerInstance: MatSnackBarContainer<D>;

/** Subject for notifying the user that the snack bar has been dismissed. */
private readonly _afterDismissed = new Subject<MatSnackBarDismiss>();
Expand All @@ -51,7 +51,7 @@ export class MatSnackBarRef<T> {
private _dismissedByAction = false;

constructor(
containerInstance: MatSnackBarContainer,
containerInstance: MatSnackBarContainer<D>,
private _overlayRef: OverlayRef,
) {
this.containerInstance = containerInstance;
Expand Down
25 changes: 17 additions & 8 deletions src/material/snack-bar/snack-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
MatSnackBarRef,
SimpleSnackBar,
} from './index';
import {MAT_SNACK_BAR_DEFAULT_OPTIONS} from './snack-bar';
import {MAT_SNACK_BAR_DEFAULT_OPTIONS, SnackBarTemplateContext} from './snack-bar';
import {MATERIAL_ANIMATIONS} from '../core';

describe('MatSnackBar', () => {
Expand Down Expand Up @@ -571,7 +571,10 @@ describe('MatSnackBar', () => {
});

it('should inject the snack bar reference into the component', () => {
const snackBarRef = snackBar.openFromComponent(BurritosNotification);
const snackBarRef = snackBar.openFromComponent<
BurritosNotification,
BurritosNotificationData
>(BurritosNotification);

expect(snackBarRef.instance.snackBarRef)
.withContext('Expected component to have an injected snack bar reference.')
Expand All @@ -585,10 +588,11 @@ describe('MatSnackBar', () => {
});

it('should be able to inject arbitrary user data', () => {
const data: BurritosNotificationData = {
burritoType: 'Chimichanga',
};
const snackBarRef = snackBar.openFromComponent(BurritosNotification, {
data: {
burritoType: 'Chimichanga',
},
data,
});

expect(snackBarRef.instance.data)
Expand Down Expand Up @@ -997,17 +1001,22 @@ class ComponentWithChildViewContainer {
`,
})
class ComponentWithTemplateRef {
@ViewChild(TemplateRef) templateRef: TemplateRef<any>;
@ViewChild(TemplateRef) templateRef: TemplateRef<SnackBarTemplateContext<{value: string}>>;
localValue: string;
}

interface BurritosNotificationData {
burritoType: string;
}

/** Simple component for testing ComponentPortal. */
@Component({
template: '<p>Burritos are on the way.</p>',
})
class BurritosNotification {
snackBarRef = inject<MatSnackBarRef<BurritosNotification>>(MatSnackBarRef);
data = inject(MAT_SNACK_BAR_DATA);
snackBarRef =
inject<MatSnackBarRef<BurritosNotification, BurritosNotificationData>>(MatSnackBarRef);
data = inject<BurritosNotificationData>(MAT_SNACK_BAR_DATA);
}

@Component({
Expand Down
Loading
Loading