暂无描述

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*!
  2. FullCalendar RRule Plugin v4.3.0
  3. Docs & License: https://fullcalendar.io/
  4. (c) 2019 Adam Shaw
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rrule'), require('@fullcalendar/core')) :
  8. typeof define === 'function' && define.amd ? define(['exports', 'rrule', '@fullcalendar/core'], factory) :
  9. (global = global || self, factory(global.FullCalendarRrule = {}, global.rrule, global.FullCalendar));
  10. }(this, function (exports, rrule, core) { 'use strict';
  11. /*! *****************************************************************************
  12. Copyright (c) Microsoft Corporation. All rights reserved.
  13. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14. this file except in compliance with the License. You may obtain a copy of the
  15. License at http://www.apache.org/licenses/LICENSE-2.0
  16. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  18. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  19. MERCHANTABLITY OR NON-INFRINGEMENT.
  20. See the Apache Version 2.0 License for specific language governing permissions
  21. and limitations under the License.
  22. ***************************************************************************** */
  23. var __assign = function() {
  24. __assign = Object.assign || function __assign(t) {
  25. for (var s, i = 1, n = arguments.length; i < n; i++) {
  26. s = arguments[i];
  27. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  28. }
  29. return t;
  30. };
  31. return __assign.apply(this, arguments);
  32. };
  33. var EVENT_DEF_PROPS = {
  34. rrule: null,
  35. duration: core.createDuration
  36. };
  37. var recurring = {
  38. parse: function (rawEvent, leftoverProps, dateEnv) {
  39. if (rawEvent.rrule != null) {
  40. var props = core.refineProps(rawEvent, EVENT_DEF_PROPS, {}, leftoverProps);
  41. var parsed = parseRRule(props.rrule, dateEnv);
  42. if (parsed) {
  43. return {
  44. typeData: parsed.rrule,
  45. allDayGuess: parsed.allDayGuess,
  46. duration: props.duration
  47. };
  48. }
  49. }
  50. return null;
  51. },
  52. expand: function (rrule, framingRange) {
  53. // we WANT an inclusive start and in exclusive end, but the js rrule lib will only do either BOTH
  54. // inclusive or BOTH exclusive, which is stupid: https://github.com/jakubroztocil/rrule/issues/84
  55. // Workaround: make inclusive, which will generate extra occurences, and then trim.
  56. return rrule.between(framingRange.start, framingRange.end, true)
  57. .filter(function (date) {
  58. return date.valueOf() < framingRange.end.valueOf();
  59. });
  60. }
  61. };
  62. var main = core.createPlugin({
  63. recurringTypes: [recurring]
  64. });
  65. function parseRRule(input, dateEnv) {
  66. var allDayGuess = null;
  67. var rrule$1;
  68. if (typeof input === 'string') {
  69. rrule$1 = rrule.rrulestr(input);
  70. }
  71. else if (typeof input === 'object' && input) { // non-null object
  72. var refined = __assign({}, input); // copy
  73. if (typeof refined.dtstart === 'string') {
  74. var dtstartMeta = dateEnv.createMarkerMeta(refined.dtstart);
  75. if (dtstartMeta) {
  76. refined.dtstart = dtstartMeta.marker;
  77. allDayGuess = dtstartMeta.isTimeUnspecified;
  78. }
  79. else {
  80. delete refined.dtstart;
  81. }
  82. }
  83. if (typeof refined.until === 'string') {
  84. refined.until = dateEnv.createMarker(refined.until);
  85. }
  86. if (refined.freq != null) {
  87. refined.freq = convertConstant(refined.freq);
  88. }
  89. if (refined.wkst != null) {
  90. refined.wkst = convertConstant(refined.wkst);
  91. }
  92. else {
  93. refined.wkst = (dateEnv.weekDow - 1 + 7) % 7; // convert Sunday-first to Monday-first
  94. }
  95. if (refined.byweekday != null) {
  96. refined.byweekday = convertConstants(refined.byweekday); // the plural version
  97. }
  98. rrule$1 = new rrule.RRule(refined);
  99. }
  100. if (rrule$1) {
  101. return { rrule: rrule$1, allDayGuess: allDayGuess };
  102. }
  103. return null;
  104. }
  105. function convertConstants(input) {
  106. if (Array.isArray(input)) {
  107. return input.map(convertConstant);
  108. }
  109. return convertConstant(input);
  110. }
  111. function convertConstant(input) {
  112. if (typeof input === 'string') {
  113. return rrule.RRule[input.toUpperCase()];
  114. }
  115. return input;
  116. }
  117. exports.default = main;
  118. Object.defineProperty(exports, '__esModule', { value: true });
  119. }));