@angular/material 12.2.0-rc.0 → 12.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/bundles/material-checkbox.umd.js +1 -1
  2. package/bundles/material-checkbox.umd.js.map +1 -1
  3. package/bundles/material-core.umd.js +15 -14
  4. package/bundles/material-core.umd.js.map +1 -1
  5. package/bundles/material-datepicker.umd.js +51 -8
  6. package/bundles/material-datepicker.umd.js.map +1 -1
  7. package/bundles/material-expansion.umd.js +1 -1
  8. package/bundles/material-expansion.umd.js.map +1 -1
  9. package/bundles/material-stepper.umd.js +1 -1
  10. package/bundles/material-stepper.umd.js.map +1 -1
  11. package/bundles/material-tabs.umd.js +1 -1
  12. package/checkbox/index.metadata.json +1 -1
  13. package/core/common-behaviors/common-module.d.ts +2 -2
  14. package/core/index.metadata.json +1 -1
  15. package/core/theming/_theming.scss +3 -1
  16. package/datepicker/index.metadata.json +1 -1
  17. package/datepicker/month-view.d.ts +6 -0
  18. package/datepicker/multi-year-view.d.ts +4 -0
  19. package/datepicker/year-view.d.ts +4 -0
  20. package/esm2015/checkbox/checkbox.js +2 -2
  21. package/esm2015/core/common-behaviors/common-module.js +15 -14
  22. package/esm2015/core/version.js +1 -1
  23. package/esm2015/datepicker/calendar-body.js +2 -2
  24. package/esm2015/datepicker/month-view.js +21 -4
  25. package/esm2015/datepicker/multi-year-view.js +16 -3
  26. package/esm2015/datepicker/year-view.js +16 -3
  27. package/esm2015/expansion/expansion-panel.js +2 -2
  28. package/esm2015/stepper/stepper.js +2 -2
  29. package/esm2015/tabs/tab-group.js +1 -1
  30. package/expansion/expansion-panel.d.ts +1 -1
  31. package/fesm2015/checkbox.js +1 -1
  32. package/fesm2015/checkbox.js.map +1 -1
  33. package/fesm2015/core.js +15 -14
  34. package/fesm2015/core.js.map +1 -1
  35. package/fesm2015/datepicker.js +51 -8
  36. package/fesm2015/datepicker.js.map +1 -1
  37. package/fesm2015/expansion.js +1 -1
  38. package/fesm2015/expansion.js.map +1 -1
  39. package/fesm2015/stepper.js +1 -1
  40. package/fesm2015/stepper.js.map +1 -1
  41. package/fesm2015/tabs.js +1 -1
  42. package/package.json +3 -6
  43. package/prebuilt-themes/deeppurple-amber.css +1 -1
  44. package/prebuilt-themes/indigo-pink.css +1 -1
  45. package/prebuilt-themes/pink-bluegrey.css +1 -1
  46. package/prebuilt-themes/purple-green.css +1 -1
  47. package/schematics/ng-add/index.js +1 -1
  48. package/schematics/ng-add/index.mjs +1 -1
  49. package/stepper/_stepper-theme.scss +6 -1
  50. package/stepper/index.metadata.json +1 -1
  51. package/tabs/index.metadata.json +1 -1
