Skip to content

Commit cdbabf7

Browse files
mmalerbaandrewseguin
authored andcommitted
feat(datepicker): add year selection mode (#8565)
* feat(datepicker): add multi-year view. * fix broken tests * add calendar tests for multi-year * add tests for multi year view * update docs * address comments * address comments
1 parent 1701b98 commit cdbabf7

13 files changed

+639
-114
lines changed

src/lib/datepicker/calendar-body.ts

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export class MatCalendarCell {
3939
styleUrls: ['calendar-body.css'],
4040
host: {
4141
'class': 'mat-calendar-body',
42+
'role': 'grid',
43+
'attr.aria-readonly': 'true'
4244
},
4345
exportAs: 'matCalendarBody',
4446
encapsulation: ViewEncapsulation.None,

src/lib/datepicker/calendar.html

+13-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<button mat-button class="mat-calendar-period-button"
44
(click)="_currentPeriodClicked()" [attr.aria-label]="_periodButtonLabel">
55
{{_periodButtonText}}
6-
<div class="mat-calendar-arrow" [class.mat-calendar-invert]="!_monthView"></div>
6+
<div class="mat-calendar-arrow" [class.mat-calendar-invert]="_currentView != 'month'"></div>
77
</button>
88

99
<div class="mat-calendar-spacer"></div>
@@ -21,9 +21,9 @@
2121
</div>
2222

2323
<div class="mat-calendar-content" (keydown)="_handleCalendarBodyKeydown($event)"
24-
[ngSwitch]="_monthView" cdkMonitorSubtreeFocus>
24+
[ngSwitch]="_currentView" cdkMonitorSubtreeFocus>
2525
<mat-month-view
26-
*ngSwitchCase="true"
26+
*ngSwitchCase="'month'"
2727
[activeDate]="_activeDate"
2828
[selected]="selected"
2929
[dateFilter]="_dateFilterForViews"
@@ -32,10 +32,18 @@
3232
</mat-month-view>
3333

3434
<mat-year-view
35-
*ngSwitchDefault
35+
*ngSwitchCase="'year'"
3636
[activeDate]="_activeDate"
3737
[selected]="selected"
3838
[dateFilter]="_dateFilterForViews"
39-
(selectedChange)="_monthSelected($event)">
39+
(selectedChange)="_goToDateInView($event, 'month')">
4040
</mat-year-view>
41+
42+
<mat-multi-year-view
43+
*ngSwitchCase="'multi-year'"
44+
[activeDate]="_activeDate"
45+
[selected]="selected"
46+
[dateFilter]="_dateFilterForViews"
47+
(selectedChange)="_goToDateInView($event, 'year')">
48+
</mat-multi-year-view>
4149
</div>

0 commit comments

Comments
 (0)