fullcalendar-daygrid.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. /*!
  2. FullCalendar v5.11.3
  3. Docs & License: https://fullcalendar.io/
  4. (c) 2022 Adam Shaw
  5. */
  6. import './main.css';
  7. 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';
  8. import { __extends, __assign, __spreadArray } from 'tslib';
  9. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  10. ----------------------------------------------------------------------------------------------------------------------*/
  11. // It is a manager for a Table subcomponent, which does most of the heavy lifting.
  12. // It is responsible for managing width/height.
  13. var TableView = /** @class */ (function (_super) {
  14. __extends(TableView, _super);
  15. function TableView() {
  16. var _this = _super !== null && _super.apply(this, arguments) || this;
  17. _this.headerElRef = createRef();
  18. return _this;
  19. }
  20. TableView.prototype.renderSimpleLayout = function (headerRowContent, bodyContent) {
  21. var _a = this, props = _a.props, context = _a.context;
  22. var sections = [];
  23. var stickyHeaderDates = getStickyHeaderDates(context.options);
  24. if (headerRowContent) {
  25. sections.push({
  26. type: 'header',
  27. key: 'header',
  28. isSticky: stickyHeaderDates,
  29. chunk: {
  30. elRef: this.headerElRef,
  31. tableClassName: 'fc-col-header',
  32. rowContent: headerRowContent,
  33. },
  34. });
  35. }
  36. sections.push({
  37. type: 'body',
  38. key: 'body',
  39. liquid: true,
  40. chunk: { content: bodyContent },
  41. });
  42. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  43. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [] /* TODO: make optional? */, sections: sections }))); }));
  44. };
  45. TableView.prototype.renderHScrollLayout = function (headerRowContent, bodyContent, colCnt, dayMinWidth) {
  46. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  47. if (!ScrollGrid) {
  48. throw new Error('No ScrollGrid implementation');
  49. }
  50. var _a = this, props = _a.props, context = _a.context;
  51. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  52. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  53. var sections = [];
  54. if (headerRowContent) {
  55. sections.push({
  56. type: 'header',
  57. key: 'header',
  58. isSticky: stickyHeaderDates,
  59. chunks: [{
  60. key: 'main',
  61. elRef: this.headerElRef,
  62. tableClassName: 'fc-col-header',
  63. rowContent: headerRowContent,
  64. }],
  65. });
  66. }
  67. sections.push({
  68. type: 'body',
  69. key: 'body',
  70. liquid: true,
  71. chunks: [{
  72. key: 'main',
  73. content: bodyContent,
  74. }],
  75. });
  76. if (stickyFooterScrollbar) {
  77. sections.push({
  78. type: 'footer',
  79. key: 'footer',
  80. isSticky: true,
  81. chunks: [{
  82. key: 'main',
  83. content: renderScrollShim,
  84. }],
  85. });
  86. }
  87. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  88. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections: sections }))); }));
  89. };
  90. return TableView;
  91. }(DateComponent));
  92. function splitSegsByRow(segs, rowCnt) {
  93. var byRow = [];
  94. for (var i = 0; i < rowCnt; i += 1) {
  95. byRow[i] = [];
  96. }
  97. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  98. var seg = segs_1[_i];
  99. byRow[seg.row].push(seg);
  100. }
  101. return byRow;
  102. }
  103. function splitSegsByFirstCol(segs, colCnt) {
  104. var byCol = [];
  105. for (var i = 0; i < colCnt; i += 1) {
  106. byCol[i] = [];
  107. }
  108. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  109. var seg = segs_2[_i];
  110. byCol[seg.firstCol].push(seg);
  111. }
  112. return byCol;
  113. }
  114. function splitInteractionByRow(ui, rowCnt) {
  115. var byRow = [];
  116. if (!ui) {
  117. for (var i = 0; i < rowCnt; i += 1) {
  118. byRow[i] = null;
  119. }
  120. }
  121. else {
  122. for (var i = 0; i < rowCnt; i += 1) {
  123. byRow[i] = {
  124. affectedInstances: ui.affectedInstances,
  125. isEvent: ui.isEvent,
  126. segs: [],
  127. };
  128. }
  129. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  130. var seg = _a[_i];
  131. byRow[seg.row].segs.push(seg);
  132. }
  133. }
  134. return byRow;
  135. }
  136. var TableCellTop = /** @class */ (function (_super) {
  137. __extends(TableCellTop, _super);
  138. function TableCellTop() {
  139. return _super !== null && _super.apply(this, arguments) || this;
  140. }
  141. TableCellTop.prototype.render = function () {
  142. var props = this.props;
  143. var navLinkAttrs = buildNavLinkAttrs(this.context, props.date);
  144. 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 },
  145. createElement("a", __assign({ id: props.dayNumberId, className: "fc-daygrid-day-number" }, navLinkAttrs), innerContent || createElement(Fragment, null, "\u00A0"))))); }));
  146. };
  147. return TableCellTop;
  148. }(BaseComponent));
  149. function renderTopInner(props) {
  150. return props.dayNumberText;
  151. }
  152. var DEFAULT_TABLE_EVENT_TIME_FORMAT = createFormatter({
  153. hour: 'numeric',
  154. minute: '2-digit',
  155. omitZeroMinute: true,
  156. meridiem: 'narrow',
  157. });
  158. function hasListItemDisplay(seg) {
  159. var display = seg.eventRange.ui.display;
  160. return display === 'list-item' || (display === 'auto' &&
  161. !seg.eventRange.def.allDay &&
  162. seg.firstCol === seg.lastCol && // can't be multi-day
  163. seg.isStart && // "
  164. seg.isEnd // "
  165. );
  166. }
  167. var TableBlockEvent = /** @class */ (function (_super) {
  168. __extends(TableBlockEvent, _super);
  169. function TableBlockEvent() {
  170. return _super !== null && _super.apply(this, arguments) || this;
  171. }
  172. TableBlockEvent.prototype.render = function () {
  173. var props = this.props;
  174. 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 })));
  175. };
  176. return TableBlockEvent;
  177. }(BaseComponent));
  178. var TableListItemEvent = /** @class */ (function (_super) {
  179. __extends(TableListItemEvent, _super);
  180. function TableListItemEvent() {
  181. return _super !== null && _super.apply(this, arguments) || this;
  182. }
  183. TableListItemEvent.prototype.render = function () {
  184. var _a = this, props = _a.props, context = _a.context;
  185. var timeFormat = context.options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT;
  186. var timeText = buildSegTimeText(props.seg, timeFormat, context, true, props.defaultDisplayEventEnd);
  187. 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!
  188. createElement("a", __assign({ className: ['fc-daygrid-event', 'fc-daygrid-dot-event'].concat(classNames).join(' '), ref: rootElRef }, getSegAnchorAttrs(props.seg, context)), innerContent)); }));
  189. };
  190. return TableListItemEvent;
  191. }(BaseComponent));
  192. function renderInnerContent(innerProps) {
  193. return (createElement(Fragment, null,
  194. createElement("div", { className: "fc-daygrid-event-dot", style: { borderColor: innerProps.borderColor || innerProps.backgroundColor } }),
  195. innerProps.timeText && (createElement("div", { className: "fc-event-time" }, innerProps.timeText)),
  196. createElement("div", { className: "fc-event-title" }, innerProps.event.title || createElement(Fragment, null, "\u00A0"))));
  197. }
  198. var TableCellMoreLink = /** @class */ (function (_super) {
  199. __extends(TableCellMoreLink, _super);
  200. function TableCellMoreLink() {
  201. var _this = _super !== null && _super.apply(this, arguments) || this;
  202. _this.compileSegs = memoize(compileSegs);
  203. return _this;
  204. }
  205. TableCellMoreLink.prototype.render = function () {
  206. var props = this.props;
  207. var _a = this.compileSegs(props.singlePlacements), allSegs = _a.allSegs, invisibleSegs = _a.invisibleSegs;
  208. 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 () {
  209. var isForcedInvisible = (props.eventDrag ? props.eventDrag.affectedInstances : null) ||
  210. (props.eventResize ? props.eventResize.affectedInstances : null) ||
  211. {};
  212. return (createElement(Fragment, null, allSegs.map(function (seg) {
  213. var instanceId = seg.eventRange.instance.instanceId;
  214. return (createElement("div", { className: "fc-daygrid-event-harness", key: instanceId, style: {
  215. visibility: isForcedInvisible[instanceId] ? 'hidden' : '',
  216. } }, 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))))));
  217. })));
  218. } }, 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)); }));
  219. };
  220. return TableCellMoreLink;
  221. }(BaseComponent));
  222. function compileSegs(singlePlacements) {
  223. var allSegs = [];
  224. var invisibleSegs = [];
  225. for (var _i = 0, singlePlacements_1 = singlePlacements; _i < singlePlacements_1.length; _i++) {
  226. var placement = singlePlacements_1[_i];
  227. allSegs.push(placement.seg);
  228. if (!placement.isVisible) {
  229. invisibleSegs.push(placement.seg);
  230. }
  231. }
  232. return { allSegs: allSegs, invisibleSegs: invisibleSegs };
  233. }
  234. var DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: 'narrow' });
  235. var TableCell = /** @class */ (function (_super) {
  236. __extends(TableCell, _super);
  237. function TableCell() {
  238. var _this = _super !== null && _super.apply(this, arguments) || this;
  239. _this.rootElRef = createRef();
  240. _this.state = {
  241. dayNumberId: getUniqueDomId(),
  242. };
  243. _this.handleRootEl = function (el) {
  244. setRef(_this.rootElRef, el);
  245. setRef(_this.props.elRef, el);
  246. };
  247. return _this;
  248. }
  249. TableCell.prototype.render = function () {
  250. var _a = this, context = _a.context, props = _a.props, state = _a.state, rootElRef = _a.rootElRef;
  251. var date = props.date, dateProfile = props.dateProfile;
  252. var navLinkAttrs = buildNavLinkAttrs(context, date, 'week');
  253. 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 } : {})),
  254. createElement("div", { className: "fc-daygrid-day-frame fc-scrollgrid-sync-inner", ref: props.innerElRef /* different from hook system! RENAME */ },
  255. 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)); })),
  256. !isDisabled && (createElement(TableCellTop, { date: date, dateProfile: dateProfile, showDayNumber: props.showDayNumber, dayNumberId: state.dayNumberId, forceDayTop: props.forceDayTop, todayRange: props.todayRange, extraHookProps: props.extraHookProps })),
  257. createElement("div", { className: "fc-daygrid-day-events", ref: props.fgContentElRef },
  258. props.fgContent,
  259. createElement("div", { className: "fc-daygrid-day-bottom", style: { marginTop: props.moreMarginTop } },
  260. 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 }))),
  261. createElement("div", { className: "fc-daygrid-day-bg" }, props.bgContent)))); }));
  262. };
  263. return TableCell;
  264. }(DateComponent));
  265. function computeFgSegPlacement(segs, // assumed already sorted
  266. dayMaxEvents, dayMaxEventRows, strictOrder, eventInstanceHeights, maxContentHeight, cells) {
  267. var hierarchy = new DayGridSegHierarchy();
  268. hierarchy.allowReslicing = true;
  269. hierarchy.strictOrder = strictOrder;
  270. if (dayMaxEvents === true || dayMaxEventRows === true) {
  271. hierarchy.maxCoord = maxContentHeight;
  272. hierarchy.hiddenConsumes = true;
  273. }
  274. else if (typeof dayMaxEvents === 'number') {
  275. hierarchy.maxStackCnt = dayMaxEvents;
  276. }
  277. else if (typeof dayMaxEventRows === 'number') {
  278. hierarchy.maxStackCnt = dayMaxEventRows;
  279. hierarchy.hiddenConsumes = true;
  280. }
  281. // create segInputs only for segs with known heights
  282. var segInputs = [];
  283. var unknownHeightSegs = [];
  284. for (var i = 0; i < segs.length; i += 1) {
  285. var seg = segs[i];
  286. var instanceId = seg.eventRange.instance.instanceId;
  287. var eventHeight = eventInstanceHeights[instanceId];
  288. if (eventHeight != null) {
  289. segInputs.push({
  290. index: i,
  291. thickness: eventHeight,
  292. span: {
  293. start: seg.firstCol,
  294. end: seg.lastCol + 1,
  295. },
  296. });
  297. }
  298. else {
  299. unknownHeightSegs.push(seg);
  300. }
  301. }
  302. var hiddenEntries = hierarchy.addSegs(segInputs);
  303. var segRects = hierarchy.toRects();
  304. var _a = placeRects(segRects, segs, cells), singleColPlacements = _a.singleColPlacements, multiColPlacements = _a.multiColPlacements, leftoverMargins = _a.leftoverMargins;
  305. var moreCnts = [];
  306. var moreMarginTops = [];
  307. // add segs with unknown heights
  308. for (var _i = 0, unknownHeightSegs_1 = unknownHeightSegs; _i < unknownHeightSegs_1.length; _i++) {
  309. var seg = unknownHeightSegs_1[_i];
  310. multiColPlacements[seg.firstCol].push({
  311. seg: seg,
  312. isVisible: false,
  313. isAbsolute: true,
  314. absoluteTop: 0,
  315. marginTop: 0,
  316. });
  317. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  318. singleColPlacements[col].push({
  319. seg: resliceSeg(seg, col, col + 1, cells),
  320. isVisible: false,
  321. isAbsolute: false,
  322. absoluteTop: 0,
  323. marginTop: 0,
  324. });
  325. }
  326. }
  327. // add the hidden entries
  328. for (var col = 0; col < cells.length; col += 1) {
  329. moreCnts.push(0);
  330. }
  331. for (var _b = 0, hiddenEntries_1 = hiddenEntries; _b < hiddenEntries_1.length; _b++) {
  332. var hiddenEntry = hiddenEntries_1[_b];
  333. var seg = segs[hiddenEntry.index];
  334. var hiddenSpan = hiddenEntry.span;
  335. multiColPlacements[hiddenSpan.start].push({
  336. seg: resliceSeg(seg, hiddenSpan.start, hiddenSpan.end, cells),
  337. isVisible: false,
  338. isAbsolute: true,
  339. absoluteTop: 0,
  340. marginTop: 0,
  341. });
  342. for (var col = hiddenSpan.start; col < hiddenSpan.end; col += 1) {
  343. moreCnts[col] += 1;
  344. singleColPlacements[col].push({
  345. seg: resliceSeg(seg, col, col + 1, cells),
  346. isVisible: false,
  347. isAbsolute: false,
  348. absoluteTop: 0,
  349. marginTop: 0,
  350. });
  351. }
  352. }
  353. // deal with leftover margins
  354. for (var col = 0; col < cells.length; col += 1) {
  355. moreMarginTops.push(leftoverMargins[col]);
  356. }
  357. return { singleColPlacements: singleColPlacements, multiColPlacements: multiColPlacements, moreCnts: moreCnts, moreMarginTops: moreMarginTops };
  358. }
  359. // rects ordered by top coord, then left
  360. function placeRects(allRects, segs, cells) {
  361. var rectsByEachCol = groupRectsByEachCol(allRects, cells.length);
  362. var singleColPlacements = [];
  363. var multiColPlacements = [];
  364. var leftoverMargins = [];
  365. for (var col = 0; col < cells.length; col += 1) {
  366. var rects = rectsByEachCol[col];
  367. // compute all static segs in singlePlacements
  368. var singlePlacements = [];
  369. var currentHeight = 0;
  370. var currentMarginTop = 0;
  371. for (var _i = 0, rects_1 = rects; _i < rects_1.length; _i++) {
  372. var rect = rects_1[_i];
  373. var seg = segs[rect.index];
  374. singlePlacements.push({
  375. seg: resliceSeg(seg, col, col + 1, cells),
  376. isVisible: true,
  377. isAbsolute: false,
  378. absoluteTop: rect.levelCoord,
  379. marginTop: rect.levelCoord - currentHeight,
  380. });
  381. currentHeight = rect.levelCoord + rect.thickness;
  382. }
  383. // compute mixed static/absolute segs in multiPlacements
  384. var multiPlacements = [];
  385. currentHeight = 0;
  386. currentMarginTop = 0;
  387. for (var _a = 0, rects_2 = rects; _a < rects_2.length; _a++) {
  388. var rect = rects_2[_a];
  389. var seg = segs[rect.index];
  390. var isAbsolute = rect.span.end - rect.span.start > 1; // multi-column?
  391. var isFirstCol = rect.span.start === col;
  392. currentMarginTop += rect.levelCoord - currentHeight; // amount of space since bottom of previous seg
  393. currentHeight = rect.levelCoord + rect.thickness; // height will now be bottom of current seg
  394. if (isAbsolute) {
  395. currentMarginTop += rect.thickness;
  396. if (isFirstCol) {
  397. multiPlacements.push({
  398. seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
  399. isVisible: true,
  400. isAbsolute: true,
  401. absoluteTop: rect.levelCoord,
  402. marginTop: 0,
  403. });
  404. }
  405. }
  406. else if (isFirstCol) {
  407. multiPlacements.push({
  408. seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
  409. isVisible: true,
  410. isAbsolute: false,
  411. absoluteTop: rect.levelCoord,
  412. marginTop: currentMarginTop, // claim the margin
  413. });
  414. currentMarginTop = 0;
  415. }
  416. }
  417. singleColPlacements.push(singlePlacements);
  418. multiColPlacements.push(multiPlacements);
  419. leftoverMargins.push(currentMarginTop);
  420. }
  421. return { singleColPlacements: singleColPlacements, multiColPlacements: multiColPlacements, leftoverMargins: leftoverMargins };
  422. }
  423. function groupRectsByEachCol(rects, colCnt) {
  424. var rectsByEachCol = [];
  425. for (var col = 0; col < colCnt; col += 1) {
  426. rectsByEachCol.push([]);
  427. }
  428. for (var _i = 0, rects_3 = rects; _i < rects_3.length; _i++) {
  429. var rect = rects_3[_i];
  430. for (var col = rect.span.start; col < rect.span.end; col += 1) {
  431. rectsByEachCol[col].push(rect);
  432. }
  433. }
  434. return rectsByEachCol;
  435. }
  436. function resliceSeg(seg, spanStart, spanEnd, cells) {
  437. if (seg.firstCol === spanStart && seg.lastCol === spanEnd - 1) {
  438. return seg;
  439. }
  440. var eventRange = seg.eventRange;
  441. var origRange = eventRange.range;
  442. var slicedRange = intersectRanges(origRange, {
  443. start: cells[spanStart].date,
  444. end: addDays(cells[spanEnd - 1].date, 1),
  445. });
  446. return __assign(__assign({}, seg), { firstCol: spanStart, lastCol: spanEnd - 1, eventRange: {
  447. def: eventRange.def,
  448. ui: __assign(__assign({}, eventRange.ui), { durationEditable: false }),
  449. instance: eventRange.instance,
  450. range: slicedRange,
  451. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() });
  452. }
  453. var DayGridSegHierarchy = /** @class */ (function (_super) {
  454. __extends(DayGridSegHierarchy, _super);
  455. function DayGridSegHierarchy() {
  456. var _this = _super !== null && _super.apply(this, arguments) || this;
  457. // config
  458. _this.hiddenConsumes = false;
  459. // allows us to keep hidden entries in the hierarchy so they take up space
  460. _this.forceHidden = {};
  461. return _this;
  462. }
  463. DayGridSegHierarchy.prototype.addSegs = function (segInputs) {
  464. var _this = this;
  465. var hiddenSegs = _super.prototype.addSegs.call(this, segInputs);
  466. var entriesByLevel = this.entriesByLevel;
  467. var excludeHidden = function (entry) { return !_this.forceHidden[buildEntryKey(entry)]; };
  468. // remove the forced-hidden segs
  469. for (var level = 0; level < entriesByLevel.length; level += 1) {
  470. entriesByLevel[level] = entriesByLevel[level].filter(excludeHidden);
  471. }
  472. return hiddenSegs;
  473. };
  474. DayGridSegHierarchy.prototype.handleInvalidInsertion = function (insertion, entry, hiddenEntries) {
  475. var _a = this, entriesByLevel = _a.entriesByLevel, forceHidden = _a.forceHidden;
  476. var touchingEntry = insertion.touchingEntry, touchingLevel = insertion.touchingLevel, touchingLateral = insertion.touchingLateral;
  477. if (this.hiddenConsumes && touchingEntry) {
  478. var touchingEntryId = buildEntryKey(touchingEntry);
  479. // if not already hidden
  480. if (!forceHidden[touchingEntryId]) {
  481. if (this.allowReslicing) {
  482. var placeholderEntry = __assign(__assign({}, touchingEntry), { span: intersectSpans(touchingEntry.span, entry.span) });
  483. var placeholderEntryId = buildEntryKey(placeholderEntry);
  484. forceHidden[placeholderEntryId] = true;
  485. entriesByLevel[touchingLevel][touchingLateral] = placeholderEntry; // replace touchingEntry with our placeholder
  486. this.splitEntry(touchingEntry, entry, hiddenEntries); // split up the touchingEntry, reinsert it
  487. }
  488. else {
  489. forceHidden[touchingEntryId] = true;
  490. hiddenEntries.push(touchingEntry);
  491. }
  492. }
  493. }
  494. return _super.prototype.handleInvalidInsertion.call(this, insertion, entry, hiddenEntries);
  495. };
  496. return DayGridSegHierarchy;
  497. }(SegHierarchy));
  498. var TableRow = /** @class */ (function (_super) {
  499. __extends(TableRow, _super);
  500. function TableRow() {
  501. var _this = _super !== null && _super.apply(this, arguments) || this;
  502. _this.cellElRefs = new RefMap(); // the <td>
  503. _this.frameElRefs = new RefMap(); // the fc-daygrid-day-frame
  504. _this.fgElRefs = new RefMap(); // the fc-daygrid-day-events
  505. _this.segHarnessRefs = new RefMap(); // indexed by "instanceId:firstCol"
  506. _this.rootElRef = createRef();
  507. _this.state = {
  508. framePositions: null,
  509. maxContentHeight: null,
  510. eventInstanceHeights: {},
  511. };
  512. return _this;
  513. }
  514. TableRow.prototype.render = function () {
  515. var _this = this;
  516. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  517. var options = context.options;
  518. var colCnt = props.cells.length;
  519. var businessHoursByCol = splitSegsByFirstCol(props.businessHourSegs, colCnt);
  520. var bgEventSegsByCol = splitSegsByFirstCol(props.bgEventSegs, colCnt);
  521. var highlightSegsByCol = splitSegsByFirstCol(this.getHighlightSegs(), colCnt);
  522. var mirrorSegsByCol = splitSegsByFirstCol(this.getMirrorSegs(), colCnt);
  523. var _b = computeFgSegPlacement(sortEventSegs(props.fgEventSegs, options.eventOrder), props.dayMaxEvents, props.dayMaxEventRows, options.eventOrderStrict, state.eventInstanceHeights, state.maxContentHeight, props.cells), singleColPlacements = _b.singleColPlacements, multiColPlacements = _b.multiColPlacements, moreCnts = _b.moreCnts, moreMarginTops = _b.moreMarginTops;
  524. var isForcedInvisible = // TODO: messy way to compute this
  525. (props.eventDrag && props.eventDrag.affectedInstances) ||
  526. (props.eventResize && props.eventResize.affectedInstances) ||
  527. {};
  528. return (createElement("tr", { ref: this.rootElRef, role: "row" },
  529. props.renderIntro && props.renderIntro(),
  530. props.cells.map(function (cell, col) {
  531. var normalFgNodes = _this.renderFgSegs(col, props.forPrint ? singleColPlacements[col] : multiColPlacements[col], props.todayRange, isForcedInvisible);
  532. var mirrorFgNodes = _this.renderFgSegs(col, buildMirrorPlacements(mirrorSegsByCol[col], multiColPlacements), props.todayRange, {}, Boolean(props.eventDrag), Boolean(props.eventResize), false);
  533. return (createElement(TableCell, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), innerElRef: _this.frameElRefs.createRef(cell.key) /* FF <td> problem, but okay to use for left/right. TODO: rename prop */, dateProfile: props.dateProfile, date: cell.date, showDayNumber: props.showDayNumbers, showWeekNumber: props.showWeekNumbers && col === 0, forceDayTop: props.showWeekNumbers /* even displaying weeknum for row, not necessarily day */, todayRange: props.todayRange, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, extraDateSpan: cell.extraDateSpan, moreCnt: moreCnts[col], moreMarginTop: moreMarginTops[col], singlePlacements: singleColPlacements[col], fgContentElRef: _this.fgElRefs.createRef(cell.key), fgContent: ( // Fragment scopes the keys
  534. createElement(Fragment, null,
  535. createElement(Fragment, null, normalFgNodes),
  536. createElement(Fragment, null, mirrorFgNodes))), bgContent: ( // Fragment scopes the keys
  537. createElement(Fragment, null,
  538. _this.renderFillSegs(highlightSegsByCol[col], 'highlight'),
  539. _this.renderFillSegs(businessHoursByCol[col], 'non-business'),
  540. _this.renderFillSegs(bgEventSegsByCol[col], 'bg-event'))) }));
  541. })));
  542. };
  543. TableRow.prototype.componentDidMount = function () {
  544. this.updateSizing(true);
  545. };
  546. TableRow.prototype.componentDidUpdate = function (prevProps, prevState) {
  547. var currentProps = this.props;
  548. this.updateSizing(!isPropsEqual(prevProps, currentProps));
  549. };
  550. TableRow.prototype.getHighlightSegs = function () {
  551. var props = this.props;
  552. if (props.eventDrag && props.eventDrag.segs.length) { // messy check
  553. return props.eventDrag.segs;
  554. }
  555. if (props.eventResize && props.eventResize.segs.length) { // messy check
  556. return props.eventResize.segs;
  557. }
  558. return props.dateSelectionSegs;
  559. };
  560. TableRow.prototype.getMirrorSegs = function () {
  561. var props = this.props;
  562. if (props.eventResize && props.eventResize.segs.length) { // messy check
  563. return props.eventResize.segs;
  564. }
  565. return [];
  566. };
  567. TableRow.prototype.renderFgSegs = function (col, segPlacements, todayRange, isForcedInvisible, isDragging, isResizing, isDateSelecting) {
  568. var context = this.context;
  569. var eventSelection = this.props.eventSelection;
  570. var framePositions = this.state.framePositions;
  571. var defaultDisplayEventEnd = this.props.cells.length === 1; // colCnt === 1
  572. var isMirror = isDragging || isResizing || isDateSelecting;
  573. var nodes = [];
  574. if (framePositions) {
  575. for (var _i = 0, segPlacements_1 = segPlacements; _i < segPlacements_1.length; _i++) {
  576. var placement = segPlacements_1[_i];
  577. var seg = placement.seg;
  578. var instanceId = seg.eventRange.instance.instanceId;
  579. var key = instanceId + ':' + col;
  580. var isVisible = placement.isVisible && !isForcedInvisible[instanceId];
  581. var isAbsolute = placement.isAbsolute;
  582. var left = '';
  583. var right = '';
  584. if (isAbsolute) {
  585. if (context.isRtl) {
  586. right = 0;
  587. left = framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol];
  588. }
  589. else {
  590. left = 0;
  591. right = framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol];
  592. }
  593. }
  594. /*
  595. known bug: events that are force to be list-item but span multiple days still take up space in later columns
  596. todo: in print view, for multi-day events, don't display title within non-start/end segs
  597. */
  598. nodes.push(createElement("div", { className: 'fc-daygrid-event-harness' + (isAbsolute ? ' fc-daygrid-event-harness-abs' : ''), key: key, ref: isMirror ? null : this.segHarnessRefs.createRef(key), style: {
  599. visibility: isVisible ? '' : 'hidden',
  600. marginTop: isAbsolute ? '' : placement.marginTop,
  601. top: isAbsolute ? placement.absoluteTop : '',
  602. left: left,
  603. right: right,
  604. } }, hasListItemDisplay(seg) ? (createElement(TableListItemEvent, __assign({ seg: seg, isDragging: isDragging, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange)))) : (createElement(TableBlockEvent, __assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange))))));
  605. }
  606. }
  607. return nodes;
  608. };
  609. TableRow.prototype.renderFillSegs = function (segs, fillType) {
  610. var isRtl = this.context.isRtl;
  611. var todayRange = this.props.todayRange;
  612. var framePositions = this.state.framePositions;
  613. var nodes = [];
  614. if (framePositions) {
  615. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  616. var seg = segs_1[_i];
  617. var leftRightCss = isRtl ? {
  618. right: 0,
  619. left: framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol],
  620. } : {
  621. left: 0,
  622. right: framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol],
  623. };
  624. nodes.push(createElement("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-daygrid-bg-harness", style: leftRightCss }, fillType === 'bg-event' ?
  625. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, todayRange))) :
  626. renderFill(fillType)));
  627. }
  628. }
  629. return createElement.apply(void 0, __spreadArray([Fragment, {}], nodes));
  630. };
  631. TableRow.prototype.updateSizing = function (isExternalSizingChange) {
  632. var _a = this, props = _a.props, frameElRefs = _a.frameElRefs;
  633. if (!props.forPrint &&
  634. props.clientWidth !== null // positioning ready?
  635. ) {
  636. if (isExternalSizingChange) {
  637. var frameEls = props.cells.map(function (cell) { return frameElRefs.currentMap[cell.key]; });
  638. if (frameEls.length) {
  639. var originEl = this.rootElRef.current;
  640. this.setState({
  641. framePositions: new PositionCache(originEl, frameEls, true, // isHorizontal
  642. false),
  643. });
  644. }
  645. }
  646. var oldInstanceHeights = this.state.eventInstanceHeights;
  647. var newInstanceHeights = this.queryEventInstanceHeights();
  648. var limitByContentHeight = props.dayMaxEvents === true || props.dayMaxEventRows === true;
  649. this.safeSetState({
  650. // HACK to prevent oscillations of events being shown/hidden from max-event-rows
  651. // Essentially, once you compute an element's height, never null-out.
  652. // TODO: always display all events, as visibility:hidden?
  653. eventInstanceHeights: __assign(__assign({}, oldInstanceHeights), newInstanceHeights),
  654. maxContentHeight: limitByContentHeight ? this.computeMaxContentHeight() : null,
  655. });
  656. }
  657. };
  658. TableRow.prototype.queryEventInstanceHeights = function () {
  659. var segElMap = this.segHarnessRefs.currentMap;
  660. var eventInstanceHeights = {};
  661. // get the max height amongst instance segs
  662. for (var key in segElMap) {
  663. var height = Math.round(segElMap[key].getBoundingClientRect().height);
  664. var instanceId = key.split(':')[0]; // deconstruct how renderFgSegs makes the key
  665. eventInstanceHeights[instanceId] = Math.max(eventInstanceHeights[instanceId] || 0, height);
  666. }
  667. return eventInstanceHeights;
  668. };
  669. TableRow.prototype.computeMaxContentHeight = function () {
  670. var firstKey = this.props.cells[0].key;
  671. var cellEl = this.cellElRefs.currentMap[firstKey];
  672. var fcContainerEl = this.fgElRefs.currentMap[firstKey];
  673. return cellEl.getBoundingClientRect().bottom - fcContainerEl.getBoundingClientRect().top;
  674. };
  675. TableRow.prototype.getCellEls = function () {
  676. var elMap = this.cellElRefs.currentMap;
  677. return this.props.cells.map(function (cell) { return elMap[cell.key]; });
  678. };
  679. return TableRow;
  680. }(DateComponent));
  681. TableRow.addStateEquality({
  682. eventInstanceHeights: isPropsEqual,
  683. });
  684. function buildMirrorPlacements(mirrorSegs, colPlacements) {
  685. if (!mirrorSegs.length) {
  686. return [];
  687. }
  688. var topsByInstanceId = buildAbsoluteTopHash(colPlacements); // TODO: cache this at first render?
  689. return mirrorSegs.map(function (seg) { return ({
  690. seg: seg,
  691. isVisible: true,
  692. isAbsolute: true,
  693. absoluteTop: topsByInstanceId[seg.eventRange.instance.instanceId],
  694. marginTop: 0,
  695. }); });
  696. }
  697. function buildAbsoluteTopHash(colPlacements) {
  698. var topsByInstanceId = {};
  699. for (var _i = 0, colPlacements_1 = colPlacements; _i < colPlacements_1.length; _i++) {
  700. var placements = colPlacements_1[_i];
  701. for (var _a = 0, placements_1 = placements; _a < placements_1.length; _a++) {
  702. var placement = placements_1[_a];
  703. topsByInstanceId[placement.seg.eventRange.instance.instanceId] = placement.absoluteTop;
  704. }
  705. }
  706. return topsByInstanceId;
  707. }
  708. var Table = /** @class */ (function (_super) {
  709. __extends(Table, _super);
  710. function Table() {
  711. var _this = _super !== null && _super.apply(this, arguments) || this;
  712. _this.splitBusinessHourSegs = memoize(splitSegsByRow);
  713. _this.splitBgEventSegs = memoize(splitSegsByRow);
  714. _this.splitFgEventSegs = memoize(splitSegsByRow);
  715. _this.splitDateSelectionSegs = memoize(splitSegsByRow);
  716. _this.splitEventDrag = memoize(splitInteractionByRow);
  717. _this.splitEventResize = memoize(splitInteractionByRow);
  718. _this.rowRefs = new RefMap();
  719. _this.handleRootEl = function (rootEl) {
  720. _this.rootEl = rootEl;
  721. if (rootEl) {
  722. _this.context.registerInteractiveComponent(_this, {
  723. el: rootEl,
  724. isHitComboAllowed: _this.props.isHitComboAllowed,
  725. });
  726. }
  727. else {
  728. _this.context.unregisterInteractiveComponent(_this);
  729. }
  730. };
  731. return _this;
  732. }
  733. Table.prototype.render = function () {
  734. var _this = this;
  735. var props = this.props;
  736. var dateProfile = props.dateProfile, dayMaxEventRows = props.dayMaxEventRows, dayMaxEvents = props.dayMaxEvents, expandRows = props.expandRows;
  737. var rowCnt = props.cells.length;
  738. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, rowCnt);
  739. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, rowCnt);
  740. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, rowCnt);
  741. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, rowCnt);
  742. var eventDragByRow = this.splitEventDrag(props.eventDrag, rowCnt);
  743. var eventResizeByRow = this.splitEventResize(props.eventResize, rowCnt);
  744. var limitViaBalanced = dayMaxEvents === true || dayMaxEventRows === true;
  745. // if rows can't expand to fill fixed height, can't do balanced-height event limit
  746. // TODO: best place to normalize these options?
  747. if (limitViaBalanced && !expandRows) {
  748. limitViaBalanced = false;
  749. dayMaxEventRows = null;
  750. dayMaxEvents = null;
  751. }
  752. var classNames = [
  753. 'fc-daygrid-body',
  754. limitViaBalanced ? 'fc-daygrid-body-balanced' : 'fc-daygrid-body-unbalanced',
  755. expandRows ? '' : 'fc-daygrid-body-natural', // will height of one row depend on the others?
  756. ];
  757. return (createElement("div", { className: classNames.join(' '), ref: this.handleRootEl, style: {
  758. // these props are important to give this wrapper correct dimensions for interactions
  759. // TODO: if we set it here, can we avoid giving to inner tables?
  760. width: props.clientWidth,
  761. minWidth: props.tableMinWidth,
  762. } },
  763. createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) { return (createElement(Fragment, null,
  764. createElement("table", { role: "presentation", className: "fc-scrollgrid-sync-table", style: {
  765. width: props.clientWidth,
  766. minWidth: props.tableMinWidth,
  767. height: expandRows ? props.clientHeight : '',
  768. } },
  769. props.colGroupNode,
  770. createElement("tbody", { role: "presentation" }, props.cells.map(function (cells, row) { return (createElement(TableRow, { ref: _this.rowRefs.createRef(row), key: cells.length
  771. ? cells[0].date.toISOString() /* best? or put key on cell? or use diff formatter? */
  772. : row // in case there are no cells (like when resource view is loading)
  773. , showDayNumbers: rowCnt > 1, showWeekNumbers: props.showWeekNumbers, todayRange: todayRange, dateProfile: dateProfile, cells: cells, renderIntro: props.renderRowIntro, businessHourSegs: businessHourSegsByRow[row], eventSelection: props.eventSelection, bgEventSegs: bgEventSegsByRow[row].filter(isSegAllDay) /* hack */, fgEventSegs: fgEventSegsByRow[row], dateSelectionSegs: dateSelectionSegsByRow[row], eventDrag: eventDragByRow[row], eventResize: eventResizeByRow[row], dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: props.forPrint })); }))))); })));
  774. };
  775. // Hit System
  776. // ----------------------------------------------------------------------------------------------------
  777. Table.prototype.prepareHits = function () {
  778. this.rowPositions = new PositionCache(this.rootEl, this.rowRefs.collect().map(function (rowObj) { return rowObj.getCellEls()[0]; }), // first cell el in each row. TODO: not optimal
  779. false, true);
  780. this.colPositions = new PositionCache(this.rootEl, this.rowRefs.currentMap[0].getCellEls(), // cell els in first row
  781. true, // horizontal
  782. false);
  783. };
  784. Table.prototype.queryHit = function (positionLeft, positionTop) {
  785. var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
  786. var col = colPositions.leftToIndex(positionLeft);
  787. var row = rowPositions.topToIndex(positionTop);
  788. if (row != null && col != null) {
  789. var cell = this.props.cells[row][col];
  790. return {
  791. dateProfile: this.props.dateProfile,
  792. dateSpan: __assign({ range: this.getCellRange(row, col), allDay: true }, cell.extraDateSpan),
  793. dayEl: this.getCellEl(row, col),
  794. rect: {
  795. left: colPositions.lefts[col],
  796. right: colPositions.rights[col],
  797. top: rowPositions.tops[row],
  798. bottom: rowPositions.bottoms[row],
  799. },
  800. layer: 0,
  801. };
  802. }
  803. return null;
  804. };
  805. Table.prototype.getCellEl = function (row, col) {
  806. return this.rowRefs.currentMap[row].getCellEls()[col]; // TODO: not optimal
  807. };
  808. Table.prototype.getCellRange = function (row, col) {
  809. var start = this.props.cells[row][col].date;
  810. var end = addDays(start, 1);
  811. return { start: start, end: end };
  812. };
  813. return Table;
  814. }(DateComponent));
  815. function isSegAllDay(seg) {
  816. return seg.eventRange.def.allDay;
  817. }
  818. var DayTableSlicer = /** @class */ (function (_super) {
  819. __extends(DayTableSlicer, _super);
  820. function DayTableSlicer() {
  821. var _this = _super !== null && _super.apply(this, arguments) || this;
  822. _this.forceDayIfListItem = true;
  823. return _this;
  824. }
  825. DayTableSlicer.prototype.sliceRange = function (dateRange, dayTableModel) {
  826. return dayTableModel.sliceRange(dateRange);
  827. };
  828. return DayTableSlicer;
  829. }(Slicer));
  830. var DayTable = /** @class */ (function (_super) {
  831. __extends(DayTable, _super);
  832. function DayTable() {
  833. var _this = _super !== null && _super.apply(this, arguments) || this;
  834. _this.slicer = new DayTableSlicer();
  835. _this.tableRef = createRef();
  836. return _this;
  837. }
  838. DayTable.prototype.render = function () {
  839. var _a = this, props = _a.props, context = _a.context;
  840. return (createElement(Table, __assign({ ref: this.tableRef }, this.slicer.sliceProps(props, props.dateProfile, props.nextDayThreshold, context, props.dayTableModel), { dateProfile: props.dateProfile, cells: props.dayTableModel.cells, colGroupNode: props.colGroupNode, tableMinWidth: props.tableMinWidth, renderRowIntro: props.renderRowIntro, dayMaxEvents: props.dayMaxEvents, dayMaxEventRows: props.dayMaxEventRows, showWeekNumbers: props.showWeekNumbers, expandRows: props.expandRows, headerAlignElRef: props.headerAlignElRef, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: props.forPrint })));
  841. };
  842. return DayTable;
  843. }(DateComponent));
  844. var DayTableView = /** @class */ (function (_super) {
  845. __extends(DayTableView, _super);
  846. function DayTableView() {
  847. var _this = _super !== null && _super.apply(this, arguments) || this;
  848. _this.buildDayTableModel = memoize(buildDayTableModel);
  849. _this.headerRef = createRef();
  850. _this.tableRef = createRef();
  851. return _this;
  852. }
  853. DayTableView.prototype.render = function () {
  854. var _this = this;
  855. var _a = this.context, options = _a.options, dateProfileGenerator = _a.dateProfileGenerator;
  856. var props = this.props;
  857. var dayTableModel = this.buildDayTableModel(props.dateProfile, dateProfileGenerator);
  858. var headerContent = options.dayHeaders && (createElement(DayHeader, { ref: this.headerRef, dateProfile: props.dateProfile, dates: dayTableModel.headerDates, datesRepDistinctDays: dayTableModel.rowCnt === 1 }));
  859. var bodyContent = function (contentArg) { return (createElement(DayTable, { ref: _this.tableRef, dateProfile: props.dateProfile, dayTableModel: dayTableModel, businessHours: props.businessHours, dateSelection: props.dateSelection, eventStore: props.eventStore, eventUiBases: props.eventUiBases, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, nextDayThreshold: options.nextDayThreshold, colGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, dayMaxEvents: options.dayMaxEvents, dayMaxEventRows: options.dayMaxEventRows, showWeekNumbers: options.weekNumbers, expandRows: !props.isHeightAuto, headerAlignElRef: _this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint })); };
  860. return options.dayMinWidth
  861. ? this.renderHScrollLayout(headerContent, bodyContent, dayTableModel.colCnt, options.dayMinWidth)
  862. : this.renderSimpleLayout(headerContent, bodyContent);
  863. };
  864. return DayTableView;
  865. }(TableView));
  866. function buildDayTableModel(dateProfile, dateProfileGenerator) {
  867. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  868. return new DayTableModel(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  869. }
  870. var TableDateProfileGenerator = /** @class */ (function (_super) {
  871. __extends(TableDateProfileGenerator, _super);
  872. function TableDateProfileGenerator() {
  873. return _super !== null && _super.apply(this, arguments) || this;
  874. }
  875. // Computes the date range that will be rendered.
  876. TableDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  877. var dateEnv = this.props.dateEnv;
  878. var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
  879. var start = renderRange.start;
  880. var end = renderRange.end;
  881. var endOfWeek;
  882. // year and month views should be aligned with weeks. this is already done for week
  883. if (/^(year|month)$/.test(currentRangeUnit)) {
  884. start = dateEnv.startOfWeek(start);
  885. // make end-of-week if not already
  886. endOfWeek = dateEnv.startOfWeek(end);
  887. if (endOfWeek.valueOf() !== end.valueOf()) {
  888. end = addWeeks(endOfWeek, 1);
  889. }
  890. }
  891. // ensure 6 weeks
  892. if (this.props.monthMode &&
  893. this.props.fixedWeekCount) {
  894. var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  895. diffWeeks(start, end));
  896. end = addWeeks(end, 6 - rowCnt);
  897. }
  898. return { start: start, end: end };
  899. };
  900. return TableDateProfileGenerator;
  901. }(DateProfileGenerator));
  902. var main = createPlugin({
  903. initialView: 'dayGridMonth',
  904. views: {
  905. dayGrid: {
  906. component: DayTableView,
  907. dateProfileGeneratorClass: TableDateProfileGenerator,
  908. },
  909. dayGridDay: {
  910. type: 'dayGrid',
  911. duration: { days: 1 },
  912. },
  913. dayGridWeek: {
  914. type: 'dayGrid',
  915. duration: { weeks: 1 },
  916. },
  917. dayGridMonth: {
  918. type: 'dayGrid',
  919. duration: { months: 1 },
  920. monthMode: true,
  921. fixedWeekCount: true,
  922. },
  923. },
  924. });
  925. export default main;
  926. export { DayTableView as DayGridView, DayTable, DayTableSlicer, Table, TableView, buildDayTableModel };
  927. //# sourceMappingURL=main.js.map