import { CssDimValue } from '@fullcalendar/core' import { DateComponent, DayHeader, ViewProps, memoize, DateFormatter, getUniqueDomId } from '@fullcalendar/core/internal' import { TableRows, buildDayTableModel, DayTableSlicer } from '@fullcalendar/daygrid/internal' import { createElement, Ref } from '@fullcalendar/core/preact' export interface SingleMonthProps extends ViewProps { elRef?: Ref isoDateStr?: string titleFormat: DateFormatter width: CssDimValue tableWidth: number | null // solely for computation purposes clientWidth: number | null clientHeight: number | null } interface SingleMonthState { labelId: string } export class SingleMonth extends DateComponent { private buildDayTableModel = memoize(buildDayTableModel) private slicer = new DayTableSlicer() state: SingleMonthState = { labelId: getUniqueDomId(), } render() { const { props, state, context } = this const { dateProfile, forPrint } = props const { options } = context const dayTableModel = this.buildDayTableModel(dateProfile, context.dateProfileGenerator) const slicedProps = this.slicer.sliceProps(props, dateProfile, options.nextDayThreshold, context, dayTableModel) // ensure single-month has aspect ratio const tableHeight = props.tableWidth != null ? props.tableWidth / options.aspectRatio : null const rowCnt = dayTableModel.cells.length const rowHeight = tableHeight != null ? tableHeight / rowCnt : null return (
{context.dateEnv.format( props.dateProfile.currentRange.start, props.titleFormat, )}
) } }