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
6 changes: 2 additions & 4 deletions goldens/material/datepicker/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class MatCalendarCell<D = any> {
// (undocumented)
compareValue: number;
// (undocumented)
cssClasses: MatCalendarCellCssClasses;
readonly cssClasses: string | string[] | Record<string, any> | undefined;
// (undocumented)
displayValue: string;
// (undocumented)
Expand All @@ -246,9 +246,7 @@ export class MatCalendarCell<D = any> {
export type MatCalendarCellClassFunction<D> = (date: D, view: 'month' | 'year' | 'multi-year') => MatCalendarCellCssClasses;

// @public
export type MatCalendarCellCssClasses = string | string[] | Set<string> | {
[key: string]: any;
};
export type MatCalendarCellCssClasses = string | string[] | Set<string> | Record<string, any>;

// @public
export class MatCalendarHeader<D> {
Expand Down
2 changes: 1 addition & 1 deletion src/material/datepicker/calendar-body.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<button
type="button"
class="mat-calendar-body-cell"
[ngClass]="item.cssClasses"
[class]="item.cssClasses"
[tabindex]="_isActiveCell(rowIndex, colIndex) ? 0 : -1"
[class.mat-calendar-body-disabled]="!item.enabled"
[class.mat-calendar-body-active]="_isActiveCell(rowIndex, colIndex)"
Expand Down
11 changes: 6 additions & 5 deletions src/material/datepicker/calendar-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ import {
Renderer2,
} from '@angular/core';
import {_IdGenerator} from '@angular/cdk/a11y';
import {NgClass} from '@angular/common';
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
import {_StructuralStylesLoader} from '../core';
import {MatDatepickerIntl} from './datepicker-intl';

/** Extra CSS classes that can be associated with a calendar cell. */
export type MatCalendarCellCssClasses = string | string[] | Set<string> | {[key: string]: any};
export type MatCalendarCellCssClasses = string | string[] | Set<string> | Record<string, any>;

/** Function that can generate the extra classes that should be added to a calendar cell. */
export type MatCalendarCellClassFunction<D> = (
Expand All @@ -48,16 +47,19 @@ let uniqueIdCounter = 0;
*/
export class MatCalendarCell<D = any> {
readonly id = uniqueIdCounter++;
readonly cssClasses: string | string[] | Record<string, any> | undefined;

constructor(
public value: number,
public displayValue: string,
public ariaLabel: string,
public enabled: boolean,
public cssClasses: MatCalendarCellCssClasses = {},
cssClasses?: MatCalendarCellCssClasses,
public compareValue = value,
public rawValue?: D,
) {}
) {
this.cssClasses = cssClasses instanceof Set ? Array.from(cssClasses) : cssClasses;
}
}

/** Event emitted when a date inside the calendar is triggered as a result of a user action. */
Expand Down Expand Up @@ -95,7 +97,6 @@ const passiveEventOptions = {passive: true};
exportAs: 'matCalendarBody',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgClass],
})
export class MatCalendarBody<D = any> implements OnChanges, OnDestroy, AfterViewChecked {
private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
Expand Down
Loading