fullcalendar
Version:
FullCalendar Vanilla JS package for rendering a calendar
88 lines (84 loc) • 5.43 kB
JavaScript
import { d as dayGridPlugin } from './a51991fc.js';
import { jsx } from 'preact/jsx-runtime';
import { e as DateComponent, m as memoize, d as NowTimer } from './66c53e04.js';
import { c as createDayHeaderFormatter, a as buildDateRowConfigs, D as DayTableSlicer } from './515d1f26.js';
import { b as buildTimeColsModel, a as buildDayRanges, o as organizeSegsByCol, s as splitInteractionByCol, A as AllDaySplitter, D as DayTimeColsSlicer, T as TimeGridLayout } from './b657da56.js';
class TimeGridView extends DateComponent {
constructor() {
super(...arguments);
// memo
this.createDayHeaderFormatter = memoize(createDayHeaderFormatter);
this.buildTimeColsModel = memoize(buildTimeColsModel);
this.buildDayRanges = memoize(buildDayRanges);
this.buildDateRowConfigs = memoize(buildDateRowConfigs);
this.splitFgEventSegs = memoize((organizeSegsByCol));
this.splitBgEventSegs = memoize((organizeSegsByCol));
this.splitBusinessHourSegs = memoize((organizeSegsByCol));
this.splitNowIndicatorSegs = memoize((organizeSegsByCol));
this.splitDateSelectionSegs = memoize((organizeSegsByCol));
this.splitEventDrag = memoize(splitInteractionByCol);
this.splitEventResize = memoize(splitInteractionByCol);
// internal
this.allDaySplitter = new AllDaySplitter();
this.dayTableSlicer = new DayTableSlicer();
this.dayTimeColsSlicer = new DayTimeColsSlicer();
}
render() {
const { props, context } = this;
const { dateProfile } = props;
const { options, dateProfileGenerator } = context;
const dayTableModel = this.buildTimeColsModel(dateProfile, dateProfileGenerator, context.dateEnv);
const dayRanges = this.buildDayRanges(dayTableModel, dateProfile, context.dateEnv);
const splitProps = this.allDaySplitter.splitProps(props);
const allDayProps = this.dayTableSlicer.sliceProps(splitProps.allDay, dateProfile, options.nextDayThreshold, context, dayTableModel);
const timedProps = this.dayTimeColsSlicer.sliceProps(splitProps.timed, dateProfile, null, context, dayRanges);
const dayHeaderFormat = this.createDayHeaderFormatter(context.options.dayHeaderFormat, true, // datesRepDistinctDays
dayTableModel.colCount);
return (jsx(NowTimer, { unit: options.nowIndicator ? 'minute' : 'day' /* hacky */, children: (nowDate, todayRange) => {
const colCount = dayTableModel.cellRows[0].length;
const nowIndicatorSeg = !props.forPrint && options.nowIndicator &&
this.dayTimeColsSlicer.sliceNowDate(nowDate, dateProfile, options.nextDayThreshold, context, dayRanges);
const fgEventSegsByCol = this.splitFgEventSegs(timedProps.fgEventSegs, colCount);
const bgEventSegsByCol = this.splitBgEventSegs(timedProps.bgEventSegs, colCount);
const businessHourSegsByCol = this.splitBusinessHourSegs(timedProps.businessHourSegs, colCount);
const nowIndicatorSegsByCol = this.splitNowIndicatorSegs(nowIndicatorSeg, colCount);
const dateSelectionSegsByCol = this.splitDateSelectionSegs(timedProps.dateSelectionSegs, colCount);
const eventDragByCol = this.splitEventDrag(timedProps.eventDrag, colCount);
const eventResizeByCol = this.splitEventResize(timedProps.eventResize, colCount);
const headerTiers = this.buildDateRowConfigs(dayTableModel.headerDates, true, // datesRepDistinctDays
props.dateProfile, todayRange, dayHeaderFormat, context);
return (jsx(TimeGridLayout, { labelId: props.labelId, labelStr: props.labelStr, dateProfile: dateProfile, nowDate: nowDate, todayRange: todayRange, cells: dayTableModel.cellRows[0], forPrint: props.forPrint, className: props.className,
// header content
headerTiers: headerTiers,
// all-day content
fgEventSegs: allDayProps.fgEventSegs, bgEventSegs: allDayProps.bgEventSegs, businessHourSegs: allDayProps.businessHourSegs, dateSelectionSegs: allDayProps.dateSelectionSegs, eventDrag: allDayProps.eventDrag, eventResize: allDayProps.eventResize,
// timed content
fgEventSegsByCol: fgEventSegsByCol, bgEventSegsByCol: bgEventSegsByCol, businessHourSegsByCol: businessHourSegsByCol, nowIndicatorSegsByCol: nowIndicatorSegsByCol, dateSelectionSegsByCol: dateSelectionSegsByCol, eventDragByCol: eventDragByCol, eventResizeByCol: eventResizeByCol,
// universal content
eventSelection: props.eventSelection }));
} }));
}
}
var timeGridPlugin = {
name: 'timegrid',
initialView: 'timeGridWeek',
deps: [dayGridPlugin],
views: {
timeGrid: {
component: TimeGridView,
usesMinMaxTime: true, // indicates that slotMinTime/slotMaxTime affects rendering
allDaySlot: true,
slotDuration: '00:30:00',
slotEventOverlap: true, // a bad name. confused with overlap/constraint system
},
timeGridDay: {
type: 'timeGrid',
duration: { days: 1 },
},
timeGridWeek: {
type: 'timeGrid',
duration: { weeks: 1 },
},
},
};
export { timeGridPlugin as t };