MCPcopy Create free account
hub / github.com/angular/components / MatCalendarHeader

Class MatCalendarHeader

src/material/datepicker/calendar.ts:61–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 imports: [MatButton, MatIconButton, MatTooltip],
60})
61export class MatCalendarHeader<D> {
62 private _intl = inject(MatDatepickerIntl);
63 calendar = inject<MatCalendar<D>>(MatCalendar);
64 private _dateAdapter = inject<DateAdapter<D>>(DateAdapter, {optional: true})!;
65 private _dateFormats = inject<MatDateFormats>(MAT_DATE_FORMATS, {optional: true})!;
66 private _periodButtonText!: string;
67 private _periodButtonDescription!: string;
68 private _periodButtonLabel!: string;
69 private _prevButtonLabel!: string;
70 private _nextButtonLabel!: string;
71
72 constructor() {
73 inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
74 const changeDetectorRef = inject(ChangeDetectorRef);
75 this._updateLabels();
76 this.calendar.stateChanges.subscribe(() => {
77 this._updateLabels();
78 changeDetectorRef.markForCheck();
79 });
80 }
81
82 /** The display text for the current calendar view. */
83 get periodButtonText(): string {
84 return this._periodButtonText;
85 }
86
87 /** The aria description for the current calendar view. */
88 get periodButtonDescription(): string {
89 return this._periodButtonDescription;
90 }
91
92 /** The `aria-label` for changing the calendar view. */
93 get periodButtonLabel(): string {
94 return this._periodButtonLabel;
95 }
96
97 /** The label for the previous button. */
98 get prevButtonLabel(): string {
99 return this._prevButtonLabel;
100 }
101
102 /** The label for the next button. */
103 get nextButtonLabel(): string {
104 return this._nextButtonLabel;
105 }
106
107 /** Handles user clicks on the period label. */
108 currentPeriodClicked(): void {
109 this.calendar.currentView = this.calendar.currentView == 'month' ? 'multi-year' : 'month';
110 }
111
112 /** Handles user clicks on the previous button. */
113 previousClicked(): void {
114 if (this.previousEnabled()) {
115 this.calendar.activeDate =
116 this.calendar.currentView == 'month'
117 ? this._dateAdapter.addCalendarMonths(this.calendar.activeDate, -1)
118 : this._dateAdapter.addCalendarYears(

Callers

nothing calls this directly

Calls 1

getIdMethod · 0.45

Tested by

no test coverage detected