@@ -319,7 +319,7 @@ class MatCalendarBody {
319
319
  MatCalendarBody.decorators = [
320
320
  { type: Component, args: [{
321
321
  selector: '[mat-calendar-body]',
322
- template: "<!--\n If there's not enough space in the first row, create a separate label row. We mark this row as\n aria-hidden because we don't want it to be read out as one of the weeks in the month.\n-->\n<tr *ngIf=\"_firstRowOffset < labelMinRequiredCells\" aria-hidden=\"true\">\n <td class=\"mat-calendar-body-label\"\n [attr.colspan]=\"numCols\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n {{label}}\n </td>\n</tr>\n\n<!-- Create the first row separately so we can include a special spacer cell. -->\n<tr *ngFor=\"let row of rows; let rowIndex = index\" role=\"row\">\n <!--\n We mark this cell as aria-hidden so it doesn't get read out as one of the days in the week.\n The aspect ratio of the table cells is maintained by setting the top and bottom padding as a\n percentage of the width (a variant of the trick described here:\n https://www.w3schools.com/howto/howto_css_aspect_ratio.asp).\n -->\n <td *ngIf=\"rowIndex === 0 && _firstRowOffset\"\n aria-hidden=\"true\"\n class=\"mat-calendar-body-label\"\n [attr.colspan]=\"_firstRowOffset\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n {{_firstRowOffset >= labelMinRequiredCells ? label : ''}}\n </td>\n <td *ngFor=\"let item of row; let colIndex = index\"\n role=\"gridcell\"\n class=\"mat-calendar-body-cell\"\n [ngClass]=\"item.cssClasses\"\n [tabindex]=\"_isActiveCell(rowIndex, colIndex) ? 0 : -1\"\n [attr.data-mat-row]=\"rowIndex\"\n [attr.data-mat-col]=\"colIndex\"\n [class.mat-calendar-body-disabled]=\"!item.enabled\"\n [class.mat-calendar-body-active]=\"_isActiveCell(rowIndex, colIndex)\"\n [class.mat-calendar-body-range-start]=\"_isRangeStart(item.compareValue)\"\n [class.mat-calendar-body-range-end]=\"_isRangeEnd(item.compareValue)\"\n [class.mat-calendar-body-in-range]=\"_isInRange(item.compareValue)\"\n [class.mat-calendar-body-comparison-bridge-start]=\"_isComparisonBridgeStart(item.compareValue, rowIndex, colIndex)\"\n [class.mat-calendar-body-comparison-bridge-end]=\"_isComparisonBridgeEnd(item.compareValue, rowIndex, colIndex)\"\n [class.mat-calendar-body-comparison-start]=\"_isComparisonStart(item.compareValue)\"\n [class.mat-calendar-body-comparison-end]=\"_isComparisonEnd(item.compareValue)\"\n [class.mat-calendar-body-in-comparison-range]=\"_isInComparisonRange(item.compareValue)\"\n [class.mat-calendar-body-preview-start]=\"_isPreviewStart(item.compareValue)\"\n [class.mat-calendar-body-preview-end]=\"_isPreviewEnd(item.compareValue)\"\n [class.mat-calendar-body-in-preview]=\"_isInPreview(item.compareValue)\"\n [attr.aria-label]=\"item.ariaLabel\"\n [attr.aria-disabled]=\"!item.enabled || null\"\n [attr.aria-selected]=\"_isSelected(item.compareValue)\"\n (click)=\"_cellClicked(item, $event)\"\n [style.width]=\"_cellWidth\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n <div class=\"mat-calendar-body-cell-content mat-focus-indicator\"\n [class.mat-calendar-body-selected]=\"_isSelected(item.compareValue)\"\n [class.mat-calendar-body-comparison-identical]=\"_isComparisonIdentical(item.compareValue)\"\n [class.mat-calendar-body-today]=\"todayValue === item.compareValue\">\n {{item.displayValue}}\n </div>\n <div class=\"mat-calendar-body-cell-preview\"></div>\n </td>\n</tr>\n",
322
+ template: "<!--\n If there's not enough space in the first row, create a separate label row. We mark this row as\n aria-hidden because we don't want it to be read out as one of the weeks in the month.\n-->\n<tr *ngIf=\"_firstRowOffset < labelMinRequiredCells\" aria-hidden=\"true\">\n <td class=\"mat-calendar-body-label\"\n [attr.colspan]=\"numCols\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n {{label}}\n </td>\n</tr>\n\n<!-- Create the first row separately so we can include a special spacer cell. -->\n<tr *ngFor=\"let row of rows; let rowIndex = index\" role=\"row\">\n <!--\n This cell is purely decorative, but we can't put `aria-hidden` or `role=\"presentation\"` on it,\n because it throws off the week days for the rest of the row on NVDA. The aspect ratio of the\n table cells is maintained by setting the top and bottom padding as a percentage of the width\n (a variant of the trick described here: https://www.w3schools.com/howto/howto_css_aspect_ratio.asp).\n -->\n <td *ngIf=\"rowIndex === 0 && _firstRowOffset\"\n class=\"mat-calendar-body-label\"\n [attr.colspan]=\"_firstRowOffset\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n {{_firstRowOffset >= labelMinRequiredCells ? label : ''}}\n </td>\n <td *ngFor=\"let item of row; let colIndex = index\"\n role=\"gridcell\"\n class=\"mat-calendar-body-cell\"\n [ngClass]=\"item.cssClasses\"\n [tabindex]=\"_isActiveCell(rowIndex, colIndex) ? 0 : -1\"\n [attr.data-mat-row]=\"rowIndex\"\n [attr.data-mat-col]=\"colIndex\"\n [class.mat-calendar-body-disabled]=\"!item.enabled\"\n [class.mat-calendar-body-active]=\"_isActiveCell(rowIndex, colIndex)\"\n [class.mat-calendar-body-range-start]=\"_isRangeStart(item.compareValue)\"\n [class.mat-calendar-body-range-end]=\"_isRangeEnd(item.compareValue)\"\n [class.mat-calendar-body-in-range]=\"_isInRange(item.compareValue)\"\n [class.mat-calendar-body-comparison-bridge-start]=\"_isComparisonBridgeStart(item.compareValue, rowIndex, colIndex)\"\n [class.mat-calendar-body-comparison-bridge-end]=\"_isComparisonBridgeEnd(item.compareValue, rowIndex, colIndex)\"\n [class.mat-calendar-body-comparison-start]=\"_isComparisonStart(item.compareValue)\"\n [class.mat-calendar-body-comparison-end]=\"_isComparisonEnd(item.compareValue)\"\n [class.mat-calendar-body-in-comparison-range]=\"_isInComparisonRange(item.compareValue)\"\n [class.mat-calendar-body-preview-start]=\"_isPreviewStart(item.compareValue)\"\n [class.mat-calendar-body-preview-end]=\"_isPreviewEnd(item.compareValue)\"\n [class.mat-calendar-body-in-preview]=\"_isInPreview(item.compareValue)\"\n [attr.aria-label]=\"item.ariaLabel\"\n [attr.aria-disabled]=\"!item.enabled || null\"\n [attr.aria-selected]=\"_isSelected(item.compareValue)\"\n (click)=\"_cellClicked(item, $event)\"\n [style.width]=\"_cellWidth\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n <div class=\"mat-calendar-body-cell-content mat-focus-indicator\"\n [class.mat-calendar-body-selected]=\"_isSelected(item.compareValue)\"\n [class.mat-calendar-body-comparison-identical]=\"_isComparisonIdentical(item.compareValue)\"\n [class.mat-calendar-body-today]=\"todayValue === item.compareValue\">\n {{item.displayValue}}\n </div>\n <div class=\"mat-calendar-body-cell-preview\"></div>\n </td>\n</tr>\n",
323
323
  host: {
324
324
  'class': 'mat-calendar-body',
325
325
  },
@@ -754,9 +754,13 @@ class MatMonthView {
754
754
  break;
755
755
  case ENTER:
756
756
  case SPACE:
757
- if (!this.dateFilter || this.dateFilter(this._activeDate)) {
758
- this._dateSelected({ value: this._dateAdapter.getDate(this._activeDate), event });
757
+ this._selectionKeyPressed = true;
758
+ if (this._canSelect(this._activeDate)) {
759
759
  // Prevent unexpected default actions such as form submission.
760
+ // Note that we only prevent the default action here while the selection happens in
761
+ // `keyup` below. We can't do the selection here, because it can cause the calendar to
762
+ // reopen if focus is restored immediately. We also can't call `preventDefault` on `keyup`
763
+ // because it's too late (see #23305).
760
764
  event.preventDefault();
761
765
  }
762
766
  return;
@@ -781,6 +785,15 @@ class MatMonthView {
781
785
  // Prevent unexpected default actions such as form submission.
782
786
  event.preventDefault();
783
787
  }
788
+ /** Handles keyup events on the calendar body when calendar is in month view. */
789
+ _handleCalendarBodyKeyup(event) {
790
+ if (event.keyCode === SPACE || event.keyCode === ENTER) {
791
+ if (this._selectionKeyPressed && this._canSelect(this._activeDate)) {
792
+ this._dateSelected({ value: this._dateAdapter.getDate(this._activeDate), event });
793
+ }
794
+ this._selectionKeyPressed = false;
795
+ }
796
+ }
784
797
  /** Initializes this month view. */
785
798
  _init() {
786
799
  this._setRanges(this.selected);
@@ -895,11 +908,15 @@ class MatMonthView {
895
908
  this._comparisonRangeStart = this._getCellCompareValue(this.comparisonStart);
896
909
  this._comparisonRangeEnd = this._getCellCompareValue(this.comparisonEnd);
897
910
  }
911
+ /** Gets whether a date can be selected in the month view. */
912
+ _canSelect(date) {
913
+ return !this.dateFilter || this.dateFilter(date);
914
+ }
898
915
  }
899
916
  MatMonthView.decorators = [
900
917
  { type: Component, args: [{
901
918
  selector: 'mat-month-view',
902
- template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead class=\"mat-calendar-table-header\">\n <tr>\n <!-- For the day-of-the-week column header, we use an `<abbr>` element because VoiceOver\n ignores the `aria-label`. ChromeVox, however, does not read the full name\n for the `<abbr>`, so we still set `aria-label` on the header element. -->\n <th scope=\"col\" *ngFor=\"let day of _weekdays\" [attr.aria-label]=\"day.long\">\n <abbr class=\"mat-calendar-abbr\" [attr.title]=\"day.long\">{{day.narrow}}</abbr>\n </th>\n </tr>\n <tr><th aria-hidden=\"true\" class=\"mat-calendar-table-header-divider\" colspan=\"7\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [label]=\"_monthLabel\"\n [rows]=\"_weeks\"\n [todayValue]=\"_todayDate!\"\n [startValue]=\"_rangeStart!\"\n [endValue]=\"_rangeEnd!\"\n [comparisonStart]=\"_comparisonRangeStart\"\n [comparisonEnd]=\"_comparisonRangeEnd\"\n [previewStart]=\"_previewStart\"\n [previewEnd]=\"_previewEnd\"\n [isRange]=\"_isRange\"\n [labelMinRequiredCells]=\"3\"\n [activeCell]=\"_dateAdapter.getDate(activeDate) - 1\"\n (selectedValueChange)=\"_dateSelected($event)\"\n (previewChange)=\"_previewChanged($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n",
919
+ template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead class=\"mat-calendar-table-header\">\n <tr>\n <!-- For the day-of-the-week column header, we use an `<abbr>` element because VoiceOver\n ignores the `aria-label`. ChromeVox, however, does not read the full name\n for the `<abbr>`, so we still set `aria-label` on the header element. -->\n <th scope=\"col\" *ngFor=\"let day of _weekdays\" [attr.aria-label]=\"day.long\">\n <abbr class=\"mat-calendar-abbr\" [attr.title]=\"day.long\">{{day.narrow}}</abbr>\n </th>\n </tr>\n <tr><th aria-hidden=\"true\" class=\"mat-calendar-table-header-divider\" colspan=\"7\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [label]=\"_monthLabel\"\n [rows]=\"_weeks\"\n [todayValue]=\"_todayDate!\"\n [startValue]=\"_rangeStart!\"\n [endValue]=\"_rangeEnd!\"\n [comparisonStart]=\"_comparisonRangeStart\"\n [comparisonEnd]=\"_comparisonRangeEnd\"\n [previewStart]=\"_previewStart\"\n [previewEnd]=\"_previewEnd\"\n [isRange]=\"_isRange\"\n [labelMinRequiredCells]=\"3\"\n [activeCell]=\"_dateAdapter.getDate(activeDate) - 1\"\n (selectedValueChange)=\"_dateSelected($event)\"\n (previewChange)=\"_previewChanged($event)\"\n (keyup)=\"_handleCalendarBodyKeyup($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n",
903
920
  exportAs: 'matMonthView',
904
921
  encapsulation: ViewEncapsulation.None,
905
922
  changeDetection: ChangeDetectionStrategy.OnPush
@@ -1057,7 +1074,11 @@ class MatMultiYearView {
1057
1074
  break;
1058
1075
  case ENTER:
1059
1076
  case SPACE:
1060
- this._yearSelected({ value: this._dateAdapter.getYear(this._activeDate), event });
1077
+ // Note that we only prevent the default action here while the selection happens in
1078
+ // `keyup` below. We can't do the selection here, because it can cause the calendar to
1079
+ // reopen if focus is restored immediately. We also can't call `preventDefault` on `keyup`
1080
+ // because it's too late (see #23305).
1081
+ this._selectionKeyPressed = true;
1061
1082
  break;
1062
1083
  default:
1063
1084
  // Don't prevent default or focus active cell on keys that we don't explicitly handle.
@@ -1070,6 +1091,15 @@ class MatMultiYearView {
1070
1091
  // Prevent unexpected default actions such as form submission.
1071
1092
  event.preventDefault();
1072
1093
  }
1094
+ /** Handles keyup events on the calendar body when calendar is in multi-year view. */
1095
+ _handleCalendarBodyKeyup(event) {
1096
+ if (event.keyCode === SPACE || event.keyCode === ENTER) {
1097
+ if (this._selectionKeyPressed) {
1098
+ this._yearSelected({ value: this._dateAdapter.getYear(this._activeDate), event });
1099
+ }
1100
+ this._selectionKeyPressed = false;
1101
+ }
1102
+ }
1073
1103
  _getActiveCell() {
1074
1104
  return getActiveOffset(this._dateAdapter, this.activeDate, this.minDate, this.maxDate);
1075
1105
  }
@@ -1126,7 +1156,7 @@ class MatMultiYearView {
1126
1156
  MatMultiYearView.decorators = [
1127
1157
  { type: Component, args: [{
1128
1158
  selector: 'mat-multi-year-view',
1129
- template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead aria-hidden=\"true\" class=\"mat-calendar-table-header\">\n <tr><th class=\"mat-calendar-table-header-divider\" colspan=\"4\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [rows]=\"_years\"\n [todayValue]=\"_todayYear\"\n [startValue]=\"_selectedYear!\"\n [endValue]=\"_selectedYear!\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"_getActiveCell()\"\n (selectedValueChange)=\"_yearSelected($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n",
1159
+ template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead aria-hidden=\"true\" class=\"mat-calendar-table-header\">\n <tr><th class=\"mat-calendar-table-header-divider\" colspan=\"4\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [rows]=\"_years\"\n [todayValue]=\"_todayYear\"\n [startValue]=\"_selectedYear!\"\n [endValue]=\"_selectedYear!\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"_getActiveCell()\"\n (selectedValueChange)=\"_yearSelected($event)\"\n (keyup)=\"_handleCalendarBodyKeyup($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n",
1130
1160
  exportAs: 'matMultiYearView',
1131
1161
  encapsulation: ViewEncapsulation.None,
1132
1162
  changeDetection: ChangeDetectionStrategy.OnPush
@@ -1302,7 +1332,11 @@ class MatYearView {
1302
1332
  break;
1303
1333
  case ENTER:
1304
1334
  case SPACE:
1305
- this._monthSelected({ value: this._dateAdapter.getMonth(this._activeDate), event });
1335
+ // Note that we only prevent the default action here while the selection happens in
1336
+ // `keyup` below. We can't do the selection here, because it can cause the calendar to
1337
+ // reopen if focus is restored immediately. We also can't call `preventDefault` on `keyup`
1338
+ // because it's too late (see #23305).
1339
+ this._selectionKeyPressed = true;
1306
1340
  break;
1307
1341
  default:
1308
1342
  // Don't prevent default or focus active cell on keys that we don't explicitly handle.
@@ -1315,6 +1349,15 @@ class MatYearView {
1315
1349
  // Prevent unexpected default actions such as form submission.
1316
1350
  event.preventDefault();
1317
1351
  }
1352
+ /** Handles keyup events on the calendar body when calendar is in year view. */
1353
+ _handleCalendarBodyKeyup(event) {
1354
+ if (event.keyCode === SPACE || event.keyCode === ENTER) {
1355
+ if (this._selectionKeyPressed) {
1356
+ this._monthSelected({ value: this._dateAdapter.getMonth(this._activeDate), event });
1357
+ }
1358
+ this._selectionKeyPressed = false;
1359
+ }
1360
+ }
1318
1361
  /** Initializes this year view. */
1319
1362
  _init() {
1320
1363
  this._setSelectedMonth(this.selected);
@@ -1406,7 +1449,7 @@ class MatYearView {
1406
1449
  MatYearView.decorators = [
1407
1450
  { type: Component, args: [{
1408
1451
  selector: 'mat-year-view',
1409
- template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead aria-hidden=\"true\" class=\"mat-calendar-table-header\">\n <tr><th class=\"mat-calendar-table-header-divider\" colspan=\"4\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [label]=\"_yearLabel\"\n [rows]=\"_months\"\n [todayValue]=\"_todayMonth!\"\n [startValue]=\"_selectedMonth!\"\n [endValue]=\"_selectedMonth!\"\n [labelMinRequiredCells]=\"2\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"_dateAdapter.getMonth(activeDate)\"\n (selectedValueChange)=\"_monthSelected($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n",
1452
+ template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead aria-hidden=\"true\" class=\"mat-calendar-table-header\">\n <tr><th class=\"mat-calendar-table-header-divider\" colspan=\"4\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [label]=\"_yearLabel\"\n [rows]=\"_months\"\n [todayValue]=\"_todayMonth!\"\n [startValue]=\"_selectedMonth!\"\n [endValue]=\"_selectedMonth!\"\n [labelMinRequiredCells]=\"2\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"_dateAdapter.getMonth(activeDate)\"\n (selectedValueChange)=\"_monthSelected($event)\"\n (keyup)=\"_handleCalendarBodyKeyup($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n",
1410
1453
  exportAs: 'matYearView',
1411
1454
  encapsulation: ViewEncapsulation.None,
1412
1455
  changeDetection: ChangeDetectionStrategy.OnPush