暂无描述

main.esm.js 72KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627
  1. /*!
  2. FullCalendar Day Grid Plugin v4.3.0
  3. Docs & License: https://fullcalendar.io/
  4. (c) 2019 Adam Shaw
  5. */
  6. import { addWeeks, diffWeeks, DateProfileGenerator, createElement, listenBySelector, removeElement, computeRect, computeClippingRect, applyStyle, cssToStr, htmlEscape, FgEventRenderer, appendToElement, prependToElement, htmlToElement, FillRenderer, memoizeRendering, createFormatter, addDays, DateComponent, rangeContainsMarker, getDayClasses, findElements, PositionCache, buildGotoAnchorHtml, findChildren, insertAfterElement, intersectRanges, ScrollComponent, matchCellWidths, uncompensateScroll, compensateScroll, subtractInnerElHeight, distributeHeight, undistributeHeight, View, Slicer, memoize, DayHeader, DaySeries, DayTable, createPlugin } from '@fullcalendar/core';
  7. /*! *****************************************************************************
  8. Copyright (c) Microsoft Corporation. All rights reserved.
  9. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  10. this file except in compliance with the License. You may obtain a copy of the
  11. License at http://www.apache.org/licenses/LICENSE-2.0
  12. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  14. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  15. MERCHANTABLITY OR NON-INFRINGEMENT.
  16. See the Apache Version 2.0 License for specific language governing permissions
  17. and limitations under the License.
  18. ***************************************************************************** */
  19. /* global Reflect, Promise */
  20. var extendStatics = function(d, b) {
  21. extendStatics = Object.setPrototypeOf ||
  22. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  23. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  24. return extendStatics(d, b);
  25. };
  26. function __extends(d, b) {
  27. extendStatics(d, b);
  28. function __() { this.constructor = d; }
  29. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30. }
  31. var __assign = function() {
  32. __assign = Object.assign || function __assign(t) {
  33. for (var s, i = 1, n = arguments.length; i < n; i++) {
  34. s = arguments[i];
  35. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  36. }
  37. return t;
  38. };
  39. return __assign.apply(this, arguments);
  40. };
  41. var DayGridDateProfileGenerator = /** @class */ (function (_super) {
  42. __extends(DayGridDateProfileGenerator, _super);
  43. function DayGridDateProfileGenerator() {
  44. return _super !== null && _super.apply(this, arguments) || this;
  45. }
  46. // Computes the date range that will be rendered.
  47. DayGridDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  48. var dateEnv = this.dateEnv;
  49. var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
  50. var start = renderRange.start;
  51. var end = renderRange.end;
  52. var endOfWeek;
  53. // year and month views should be aligned with weeks. this is already done for week
  54. if (/^(year|month)$/.test(currentRangeUnit)) {
  55. start = dateEnv.startOfWeek(start);
  56. // make end-of-week if not already
  57. endOfWeek = dateEnv.startOfWeek(end);
  58. if (endOfWeek.valueOf() !== end.valueOf()) {
  59. end = addWeeks(endOfWeek, 1);
  60. }
  61. }
  62. // ensure 6 weeks
  63. if (this.options.monthMode &&
  64. this.options.fixedWeekCount) {
  65. var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  66. diffWeeks(start, end));
  67. end = addWeeks(end, 6 - rowCnt);
  68. }
  69. return { start: start, end: end };
  70. };
  71. return DayGridDateProfileGenerator;
  72. }(DateProfileGenerator));
  73. /* A rectangular panel that is absolutely positioned over other content
  74. ------------------------------------------------------------------------------------------------------------------------
  75. Options:
  76. - className (string)
  77. - content (HTML string, element, or element array)
  78. - parentEl
  79. - top
  80. - left
  81. - right (the x coord of where the right edge should be. not a "CSS" right)
  82. - autoHide (boolean)
  83. - show (callback)
  84. - hide (callback)
  85. */
  86. var Popover = /** @class */ (function () {
  87. function Popover(options) {
  88. var _this = this;
  89. this.isHidden = true;
  90. this.margin = 10; // the space required between the popover and the edges of the scroll container
  91. // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
  92. this.documentMousedown = function (ev) {
  93. // only hide the popover if the click happened outside the popover
  94. if (_this.el && !_this.el.contains(ev.target)) {
  95. _this.hide();
  96. }
  97. };
  98. this.options = options;
  99. }
  100. // Shows the popover on the specified position. Renders it if not already
  101. Popover.prototype.show = function () {
  102. if (this.isHidden) {
  103. if (!this.el) {
  104. this.render();
  105. }
  106. this.el.style.display = '';
  107. this.position();
  108. this.isHidden = false;
  109. this.trigger('show');
  110. }
  111. };
  112. // Hides the popover, through CSS, but does not remove it from the DOM
  113. Popover.prototype.hide = function () {
  114. if (!this.isHidden) {
  115. this.el.style.display = 'none';
  116. this.isHidden = true;
  117. this.trigger('hide');
  118. }
  119. };
  120. // Creates `this.el` and renders content inside of it
  121. Popover.prototype.render = function () {
  122. var _this = this;
  123. var options = this.options;
  124. var el = this.el = createElement('div', {
  125. className: 'fc-popover ' + (options.className || ''),
  126. style: {
  127. top: '0',
  128. left: '0'
  129. }
  130. });
  131. if (typeof options.content === 'function') {
  132. options.content(el);
  133. }
  134. options.parentEl.appendChild(el);
  135. // when a click happens on anything inside with a 'fc-close' className, hide the popover
  136. listenBySelector(el, 'click', '.fc-close', function (ev) {
  137. _this.hide();
  138. });
  139. if (options.autoHide) {
  140. document.addEventListener('mousedown', this.documentMousedown);
  141. }
  142. };
  143. // Hides and unregisters any handlers
  144. Popover.prototype.destroy = function () {
  145. this.hide();
  146. if (this.el) {
  147. removeElement(this.el);
  148. this.el = null;
  149. }
  150. document.removeEventListener('mousedown', this.documentMousedown);
  151. };
  152. // Positions the popover optimally, using the top/left/right options
  153. Popover.prototype.position = function () {
  154. var options = this.options;
  155. var el = this.el;
  156. var elDims = el.getBoundingClientRect(); // only used for width,height
  157. var origin = computeRect(el.offsetParent);
  158. var clippingRect = computeClippingRect(options.parentEl);
  159. var top; // the "position" (not "offset") values for the popover
  160. var left; //
  161. // compute top and left
  162. top = options.top || 0;
  163. if (options.left !== undefined) {
  164. left = options.left;
  165. }
  166. else if (options.right !== undefined) {
  167. left = options.right - elDims.width; // derive the left value from the right value
  168. }
  169. else {
  170. left = 0;
  171. }
  172. // constrain to the view port. if constrained by two edges, give precedence to top/left
  173. top = Math.min(top, clippingRect.bottom - elDims.height - this.margin);
  174. top = Math.max(top, clippingRect.top + this.margin);
  175. left = Math.min(left, clippingRect.right - elDims.width - this.margin);
  176. left = Math.max(left, clippingRect.left + this.margin);
  177. applyStyle(el, {
  178. top: top - origin.top,
  179. left: left - origin.left
  180. });
  181. };
  182. // Triggers a callback. Calls a function in the option hash of the same name.
  183. // Arguments beyond the first `name` are forwarded on.
  184. // TODO: better code reuse for this. Repeat code
  185. // can kill this???
  186. Popover.prototype.trigger = function (name) {
  187. if (this.options[name]) {
  188. this.options[name].apply(this, Array.prototype.slice.call(arguments, 1));
  189. }
  190. };
  191. return Popover;
  192. }());
  193. /* Event-rendering methods for the DayGrid class
  194. ----------------------------------------------------------------------------------------------------------------------*/
  195. // "Simple" is bad a name. has nothing to do with SimpleDayGrid
  196. var SimpleDayGridEventRenderer = /** @class */ (function (_super) {
  197. __extends(SimpleDayGridEventRenderer, _super);
  198. function SimpleDayGridEventRenderer() {
  199. return _super !== null && _super.apply(this, arguments) || this;
  200. }
  201. // Builds the HTML to be used for the default element for an individual segment
  202. SimpleDayGridEventRenderer.prototype.renderSegHtml = function (seg, mirrorInfo) {
  203. var _a = this.context, view = _a.view, options = _a.options;
  204. var eventRange = seg.eventRange;
  205. var eventDef = eventRange.def;
  206. var eventUi = eventRange.ui;
  207. var allDay = eventDef.allDay;
  208. var isDraggable = view.computeEventDraggable(eventDef, eventUi);
  209. var isResizableFromStart = allDay && seg.isStart && view.computeEventStartResizable(eventDef, eventUi);
  210. var isResizableFromEnd = allDay && seg.isEnd && view.computeEventEndResizable(eventDef, eventUi);
  211. var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd, mirrorInfo);
  212. var skinCss = cssToStr(this.getSkinCss(eventUi));
  213. var timeHtml = '';
  214. var timeText;
  215. var titleHtml;
  216. classes.unshift('fc-day-grid-event', 'fc-h-event');
  217. // Only display a timed events time if it is the starting segment
  218. if (seg.isStart) {
  219. timeText = this.getTimeText(eventRange);
  220. if (timeText) {
  221. timeHtml = '<span class="fc-time">' + htmlEscape(timeText) + '</span>';
  222. }
  223. }
  224. titleHtml =
  225. '<span class="fc-title">' +
  226. (htmlEscape(eventDef.title || '') || '&nbsp;') + // we always want one line of height
  227. '</span>';
  228. return '<a class="' + classes.join(' ') + '"' +
  229. (eventDef.url ?
  230. ' href="' + htmlEscape(eventDef.url) + '"' :
  231. '') +
  232. (skinCss ?
  233. ' style="' + skinCss + '"' :
  234. '') +
  235. '>' +
  236. '<div class="fc-content">' +
  237. (options.dir === 'rtl' ?
  238. titleHtml + ' ' + timeHtml : // put a natural space in between
  239. timeHtml + ' ' + titleHtml //
  240. ) +
  241. '</div>' +
  242. (isResizableFromStart ?
  243. '<div class="fc-resizer fc-start-resizer"></div>' :
  244. '') +
  245. (isResizableFromEnd ?
  246. '<div class="fc-resizer fc-end-resizer"></div>' :
  247. '') +
  248. '</a>';
  249. };
  250. // Computes a default event time formatting string if `eventTimeFormat` is not explicitly defined
  251. SimpleDayGridEventRenderer.prototype.computeEventTimeFormat = function () {
  252. return {
  253. hour: 'numeric',
  254. minute: '2-digit',
  255. omitZeroMinute: true,
  256. meridiem: 'narrow'
  257. };
  258. };
  259. SimpleDayGridEventRenderer.prototype.computeDisplayEventEnd = function () {
  260. return false; // TODO: somehow consider the originating DayGrid's column count
  261. };
  262. return SimpleDayGridEventRenderer;
  263. }(FgEventRenderer));
  264. /* Event-rendering methods for the DayGrid class
  265. ----------------------------------------------------------------------------------------------------------------------*/
  266. var DayGridEventRenderer = /** @class */ (function (_super) {
  267. __extends(DayGridEventRenderer, _super);
  268. function DayGridEventRenderer(dayGrid) {
  269. var _this = _super.call(this, dayGrid.context) || this;
  270. _this.dayGrid = dayGrid;
  271. return _this;
  272. }
  273. // Renders the given foreground event segments onto the grid
  274. DayGridEventRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  275. var rowStructs = this.rowStructs = this.renderSegRows(segs);
  276. // append to each row's content skeleton
  277. this.dayGrid.rowEls.forEach(function (rowNode, i) {
  278. rowNode.querySelector('.fc-content-skeleton > table').appendChild(rowStructs[i].tbodyEl);
  279. });
  280. // removes the "more.." events popover
  281. if (!mirrorInfo) {
  282. this.dayGrid.removeSegPopover();
  283. }
  284. };
  285. // Unrenders all currently rendered foreground event segments
  286. DayGridEventRenderer.prototype.detachSegs = function () {
  287. var rowStructs = this.rowStructs || [];
  288. var rowStruct;
  289. while ((rowStruct = rowStructs.pop())) {
  290. removeElement(rowStruct.tbodyEl);
  291. }
  292. this.rowStructs = null;
  293. };
  294. // Uses the given events array to generate <tbody> elements that should be appended to each row's content skeleton.
  295. // Returns an array of rowStruct objects (see the bottom of `renderSegRow`).
  296. // PRECONDITION: each segment shoud already have a rendered and assigned `.el`
  297. DayGridEventRenderer.prototype.renderSegRows = function (segs) {
  298. var rowStructs = [];
  299. var segRows;
  300. var row;
  301. segRows = this.groupSegRows(segs); // group into nested arrays
  302. // iterate each row of segment groupings
  303. for (row = 0; row < segRows.length; row++) {
  304. rowStructs.push(this.renderSegRow(row, segRows[row]));
  305. }
  306. return rowStructs;
  307. };
  308. // Given a row # and an array of segments all in the same row, render a <tbody> element, a skeleton that contains
  309. // the segments. Returns object with a bunch of internal data about how the render was calculated.
  310. // NOTE: modifies rowSegs
  311. DayGridEventRenderer.prototype.renderSegRow = function (row, rowSegs) {
  312. var dayGrid = this.dayGrid;
  313. var colCnt = dayGrid.colCnt, isRtl = dayGrid.isRtl;
  314. var segLevels = this.buildSegLevels(rowSegs); // group into sub-arrays of levels
  315. var levelCnt = Math.max(1, segLevels.length); // ensure at least one level
  316. var tbody = document.createElement('tbody');
  317. var segMatrix = []; // lookup for which segments are rendered into which level+col cells
  318. var cellMatrix = []; // lookup for all <td> elements of the level+col matrix
  319. var loneCellMatrix = []; // lookup for <td> elements that only take up a single column
  320. var i;
  321. var levelSegs;
  322. var col;
  323. var tr;
  324. var j;
  325. var seg;
  326. var td;
  327. // populates empty cells from the current column (`col`) to `endCol`
  328. function emptyCellsUntil(endCol) {
  329. while (col < endCol) {
  330. // try to grab a cell from the level above and extend its rowspan. otherwise, create a fresh cell
  331. td = (loneCellMatrix[i - 1] || [])[col];
  332. if (td) {
  333. td.rowSpan = (td.rowSpan || 1) + 1;
  334. }
  335. else {
  336. td = document.createElement('td');
  337. tr.appendChild(td);
  338. }
  339. cellMatrix[i][col] = td;
  340. loneCellMatrix[i][col] = td;
  341. col++;
  342. }
  343. }
  344. for (i = 0; i < levelCnt; i++) { // iterate through all levels
  345. levelSegs = segLevels[i];
  346. col = 0;
  347. tr = document.createElement('tr');
  348. segMatrix.push([]);
  349. cellMatrix.push([]);
  350. loneCellMatrix.push([]);
  351. // levelCnt might be 1 even though there are no actual levels. protect against this.
  352. // this single empty row is useful for styling.
  353. if (levelSegs) {
  354. for (j = 0; j < levelSegs.length; j++) { // iterate through segments in level
  355. seg = levelSegs[j];
  356. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  357. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  358. emptyCellsUntil(leftCol);
  359. // create a container that occupies or more columns. append the event element.
  360. td = createElement('td', { className: 'fc-event-container' }, seg.el);
  361. if (leftCol !== rightCol) {
  362. td.colSpan = rightCol - leftCol + 1;
  363. }
  364. else { // a single-column segment
  365. loneCellMatrix[i][col] = td;
  366. }
  367. while (col <= rightCol) {
  368. cellMatrix[i][col] = td;
  369. segMatrix[i][col] = seg;
  370. col++;
  371. }
  372. tr.appendChild(td);
  373. }
  374. }
  375. emptyCellsUntil(colCnt); // finish off the row
  376. var introHtml = dayGrid.renderProps.renderIntroHtml();
  377. if (introHtml) {
  378. if (dayGrid.isRtl) {
  379. appendToElement(tr, introHtml);
  380. }
  381. else {
  382. prependToElement(tr, introHtml);
  383. }
  384. }
  385. tbody.appendChild(tr);
  386. }
  387. return {
  388. row: row,
  389. tbodyEl: tbody,
  390. cellMatrix: cellMatrix,
  391. segMatrix: segMatrix,
  392. segLevels: segLevels,
  393. segs: rowSegs
  394. };
  395. };
  396. // Stacks a flat array of segments, which are all assumed to be in the same row, into subarrays of vertical levels.
  397. // NOTE: modifies segs
  398. DayGridEventRenderer.prototype.buildSegLevels = function (segs) {
  399. var _a = this.dayGrid, isRtl = _a.isRtl, colCnt = _a.colCnt;
  400. var levels = [];
  401. var i;
  402. var seg;
  403. var j;
  404. // Give preference to elements with certain criteria, so they have
  405. // a chance to be closer to the top.
  406. segs = this.sortEventSegs(segs);
  407. for (i = 0; i < segs.length; i++) {
  408. seg = segs[i];
  409. // loop through levels, starting with the topmost, until the segment doesn't collide with other segments
  410. for (j = 0; j < levels.length; j++) {
  411. if (!isDaySegCollision(seg, levels[j])) {
  412. break;
  413. }
  414. }
  415. // `j` now holds the desired subrow index
  416. seg.level = j;
  417. seg.leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol; // for sorting only
  418. seg.rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol // for sorting only
  419. ;
  420. (levels[j] || (levels[j] = [])).push(seg);
  421. }
  422. // order segments left-to-right. very important if calendar is RTL
  423. for (j = 0; j < levels.length; j++) {
  424. levels[j].sort(compareDaySegCols);
  425. }
  426. return levels;
  427. };
  428. // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's row
  429. DayGridEventRenderer.prototype.groupSegRows = function (segs) {
  430. var segRows = [];
  431. var i;
  432. for (i = 0; i < this.dayGrid.rowCnt; i++) {
  433. segRows.push([]);
  434. }
  435. for (i = 0; i < segs.length; i++) {
  436. segRows[segs[i].row].push(segs[i]);
  437. }
  438. return segRows;
  439. };
  440. // Computes a default `displayEventEnd` value if one is not expliclty defined
  441. DayGridEventRenderer.prototype.computeDisplayEventEnd = function () {
  442. return this.dayGrid.colCnt === 1; // we'll likely have space if there's only one day
  443. };
  444. return DayGridEventRenderer;
  445. }(SimpleDayGridEventRenderer));
  446. // Computes whether two segments' columns collide. They are assumed to be in the same row.
  447. function isDaySegCollision(seg, otherSegs) {
  448. var i;
  449. var otherSeg;
  450. for (i = 0; i < otherSegs.length; i++) {
  451. otherSeg = otherSegs[i];
  452. if (otherSeg.firstCol <= seg.lastCol &&
  453. otherSeg.lastCol >= seg.firstCol) {
  454. return true;
  455. }
  456. }
  457. return false;
  458. }
  459. // A cmp function for determining the leftmost event
  460. function compareDaySegCols(a, b) {
  461. return a.leftCol - b.leftCol;
  462. }
  463. var DayGridMirrorRenderer = /** @class */ (function (_super) {
  464. __extends(DayGridMirrorRenderer, _super);
  465. function DayGridMirrorRenderer() {
  466. return _super !== null && _super.apply(this, arguments) || this;
  467. }
  468. DayGridMirrorRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  469. var sourceSeg = mirrorInfo.sourceSeg;
  470. var rowStructs = this.rowStructs = this.renderSegRows(segs);
  471. // inject each new event skeleton into each associated row
  472. this.dayGrid.rowEls.forEach(function (rowNode, row) {
  473. var skeletonEl = htmlToElement('<div class="fc-mirror-skeleton"><table></table></div>'); // will be absolutely positioned
  474. var skeletonTopEl;
  475. var skeletonTop;
  476. // If there is an original segment, match the top position. Otherwise, put it at the row's top level
  477. if (sourceSeg && sourceSeg.row === row) {
  478. skeletonTopEl = sourceSeg.el;
  479. }
  480. else {
  481. skeletonTopEl = rowNode.querySelector('.fc-content-skeleton tbody');
  482. if (!skeletonTopEl) { // when no events
  483. skeletonTopEl = rowNode.querySelector('.fc-content-skeleton table');
  484. }
  485. }
  486. skeletonTop = skeletonTopEl.getBoundingClientRect().top -
  487. rowNode.getBoundingClientRect().top; // the offsetParent origin
  488. skeletonEl.style.top = skeletonTop + 'px';
  489. skeletonEl.querySelector('table').appendChild(rowStructs[row].tbodyEl);
  490. rowNode.appendChild(skeletonEl);
  491. });
  492. };
  493. return DayGridMirrorRenderer;
  494. }(DayGridEventRenderer));
  495. var EMPTY_CELL_HTML = '<td style="pointer-events:none"></td>';
  496. var DayGridFillRenderer = /** @class */ (function (_super) {
  497. __extends(DayGridFillRenderer, _super);
  498. function DayGridFillRenderer(dayGrid) {
  499. var _this = _super.call(this, dayGrid.context) || this;
  500. _this.fillSegTag = 'td'; // override the default tag name
  501. _this.dayGrid = dayGrid;
  502. return _this;
  503. }
  504. DayGridFillRenderer.prototype.renderSegs = function (type, segs) {
  505. // don't render timed background events
  506. if (type === 'bgEvent') {
  507. segs = segs.filter(function (seg) {
  508. return seg.eventRange.def.allDay;
  509. });
  510. }
  511. _super.prototype.renderSegs.call(this, type, segs);
  512. };
  513. DayGridFillRenderer.prototype.attachSegs = function (type, segs) {
  514. var els = [];
  515. var i;
  516. var seg;
  517. var skeletonEl;
  518. for (i = 0; i < segs.length; i++) {
  519. seg = segs[i];
  520. skeletonEl = this.renderFillRow(type, seg);
  521. this.dayGrid.rowEls[seg.row].appendChild(skeletonEl);
  522. els.push(skeletonEl);
  523. }
  524. return els;
  525. };
  526. // Generates the HTML needed for one row of a fill. Requires the seg's el to be rendered.
  527. DayGridFillRenderer.prototype.renderFillRow = function (type, seg) {
  528. var dayGrid = this.dayGrid;
  529. var colCnt = dayGrid.colCnt, isRtl = dayGrid.isRtl;
  530. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  531. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  532. var startCol = leftCol;
  533. var endCol = rightCol + 1;
  534. var className;
  535. var skeletonEl;
  536. var trEl;
  537. if (type === 'businessHours') {
  538. className = 'bgevent';
  539. }
  540. else {
  541. className = type.toLowerCase();
  542. }
  543. skeletonEl = htmlToElement('<div class="fc-' + className + '-skeleton">' +
  544. '<table><tr></tr></table>' +
  545. '</div>');
  546. trEl = skeletonEl.getElementsByTagName('tr')[0];
  547. if (startCol > 0) {
  548. appendToElement(trEl,
  549. // will create (startCol + 1) td's
  550. new Array(startCol + 1).join(EMPTY_CELL_HTML));
  551. }
  552. seg.el.colSpan = endCol - startCol;
  553. trEl.appendChild(seg.el);
  554. if (endCol < colCnt) {
  555. appendToElement(trEl,
  556. // will create (colCnt - endCol) td's
  557. new Array(colCnt - endCol + 1).join(EMPTY_CELL_HTML));
  558. }
  559. var introHtml = dayGrid.renderProps.renderIntroHtml();
  560. if (introHtml) {
  561. if (dayGrid.isRtl) {
  562. appendToElement(trEl, introHtml);
  563. }
  564. else {
  565. prependToElement(trEl, introHtml);
  566. }
  567. }
  568. return skeletonEl;
  569. };
  570. return DayGridFillRenderer;
  571. }(FillRenderer));
  572. var DayTile = /** @class */ (function (_super) {
  573. __extends(DayTile, _super);
  574. function DayTile(context, el) {
  575. var _this = _super.call(this, context, el) || this;
  576. var eventRenderer = _this.eventRenderer = new DayTileEventRenderer(_this);
  577. var renderFrame = _this.renderFrame = memoizeRendering(_this._renderFrame);
  578. _this.renderFgEvents = memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderFrame]);
  579. _this.renderEventSelection = memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
  580. _this.renderEventDrag = memoizeRendering(eventRenderer.hideByHash.bind(eventRenderer), eventRenderer.showByHash.bind(eventRenderer), [renderFrame]);
  581. _this.renderEventResize = memoizeRendering(eventRenderer.hideByHash.bind(eventRenderer), eventRenderer.showByHash.bind(eventRenderer), [renderFrame]);
  582. context.calendar.registerInteractiveComponent(_this, {
  583. el: _this.el,
  584. useEventCenter: false
  585. });
  586. return _this;
  587. }
  588. DayTile.prototype.render = function (props) {
  589. this.renderFrame(props.date);
  590. this.renderFgEvents(props.fgSegs);
  591. this.renderEventSelection(props.eventSelection);
  592. this.renderEventDrag(props.eventDragInstances);
  593. this.renderEventResize(props.eventResizeInstances);
  594. };
  595. DayTile.prototype.destroy = function () {
  596. _super.prototype.destroy.call(this);
  597. this.renderFrame.unrender(); // should unrender everything else
  598. this.calendar.unregisterInteractiveComponent(this);
  599. };
  600. DayTile.prototype._renderFrame = function (date) {
  601. var _a = this, theme = _a.theme, dateEnv = _a.dateEnv;
  602. var title = dateEnv.format(date, createFormatter(this.opt('dayPopoverFormat')) // TODO: cache
  603. );
  604. this.el.innerHTML =
  605. '<div class="fc-header ' + theme.getClass('popoverHeader') + '">' +
  606. '<span class="fc-title">' +
  607. htmlEscape(title) +
  608. '</span>' +
  609. '<span class="fc-close ' + theme.getIconClass('close') + '"></span>' +
  610. '</div>' +
  611. '<div class="fc-body ' + theme.getClass('popoverContent') + '">' +
  612. '<div class="fc-event-container"></div>' +
  613. '</div>';
  614. this.segContainerEl = this.el.querySelector('.fc-event-container');
  615. };
  616. DayTile.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  617. var date = this.props.date; // HACK
  618. if (positionLeft < elWidth && positionTop < elHeight) {
  619. return {
  620. component: this,
  621. dateSpan: {
  622. allDay: true,
  623. range: { start: date, end: addDays(date, 1) }
  624. },
  625. dayEl: this.el,
  626. rect: {
  627. left: 0,
  628. top: 0,
  629. right: elWidth,
  630. bottom: elHeight
  631. },
  632. layer: 1
  633. };
  634. }
  635. };
  636. return DayTile;
  637. }(DateComponent));
  638. var DayTileEventRenderer = /** @class */ (function (_super) {
  639. __extends(DayTileEventRenderer, _super);
  640. function DayTileEventRenderer(dayTile) {
  641. var _this = _super.call(this, dayTile.context) || this;
  642. _this.dayTile = dayTile;
  643. return _this;
  644. }
  645. DayTileEventRenderer.prototype.attachSegs = function (segs) {
  646. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  647. var seg = segs_1[_i];
  648. this.dayTile.segContainerEl.appendChild(seg.el);
  649. }
  650. };
  651. DayTileEventRenderer.prototype.detachSegs = function (segs) {
  652. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  653. var seg = segs_2[_i];
  654. removeElement(seg.el);
  655. }
  656. };
  657. return DayTileEventRenderer;
  658. }(SimpleDayGridEventRenderer));
  659. var DayBgRow = /** @class */ (function () {
  660. function DayBgRow(context) {
  661. this.context = context;
  662. }
  663. DayBgRow.prototype.renderHtml = function (props) {
  664. var parts = [];
  665. if (props.renderIntroHtml) {
  666. parts.push(props.renderIntroHtml());
  667. }
  668. for (var _i = 0, _a = props.cells; _i < _a.length; _i++) {
  669. var cell = _a[_i];
  670. parts.push(renderCellHtml(cell.date, props.dateProfile, this.context, cell.htmlAttrs));
  671. }
  672. if (!props.cells.length) {
  673. parts.push('<td class="fc-day ' + this.context.theme.getClass('widgetContent') + '"></td>');
  674. }
  675. if (this.context.options.dir === 'rtl') {
  676. parts.reverse();
  677. }
  678. return '<tr>' + parts.join('') + '</tr>';
  679. };
  680. return DayBgRow;
  681. }());
  682. function renderCellHtml(date, dateProfile, context, otherAttrs) {
  683. var dateEnv = context.dateEnv, theme = context.theme;
  684. var isDateValid = rangeContainsMarker(dateProfile.activeRange, date); // TODO: called too frequently. cache somehow.
  685. var classes = getDayClasses(date, dateProfile, context);
  686. classes.unshift('fc-day', theme.getClass('widgetContent'));
  687. return '<td class="' + classes.join(' ') + '"' +
  688. (isDateValid ?
  689. ' data-date="' + dateEnv.formatIso(date, { omitTime: true }) + '"' :
  690. '') +
  691. (otherAttrs ?
  692. ' ' + otherAttrs :
  693. '') +
  694. '></td>';
  695. }
  696. var DAY_NUM_FORMAT = createFormatter({ day: 'numeric' });
  697. var WEEK_NUM_FORMAT = createFormatter({ week: 'numeric' });
  698. var DayGrid = /** @class */ (function (_super) {
  699. __extends(DayGrid, _super);
  700. function DayGrid(context, el, renderProps) {
  701. var _this = _super.call(this, context, el) || this;
  702. _this.bottomCoordPadding = 0; // hack for extending the hit area for the last row of the coordinate grid
  703. _this.isCellSizesDirty = false;
  704. var eventRenderer = _this.eventRenderer = new DayGridEventRenderer(_this);
  705. var fillRenderer = _this.fillRenderer = new DayGridFillRenderer(_this);
  706. _this.mirrorRenderer = new DayGridMirrorRenderer(_this);
  707. var renderCells = _this.renderCells = memoizeRendering(_this._renderCells, _this._unrenderCells);
  708. _this.renderBusinessHours = memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'businessHours'), fillRenderer.unrender.bind(fillRenderer, 'businessHours'), [renderCells]);
  709. _this.renderDateSelection = memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'highlight'), fillRenderer.unrender.bind(fillRenderer, 'highlight'), [renderCells]);
  710. _this.renderBgEvents = memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'bgEvent'), fillRenderer.unrender.bind(fillRenderer, 'bgEvent'), [renderCells]);
  711. _this.renderFgEvents = memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderCells]);
  712. _this.renderEventSelection = memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
  713. _this.renderEventDrag = memoizeRendering(_this._renderEventDrag, _this._unrenderEventDrag, [renderCells]);
  714. _this.renderEventResize = memoizeRendering(_this._renderEventResize, _this._unrenderEventResize, [renderCells]);
  715. _this.renderProps = renderProps;
  716. return _this;
  717. }
  718. DayGrid.prototype.render = function (props) {
  719. var cells = props.cells;
  720. this.rowCnt = cells.length;
  721. this.colCnt = cells[0].length;
  722. this.renderCells(cells, props.isRigid);
  723. this.renderBusinessHours(props.businessHourSegs);
  724. this.renderDateSelection(props.dateSelectionSegs);
  725. this.renderBgEvents(props.bgEventSegs);
  726. this.renderFgEvents(props.fgEventSegs);
  727. this.renderEventSelection(props.eventSelection);
  728. this.renderEventDrag(props.eventDrag);
  729. this.renderEventResize(props.eventResize);
  730. if (this.segPopoverTile) {
  731. this.updateSegPopoverTile();
  732. }
  733. };
  734. DayGrid.prototype.destroy = function () {
  735. _super.prototype.destroy.call(this);
  736. this.renderCells.unrender(); // will unrender everything else
  737. };
  738. DayGrid.prototype.getCellRange = function (row, col) {
  739. var start = this.props.cells[row][col].date;
  740. var end = addDays(start, 1);
  741. return { start: start, end: end };
  742. };
  743. DayGrid.prototype.updateSegPopoverTile = function (date, segs) {
  744. var ownProps = this.props;
  745. this.segPopoverTile.receiveProps({
  746. date: date || this.segPopoverTile.props.date,
  747. fgSegs: segs || this.segPopoverTile.props.fgSegs,
  748. eventSelection: ownProps.eventSelection,
  749. eventDragInstances: ownProps.eventDrag ? ownProps.eventDrag.affectedInstances : null,
  750. eventResizeInstances: ownProps.eventResize ? ownProps.eventResize.affectedInstances : null
  751. });
  752. };
  753. /* Date Rendering
  754. ------------------------------------------------------------------------------------------------------------------*/
  755. DayGrid.prototype._renderCells = function (cells, isRigid) {
  756. var _a = this, view = _a.view, dateEnv = _a.dateEnv;
  757. var _b = this, rowCnt = _b.rowCnt, colCnt = _b.colCnt;
  758. var html = '';
  759. var row;
  760. var col;
  761. for (row = 0; row < rowCnt; row++) {
  762. html += this.renderDayRowHtml(row, isRigid);
  763. }
  764. this.el.innerHTML = html;
  765. this.rowEls = findElements(this.el, '.fc-row');
  766. this.cellEls = findElements(this.el, '.fc-day, .fc-disabled-day');
  767. if (this.isRtl) {
  768. this.cellEls.reverse();
  769. }
  770. this.rowPositions = new PositionCache(this.el, this.rowEls, false, true // vertical
  771. );
  772. this.colPositions = new PositionCache(this.el, this.cellEls.slice(0, colCnt), // only the first row
  773. true, false // horizontal
  774. );
  775. // trigger dayRender with each cell's element
  776. for (row = 0; row < rowCnt; row++) {
  777. for (col = 0; col < colCnt; col++) {
  778. this.publiclyTrigger('dayRender', [
  779. {
  780. date: dateEnv.toDate(cells[row][col].date),
  781. el: this.getCellEl(row, col),
  782. view: view
  783. }
  784. ]);
  785. }
  786. }
  787. this.isCellSizesDirty = true;
  788. };
  789. DayGrid.prototype._unrenderCells = function () {
  790. this.removeSegPopover();
  791. };
  792. // Generates the HTML for a single row, which is a div that wraps a table.
  793. // `row` is the row number.
  794. DayGrid.prototype.renderDayRowHtml = function (row, isRigid) {
  795. var theme = this.theme;
  796. var classes = ['fc-row', 'fc-week', theme.getClass('dayRow')];
  797. if (isRigid) {
  798. classes.push('fc-rigid');
  799. }
  800. var bgRow = new DayBgRow(this.context);
  801. return '' +
  802. '<div class="' + classes.join(' ') + '">' +
  803. '<div class="fc-bg">' +
  804. '<table class="' + theme.getClass('tableGrid') + '">' +
  805. bgRow.renderHtml({
  806. cells: this.props.cells[row],
  807. dateProfile: this.props.dateProfile,
  808. renderIntroHtml: this.renderProps.renderBgIntroHtml
  809. }) +
  810. '</table>' +
  811. '</div>' +
  812. '<div class="fc-content-skeleton">' +
  813. '<table>' +
  814. (this.getIsNumbersVisible() ?
  815. '<thead>' +
  816. this.renderNumberTrHtml(row) +
  817. '</thead>' :
  818. '') +
  819. '</table>' +
  820. '</div>' +
  821. '</div>';
  822. };
  823. DayGrid.prototype.getIsNumbersVisible = function () {
  824. return this.getIsDayNumbersVisible() ||
  825. this.renderProps.cellWeekNumbersVisible ||
  826. this.renderProps.colWeekNumbersVisible;
  827. };
  828. DayGrid.prototype.getIsDayNumbersVisible = function () {
  829. return this.rowCnt > 1;
  830. };
  831. /* Grid Number Rendering
  832. ------------------------------------------------------------------------------------------------------------------*/
  833. DayGrid.prototype.renderNumberTrHtml = function (row) {
  834. var intro = this.renderProps.renderNumberIntroHtml(row, this);
  835. return '' +
  836. '<tr>' +
  837. (this.isRtl ? '' : intro) +
  838. this.renderNumberCellsHtml(row) +
  839. (this.isRtl ? intro : '') +
  840. '</tr>';
  841. };
  842. DayGrid.prototype.renderNumberCellsHtml = function (row) {
  843. var htmls = [];
  844. var col;
  845. var date;
  846. for (col = 0; col < this.colCnt; col++) {
  847. date = this.props.cells[row][col].date;
  848. htmls.push(this.renderNumberCellHtml(date));
  849. }
  850. if (this.isRtl) {
  851. htmls.reverse();
  852. }
  853. return htmls.join('');
  854. };
  855. // Generates the HTML for the <td>s of the "number" row in the DayGrid's content skeleton.
  856. // The number row will only exist if either day numbers or week numbers are turned on.
  857. DayGrid.prototype.renderNumberCellHtml = function (date) {
  858. var _a = this, view = _a.view, dateEnv = _a.dateEnv;
  859. var html = '';
  860. var isDateValid = rangeContainsMarker(this.props.dateProfile.activeRange, date); // TODO: called too frequently. cache somehow.
  861. var isDayNumberVisible = this.getIsDayNumbersVisible() && isDateValid;
  862. var classes;
  863. var weekCalcFirstDow;
  864. if (!isDayNumberVisible && !this.renderProps.cellWeekNumbersVisible) {
  865. // no numbers in day cell (week number must be along the side)
  866. return '<td></td>'; // will create an empty space above events :(
  867. }
  868. classes = getDayClasses(date, this.props.dateProfile, this.context);
  869. classes.unshift('fc-day-top');
  870. if (this.renderProps.cellWeekNumbersVisible) {
  871. weekCalcFirstDow = dateEnv.weekDow;
  872. }
  873. html += '<td class="' + classes.join(' ') + '"' +
  874. (isDateValid ?
  875. ' data-date="' + dateEnv.formatIso(date, { omitTime: true }) + '"' :
  876. '') +
  877. '>';
  878. if (this.renderProps.cellWeekNumbersVisible && (date.getUTCDay() === weekCalcFirstDow)) {
  879. html += buildGotoAnchorHtml(view, { date: date, type: 'week' }, { 'class': 'fc-week-number' }, dateEnv.format(date, WEEK_NUM_FORMAT) // inner HTML
  880. );
  881. }
  882. if (isDayNumberVisible) {
  883. html += buildGotoAnchorHtml(view, date, { 'class': 'fc-day-number' }, dateEnv.format(date, DAY_NUM_FORMAT) // inner HTML
  884. );
  885. }
  886. html += '</td>';
  887. return html;
  888. };
  889. /* Sizing
  890. ------------------------------------------------------------------------------------------------------------------*/
  891. DayGrid.prototype.updateSize = function (isResize) {
  892. var _a = this, fillRenderer = _a.fillRenderer, eventRenderer = _a.eventRenderer, mirrorRenderer = _a.mirrorRenderer;
  893. if (isResize ||
  894. this.isCellSizesDirty ||
  895. this.view.calendar.isEventsUpdated // hack
  896. ) {
  897. this.buildPositionCaches();
  898. this.isCellSizesDirty = false;
  899. }
  900. fillRenderer.computeSizes(isResize);
  901. eventRenderer.computeSizes(isResize);
  902. mirrorRenderer.computeSizes(isResize);
  903. fillRenderer.assignSizes(isResize);
  904. eventRenderer.assignSizes(isResize);
  905. mirrorRenderer.assignSizes(isResize);
  906. };
  907. DayGrid.prototype.buildPositionCaches = function () {
  908. this.buildColPositions();
  909. this.buildRowPositions();
  910. };
  911. DayGrid.prototype.buildColPositions = function () {
  912. this.colPositions.build();
  913. };
  914. DayGrid.prototype.buildRowPositions = function () {
  915. this.rowPositions.build();
  916. this.rowPositions.bottoms[this.rowCnt - 1] += this.bottomCoordPadding; // hack
  917. };
  918. /* Hit System
  919. ------------------------------------------------------------------------------------------------------------------*/
  920. DayGrid.prototype.positionToHit = function (leftPosition, topPosition) {
  921. var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
  922. var col = colPositions.leftToIndex(leftPosition);
  923. var row = rowPositions.topToIndex(topPosition);
  924. if (row != null && col != null) {
  925. return {
  926. row: row,
  927. col: col,
  928. dateSpan: {
  929. range: this.getCellRange(row, col),
  930. allDay: true
  931. },
  932. dayEl: this.getCellEl(row, col),
  933. relativeRect: {
  934. left: colPositions.lefts[col],
  935. right: colPositions.rights[col],
  936. top: rowPositions.tops[row],
  937. bottom: rowPositions.bottoms[row]
  938. }
  939. };
  940. }
  941. };
  942. /* Cell System
  943. ------------------------------------------------------------------------------------------------------------------*/
  944. // FYI: the first column is the leftmost column, regardless of date
  945. DayGrid.prototype.getCellEl = function (row, col) {
  946. return this.cellEls[row * this.colCnt + col];
  947. };
  948. /* Event Drag Visualization
  949. ------------------------------------------------------------------------------------------------------------------*/
  950. DayGrid.prototype._renderEventDrag = function (state) {
  951. if (state) {
  952. this.eventRenderer.hideByHash(state.affectedInstances);
  953. this.fillRenderer.renderSegs('highlight', state.segs);
  954. }
  955. };
  956. DayGrid.prototype._unrenderEventDrag = function (state) {
  957. if (state) {
  958. this.eventRenderer.showByHash(state.affectedInstances);
  959. this.fillRenderer.unrender('highlight');
  960. }
  961. };
  962. /* Event Resize Visualization
  963. ------------------------------------------------------------------------------------------------------------------*/
  964. DayGrid.prototype._renderEventResize = function (state) {
  965. if (state) {
  966. this.eventRenderer.hideByHash(state.affectedInstances);
  967. this.fillRenderer.renderSegs('highlight', state.segs);
  968. this.mirrorRenderer.renderSegs(state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  969. }
  970. };
  971. DayGrid.prototype._unrenderEventResize = function (state) {
  972. if (state) {
  973. this.eventRenderer.showByHash(state.affectedInstances);
  974. this.fillRenderer.unrender('highlight');
  975. this.mirrorRenderer.unrender(state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  976. }
  977. };
  978. /* More+ Link Popover
  979. ------------------------------------------------------------------------------------------------------------------*/
  980. DayGrid.prototype.removeSegPopover = function () {
  981. if (this.segPopover) {
  982. this.segPopover.hide(); // in handler, will call segPopover's removeElement
  983. }
  984. };
  985. // Limits the number of "levels" (vertically stacking layers of events) for each row of the grid.
  986. // `levelLimit` can be false (don't limit), a number, or true (should be computed).
  987. DayGrid.prototype.limitRows = function (levelLimit) {
  988. var rowStructs = this.eventRenderer.rowStructs || [];
  989. var row; // row #
  990. var rowLevelLimit;
  991. for (row = 0; row < rowStructs.length; row++) {
  992. this.unlimitRow(row);
  993. if (!levelLimit) {
  994. rowLevelLimit = false;
  995. }
  996. else if (typeof levelLimit === 'number') {
  997. rowLevelLimit = levelLimit;
  998. }
  999. else {
  1000. rowLevelLimit = this.computeRowLevelLimit(row);
  1001. }
  1002. if (rowLevelLimit !== false) {
  1003. this.limitRow(row, rowLevelLimit);
  1004. }
  1005. }
  1006. };
  1007. // Computes the number of levels a row will accomodate without going outside its bounds.
  1008. // Assumes the row is "rigid" (maintains a constant height regardless of what is inside).
  1009. // `row` is the row number.
  1010. DayGrid.prototype.computeRowLevelLimit = function (row) {
  1011. var rowEl = this.rowEls[row]; // the containing "fake" row div
  1012. var rowBottom = rowEl.getBoundingClientRect().bottom; // relative to viewport!
  1013. var trEls = findChildren(this.eventRenderer.rowStructs[row].tbodyEl);
  1014. var i;
  1015. var trEl;
  1016. // Reveal one level <tr> at a time and stop when we find one out of bounds
  1017. for (i = 0; i < trEls.length; i++) {
  1018. trEl = trEls[i];
  1019. trEl.classList.remove('fc-limited'); // reset to original state (reveal)
  1020. if (trEl.getBoundingClientRect().bottom > rowBottom) {
  1021. return i;
  1022. }
  1023. }
  1024. return false; // should not limit at all
  1025. };
  1026. // Limits the given grid row to the maximum number of levels and injects "more" links if necessary.
  1027. // `row` is the row number.
  1028. // `levelLimit` is a number for the maximum (inclusive) number of levels allowed.
  1029. DayGrid.prototype.limitRow = function (row, levelLimit) {
  1030. var _this = this;
  1031. var _a = this, colCnt = _a.colCnt, isRtl = _a.isRtl;
  1032. var rowStruct = this.eventRenderer.rowStructs[row];
  1033. var moreNodes = []; // array of "more" <a> links and <td> DOM nodes
  1034. var col = 0; // col #, left-to-right (not chronologically)
  1035. var levelSegs; // array of segment objects in the last allowable level, ordered left-to-right
  1036. var cellMatrix; // a matrix (by level, then column) of all <td> elements in the row
  1037. var limitedNodes; // array of temporarily hidden level <tr> and segment <td> DOM nodes
  1038. var i;
  1039. var seg;
  1040. var segsBelow; // array of segment objects below `seg` in the current `col`
  1041. var totalSegsBelow; // total number of segments below `seg` in any of the columns `seg` occupies
  1042. var colSegsBelow; // array of segment arrays, below seg, one for each column (offset from segs's first column)
  1043. var td;
  1044. var rowSpan;
  1045. var segMoreNodes; // array of "more" <td> cells that will stand-in for the current seg's cell
  1046. var j;
  1047. var moreTd;
  1048. var moreWrap;
  1049. var moreLink;
  1050. // Iterates through empty level cells and places "more" links inside if need be
  1051. var emptyCellsUntil = function (endCol) {
  1052. while (col < endCol) {
  1053. segsBelow = _this.getCellSegs(row, col, levelLimit);
  1054. if (segsBelow.length) {
  1055. td = cellMatrix[levelLimit - 1][col];
  1056. moreLink = _this.renderMoreLink(row, col, segsBelow);
  1057. moreWrap = createElement('div', null, moreLink);
  1058. td.appendChild(moreWrap);
  1059. moreNodes.push(moreWrap);
  1060. }
  1061. col++;
  1062. }
  1063. };
  1064. if (levelLimit && levelLimit < rowStruct.segLevels.length) { // is it actually over the limit?
  1065. levelSegs = rowStruct.segLevels[levelLimit - 1];
  1066. cellMatrix = rowStruct.cellMatrix;
  1067. limitedNodes = findChildren(rowStruct.tbodyEl).slice(levelLimit); // get level <tr> elements past the limit
  1068. limitedNodes.forEach(function (node) {
  1069. node.classList.add('fc-limited'); // hide elements and get a simple DOM-nodes array
  1070. });
  1071. // iterate though segments in the last allowable level
  1072. for (i = 0; i < levelSegs.length; i++) {
  1073. seg = levelSegs[i];
  1074. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  1075. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  1076. emptyCellsUntil(leftCol); // process empty cells before the segment
  1077. // determine *all* segments below `seg` that occupy the same columns
  1078. colSegsBelow = [];
  1079. totalSegsBelow = 0;
  1080. while (col <= rightCol) {
  1081. segsBelow = this.getCellSegs(row, col, levelLimit);
  1082. colSegsBelow.push(segsBelow);
  1083. totalSegsBelow += segsBelow.length;
  1084. col++;
  1085. }
  1086. if (totalSegsBelow) { // do we need to replace this segment with one or many "more" links?
  1087. td = cellMatrix[levelLimit - 1][leftCol]; // the segment's parent cell
  1088. rowSpan = td.rowSpan || 1;
  1089. segMoreNodes = [];
  1090. // make a replacement <td> for each column the segment occupies. will be one for each colspan
  1091. for (j = 0; j < colSegsBelow.length; j++) {
  1092. moreTd = createElement('td', { className: 'fc-more-cell', rowSpan: rowSpan });
  1093. segsBelow = colSegsBelow[j];
  1094. moreLink = this.renderMoreLink(row, leftCol + j, [seg].concat(segsBelow) // count seg as hidden too
  1095. );
  1096. moreWrap = createElement('div', null, moreLink);
  1097. moreTd.appendChild(moreWrap);
  1098. segMoreNodes.push(moreTd);
  1099. moreNodes.push(moreTd);
  1100. }
  1101. td.classList.add('fc-limited');
  1102. insertAfterElement(td, segMoreNodes);
  1103. limitedNodes.push(td);
  1104. }
  1105. }
  1106. emptyCellsUntil(this.colCnt); // finish off the level
  1107. rowStruct.moreEls = moreNodes; // for easy undoing later
  1108. rowStruct.limitedEls = limitedNodes; // for easy undoing later
  1109. }
  1110. };
  1111. // Reveals all levels and removes all "more"-related elements for a grid's row.
  1112. // `row` is a row number.
  1113. DayGrid.prototype.unlimitRow = function (row) {
  1114. var rowStruct = this.eventRenderer.rowStructs[row];
  1115. if (rowStruct.moreEls) {
  1116. rowStruct.moreEls.forEach(removeElement);
  1117. rowStruct.moreEls = null;
  1118. }
  1119. if (rowStruct.limitedEls) {
  1120. rowStruct.limitedEls.forEach(function (limitedEl) {
  1121. limitedEl.classList.remove('fc-limited');
  1122. });
  1123. rowStruct.limitedEls = null;
  1124. }
  1125. };
  1126. // Renders an <a> element that represents hidden event element for a cell.
  1127. // Responsible for attaching click handler as well.
  1128. DayGrid.prototype.renderMoreLink = function (row, col, hiddenSegs) {
  1129. var _this = this;
  1130. var _a = this, view = _a.view, dateEnv = _a.dateEnv;
  1131. var a = createElement('a', { className: 'fc-more' });
  1132. a.innerText = this.getMoreLinkText(hiddenSegs.length);
  1133. a.addEventListener('click', function (ev) {
  1134. var clickOption = _this.opt('eventLimitClick');
  1135. var _col = _this.isRtl ? _this.colCnt - col - 1 : col; // HACK: props.cells has different dir system?
  1136. var date = _this.props.cells[row][_col].date;
  1137. var moreEl = ev.currentTarget;
  1138. var dayEl = _this.getCellEl(row, col);
  1139. var allSegs = _this.getCellSegs(row, col);
  1140. // rescope the segments to be within the cell's date
  1141. var reslicedAllSegs = _this.resliceDaySegs(allSegs, date);
  1142. var reslicedHiddenSegs = _this.resliceDaySegs(hiddenSegs, date);
  1143. if (typeof clickOption === 'function') {
  1144. // the returned value can be an atomic option
  1145. clickOption = _this.publiclyTrigger('eventLimitClick', [
  1146. {
  1147. date: dateEnv.toDate(date),
  1148. allDay: true,
  1149. dayEl: dayEl,
  1150. moreEl: moreEl,
  1151. segs: reslicedAllSegs,
  1152. hiddenSegs: reslicedHiddenSegs,
  1153. jsEvent: ev,
  1154. view: view
  1155. }
  1156. ]);
  1157. }
  1158. if (clickOption === 'popover') {
  1159. _this.showSegPopover(row, col, moreEl, reslicedAllSegs);
  1160. }
  1161. else if (typeof clickOption === 'string') { // a view name
  1162. view.calendar.zoomTo(date, clickOption);
  1163. }
  1164. });
  1165. return a;
  1166. };
  1167. // Reveals the popover that displays all events within a cell
  1168. DayGrid.prototype.showSegPopover = function (row, col, moreLink, segs) {
  1169. var _this = this;
  1170. var _a = this, calendar = _a.calendar, view = _a.view, theme = _a.theme;
  1171. var _col = this.isRtl ? this.colCnt - col - 1 : col; // HACK: props.cells has different dir system?
  1172. var moreWrap = moreLink.parentNode; // the <div> wrapper around the <a>
  1173. var topEl; // the element we want to match the top coordinate of
  1174. var options;
  1175. if (this.rowCnt === 1) {
  1176. topEl = view.el; // will cause the popover to cover any sort of header
  1177. }
  1178. else {
  1179. topEl = this.rowEls[row]; // will align with top of row
  1180. }
  1181. options = {
  1182. className: 'fc-more-popover ' + theme.getClass('popover'),
  1183. parentEl: view.el,
  1184. top: computeRect(topEl).top,
  1185. autoHide: true,
  1186. content: function (el) {
  1187. _this.segPopoverTile = new DayTile(_this.context, el);
  1188. _this.updateSegPopoverTile(_this.props.cells[row][_col].date, segs);
  1189. },
  1190. hide: function () {
  1191. _this.segPopoverTile.destroy();
  1192. _this.segPopoverTile = null;
  1193. _this.segPopover.destroy();
  1194. _this.segPopover = null;
  1195. }
  1196. };
  1197. // Determine horizontal coordinate.
  1198. // We use the moreWrap instead of the <td> to avoid border confusion.
  1199. if (this.isRtl) {
  1200. options.right = computeRect(moreWrap).right + 1; // +1 to be over cell border
  1201. }
  1202. else {
  1203. options.left = computeRect(moreWrap).left - 1; // -1 to be over cell border
  1204. }
  1205. this.segPopover = new Popover(options);
  1206. this.segPopover.show();
  1207. calendar.releaseAfterSizingTriggers(); // hack for eventPositioned
  1208. };
  1209. // Given the events within an array of segment objects, reslice them to be in a single day
  1210. DayGrid.prototype.resliceDaySegs = function (segs, dayDate) {
  1211. var dayStart = dayDate;
  1212. var dayEnd = addDays(dayStart, 1);
  1213. var dayRange = { start: dayStart, end: dayEnd };
  1214. var newSegs = [];
  1215. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  1216. var seg = segs_1[_i];
  1217. var eventRange = seg.eventRange;
  1218. var origRange = eventRange.range;
  1219. var slicedRange = intersectRanges(origRange, dayRange);
  1220. if (slicedRange) {
  1221. newSegs.push(__assign({}, seg, { eventRange: {
  1222. def: eventRange.def,
  1223. ui: __assign({}, eventRange.ui, { durationEditable: false }),
  1224. instance: eventRange.instance,
  1225. range: slicedRange
  1226. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() }));
  1227. }
  1228. }
  1229. return newSegs;
  1230. };
  1231. // Generates the text that should be inside a "more" link, given the number of events it represents
  1232. DayGrid.prototype.getMoreLinkText = function (num) {
  1233. var opt = this.opt('eventLimitText');
  1234. if (typeof opt === 'function') {
  1235. return opt(num);
  1236. }
  1237. else {
  1238. return '+' + num + ' ' + opt;
  1239. }
  1240. };
  1241. // Returns segments within a given cell.
  1242. // If `startLevel` is specified, returns only events including and below that level. Otherwise returns all segs.
  1243. DayGrid.prototype.getCellSegs = function (row, col, startLevel) {
  1244. var segMatrix = this.eventRenderer.rowStructs[row].segMatrix;
  1245. var level = startLevel || 0;
  1246. var segs = [];
  1247. var seg;
  1248. while (level < segMatrix.length) {
  1249. seg = segMatrix[level][col];
  1250. if (seg) {
  1251. segs.push(seg);
  1252. }
  1253. level++;
  1254. }
  1255. return segs;
  1256. };
  1257. return DayGrid;
  1258. }(DateComponent));
  1259. var WEEK_NUM_FORMAT$1 = createFormatter({ week: 'numeric' });
  1260. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  1261. ----------------------------------------------------------------------------------------------------------------------*/
  1262. // It is a manager for a DayGrid subcomponent, which does most of the heavy lifting.
  1263. // It is responsible for managing width/height.
  1264. var DayGridView = /** @class */ (function (_super) {
  1265. __extends(DayGridView, _super);
  1266. function DayGridView(context, viewSpec, dateProfileGenerator, parentEl) {
  1267. var _this = _super.call(this, context, viewSpec, dateProfileGenerator, parentEl) || this;
  1268. /* Header Rendering
  1269. ------------------------------------------------------------------------------------------------------------------*/
  1270. // Generates the HTML that will go before the day-of week header cells
  1271. _this.renderHeadIntroHtml = function () {
  1272. var theme = _this.theme;
  1273. if (_this.colWeekNumbersVisible) {
  1274. return '' +
  1275. '<th class="fc-week-number ' + theme.getClass('widgetHeader') + '" ' + _this.weekNumberStyleAttr() + '>' +
  1276. '<span>' + // needed for matchCellWidths
  1277. htmlEscape(_this.opt('weekLabel')) +
  1278. '</span>' +
  1279. '</th>';
  1280. }
  1281. return '';
  1282. };
  1283. /* Day Grid Rendering
  1284. ------------------------------------------------------------------------------------------------------------------*/
  1285. // Generates the HTML that will go before content-skeleton cells that display the day/week numbers
  1286. _this.renderDayGridNumberIntroHtml = function (row, dayGrid) {
  1287. var dateEnv = _this.dateEnv;
  1288. var weekStart = dayGrid.props.cells[row][0].date;
  1289. if (_this.colWeekNumbersVisible) {
  1290. return '' +
  1291. '<td class="fc-week-number" ' + _this.weekNumberStyleAttr() + '>' +
  1292. buildGotoAnchorHtml(// aside from link, important for matchCellWidths
  1293. _this, { date: weekStart, type: 'week', forceOff: dayGrid.colCnt === 1 }, dateEnv.format(weekStart, WEEK_NUM_FORMAT$1) // inner HTML
  1294. ) +
  1295. '</td>';
  1296. }
  1297. return '';
  1298. };
  1299. // Generates the HTML that goes before the day bg cells for each day-row
  1300. _this.renderDayGridBgIntroHtml = function () {
  1301. var theme = _this.theme;
  1302. if (_this.colWeekNumbersVisible) {
  1303. return '<td class="fc-week-number ' + theme.getClass('widgetContent') + '" ' + _this.weekNumberStyleAttr() + '></td>';
  1304. }
  1305. return '';
  1306. };
  1307. // Generates the HTML that goes before every other type of row generated by DayGrid.
  1308. // Affects mirror-skeleton and highlight-skeleton rows.
  1309. _this.renderDayGridIntroHtml = function () {
  1310. if (_this.colWeekNumbersVisible) {
  1311. return '<td class="fc-week-number" ' + _this.weekNumberStyleAttr() + '></td>';
  1312. }
  1313. return '';
  1314. };
  1315. _this.el.classList.add('fc-dayGrid-view');
  1316. _this.el.innerHTML = _this.renderSkeletonHtml();
  1317. _this.scroller = new ScrollComponent('hidden', // overflow x
  1318. 'auto' // overflow y
  1319. );
  1320. var dayGridContainerEl = _this.scroller.el;
  1321. _this.el.querySelector('.fc-body > tr > td').appendChild(dayGridContainerEl);
  1322. dayGridContainerEl.classList.add('fc-day-grid-container');
  1323. var dayGridEl = createElement('div', { className: 'fc-day-grid' });
  1324. dayGridContainerEl.appendChild(dayGridEl);
  1325. var cellWeekNumbersVisible;
  1326. if (_this.opt('weekNumbers')) {
  1327. if (_this.opt('weekNumbersWithinDays')) {
  1328. cellWeekNumbersVisible = true;
  1329. _this.colWeekNumbersVisible = false;
  1330. }
  1331. else {
  1332. cellWeekNumbersVisible = false;
  1333. _this.colWeekNumbersVisible = true;
  1334. }
  1335. }
  1336. else {
  1337. _this.colWeekNumbersVisible = false;
  1338. cellWeekNumbersVisible = false;
  1339. }
  1340. _this.dayGrid = new DayGrid(_this.context, dayGridEl, {
  1341. renderNumberIntroHtml: _this.renderDayGridNumberIntroHtml,
  1342. renderBgIntroHtml: _this.renderDayGridBgIntroHtml,
  1343. renderIntroHtml: _this.renderDayGridIntroHtml,
  1344. colWeekNumbersVisible: _this.colWeekNumbersVisible,
  1345. cellWeekNumbersVisible: cellWeekNumbersVisible
  1346. });
  1347. return _this;
  1348. }
  1349. DayGridView.prototype.destroy = function () {
  1350. _super.prototype.destroy.call(this);
  1351. this.dayGrid.destroy();
  1352. this.scroller.destroy();
  1353. };
  1354. // Builds the HTML skeleton for the view.
  1355. // The day-grid component will render inside of a container defined by this HTML.
  1356. DayGridView.prototype.renderSkeletonHtml = function () {
  1357. var theme = this.theme;
  1358. return '' +
  1359. '<table class="' + theme.getClass('tableGrid') + '">' +
  1360. (this.opt('columnHeader') ?
  1361. '<thead class="fc-head">' +
  1362. '<tr>' +
  1363. '<td class="fc-head-container ' + theme.getClass('widgetHeader') + '">&nbsp;</td>' +
  1364. '</tr>' +
  1365. '</thead>' :
  1366. '') +
  1367. '<tbody class="fc-body">' +
  1368. '<tr>' +
  1369. '<td class="' + theme.getClass('widgetContent') + '"></td>' +
  1370. '</tr>' +
  1371. '</tbody>' +
  1372. '</table>';
  1373. };
  1374. // Generates an HTML attribute string for setting the width of the week number column, if it is known
  1375. DayGridView.prototype.weekNumberStyleAttr = function () {
  1376. if (this.weekNumberWidth != null) {
  1377. return 'style="width:' + this.weekNumberWidth + 'px"';
  1378. }
  1379. return '';
  1380. };
  1381. // Determines whether each row should have a constant height
  1382. DayGridView.prototype.hasRigidRows = function () {
  1383. var eventLimit = this.opt('eventLimit');
  1384. return eventLimit && typeof eventLimit !== 'number';
  1385. };
  1386. /* Dimensions
  1387. ------------------------------------------------------------------------------------------------------------------*/
  1388. DayGridView.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  1389. _super.prototype.updateSize.call(this, isResize, viewHeight, isAuto); // will call updateBaseSize. important that executes first
  1390. this.dayGrid.updateSize(isResize);
  1391. };
  1392. // Refreshes the horizontal dimensions of the view
  1393. DayGridView.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
  1394. var dayGrid = this.dayGrid;
  1395. var eventLimit = this.opt('eventLimit');
  1396. var headRowEl = this.header ? this.header.el : null; // HACK
  1397. var scrollerHeight;
  1398. var scrollbarWidths;
  1399. // hack to give the view some height prior to dayGrid's columns being rendered
  1400. // TODO: separate setting height from scroller VS dayGrid.
  1401. if (!dayGrid.rowEls) {
  1402. if (!isAuto) {
  1403. scrollerHeight = this.computeScrollerHeight(viewHeight);
  1404. this.scroller.setHeight(scrollerHeight);
  1405. }
  1406. return;
  1407. }
  1408. if (this.colWeekNumbersVisible) {
  1409. // Make sure all week number cells running down the side have the same width.
  1410. this.weekNumberWidth = matchCellWidths(findElements(this.el, '.fc-week-number'));
  1411. }
  1412. // reset all heights to be natural
  1413. this.scroller.clear();
  1414. if (headRowEl) {
  1415. uncompensateScroll(headRowEl);
  1416. }
  1417. dayGrid.removeSegPopover(); // kill the "more" popover if displayed
  1418. // is the event limit a constant level number?
  1419. if (eventLimit && typeof eventLimit === 'number') {
  1420. dayGrid.limitRows(eventLimit); // limit the levels first so the height can redistribute after
  1421. }
  1422. // distribute the height to the rows
  1423. // (viewHeight is a "recommended" value if isAuto)
  1424. scrollerHeight = this.computeScrollerHeight(viewHeight);
  1425. this.setGridHeight(scrollerHeight, isAuto);
  1426. // is the event limit dynamically calculated?
  1427. if (eventLimit && typeof eventLimit !== 'number') {
  1428. dayGrid.limitRows(eventLimit); // limit the levels after the grid's row heights have been set
  1429. }
  1430. if (!isAuto) { // should we force dimensions of the scroll container?
  1431. this.scroller.setHeight(scrollerHeight);
  1432. scrollbarWidths = this.scroller.getScrollbarWidths();
  1433. if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars?
  1434. if (headRowEl) {
  1435. compensateScroll(headRowEl, scrollbarWidths);
  1436. }
  1437. // doing the scrollbar compensation might have created text overflow which created more height. redo
  1438. scrollerHeight = this.computeScrollerHeight(viewHeight);
  1439. this.scroller.setHeight(scrollerHeight);
  1440. }
  1441. // guarantees the same scrollbar widths
  1442. this.scroller.lockOverflow(scrollbarWidths);
  1443. }
  1444. };
  1445. // given a desired total height of the view, returns what the height of the scroller should be
  1446. DayGridView.prototype.computeScrollerHeight = function (viewHeight) {
  1447. return viewHeight -
  1448. subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
  1449. };
  1450. // Sets the height of just the DayGrid component in this view
  1451. DayGridView.prototype.setGridHeight = function (height, isAuto) {
  1452. if (this.opt('monthMode')) {
  1453. // if auto, make the height of each row the height that it would be if there were 6 weeks
  1454. if (isAuto) {
  1455. height *= this.dayGrid.rowCnt / 6;
  1456. }
  1457. distributeHeight(this.dayGrid.rowEls, height, !isAuto); // if auto, don't compensate for height-hogging rows
  1458. }
  1459. else {
  1460. if (isAuto) {
  1461. undistributeHeight(this.dayGrid.rowEls); // let the rows be their natural height with no expanding
  1462. }
  1463. else {
  1464. distributeHeight(this.dayGrid.rowEls, height, true); // true = compensate for height-hogging rows
  1465. }
  1466. }
  1467. };
  1468. /* Scroll
  1469. ------------------------------------------------------------------------------------------------------------------*/
  1470. DayGridView.prototype.computeDateScroll = function (duration) {
  1471. return { top: 0 };
  1472. };
  1473. DayGridView.prototype.queryDateScroll = function () {
  1474. return { top: this.scroller.getScrollTop() };
  1475. };
  1476. DayGridView.prototype.applyDateScroll = function (scroll) {
  1477. if (scroll.top !== undefined) {
  1478. this.scroller.setScrollTop(scroll.top);
  1479. }
  1480. };
  1481. return DayGridView;
  1482. }(View));
  1483. DayGridView.prototype.dateProfileGeneratorClass = DayGridDateProfileGenerator;
  1484. var SimpleDayGrid = /** @class */ (function (_super) {
  1485. __extends(SimpleDayGrid, _super);
  1486. function SimpleDayGrid(context, dayGrid) {
  1487. var _this = _super.call(this, context, dayGrid.el) || this;
  1488. _this.slicer = new DayGridSlicer();
  1489. _this.dayGrid = dayGrid;
  1490. context.calendar.registerInteractiveComponent(_this, { el: _this.dayGrid.el });
  1491. return _this;
  1492. }
  1493. SimpleDayGrid.prototype.destroy = function () {
  1494. _super.prototype.destroy.call(this);
  1495. this.calendar.unregisterInteractiveComponent(this);
  1496. };
  1497. SimpleDayGrid.prototype.render = function (props) {
  1498. var dayGrid = this.dayGrid;
  1499. var dateProfile = props.dateProfile, dayTable = props.dayTable;
  1500. dayGrid.receiveProps(__assign({}, this.slicer.sliceProps(props, dateProfile, props.nextDayThreshold, dayGrid, dayTable), { dateProfile: dateProfile, cells: dayTable.cells, isRigid: props.isRigid }));
  1501. };
  1502. SimpleDayGrid.prototype.buildPositionCaches = function () {
  1503. this.dayGrid.buildPositionCaches();
  1504. };
  1505. SimpleDayGrid.prototype.queryHit = function (positionLeft, positionTop) {
  1506. var rawHit = this.dayGrid.positionToHit(positionLeft, positionTop);
  1507. if (rawHit) {
  1508. return {
  1509. component: this.dayGrid,
  1510. dateSpan: rawHit.dateSpan,
  1511. dayEl: rawHit.dayEl,
  1512. rect: {
  1513. left: rawHit.relativeRect.left,
  1514. right: rawHit.relativeRect.right,
  1515. top: rawHit.relativeRect.top,
  1516. bottom: rawHit.relativeRect.bottom
  1517. },
  1518. layer: 0
  1519. };
  1520. }
  1521. };
  1522. return SimpleDayGrid;
  1523. }(DateComponent));
  1524. var DayGridSlicer = /** @class */ (function (_super) {
  1525. __extends(DayGridSlicer, _super);
  1526. function DayGridSlicer() {
  1527. return _super !== null && _super.apply(this, arguments) || this;
  1528. }
  1529. DayGridSlicer.prototype.sliceRange = function (dateRange, dayTable) {
  1530. return dayTable.sliceRange(dateRange);
  1531. };
  1532. return DayGridSlicer;
  1533. }(Slicer));
  1534. var DayGridView$1 = /** @class */ (function (_super) {
  1535. __extends(DayGridView, _super);
  1536. function DayGridView(_context, viewSpec, dateProfileGenerator, parentEl) {
  1537. var _this = _super.call(this, _context, viewSpec, dateProfileGenerator, parentEl) || this;
  1538. _this.buildDayTable = memoize(buildDayTable);
  1539. if (_this.opt('columnHeader')) {
  1540. _this.header = new DayHeader(_this.context, _this.el.querySelector('.fc-head-container'));
  1541. }
  1542. _this.simpleDayGrid = new SimpleDayGrid(_this.context, _this.dayGrid);
  1543. return _this;
  1544. }
  1545. DayGridView.prototype.destroy = function () {
  1546. _super.prototype.destroy.call(this);
  1547. if (this.header) {
  1548. this.header.destroy();
  1549. }
  1550. this.simpleDayGrid.destroy();
  1551. };
  1552. DayGridView.prototype.render = function (props) {
  1553. _super.prototype.render.call(this, props);
  1554. var dateProfile = this.props.dateProfile;
  1555. var dayTable = this.dayTable =
  1556. this.buildDayTable(dateProfile, this.dateProfileGenerator);
  1557. if (this.header) {
  1558. this.header.receiveProps({
  1559. dateProfile: dateProfile,
  1560. dates: dayTable.headerDates,
  1561. datesRepDistinctDays: dayTable.rowCnt === 1,
  1562. renderIntroHtml: this.renderHeadIntroHtml
  1563. });
  1564. }
  1565. this.simpleDayGrid.receiveProps({
  1566. dateProfile: dateProfile,
  1567. dayTable: dayTable,
  1568. businessHours: props.businessHours,
  1569. dateSelection: props.dateSelection,
  1570. eventStore: props.eventStore,
  1571. eventUiBases: props.eventUiBases,
  1572. eventSelection: props.eventSelection,
  1573. eventDrag: props.eventDrag,
  1574. eventResize: props.eventResize,
  1575. isRigid: this.hasRigidRows(),
  1576. nextDayThreshold: this.nextDayThreshold
  1577. });
  1578. };
  1579. return DayGridView;
  1580. }(DayGridView));
  1581. function buildDayTable(dateProfile, dateProfileGenerator) {
  1582. var daySeries = new DaySeries(dateProfile.renderRange, dateProfileGenerator);
  1583. return new DayTable(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  1584. }
  1585. var main = createPlugin({
  1586. defaultView: 'dayGridMonth',
  1587. views: {
  1588. dayGrid: DayGridView$1,
  1589. dayGridDay: {
  1590. type: 'dayGrid',
  1591. duration: { days: 1 }
  1592. },
  1593. dayGridWeek: {
  1594. type: 'dayGrid',
  1595. duration: { weeks: 1 }
  1596. },
  1597. dayGridMonth: {
  1598. type: 'dayGrid',
  1599. duration: { months: 1 },
  1600. monthMode: true,
  1601. fixedWeekCount: true
  1602. }
  1603. }
  1604. });
  1605. export default main;
  1606. export { DayGridView as AbstractDayGridView, DayBgRow, DayGrid, DayGridSlicer, DayGridView$1 as DayGridView, SimpleDayGrid, buildDayTable as buildBasicDayTable };