import { dispatch, upgrade } from '../../../../node_modules/@browserkids/dom/index.js'; export default class CalendarMonth extends HTMLElement { constructor() { super(); upgrade(this, ` `); } async onPostUpdate({ detail }) { const { selectedMonth } = detail; const { calendar } = window; const { $content } = this.$refs; const { weekdays, weeks, days } = await calendar.getCalendar({ date: selectedMonth }); const $weekdays = weekdays.map((weekday) => `${weekday}`).join(''); const $weeks = weeks.map((week) => `${week}`).join(''); const $days = days.map(({ day, isToday, isThisWeek, previousMonth, nextMonth, }) => { const cssClass = [ 'day', isToday ? '-today' : null, isThisWeek ? '-week' : null, previousMonth ? '-previous' : null, nextMonth ? '-next' : null, ] .filter(Boolean) .join(' '); return `${day.getDate()}`; }).join(''); $content.innerHTML = `