/*! FullCalendar v5.10.2 Docs & License: https://fullcalendar.io/ (c) 2021 Adam Shaw */ import './main.css'; import { createRef, getStickyHeaderDates, createElement, ViewRoot, SimpleScrollGrid, getStickyFooterScrollbar, renderScrollShim, DateComponent, buildNavLinkAttrs, DayCellContent, Fragment, BaseComponent, createFormatter, StandardEvent, buildSegTimeText, EventRoot, getSegAnchorAttrs, memoize, MoreLinkRoot, getSegMeta, createAriaClickAttrs, getUniqueDomId, setRef, DayCellRoot, WeekNumberRoot, buildEntryKey, intersectSpans, SegHierarchy, intersectRanges, addDays, RefMap, sortEventSegs, isPropsEqual, buildEventRangeKey, BgEvent, renderFill, PositionCache, NowTimer, Slicer, DayHeader, DaySeriesModel, DayTableModel, addWeeks, diffWeeks, DateProfileGenerator, createPlugin } from '@fullcalendar/common'; import { __extends, __assign, __spreadArray } from 'tslib'; /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells. ----------------------------------------------------------------------------------------------------------------------*/ // It is a manager for a Table subcomponent, which does most of the heavy lifting. // It is responsible for managing width/height. var TableView = /** @class */ (function (_super) { __extends(TableView, _super); function TableView() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.headerElRef = createRef(); return _this; } TableView.prototype.renderSimpleLayout = function (headerRowContent, bodyContent) { var _a = this, props = _a.props, context = _a.context; var sections = []; var stickyHeaderDates = getStickyHeaderDates(context.options); if (headerRowContent) { sections.push({ type: 'header', key: 'header', isSticky: stickyHeaderDates, chunk: { elRef: this.headerElRef, tableClassName: 'fc-col-header', rowContent: headerRowContent, }, }); } sections.push({ type: 'body', key: 'body', liquid: true, chunk: { content: bodyContent }, }); return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') }, createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [] /* TODO: make optional? */, sections: sections }))); })); }; TableView.prototype.renderHScrollLayout = function (headerRowContent, bodyContent, colCnt, dayMinWidth) { var ScrollGrid = this.context.pluginHooks.scrollGridImpl; if (!ScrollGrid) { throw new Error('No ScrollGrid implementation'); } var _a = this, props = _a.props, context = _a.context; var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options); var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options); var sections = []; if (headerRowContent) { sections.push({ type: 'header', key: 'header', isSticky: stickyHeaderDates, chunks: [{ key: 'main', elRef: this.headerElRef, tableClassName: 'fc-col-header', rowContent: headerRowContent, }], }); } sections.push({ type: 'body', key: 'body', liquid: true, chunks: [{ key: 'main', content: bodyContent, }], }); if (stickyFooterScrollbar) { sections.push({ type: 'footer', key: 'footer', isSticky: true, chunks: [{ key: 'main', content: renderScrollShim, }], }); } return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') }, createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections: sections }))); })); }; return TableView; }(DateComponent)); function splitSegsByRow(segs, rowCnt) { var byRow = []; for (var i = 0; i < rowCnt; i += 1) { byRow[i] = []; } for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) { var seg = segs_1[_i]; byRow[seg.row].push(seg); } return byRow; } function splitSegsByFirstCol(segs, colCnt) { var byCol = []; for (var i = 0; i < colCnt; i += 1) { byCol[i] = []; } for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) { var seg = segs_2[_i]; byCol[seg.firstCol].push(seg); } return byCol; } function splitInteractionByRow(ui, rowCnt) { var byRow = []; if (!ui) { for (var i = 0; i < rowCnt; i += 1) { byRow[i] = null; } } else { for (var i = 0; i < rowCnt; i += 1) { byRow[i] = { affectedInstances: ui.affectedInstances, isEvent: ui.isEvent, segs: [], }; } for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) { var seg = _a[_i]; byRow[seg.row].segs.push(seg); } } return byRow; } var TableCellTop = /** @class */ (function (_super) { __extends(TableCellTop, _super); function TableCellTop() { return _super !== null && _super.apply(this, arguments) || this; } TableCellTop.prototype.render = function () { var props = this.props; var navLinkAttrs = buildNavLinkAttrs(this.context, props.date); return (createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, defaultContent: renderTopInner }, function (innerElRef, innerContent) { return ((innerContent || props.forceDayTop) && (createElement("div", { className: "fc-daygrid-day-top", ref: innerElRef }, createElement("a", __assign({ id: props.dayNumberId, className: "fc-daygrid-day-number" }, navLinkAttrs), innerContent || createElement(Fragment, null, "\u00A0"))))); })); }; return TableCellTop; }(BaseComponent)); function renderTopInner(props) { return props.dayNumberText; } var DEFAULT_TABLE_EVENT_TIME_FORMAT = createFormatter({ hour: 'numeric', minute: '2-digit', omitZeroMinute: true, meridiem: 'narrow', }); function hasListItemDisplay(seg) { var display = seg.eventRange.ui.display; return display === 'list-item' || (display === 'auto' && !seg.eventRange.def.allDay && seg.firstCol === seg.lastCol && // can't be multi-day seg.isStart && // " seg.isEnd // " ); } var TableBlockEvent = /** @class */ (function (_super) { __extends(TableBlockEvent, _super); function TableBlockEvent() { return _super !== null && _super.apply(this, arguments) || this; } TableBlockEvent.prototype.render = function () { var props = this.props; return (createElement(StandardEvent, __assign({}, props, { extraClassNames: ['fc-daygrid-event', 'fc-daygrid-block-event', 'fc-h-event'], defaultTimeFormat: DEFAULT_TABLE_EVENT_TIME_FORMAT, defaultDisplayEventEnd: props.defaultDisplayEventEnd, disableResizing: !props.seg.eventRange.def.allDay }))); }; return TableBlockEvent; }(BaseComponent)); var TableListItemEvent = /** @class */ (function (_super) { __extends(TableListItemEvent, _super); function TableListItemEvent() { return _super !== null && _super.apply(this, arguments) || this; } TableListItemEvent.prototype.render = function () { var _a = this, props = _a.props, context = _a.context; var timeFormat = context.options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT; var timeText = buildSegTimeText(props.seg, timeFormat, context, true, props.defaultDisplayEventEnd); return (createElement(EventRoot, { seg: props.seg, timeText: timeText, defaultContent: renderInnerContent, isDragging: props.isDragging, isResizing: false, isDateSelecting: false, isSelected: props.isSelected, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent) { return ( // we don't use styles! createElement("a", __assign({ className: ['fc-daygrid-event', 'fc-daygrid-dot-event'].concat(classNames).join(' '), ref: rootElRef }, getSegAnchorAttrs(props.seg, context)), innerContent)); })); }; return TableListItemEvent; }(BaseComponent)); function renderInnerContent(innerProps) { return (createElement(Fragment, null, createElement("div", { className: "fc-daygrid-event-dot", style: { borderColor: innerProps.borderColor || innerProps.backgroundColor } }), innerProps.timeText && (createElement("div", { className: "fc-event-time" }, innerProps.timeText)), createElement("div", { className: "fc-event-title" }, innerProps.event.title || createElement(Fragment, null, "\u00A0")))); } var TableCellMoreLink = /** @class */ (function (_super) { __extends(TableCellMoreLink, _super); function TableCellMoreLink() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.compileSegs = memoize(compileSegs); return _this; } TableCellMoreLink.prototype.render = function () { var props = this.props; var _a = this.compileSegs(props.singlePlacements), allSegs = _a.allSegs, invisibleSegs = _a.invisibleSegs; return (createElement(MoreLinkRoot, { dateProfile: props.dateProfile, todayRange: props.todayRange, allDayDate: props.allDayDate, moreCnt: props.moreCnt, allSegs: allSegs, hiddenSegs: invisibleSegs, alignmentElRef: props.alignmentElRef, alignGridTop: props.alignGridTop, extraDateSpan: props.extraDateSpan, popoverContent: function () { var isForcedInvisible = (props.eventDrag ? props.eventDrag.affectedInstances : null) || (props.eventResize ? props.eventResize.affectedInstances : null) || {}; return (createElement(Fragment, null, allSegs.map(function (seg) { var instanceId = seg.eventRange.instance.instanceId; return (createElement("div", { className: "fc-daygrid-event-harness", key: instanceId, style: { visibility: isForcedInvisible[instanceId] ? 'hidden' : '', } }, hasListItemDisplay(seg) ? (createElement(TableListItemEvent, __assign({ seg: seg, isDragging: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange)))) : (createElement(TableBlockEvent, __assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange)))))); }))); } }, function (rootElRef, classNames, innerElRef, innerContent, handleClick, title, isExpanded, popoverId) { return (createElement("a", __assign({ ref: rootElRef, className: ['fc-daygrid-more-link'].concat(classNames).join(' '), title: title, "aria-expanded": isExpanded, "aria-controls": popoverId }, createAriaClickAttrs(handleClick)), innerContent)); })); }; return TableCellMoreLink; }(BaseComponent)); function compileSegs(singlePlacements) { var allSegs = []; var invisibleSegs = []; for (var _i = 0, singlePlacements_1 = singlePlacements; _i < singlePlacements_1.length; _i++) { var placement = singlePlacements_1[_i]; allSegs.push(placement.seg); if (!placement.isVisible) { invisibleSegs.push(placement.seg); } } return { allSegs: allSegs, invisibleSegs: invisibleSegs }; } var DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: 'narrow' }); var TableCell = /** @class */ (function (_super) { __extends(TableCell, _super); function TableCell() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.rootElRef = createRef(); _this.state = { dayNumberId: getUniqueDomId(), }; _this.handleRootEl = function (el) { setRef(_this.rootElRef, el); setRef(_this.props.elRef, el); }; return _this; } TableCell.prototype.render = function () { var _a = this, context = _a.context, props = _a.props, state = _a.state, rootElRef = _a.rootElRef; var date = props.date, dateProfile = props.dateProfile; var navLinkAttrs = buildNavLinkAttrs(context, date, 'week'); return (createElement(DayCellRoot, { date: date, dateProfile: dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, elRef: this.handleRootEl }, function (dayElRef, dayClassNames, rootDataAttrs, isDisabled) { return (createElement("td", __assign({ ref: dayElRef, role: "gridcell", className: ['fc-daygrid-day'].concat(dayClassNames, props.extraClassNames || []).join(' ') }, rootDataAttrs, props.extraDataAttrs, (props.showDayNumber ? { 'aria-labelledby': state.dayNumberId } : {})), createElement("div", { className: "fc-daygrid-day-frame fc-scrollgrid-sync-inner", ref: props.innerElRef /* different from hook system! RENAME */ }, props.showWeekNumber && (createElement(WeekNumberRoot, { date: date, defaultFormat: DEFAULT_WEEK_NUM_FORMAT }, function (weekElRef, weekClassNames, innerElRef, innerContent) { return (createElement("a", __assign({ ref: weekElRef, className: ['fc-daygrid-week-number'].concat(weekClassNames).join(' ') }, navLinkAttrs), innerContent)); })), !isDisabled && (createElement(TableCellTop, { date: date, dateProfile: dateProfile, showDayNumber: props.showDayNumber, dayNumberId: state.dayNumberId, forceDayTop: props.forceDayTop, todayRange: props.todayRange, extraHookProps: props.extraHookProps })), createElement("div", { className: "fc-daygrid-day-events", ref: props.fgContentElRef }, props.fgContent, createElement("div", { className: "fc-daygrid-day-bottom", style: { marginTop: props.moreMarginTop } }, createElement(TableCellMoreLink, { allDayDate: date, singlePlacements: props.singlePlacements, moreCnt: props.moreCnt, alignmentElRef: rootElRef, alignGridTop: !props.showDayNumber, extraDateSpan: props.extraDateSpan, dateProfile: props.dateProfile, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, todayRange: props.todayRange }))), createElement("div", { className: "fc-daygrid-day-bg" }, props.bgContent)))); })); }; return TableCell; }(DateComponent)); function computeFgSegPlacement(segs, // assumed already sorted dayMaxEvents, dayMaxEventRows, strictOrder, eventInstanceHeights, maxContentHeight, cells) { var hierarchy = new DayGridSegHierarchy(); hierarchy.allowReslicing = true; hierarchy.strictOrder = strictOrder; if (dayMaxEvents === true || dayMaxEventRows === true) { hierarchy.maxCoord = maxContentHeight; hierarchy.hiddenConsumes = true; } else if (typeof dayMaxEvents === 'number') { hierarchy.maxStackCnt = dayMaxEvents; } else if (typeof dayMaxEventRows === 'number') { hierarchy.maxStackCnt = dayMaxEventRows; hierarchy.hiddenConsumes = true; } // create segInputs only for segs with known heights var segInputs = []; var unknownHeightSegs = []; for (var i = 0; i < segs.length; i += 1) { var seg = segs[i]; var instanceId = seg.eventRange.instance.instanceId; var eventHeight = eventInstanceHeights[instanceId]; if (eventHeight != null) { segInputs.push({ index: i, thickness: eventHeight, span: { start: seg.firstCol, end: seg.lastCol + 1, }, }); } else { unknownHeightSegs.push(seg); } } var hiddenEntries = hierarchy.addSegs(segInputs); var segRects = hierarchy.toRects(); var _a = placeRects(segRects, segs, cells), singleColPlacements = _a.singleColPlacements, multiColPlacements = _a.multiColPlacements, leftoverMargins = _a.leftoverMargins; var moreCnts = []; var moreMarginTops = []; // add segs with unknown heights for (var _i = 0, unknownHeightSegs_1 = unknownHeightSegs; _i < unknownHeightSegs_1.length; _i++) { var seg = unknownHeightSegs_1[_i]; multiColPlacements[seg.firstCol].push({ seg: seg, isVisible: false, isAbsolute: true, absoluteTop: 0, marginTop: 0, }); for (var col = seg.firstCol; col <= seg.lastCol; col += 1) { singleColPlacements[col].push({ seg: resliceSeg(seg, col, col + 1, cells), isVisible: false, isAbsolute: false, absoluteTop: 0, marginTop: 0, }); } } // add the hidden entries for (var col = 0; col < cells.length; col += 1) { moreCnts.push(0); } for (var _b = 0, hiddenEntries_1 = hiddenEntries; _b < hiddenEntries_1.length; _b++) { var hiddenEntry = hiddenEntries_1[_b]; var seg = segs[hiddenEntry.index]; var hiddenSpan = hiddenEntry.span; multiColPlacements[hiddenSpan.start].push({ seg: resliceSeg(seg, hiddenSpan.start, hiddenSpan.end, cells), isVisible: false, isAbsolute: true, absoluteTop: 0, marginTop: 0, }); for (var col = hiddenSpan.start; col < hiddenSpan.end; col += 1) { moreCnts[col] += 1; singleColPlacements[col].push({ seg: resliceSeg(seg, col, col + 1, cells), isVisible: false, isAbsolute: false, absoluteTop: 0, marginTop: 0, }); } } // deal with leftover margins for (var col = 0; col < cells.length; col += 1) { moreMarginTops.push(leftoverMargins[col]); } return { singleColPlacements: singleColPlacements, multiColPlacements: multiColPlacements, moreCnts: moreCnts, moreMarginTops: moreMarginTops }; } // rects ordered by top coord, then left function placeRects(allRects, segs, cells) { var rectsByEachCol = groupRectsByEachCol(allRects, cells.length); var singleColPlacements = []; var multiColPlacements = []; var leftoverMargins = []; for (var col = 0; col < cells.length; col += 1) { var rects = rectsByEachCol[col]; // compute all static segs in singlePlacements var singlePlacements = []; var currentHeight = 0; var currentMarginTop = 0; for (var _i = 0, rects_1 = rects; _i < rects_1.length; _i++) { var rect = rects_1[_i]; var seg = segs[rect.index]; singlePlacements.push({ seg: resliceSeg(seg, col, col + 1, cells), isVisible: true, isAbsolute: false, absoluteTop: rect.levelCoord, marginTop: rect.levelCoord - currentHeight, }); currentHeight = rect.levelCoord + rect.thickness; } // compute mixed static/absolute segs in multiPlacements var multiPlacements = []; currentHeight = 0; currentMarginTop = 0; for (var _a = 0, rects_2 = rects; _a < rects_2.length; _a++) { var rect = rects_2[_a]; var seg = segs[rect.index]; var isAbsolute = rect.span.end - rect.span.start > 1; // multi-column? var isFirstCol = rect.span.start === col; currentMarginTop += rect.levelCoord - currentHeight; // amount of space since bottom of previous seg currentHeight = rect.levelCoord + rect.thickness; // height will now be bottom of current seg if (isAbsolute) { currentMarginTop += rect.thickness; if (isFirstCol) { multiPlacements.push({ seg: resliceSeg(seg, rect.span.start, rect.span.end, cells), isVisible: true, isAbsolute: true, absoluteTop: rect.levelCoord, marginTop: 0, }); } } else if (isFirstCol) { multiPlacements.push({ seg: resliceSeg(seg, rect.span.start, rect.span.end, cells), isVisible: true, isAbsolute: false, absoluteTop: rect.levelCoord, marginTop: currentMarginTop, // claim the margin }); currentMarginTop = 0; } } singleColPlacements.push(singlePlacements); multiColPlacements.push(multiPlacements); leftoverMargins.push(currentMarginTop); } return { singleColPlacements: singleColPlacements, multiColPlacements: multiColPlacements, leftoverMargins: leftoverMargins }; } function groupRectsByEachCol(rects, colCnt) { var rectsByEachCol = []; for (var col = 0; col < colCnt; col += 1) { rectsByEachCol.push([]); } for (var _i = 0, rects_3 = rects; _i < rects_3.length; _i++) { var rect = rects_3[_i]; for (var col = rect.span.start; col < rect.span.end; col += 1) { rectsByEachCol[col].push(rect); } } return rectsByEachCol; } function resliceSeg(seg, spanStart, spanEnd, cells) { if (seg.firstCol === spanStart && seg.lastCol === spanEnd - 1) { return seg; } var eventRange = seg.eventRange; var origRange = eventRange.range; var slicedRange = intersectRanges(origRange, { start: cells[spanStart].date, end: addDays(cells[spanEnd - 1].date, 1), }); return __assign(__assign({}, seg), { firstCol: spanStart, lastCol: spanEnd - 1, eventRange: { def: eventRange.def, ui: __assign(__assign({}, eventRange.ui), { durationEditable: false }), instance: eventRange.instance, range: slicedRange, }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() }); } var DayGridSegHierarchy = /** @class */ (function (_super) { __extends(DayGridSegHierarchy, _super); function DayGridSegHierarchy() { var _this = _super !== null && _super.apply(this, arguments) || this; // config _this.hiddenConsumes = false; // allows us to keep hidden entries in the hierarchy so they take up space _this.forceHidden = {}; return _this; } DayGridSegHierarchy.prototype.addSegs = function (segInputs) { var _this = this; var hiddenSegs = _super.prototype.addSegs.call(this, segInputs); var entriesByLevel = this.entriesByLevel; var excludeHidden = function (entry) { return !_this.forceHidden[buildEntryKey(entry)]; }; // remove the forced-hidden segs for (var level = 0; level < entriesByLevel.length; level += 1) { entriesByLevel[level] = entriesByLevel[level].filter(excludeHidden); } return hiddenSegs; }; DayGridSegHierarchy.prototype.handleInvalidInsertion = function (insertion, entry, hiddenEntries) { var _a = this, entriesByLevel = _a.entriesByLevel, forceHidden = _a.forceHidden; var touchingEntry = insertion.touchingEntry, touchingLevel = insertion.touchingLevel, touchingLateral = insertion.touchingLateral; if (this.hiddenConsumes && touchingEntry) { var touchingEntryId = buildEntryKey(touchingEntry); // if not already hidden if (!forceHidden[touchingEntryId]) { if (this.allowReslicing) { var placeholderEntry = __assign(__assign({}, touchingEntry), { span: intersectSpans(touchingEntry.span, entry.span) }); var placeholderEntryId = buildEntryKey(placeholderEntry); forceHidden[placeholderEntryId] = true; entriesByLevel[touchingLevel][touchingLateral] = placeholderEntry; // replace touchingEntry with our placeholder this.splitEntry(touchingEntry, entry, hiddenEntries); // split up the touchingEntry, reinsert it } else { forceHidden[touchingEntryId] = true; hiddenEntries.push(touchingEntry); } } } return _super.prototype.handleInvalidInsertion.call(this, insertion, entry, hiddenEntries); }; return DayGridSegHierarchy; }(SegHierarchy)); var TableRow = /** @class */ (function (_super) { __extends(TableRow, _super); function TableRow() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.cellElRefs = new RefMap(); // the