/*! FullCalendar v5.10.2 Docs & License: https://fullcalendar.io/ (c) 2021 Adam Shaw */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var common = require('@fullcalendar/common'); var tslib = require('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) { tslib.__extends(TableView, _super); function TableView() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.headerElRef = common.createRef(); return _this; } TableView.prototype.renderSimpleLayout = function (headerRowContent, bodyContent) { var _a = this, props = _a.props, context = _a.context; var sections = []; var stickyHeaderDates = common.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 (common.createElement(common.ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (common.createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') }, common.createElement(common.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 && common.getStickyHeaderDates(context.options); var stickyFooterScrollbar = !props.forPrint && common.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: common.renderScrollShim, }], }); } return (common.createElement(common.ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (common.createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') }, common.createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections: sections }))); })); }; return TableView; }(common.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) { tslib.__extends(TableCellTop, _super); function TableCellTop() { return _super !== null && _super.apply(this, arguments) || this; } TableCellTop.prototype.render = function () { var props = this.props; var navLinkAttrs = common.buildNavLinkAttrs(this.context, props.date); return (common.createElement(common.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) && (common.createElement("div", { className: "fc-daygrid-day-top", ref: innerElRef }, common.createElement("a", tslib.__assign({ id: props.dayNumberId, className: "fc-daygrid-day-number" }, navLinkAttrs), innerContent || common.createElement(common.Fragment, null, "\u00A0"))))); })); }; return TableCellTop; }(common.BaseComponent)); function renderTopInner(props) { return props.dayNumberText; } var DEFAULT_TABLE_EVENT_TIME_FORMAT = common.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) { tslib.__extends(TableBlockEvent, _super); function TableBlockEvent() { return _super !== null && _super.apply(this, arguments) || this; } TableBlockEvent.prototype.render = function () { var props = this.props; return (common.createElement(common.StandardEvent, tslib.__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; }(common.BaseComponent)); var TableListItemEvent = /** @class */ (function (_super) { tslib.__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 = common.buildSegTimeText(props.seg, timeFormat, context, true, props.defaultDisplayEventEnd); return (common.createElement(common.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! common.createElement("a", tslib.__assign({ className: ['fc-daygrid-event', 'fc-daygrid-dot-event'].concat(classNames).join(' '), ref: rootElRef }, common.getSegAnchorAttrs(props.seg, context)), innerContent)); })); }; return TableListItemEvent; }(common.BaseComponent)); function renderInnerContent(innerProps) { return (common.createElement(common.Fragment, null, common.createElement("div", { className: "fc-daygrid-event-dot", style: { borderColor: innerProps.borderColor || innerProps.backgroundColor } }), innerProps.timeText && (common.createElement("div", { className: "fc-event-time" }, innerProps.timeText)), common.createElement("div", { className: "fc-event-title" }, innerProps.event.title || common.createElement(common.Fragment, null, "\u00A0")))); } var TableCellMoreLink = /** @class */ (function (_super) { tslib.__extends(TableCellMoreLink, _super); function TableCellMoreLink() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.compileSegs = common.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 (common.createElement(common.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 (common.createElement(common.Fragment, null, allSegs.map(function (seg) { var instanceId = seg.eventRange.instance.instanceId; return (common.createElement("div", { className: "fc-daygrid-event-harness", key: instanceId, style: { visibility: isForcedInvisible[instanceId] ? 'hidden' : '', } }, hasListItemDisplay(seg) ? (common.createElement(TableListItemEvent, tslib.__assign({ seg: seg, isDragging: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, common.getSegMeta(seg, props.todayRange)))) : (common.createElement(TableBlockEvent, tslib.__assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, common.getSegMeta(seg, props.todayRange)))))); }))); } }, function (rootElRef, classNames, innerElRef, innerContent, handleClick, title, isExpanded, popoverId) { return (common.createElement("a", tslib.__assign({ ref: rootElRef, className: ['fc-daygrid-more-link'].concat(classNames).join(' '), title: title, "aria-expanded": isExpanded, "aria-controls": popoverId }, common.createAriaClickAttrs(handleClick)), innerContent)); })); }; return TableCellMoreLink; }(common.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 = common.createFormatter({ week: 'narrow' }); var TableCell = /** @class */ (function (_super) { tslib.__extends(TableCell, _super); function TableCell() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.rootElRef = common.createRef(); _this.state = { dayNumberId: common.getUniqueDomId(), }; _this.handleRootEl = function (el) { common.setRef(_this.rootElRef, el); common.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 = common.buildNavLinkAttrs(context, date, 'week'); return (common.createElement(common.DayCellRoot, { date: date, dateProfile: dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, elRef: this.handleRootEl }, function (dayElRef, dayClassNames, rootDataAttrs, isDisabled) { return (common.createElement("td", tslib.__assign({ ref: dayElRef, role: "gridcell", className: ['fc-daygrid-day'].concat(dayClassNames, props.extraClassNames || []).join(' ') }, rootDataAttrs, props.extraDataAttrs, (props.showDayNumber ? { 'aria-labelledby': state.dayNumberId } : {})), common.createElement("div", { className: "fc-daygrid-day-frame fc-scrollgrid-sync-inner", ref: props.innerElRef /* different from hook system! RENAME */ }, props.showWeekNumber && (common.createElement(common.WeekNumberRoot, { date: date, defaultFormat: DEFAULT_WEEK_NUM_FORMAT }, function (weekElRef, weekClassNames, innerElRef, innerContent) { return (common.createElement("a", tslib.__assign({ ref: weekElRef, className: ['fc-daygrid-week-number'].concat(weekClassNames).join(' ') }, navLinkAttrs), innerContent)); })), !isDisabled && (common.createElement(TableCellTop, { date: date, dateProfile: dateProfile, showDayNumber: props.showDayNumber, dayNumberId: state.dayNumberId, forceDayTop: props.forceDayTop, todayRange: props.todayRange, extraHookProps: props.extraHookProps })), common.createElement("div", { className: "fc-daygrid-day-events", ref: props.fgContentElRef }, props.fgContent, common.createElement("div", { className: "fc-daygrid-day-bottom", style: { marginTop: props.moreMarginTop } }, common.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 }))), common.createElement("div", { className: "fc-daygrid-day-bg" }, props.bgContent)))); })); }; return TableCell; }(common.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 = common.intersectRanges(origRange, { start: cells[spanStart].date, end: common.addDays(cells[spanEnd - 1].date, 1), }); return tslib.__assign(tslib.__assign({}, seg), { firstCol: spanStart, lastCol: spanEnd - 1, eventRange: { def: eventRange.def, ui: tslib.__assign(tslib.__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) { tslib.__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[common.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 = common.buildEntryKey(touchingEntry); // if not already hidden if (!forceHidden[touchingEntryId]) { if (this.allowReslicing) { var placeholderEntry = tslib.__assign(tslib.__assign({}, touchingEntry), { span: common.intersectSpans(touchingEntry.span, entry.span) }); var placeholderEntryId = common.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; }(common.SegHierarchy)); var TableRow = /** @class */ (function (_super) { tslib.__extends(TableRow, _super); function TableRow() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.cellElRefs = new common.RefMap(); // the