Creates MatCalendarCells for the dates in this month.
()
| 514 | |
| 515 | /** Creates MatCalendarCells for the dates in this month. */ |
| 516 | private _createWeekCells() { |
| 517 | const daysInMonth = this._dateAdapter.getNumDaysInMonth(this.activeDate); |
| 518 | const dateNames = this._dateAdapter.getDateNames(); |
| 519 | const weeks: MatCalendarCell[][] = [[]]; |
| 520 | for (let i = 0, cell = this._firstWeekOffset(); i < daysInMonth; i++, cell++) { |
| 521 | if (cell == DAYS_PER_WEEK) { |
| 522 | weeks.push([]); |
| 523 | cell = 0; |
| 524 | } |
| 525 | const date = this._dateAdapter.createDate( |
| 526 | this._dateAdapter.getYear(this.activeDate), |
| 527 | this._dateAdapter.getMonth(this.activeDate), |
| 528 | i + 1, |
| 529 | ); |
| 530 | const enabled = this._shouldEnableDate(date); |
| 531 | const ariaLabel = this._dateAdapter.format(date, this._dateFormats.display.dateA11yLabel); |
| 532 | const cellClasses = this.dateClass ? this.dateClass(date, 'month') : undefined; |
| 533 | |
| 534 | weeks[weeks.length - 1].push( |
| 535 | new MatCalendarCell<D>( |
| 536 | i + 1, |
| 537 | dateNames[i], |
| 538 | ariaLabel, |
| 539 | enabled, |
| 540 | cellClasses, |
| 541 | this._getCellCompareValue(date)!, |
| 542 | date, |
| 543 | ), |
| 544 | ); |
| 545 | } |
| 546 | this._weeks.set(weeks); |
| 547 | } |
| 548 | |
| 549 | /** Date filter for the month */ |
| 550 | private _shouldEnableDate(date: D): boolean { |
no test coverage detected