Skip to content
Merged
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
3 changes: 2 additions & 1 deletion goldens/material/timepicker/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class MatTimepicker<D> implements OnDestroy, MatOptionParentComponent {
readonly options: InputSignal<readonly MatTimepickerOption<D>[] | null>;
// (undocumented)
protected _options: Signal<readonly MatOption<any>[]>;
readonly panelClass: InputSignal<string | string[] | undefined>;
readonly panelId: string;
// (undocumented)
protected _panelTemplate: Signal<TemplateRef<unknown>>;
Expand All @@ -67,7 +68,7 @@ export class MatTimepicker<D> implements OnDestroy, MatOptionParentComponent {
// (undocumented)
protected _timeOptions: readonly MatTimepickerOption<D>[];
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<MatTimepicker<any>, "mat-timepicker", ["matTimepicker"], { "interval": { "alias": "interval"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "disableRipple": { "alias": "disableRipple"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; }, { "selected": "selected"; "opened": "opened"; "closed": "closed"; }, never, never, true, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatTimepicker<any>, "mat-timepicker", ["matTimepicker"], { "interval": { "alias": "interval"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "disableRipple": { "alias": "disableRipple"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "panelClass": { "alias": "panelClass"; "required": false; "isSignal": true; }; }, { "selected": "selected"; "opened": "opened"; "closed": "closed"; }, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatTimepicker<any>, never>;
}
Expand Down
15 changes: 14 additions & 1 deletion src/material/timepicker/timepicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,17 @@ describe('MatTimepicker', () => {
fixture.detectChanges();
expect(input.hasAttribute('aria-activedescendant')).toBe(false);
});

it('should be able to set classes on the panel', () => {
const fixture = TestBed.createComponent(StandaloneTimepicker);
fixture.componentInstance.panelClass.set(['foo', 'bar']);
fixture.detectChanges();
getInput(fixture).click();
fixture.detectChanges();
const classList = fixture.nativeElement.querySelector('.cdk-overlay-pane').classList;
expect(classList).toContain('foo');
expect(classList).toContain('bar');
});
});

describe('forms integration', () => {
Expand Down Expand Up @@ -1415,7 +1426,8 @@ describe('MatTimepicker', () => {
[interval]="interval()"
[options]="customOptions()"
[aria-label]="ariaLabel()"
[aria-labelledby]="ariaLabelledby()"/>
[aria-labelledby]="ariaLabelledby()"
[panelClass]="panelClass()"/>
<mat-timepicker-toggle
[for]="picker"
[aria-label]="toggleAriaLabel()"
Expand All @@ -1439,6 +1451,7 @@ class StandaloneTimepicker {
readonly toggleTabIndex = signal<number>(0);
readonly customOptions = signal<MatTimepickerOption<Date>[] | null>(null);
readonly openOnClick = signal(true);
readonly panelClass = signal<string[]>([]);
readonly openedSpy = jasmine.createSpy('opened');
readonly closedSpy = jasmine.createSpy('closed');
readonly selectedSpy = jasmine.createSpy('selected');
Expand Down
4 changes: 4 additions & 0 deletions src/material/timepicker/timepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ export class MatTimepicker<D> implements OnDestroy, MatOptionParentComponent {
/** Whether the timepicker is currently disabled. */
readonly disabled: Signal<boolean> = computed(() => !!this._input()?.disabled());

/** Classes to be passed to the timepicker panel. */
readonly panelClass = input<string | string[]>();

constructor() {
if (typeof ngDevMode === 'undefined' || ngDevMode) {
validateAdapter(this._dateAdapter, this._dateFormats);
Expand Down Expand Up @@ -383,6 +386,7 @@ export class MatTimepicker<D> implements OnDestroy, MatOptionParentComponent {
direction: this._dir || 'ltr',
hasBackdrop: false,
disableAnimations: this._animationsDisabled,
panelClass: this.panelClass(),
});

this._overlayRef.detachments().subscribe(() => this.close());
Expand Down
Loading