import { CssDimValue, DayCellContentArg } from '@fullcalendar/core' import { DateMarker, DateComponent, DateRange, buildNavLinkAttrs, WeekNumberContainer, DayCellContainer, DateProfile, setRef, createFormatter, Dictionary, EventSegUiInteractionState, getUniqueDomId, hasCustomDayCellContent, addMs, DateEnv, } from '@fullcalendar/core/internal' import { Ref, ComponentChildren, createElement, createRef, ComponentChild, Fragment, } from '@fullcalendar/core/preact' import { TableCellMoreLink } from './TableCellMoreLink.js' import { TableSegPlacement } from './event-placement.js' export interface TableCellProps { elRef?: Ref date: DateMarker dateProfile: DateProfile extraRenderProps?: Dictionary extraDataAttrs?: Dictionary extraClassNames?: string[] extraDateSpan?: Dictionary innerElRef?: Ref bgContent: ComponentChildren fgContentElRef?: Ref // TODO: rename!!! classname confusion. is the "event" div fgContent: ComponentChildren moreCnt: number moreMarginTop: number showDayNumber: boolean showWeekNumber: boolean forceDayTop: boolean todayRange: DateRange eventSelection: string eventDrag: EventSegUiInteractionState | null eventResize: EventSegUiInteractionState | null singlePlacements: TableSegPlacement[] minHeight?: CssDimValue } const DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: 'narrow' }) export class TableCell extends DateComponent { private rootElRef = createRef() state = { dayNumberId: getUniqueDomId(), } render() { let { context, props, state, rootElRef } = this let { options, dateEnv } = context let { date, dateProfile } = props // TODO: memoize this? const isMonthStart = props.showDayNumber && shouldDisplayMonthStart(date, dateProfile.currentRange, dateEnv) return ( {(InnerContent, renderProps) => (
{props.showWeekNumber && ( )} {!renderProps.isDisabled && (props.showDayNumber || hasCustomDayCellContent(options) || props.forceDayTop) ? (
) : props.showDayNumber ? ( // for creating correct amount of space (see issue #7162)
 
) : undefined}
{props.fgContent}
{props.bgContent}
)}
) } handleRootEl = (el: HTMLElement) => { setRef(this.rootElRef, el) setRef(this.props.elRef, el) } } function renderTopInner(props: DayCellContentArg): ComponentChild { return props.dayNumberText ||   } function shouldDisplayMonthStart(date: DateMarker, currentRange: DateRange, dateEnv: DateEnv): boolean { const { start: currentStart, end: currentEnd } = currentRange const currentEndIncl = addMs(currentEnd, -1) const currentFirstYear = dateEnv.getYear(currentStart) const currentFirstMonth = dateEnv.getMonth(currentStart) const currentLastYear = dateEnv.getYear(currentEndIncl) const currentLastMonth = dateEnv.getMonth(currentEndIncl) // spans more than one month? return !(currentFirstYear === currentLastYear && currentFirstMonth === currentLastMonth) && Boolean( // first date in current view? date.valueOf() === currentStart.valueOf() || // a month-start that's within the current range? (dateEnv.getDay(date) === 1 && date.valueOf() < currentEnd.valueOf()), ) }