| ${week.number} | ` : nothing} +|
| + ${week.number} + | + ` + : nothing} ${week.days.map(day => this.renderDay(day))}|
| ${this.localizedWeekOfYear} | ` : nothing} - ${this.weekDays.map(day => html`${day.short} | `)} +
|---|---|
| + ${this.localizedWeekOfYear} + | + ` + : nothing} + ${this.weekDays.map(day => html`${day.short} | `)}`; - } else { - const parts = this.getDayParts(day).join(' '), - ariaLabel = `${day.date.getDate()}, ${format(day.date, this.locale, { weekday: 'long' })} ${format(day.date, this.locale, { month: 'long', year: 'numeric' })}`; + return html` | `; + } + + const parts = this.getDayParts(day), + selected = parts.includes('selected'); + + // If the custom renderer returned `undefined`, we fall back to the default rendering + if (!template) { + const autofocus = this.#hasAutofocus(day, selected); template = - this.readonly || !day.currentMonth || day.unselectable - ? html`${day.date.getDate()}` + this.readonly || day.disabled || day.outOfRange + ? html` + + ` : html` + ${day.indicator?.label + ? html` + | this.#onClick(event, day)} data-date=${day.date.toISOString()}>${template} | +${template} | `; } - /** Returns an array of part names for a day. */ + /** Returns the default aria-label for a given day. */ + getDayLabel = (day: Day): string => { + return `${day.date.getDate()}, ${format(day.date, this.locale, { weekday: 'long' })} ${format(day.date, this.locale, { month: 'long', year: 'numeric' })}`; + }; + + /** Returns an array of part names for a given day. */ getDayParts = (day: Day): string[] => { return [ 'day', + day.disabled ? 'disabled' : '', + day.indicator ? 'indicator' : '', + day.indicator?.color ? `indicator-${day.indicator.color}` : '', day.nextMonth ? 'next-month' : '', + day.outOfRange ? 'out-of-range' : '', day.previousMonth ? 'previous-month' : '', day.today ? 'today' : '', - day.unselectable ? 'unselectable' : '', this.selected && isSameDate(day.date, this.selected) ? 'selected' : '' ].filter(part => part !== ''); }; - focusDay(day: Date): void { - const button = this.renderRoot.querySelector