UNPKG

@revived-repoes/vue-persian-calendar

Version:
1,335 lines (1,113 loc) 54.3 kB
module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "fb15"); /******/ }) /************************************************************************/ /******/ ({ /***/ "025e": /***/ (function(module, exports) { String.prototype.toPersianDigits = function () { const id = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; return this.replace(/[0-9]/g, function (w) { return id[+w]; }); }; /***/ }), /***/ "24fb": /***/ (function(module, exports, __webpack_require__) { "use strict"; /* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ // css base code, injected by the css-loader // eslint-disable-next-line func-names module.exports = function (useSourceMap) { var list = []; // return the list of modules as css string list.toString = function toString() { return this.map(function (item) { var content = cssWithMappingToString(item, useSourceMap); if (item[2]) { return "@media ".concat(item[2], " {").concat(content, "}"); } return content; }).join(''); }; // import a list of modules into the list // eslint-disable-next-line func-names list.i = function (modules, mediaQuery, dedupe) { if (typeof modules === 'string') { // eslint-disable-next-line no-param-reassign modules = [[null, modules, '']]; } var alreadyImportedModules = {}; if (dedupe) { for (var i = 0; i < this.length; i++) { // eslint-disable-next-line prefer-destructuring var id = this[i][0]; if (id != null) { alreadyImportedModules[id] = true; } } } for (var _i = 0; _i < modules.length; _i++) { var item = [].concat(modules[_i]); if (dedupe && alreadyImportedModules[item[0]]) { // eslint-disable-next-line no-continue continue; } if (mediaQuery) { if (!item[2]) { item[2] = mediaQuery; } else { item[2] = "".concat(mediaQuery, " and ").concat(item[2]); } } list.push(item); } }; return list; }; function cssWithMappingToString(item, useSourceMap) { var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring var cssMapping = item[3]; if (!cssMapping) { return content; } if (useSourceMap && typeof btoa === 'function') { var sourceMapping = toComment(cssMapping); var sourceURLs = cssMapping.sources.map(function (source) { return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */"); }); return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); } return [content].join('\n'); } // Adapted from convert-source-map (MIT) function toComment(sourceMap) { // eslint-disable-next-line no-undef var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))); var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64); return "/*# ".concat(data, " */"); } /***/ }), /***/ "499e": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, "default", function() { return /* binding */ addStylesClient; }); // CONCATENATED MODULE: ./node_modules/vue-style-loader/lib/listToStyles.js /** * Translates the list format produced by css-loader into something * easier to manipulate. */ function listToStyles (parentId, list) { var styles = [] var newStyles = {} for (var i = 0; i < list.length; i++) { var item = list[i] var id = item[0] var css = item[1] var media = item[2] var sourceMap = item[3] var part = { id: parentId + ':' + i, css: css, media: media, sourceMap: sourceMap } if (!newStyles[id]) { styles.push(newStyles[id] = { id: id, parts: [part] }) } else { newStyles[id].parts.push(part) } } return styles } // CONCATENATED MODULE: ./node_modules/vue-style-loader/lib/addStylesClient.js /* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra Modified by Evan You @yyx990803 */ var hasDocument = typeof document !== 'undefined' if (typeof DEBUG !== 'undefined' && DEBUG) { if (!hasDocument) { throw new Error( 'vue-style-loader cannot be used in a non-browser environment. ' + "Use { target: 'node' } in your Webpack config to indicate a server-rendering environment." ) } } /* type StyleObject = { id: number; parts: Array<StyleObjectPart> } type StyleObjectPart = { css: string; media: string; sourceMap: ?string } */ var stylesInDom = {/* [id: number]: { id: number, refs: number, parts: Array<(obj?: StyleObjectPart) => void> } */} var head = hasDocument && (document.head || document.getElementsByTagName('head')[0]) var singletonElement = null var singletonCounter = 0 var isProduction = false var noop = function () {} var options = null var ssrIdKey = 'data-vue-ssr-id' // Force single-tag solution on IE6-9, which has a hard limit on the # of <style> // tags it will allow on a page var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\b/.test(navigator.userAgent.toLowerCase()) function addStylesClient (parentId, list, _isProduction, _options) { isProduction = _isProduction options = _options || {} var styles = listToStyles(parentId, list) addStylesToDom(styles) return function update (newList) { var mayRemove = [] for (var i = 0; i < styles.length; i++) { var item = styles[i] var domStyle = stylesInDom[item.id] domStyle.refs-- mayRemove.push(domStyle) } if (newList) { styles = listToStyles(parentId, newList) addStylesToDom(styles) } else { styles = [] } for (var i = 0; i < mayRemove.length; i++) { var domStyle = mayRemove[i] if (domStyle.refs === 0) { for (var j = 0; j < domStyle.parts.length; j++) { domStyle.parts[j]() } delete stylesInDom[domStyle.id] } } } } function addStylesToDom (styles /* Array<StyleObject> */) { for (var i = 0; i < styles.length; i++) { var item = styles[i] var domStyle = stylesInDom[item.id] if (domStyle) { domStyle.refs++ for (var j = 0; j < domStyle.parts.length; j++) { domStyle.parts[j](item.parts[j]) } for (; j < item.parts.length; j++) { domStyle.parts.push(addStyle(item.parts[j])) } if (domStyle.parts.length > item.parts.length) { domStyle.parts.length = item.parts.length } } else { var parts = [] for (var j = 0; j < item.parts.length; j++) { parts.push(addStyle(item.parts[j])) } stylesInDom[item.id] = { id: item.id, refs: 1, parts: parts } } } } function createStyleElement () { var styleElement = document.createElement('style') styleElement.type = 'text/css' head.appendChild(styleElement) return styleElement } function addStyle (obj /* StyleObjectPart */) { var update, remove var styleElement = document.querySelector('style[' + ssrIdKey + '~="' + obj.id + '"]') if (styleElement) { if (isProduction) { // has SSR styles and in production mode. // simply do nothing. return noop } else { // has SSR styles but in dev mode. // for some reason Chrome can't handle source map in server-rendered // style tags - source maps in <style> only works if the style tag is // created and inserted dynamically. So we remove the server rendered // styles and inject new ones. styleElement.parentNode.removeChild(styleElement) } } if (isOldIE) { // use singleton mode for IE9. var styleIndex = singletonCounter++ styleElement = singletonElement || (singletonElement = createStyleElement()) update = applyToSingletonTag.bind(null, styleElement, styleIndex, false) remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true) } else { // use multi-style-tag mode in all other cases styleElement = createStyleElement() update = applyToTag.bind(null, styleElement) remove = function () { styleElement.parentNode.removeChild(styleElement) } } update(obj) return function updateStyle (newObj /* StyleObjectPart */) { if (newObj) { if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) { return } update(obj = newObj) } else { remove() } } } var replaceText = (function () { var textStore = [] return function (index, replacement) { textStore[index] = replacement return textStore.filter(Boolean).join('\n') } })() function applyToSingletonTag (styleElement, index, remove, obj) { var css = remove ? '' : obj.css if (styleElement.styleSheet) { styleElement.styleSheet.cssText = replaceText(index, css) } else { var cssNode = document.createTextNode(css) var childNodes = styleElement.childNodes if (childNodes[index]) styleElement.removeChild(childNodes[index]) if (childNodes.length) { styleElement.insertBefore(cssNode, childNodes[index]) } else { styleElement.appendChild(cssNode) } } } function applyToTag (styleElement, obj) { var css = obj.css var media = obj.media var sourceMap = obj.sourceMap if (media) { styleElement.setAttribute('media', media) } if (options.ssrId) { styleElement.setAttribute(ssrIdKey, obj.id) } if (sourceMap) { // https://developer.chrome.com/devtools/docs/javascript-debugging // this makes source maps inside style tags work properly in Chrome css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */' // http://stackoverflow.com/a/26603875 css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */' } if (styleElement.styleSheet) { styleElement.styleSheet.cssText = css } else { while (styleElement.firstChild) { styleElement.removeChild(styleElement.firstChild) } styleElement.appendChild(document.createTextNode(css)) } } /***/ }), /***/ "7cd6": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return install; }); /* harmony import */ var _PersianCalendar_vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("d0ef"); /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("025e"); /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_utils__WEBPACK_IMPORTED_MODULE_1__); // Import vue component // Import utilities functions // Declare install function executed by Vue.use() function install(Vue) { if (install.installed) return; install.installed = true; Vue.component('PersianCalendar', _PersianCalendar_vue__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"]); } // Create module definition for Vue.use() const plugin = { install }; // Auto-install when vue is found (eg. in browser via <script> tag) let GlobalVue = null; if (typeof window !== 'undefined') { GlobalVue = window.Vue; } else if (typeof global !== 'undefined') { GlobalVue = global.Vue; } if (GlobalVue) { GlobalVue.use(plugin); } // To allow use as module (npm/webpack/etc.) export component /* harmony default export */ __webpack_exports__["a"] = (_PersianCalendar_vue__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"]); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("c8ba"))) /***/ }), /***/ "8875": /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// addapted from the document.currentScript polyfill by Adam Miller // MIT license // source: https://github.com/amiller-gh/currentScript-polyfill // added support for Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1620505 (function (root, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else {} }(typeof self !== 'undefined' ? self : this, function () { function getCurrentScript () { var descriptor = Object.getOwnPropertyDescriptor(document, 'currentScript') // for chrome if (!descriptor && 'currentScript' in document && document.currentScript) { return document.currentScript } // for other browsers with native support for currentScript if (descriptor && descriptor.get !== getCurrentScript && document.currentScript) { return document.currentScript } // IE 8-10 support script readyState // IE 11+ & Firefox support stack trace try { throw new Error(); } catch (err) { // Find the second match for the "at" string to get file src url from stack. var ieStackRegExp = /.*at [^(]*\((.*):(.+):(.+)\)$/ig, ffStackRegExp = /@([^@]*):(\d+):(\d+)\s*$/ig, stackDetails = ieStackRegExp.exec(err.stack) || ffStackRegExp.exec(err.stack), scriptLocation = (stackDetails && stackDetails[1]) || false, line = (stackDetails && stackDetails[2]) || false, currentLocation = document.location.href.replace(document.location.hash, ''), pageSource, inlineScriptSourceRegExp, inlineScriptSource, scripts = document.getElementsByTagName('script'); // Live NodeList collection if (scriptLocation === currentLocation) { pageSource = document.documentElement.outerHTML; inlineScriptSourceRegExp = new RegExp('(?:[^\\n]+?\\n){0,' + (line - 2) + '}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*', 'i'); inlineScriptSource = pageSource.replace(inlineScriptSourceRegExp, '$1').trim(); } for (var i = 0; i < scripts.length; i++) { // If ready state is interactive, return the script tag if (scripts[i].readyState === 'interactive') { return scripts[i]; } // If src matches, return the script tag if (scripts[i].src === scriptLocation) { return scripts[i]; } // If inline source matches, return the script tag if ( scriptLocation === currentLocation && scripts[i].innerHTML && scripts[i].innerHTML.trim() === inlineScriptSource ) { return scripts[i]; } } // If no match, return null return null; } }; return getCurrentScript })); /***/ }), /***/ "afc5": /***/ (function(module, exports, __webpack_require__) { // style-loader: Adds some css to the DOM by adding a <style> tag // load the styles var content = __webpack_require__("ef80"); if(content.__esModule) content = content.default; if(typeof content === 'string') content = [[module.i, content, '']]; if(content.locals) module.exports = content.locals; // add the styles to the DOM var add = __webpack_require__("499e").default var update = add("45a3b2f0", content, true, {"sourceMap":false,"shadowMode":false}); /***/ }), /***/ "c8ba": /***/ (function(module, exports) { var g; // This works in non-strict mode g = (function() { return this; })(); try { // This works if eval is allowed (see CSP) g = g || new Function("return this")(); } catch (e) { // This works if the window reference is available if (typeof window === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }), /***/ "d0ef": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"e763f55a-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/PersianCalendar.vue?vue&type=template&id=e14308d4& var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{attrs:{"id":"persian-calendar"}},[_c('div',{attrs:{"slot":"header","id":"vpc_header"},slot:"header"},[_c('div',{attrs:{"id":"vpc_date-control"}},[_c('div',{staticClass:"vpc_control-btn",attrs:{"disabled":_vm.isBeforeMin()},on:{"click":_vm.subtractPeriod}},[_c('svg',{attrs:{"xmlns":"http://www.w3.org/2000/svg","width":"1em","height":"1em","viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}},[_c('polyline',{attrs:{"points":"9 18 15 12 9 6"}})])]),(_vm.isWeekPeriod)?_c('span',{staticClass:"vpc_now-date"},[_vm._v(" "+_vm._s(_vm.displayRangeText.toPersianDigits())+" ")]):_c('span',{staticClass:"vpc_now-date"},[_vm._v(_vm._s(_vm.currentDate.locale('fa').format('jMMMM jYYYY').toPersianDigits()))]),_c('div',{staticClass:"vpc_control-btn",attrs:{"disabled":_vm.isAfterMax()},on:{"click":_vm.addPeriod}},[_c('svg',{attrs:{"xmlns":"http://www.w3.org/2000/svg","width":"1em","height":"1em","viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}},[_c('polyline',{attrs:{"points":"15 18 9 12 15 6"}})])]),(!_vm.disableToday)?_c('div',{staticClass:"vpc_today-btn",attrs:{"disabled":_vm.todayBtnDisable},on:{"click":_vm.goToday}},[_vm._v("امروز")]):_vm._e()]),(!_vm.disablePeriod)?_c('div',{staticClass:"vpc_period-control"},[_c('div',{staticClass:"vpc_period-btn",on:{"click":_vm.togglePeriod}},[_vm._v(_vm._s(_vm.displayPeriodText))])]):_vm._e()]),_c('transition',{attrs:{"name":_vm.transitionAction},on:{"after-leave":_vm.afterLeave}},[(_vm.currentDateChange)?_c('div',[_c('div',{attrs:{"id":"vpc_calendar"}},[_c('div',{attrs:{"id":"vpc_days-header"}},[_c('div',[_vm._v("شنبه")]),_c('div',[_vm._v("یکشنبه")]),_c('div',[_vm._v("دوشنبه")]),_c('div',[_vm._v("سه شنبه")]),_c('div',[_vm._v("چهار شنبه")]),_c('div',[_vm._v("پنج شنبه")]),_c('div',[_vm._v("جمعه")])]),_vm._l((_vm.periodWeeks),function(week){return _c('div',{key:week.uid,class:_vm.weekClassObject},[_vm._l((_vm.getWeekEvents(week[0].startOf('jWeek'))),function(i){return [_vm._t("event",[_c('div',{key:i.id,staticClass:"vpc_event",class:i.classes,style:(("top:" + (_vm.getEventTop(i)) + ";background-color:" + (i.color) + ";")),on:{"click":function($event){return _vm.$emit('on-event-click', i)}}},[_c('div',{staticClass:"vpc_event-ball",style:({'background-color':i.color})}),(!_vm.hideEventTimes)?_c('span',{staticClass:"vpc_event-start-time"},[_vm._v(_vm._s(i.startDateTime.format('HH:mm').toPersianDigits())),_c('span',[_vm._v(" - "+_vm._s(i.endDateTime.format('HH:mm').toPersianDigits())+" ")])]):_vm._e(),(!_vm.hideEventTimes)?_c('span',{staticClass:"vpc_event-start-date"},[_vm._v(_vm._s(i.startDateTime.format('jMM/jDD').toPersianDigits()))]):_vm._e(),_c('span',{staticClass:"vpc_event-title"},[_vm._v(_vm._s(i.title))]),(!_vm.hideEventTimes)?_c('span',{staticClass:"vpc_event-end-time"},[_vm._v(_vm._s(i.endDateTime.format('HH:mm').toPersianDigits()))]):_vm._e(),(!_vm.hideEventTimes)?_c('span',{staticClass:"vpc_event-end-date"},[_vm._v(_vm._s(i.endDateTime.format('jMM/jDD').toPersianDigits()))]):_vm._e()])],{"value":i,"weekStartDate":_vm.$moment(week).startOf('jWeek'),"top":_vm.getEventTop(i)})]}),_vm._l((week),function(day){return _c('div',{key:day.uid,class:_vm.dayClassObject(day),on:{"click":function($event){return _vm.emitDay(day, $event)}}},[_c('div',{staticClass:"vpc_day-number"},[_vm._v(_vm._s(day.format('jD').toPersianDigits()))])])})],2)})],2)]):_vm._e()])],1)} var staticRenderFns = [] // CONCATENATED MODULE: ./src/PersianCalendar.vue?vue&type=template&id=e14308d4& // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/PersianCalendar.vue?vue&type=script&lang=js& // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /* harmony default export */ var PersianCalendarvue_type_script_lang_js_ = ({ name: 'PersianCalendar', props: { dateFormat: { type: String, default() { return 'jYYYY/jMM/jDD'; } }, showDate: { type: [Object, String], default() { return this.$moment(); } }, displayPeriod: String, eventsList: { type: Array, default() { return []; } }, minDate: [Object, String], maxDate: [Object, String], hideEventTimes: { type: Boolean, default() { return false; } }, disableToday: { type: Boolean, default() { return false; } }, disablePeriod: { type: Boolean, default() { return false; } }, hideMonthShadow: { type: Boolean, default() { return false; } }, hidePastDaysShadow: { type: Boolean, default() { return false; } }, disablePastDays: { type: Boolean, default() { return false; } } }, data() { return { currentDate: null, currentDateChange: true, transitionAction: 'slide-right', addEventModalShow: false, period: 'month', events: [], min: null, max: null }; }, computed: { month: { get() { return this.currentDate.format('jM'); }, set(value) { this.currentDate = value; } }, year: { get() { return this.currentDate.format('jYYYY'); }, set(value) { this.currentDate = value; } }, daysInMonth() { // Generating all days in current month const days = []; let currentDay = this.$moment(`${this.year}-${this.month}-1`, 'jYYYY-jM-jD').locale('fa'); do { days.push(currentDay); currentDay = this.$moment(currentDay).add(1, 'days'); } while (this.$moment(currentDay).format('M') === this.month); // Add previous days to start currentDay = this.$moment(days[0]); const SHANBE = 0; const JOMEE = 6; if (currentDay.jDay() !== SHANBE) { do { currentDay = this.$moment(currentDay).subtract(1, 'days'); days.unshift(currentDay); } while (currentDay.jDay() !== SHANBE); } // Add following days to end currentDay = this.$moment(days[days.length - 1]); if (currentDay.jDay() !== JOMEE) { do { currentDay = this.$moment(currentDay).add(1, 'days'); days.push(currentDay); } while (currentDay.jDay() !== JOMEE); } return days; }, daysInWeek() { const days = []; const showDay = this.currentDate.locale('fa'); let day = showDay.startOf('jWeek'); do { days.push(day); day = this.$moment(day).add(1, 'days'); } while (!day.isSame(this.$moment(showDay).add(7, 'days'))); return days; }, weeksInMonth() { const weeks = []; let week = []; for (let i = 0; i < this.daysInMonth.length; i++) { week.push(this.daysInMonth[i]); if (week.length === 7) { weeks.push(week); week = []; } } return weeks; }, isWeekPeriod() { return this.period === 'week'; }, periodWeeks() { return this.isWeekPeriod ? [this.daysInWeek] : this.weeksInMonth; }, displayPeriodText() { return this.isWeekPeriod ? 'ماه' : 'هفته'; }, displayRangeText() { const start = this.$moment(this.currentDate).locale('fa').startOf('jWeek'); const end = this.$moment(start).locale('fa').add(6, 'days'); let startformat = 'DD'; if (!start.isSame(end, 'month')) startformat = 'DD jMMMM'; if (!start.isSame(end, 'year')) startformat = 'DD jMMMM jYYYY'; return `${start.format(startformat)} - ${end.format('DD jMMMM jYYYY')}`; }, todayBtnDisable() { if (this.min) { if (this.max) return !this.$moment().isBetween(this.$moment(this.min).startOf('day'), this.$moment(this.max).endOf('day')); return this.min.isAfter(this.$moment().startOf('day'), 'day'); } if (this.max) { return this.max.isBefore(this.$moment().endOf('day'), 'day'); } return false; }, weekClassObject() { return { 'vpc_week': true, 'vpc_week-period': this.isWeekPeriod }; } }, watch: { currentDate() { // update transition this.currentDateChange = false; }, showDate(value) { this.currentDate = this.getDateByFormat(value); }, displayPeriod(value) { this.period = value; }, eventsList(value) { this.events = value; }, minDate(value) { this.min = this.getDateByFormat(value); }, maxDate(value) { this.max = this.getDateByFormat(value); } }, created() { // this.$moment.locale('fa') this.currentDate = this.getDateByFormat(this.showDate); if (this.minDate) this.min = this.getDateByFormat(this.minDate); if (this.maxDate) this.max = this.getDateByFormat(this.maxDate); this.period = this.displayPeriod; this.events = this.eventsList; }, methods: { getDateByFormat(value) { try { if (typeof value === 'string') return this.$moment(value, this.dateFormat);else if (typeof value === 'object') return this.$moment(value); } catch (error) { throw new TypeError('[VuePersianCalendar Error]: showDate property value is not valid'); } }, isAfterMax() { if (!this.max) return; const newDate = this.$moment(this.currentDate).add(1, this.isWeekPeriod ? 'weeks' : 'months'); const periodStart = newDate.startOf(this.isWeekPeriod ? 'jWeek' : 'jMonth'); return this.max.isValid() && periodStart.isAfter(this.max); }, isBeforeMin() { if (!this.min) return; const newDate = this.$moment(this.currentDate).subtract(1, this.isWeekPeriod ? 'weeks' : 'months'); const periodEnd = this.$moment(this.min).startOf(this.isWeekPeriod ? 'jWeek' : 'jMonth'); return this.min.isValid() && periodEnd.isAfter(newDate); }, notCurrentMonth(day) { return !day.isSame(this.currentDate, 'month') && !this.isWeekPeriod && !this.hideMonthShadow; }, addPeriod() { if (this.isAfterMax()) return; this.transitionAction = 'slide-left'; this.currentDate = this.$moment(this.currentDate).add(1, this.isWeekPeriod ? 'weeks' : 'months'); this.$emit('on-page-add', this.currentDate); }, subtractPeriod() { if (this.isBeforeMin()) return; this.transitionAction = 'slide-right'; this.currentDate = this.$moment(this.currentDate).subtract(1, this.isWeekPeriod ? 'weeks' : 'months'); this.$emit('on-page-subtract', this.currentDate); }, goToday() { if (this.todayBtnDisable) return; this.$emit('on-today-click', this.$moment()); if (this.currentDate.isBefore(this.$moment(), 'month') || this.isWeekPeriod && this.currentDate.isBefore(this.$moment().startOf('jWeek'))) { this.transitionAction = 'slide-left'; this.currentDate = this.$moment(); } else if (this.currentDate.isAfter(this.$moment(), 'month') || this.isWeekPeriod && this.currentDate.isAfter(this.$moment(), 'week')) { this.transitionAction = 'slide-right'; this.currentDate = this.$moment(); } }, togglePeriod() { this.period = this.isWeekPeriod ? 'month' : 'week'; this.$emit('update:displayPeriod', this.period); this.$emit('on-display-period-change', this.period); // update transition this.currentDateChange = false; }, dayClassObject(day) { const today = day.isSame(this.$moment(), 'day'); let disable = false; if (this.min) { disable = this.min.isValid() && day.isBefore(this.min, 'day') || disable; } if (this.max) { disable = this.max.isValid() && day.isAfter(this.max, 'day') || disable; } return { 'vpc_day': true, 'vpc_today': today && !this.disableToday, 'vpc_past': day.isSameOrBefore(this.$moment(), 'day') && !today && !this.hidePastDaysShadow, 'vpc_not-current-month': this.notCurrentMonth(day), 'vpc_week-period-day': this.isWeekPeriod, 'vpc_day-disable': disable }; }, afterLeave() { // Transition show month after fade out this.currentDateChange = true; }, eventComparer(a, b) { if (a.startDateTime.isBefore(b.startDateTime)) return -1; if (b.startDateTime.isBefore(a.startDateTime)) return 1; if (a.endDateTime.isAfter(b.endDateTime)) return -1; if (b.endDateTime.isAfter(a.endDateTime)) return 1; return a.id < b.id ? -1 : 1; }, findAndSortEventsInWeek(weekStart) { // Return a list of events that INCLUDE any portion of a given week. return this.findAndSortEventsInDateRange(weekStart, this.$moment(weekStart).hours(23).minutes(59).seconds(59).add(6, 'days')); }, findAndSortEventsInDateRange(startDateTime, endDateTime) { // Return a list of events that INCLUDE any day within the date range, // inclusive, sorted so events that start earlier are returned first. return this.events.filter( // (event) => event.endDateTime >= startDateTime && this.dateOnly(event.startDateTime) <= endDateTime, event => event.endDateTime.isSameOrAfter(startDateTime) && event.startDateTime.isSameOrBefore(endDateTime), this).sort(this.eventComparer); }, dayHasEvents(day) { return this.events.find(d => d.endDateTime.isSameOrAfter(day) && d.startDateTime.isSameOrBefore(day)); }, dayEvents(day) { return this.events.filter(d => d.endDateTime.isSameOrAfter(day) && d.startDateTime.isSameOrBefore(day)).sort(this.eventComparer); }, dayIsSelected(day) { if (!this.selectionStart || day < this.selectionStart) return false; return !(!this.selectionEnd || day > this.selectionEnd); }, getWeekEvents(weekStart) { // Return a list of events that CONTAIN the week starting on a day. // Sorted so the events that start earlier are always shown first. const events = this.findAndSortEventsInWeek(weekStart.startOf('day')); const results = []; const eventRows = [[], [], [], [], [], [], []]; for (let i = 0; i < events.length; i++) { const ep = Object.assign({}, events[i], { classes: events[i].classes ? [...events[i].classes] : [], eventRow: 0 }); const continued = ep.startDateTime.isBefore(weekStart); const startOffset = continued ? 0 : this.diff(ep.startDateTime, weekStart); const spanContinued = continued ? this.diff(this.$moment(ep.endDateTime), weekStart) + 1 : this.diff(this.$moment(ep.endDateTime), ep.startDateTime) + 1; const span = Math.min(7 - startOffset, spanContinued); if (continued) ep.classes.push('continued'); if (this.diff(ep.endDateTime, weekStart) > 6) ep.classes.push('toBeContinued'); if (ep.endDateTime.isBefore(this.$moment())) ep.classes.push('past'); if (ep.endDateTime.isBetween(this.$moment(ep.startDateTime), this.$moment(ep.startDateTime).endOf('day'), undefined, '[]')) ep.classes.push('oneDay'); for (let d = 0; d < 7; d++) { if (d === startOffset) { let s = 0; while (eventRows[d][s]) s++; ep.eventRow = s; eventRows[d][s] = true; } else if (d < startOffset + span) { eventRows[d][ep.eventRow] = true; } } ep.classes.push(`offset${startOffset}`); ep.classes.push(`span${span}`); results.push(ep); } return results; }, getEventTop(e) { // Compute the top position of the event based on its assigned row within the given week. const r = e.eventRow; const h = this.isWeekPeriod ? '2.6em' : '1.3em'; const b = '2px'; return `calc( 2.5em + ${r}*${h} + ${r}*${b})`; }, diff(e, s) { s.locale('fa'); e.locale('fa'); const add_diff = s.clone().startOf('day').add(e.diff(s, 'm'), 'm').locale('fa'), diff = e.diff(s, 'day'); if (add_diff.isBefore(e, 'day')) return diff + 1; return diff; }, emitDay(day, $event) { $event.stopPropagation(); if (this.notCurrentMonth(day)) { return; } this.$emit('on-day-click', day); } } }); // CONCATENATED MODULE: ./src/PersianCalendar.vue?vue&type=script&lang=js& /* harmony default export */ var src_PersianCalendarvue_type_script_lang_js_ = (PersianCalendarvue_type_script_lang_js_); // EXTERNAL MODULE: ./src/PersianCalendar.vue?vue&type=style&index=0&lang=sass& var PersianCalendarvue_type_style_index_0_lang_sass_ = __webpack_require__("d6ab"); // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js /* globals __VUE_SSR_CONTEXT__ */ // IMPORTANT: Do NOT use ES2015 features in this file (except for modules). // This module is a runtime utility for cleaner component module output and will // be included in the final webpack user bundle. function normalizeComponent ( scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, /* server only */ shadowMode /* vue-cli only */ ) { // Vue.extend constructor export interop var options = typeof scriptExports === 'function' ? scriptExports.options : scriptExports // render functions if (render) { options.render = render options.staticRenderFns = staticRenderFns options._compiled = true } // functional template if (functionalTemplate) { options.functional = true } // scopedId if (scopeId) { options._scopeId = 'data-v-' + scopeId } var hook if (moduleIdentifier) { // server build hook = function (context) { // 2.3 injection context = context || // cached call (this.$vnode && this.$vnode.ssrContext) || // stateful (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional // 2.2 with runInNewContext: true if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { context = __VUE_SSR_CONTEXT__ } // inject component styles if (injectStyles) { injectStyles.call(this, context) } // register component module identifier for async chunk inferrence if (context && context._registeredComponents) { context._registeredComponents.add(moduleIdentifier) } } // used by ssr in case component is cached and beforeCreate // never gets called options._ssrRegister = hook } else if (injectStyles) { hook = shadowMode ? function () { injectStyles.call( this, (options.functional ? this.parent : this).$root.$options.shadowRoot ) } : injectStyles } if (hook) { if (options.functional) { // for template-only hot-reload because in that case the render fn doesn't // go through the normalizer options._injectStyles = hook // register for functional component in vue file var originalRender = options.render options.render = function renderWithStyleInjection (h, context) { hook.call(context) return originalRender(h, context) } } else { // inject component registration as beforeCreate hook var existing = options.beforeCreate options.beforeCreate = existing ? [].concat(existing, hook) : [hook] } } return { exports: scriptExports, options: options } } // CONCATENATED MODULE: ./src/PersianCalendar.vue /* normalize component */ var component = normalizeComponent( src_PersianCalendarvue_type_script_lang_js_, render, staticRenderFns, false, null, null, null ) /* harmony default export */ var PersianCalendar = __webpack_exports__["a"] = (component.exports); /***/ }), /***/ "d6ab": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var _node_modules_vue_style_loader_index_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_3_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_4_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_PersianCalendar_vue_vue_type_style_index_0_lang_sass___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("afc5"); /* harmony import */ var _node_modules_vue_style_loader_index_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_3_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_4_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_PersianCalendar_vue_vue_type_style_index_0_lang_sass___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_vue_style_loader_index_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_3_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_4_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_PersianCalendar_vue_vue_type_style_index_0_lang_sass___WEBPACK_IMPORTED_MODULE_0__); /* unused harmony reexport * */ /***/ }), /***/ "ef80": /***/ (function(module, exports, __webpack_require__) { // Imports var ___CSS_LOADER_API_IMPORT___ = __webpack_require__("24fb"); exports = ___CSS_LOADER_API_IMPORT___(false); // Module exports.push([module.i, "#persian-calendar{font-weight:400;font-size:1em;direction:rtl;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#persian-calendar *{padding:0;margin:0;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;outline:none;text-transform:none;text-decoration:none}#persian-calendar #vpc_header{padding:20px 15px;display:flex}#persian-calendar #vpc_header #vpc_date-control{display:flex;justify-content:flex-start;font-size:1em}#persian-calendar #vpc_header #vpc_date-control .vpc_control-btn{width:1em;height:1em;padding:.3em;border-radius:9999px!important;cursor:pointer!important;background-color:#7367f0!important;color:#fff!important}#persian-calendar #vpc_header #vpc_date-control .vpc_control-btn[disabled]{background-color:#ccc!important;cursor:not-allowed!important}#persian-calendar #vpc_header #vpc_date-control .vpc_now-date{margin:auto .75em;white-space:nowrap}#persian-calendar #vpc_header #vpc_date-control .vpc_today-btn{display:flex;justify-content:center;align-items:center;height:1em;margin:0 10px;height:1.3em;line-height:1em;vertical-align:middle;padding:.2em 1.2em;border-radius:15px!important;cursor:pointer!important;background-color:#7367f0!important;color:#fff!important}#persian-calendar #vpc_header #vpc_date-control .vpc_today-btn[disabled]{background-color:#ccc!important;cursor:not-allowed!important}#persian-calendar #vpc_header .vpc_period-control{margin-right:auto}#persian-calendar #vpc_header .vpc_period-control .vpc_period-btn{display:flex;justify-content:center;align-items:center;height:1em;margin:0 10px;height:1.3em;line-height:1em;vertical-align:middle;padding:.2em 1.2em;border-radius:15px!important;cursor:pointer!important;background-color:#7367f0!important;color:#fff!important}#persian-calendar #vpc_calendar{border-radius:15px;box-shadow:0 4px 25px 0 rgba(0,0,0,.1)}#persian-calendar #vpc_calendar #vpc_days-header{display:flex;justify-content:flex-start;width:100%;flex-grow:1;flex-shrink:1;flex-basis:0;flex-flow:row nowrap;border-width:0;position:relative;overflow-y:auto;-ms-overflow-style:none}#persian-calendar #vpc_calendar #vpc_days-header div{width:100%;overflow:hidden;padding:.5em;border-right:1px solid #ddd;border-top:1px solid #ddd;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background:#fff;color:#626262;font-size:.9em;line-height:.6em;text-align:center;cursor:default}#persian-calendar #vpc_calendar #vpc_days-header div:first-child{border-top-right-radius:15px}#persian-calendar #vpc_calendar #vpc_days-header div:last-child{border-top-left-radius:15px;border-left:1px solid #ddd}#persian-calendar #vpc_calendar .vpc_week{display:flex;justify-content:flex-start;width:100%;flex-grow:1;flex-shrink:1;flex-basis:0;flex-flow:row nowrap;border-width:0;position:relative;overflow-y:auto;-ms-overflow-style:none;scrollbar-width:none}#persian-calendar #vpc_calendar .vpc_week::-webkit-scrollbar{display:none}#persian-calendar #vpc_calendar .vpc_week .vpc_day{width:100%;overflow:hidden;padding:.5em;border-right:1px solid #ddd;border-top:1px solid #ddd;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background:#fff;min-height:120px;cursor:default}#persian-calendar #vpc_calendar .vpc_week .vpc_day.vpc_past{background-color:#fafafa}#persian-calendar #vpc_calendar .vpc_week .vpc_day.vpc_past .vpc_day-number{background-color:#565656;color:transparent;text-shadow:0 1px 1px hsla(0,0%,100%,.5);-webkit-background-clip:text;-moz-background-clip:text;background-clip:text}#persian-calendar #vpc_calendar .vpc_week .vpc_day.vpc_not-current-month{background-color:#ececec}#persian-calendar #vpc_calendar .vpc_week .vpc_day.vpc_not-current-month .vpc_day-number{background-color:#565656;color:transparent;text-shadow:0 1px 1px hsla(0,0%,100%,.5);-webkit-background-clip:text;-moz-background-clip:text;background-clip:text}#persian-calendar #vpc_calendar .vpc_week .vpc_day.vpc_week-period-day{min-height:600px}#persian-calendar #vpc_calendar .vpc_week .vpc_day.vpc_week-period-day .vpc_day-number{font-size:1.4em;text-align:center;width:auto!important}#persian-calendar #vpc_calendar .vpc_week .vpc_day.vpc_today .vpc_day-number{line-height:1.5em;width:1.2em;height:1.2em;padding:0;margin-top:0;margin-right:0;border-radius:9999px!important;background-color:#7367f0!important;color:#fff!important;text-align:center}#persian-calendar #vpc_calendar .vpc_week .vpc_day.vpc_day-disable{background-color:#ececec!important}#persian-calendar #vpc_calendar .vpc_week .vpc_day .vpc_day-number{font-weight:700;line-height:1.2em}#persian-calendar #vpc_calendar .vpc_week .vpc_day:last-child{border-left:1px solid #ddd}#persian-calendar #vpc_calendar .vpc_week .vpc_event{display:flex;justify-content:center;align-items:center;height:1em;font-size:.9em;height:1.2em;padding-left:.78em;border-color:#e0e0f0;border-radius:.5em;text-overflow:ellipsis;position:absolute;white-space:nowrap;overflow:hidden;background-color:#666;color:#fff;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#persian-calendar #vpc_calendar .vpc_week .vpc_event.offset0{right:0}#persian-calendar #vpc_calendar .vpc_week .vpc_event.span1{text-align:center;width:calc(14.28571% - .75em)}#persian-calendar #vpc_calendar .vpc_week .vpc_event.offset1{right:14.28571%}#persian-calendar #vpc_calendar .vpc_week .vpc_event.span2{text-align:center;width:calc(28.57143% - .75em)}#persian-calendar #vpc_calendar .vpc_week .vpc_event.offset2{right:28.57143%}#persian-calendar #vpc_calendar .vpc_week .vpc_event.span3{text-align:center;width:calc(42.85714% - .75em)}#persian-calendar #vpc_calendar .vpc_week .vpc_event.offset3{right:42.85714%}#persian-calendar #vpc_calendar .vpc_week .vpc_event.span4{text-align:center;width:calc(57.14286% - .75em)}#persian-calendar #vpc_calendar .vpc_week .vpc_event.offset4{right:57.14286%}#persian-calendar #vpc_calendar .vpc_week .vpc_event.span5{text-align:center;width:calc(71.42857% - .75em)}#persian-calendar #vpc_calendar .vpc_week .vpc_event.offset5{right:71.42857%}#persian-calendar #vpc_calendar .vpc_week .vpc_event.span6{text-align:center;width:calc(85.71429% - .75em)}#persian-calendar #vpc_calendar .vpc_week .vpc_event.offset6{right:85.71429%}#persian-calendar #vpc_calendar .vpc_week .vpc_event.span7{text-align:center;width:calc(100% - .75em)}#persian-calendar #vpc_calendar .vpc_week .vpc_event.offset7{right:100%}#persian-calendar #vpc_calendar .vpc_week .vpc_event.isHovered{filter:brightness(95%)}#persian-calendar #vpc_calendar .vpc_week .vpc_event.continued{border-right-style:none;border-top-right-radius:0;border-bottom-right-radius:0}#persian-calendar #vpc_calendar .vpc_week .vpc_event.continued:not(.toBeContinued) .vpc_event-end-time{display:block}#persian-calendar #vpc_calendar .vpc_week .vpc_event.continued.span1 .vpc_event-start-date{display:none}#persian-calendar #vpc_calendar .vpc_week .vpc_event.continued .vpc_event-start-date{display:block}#persian-calendar #vpc_calendar .vpc_week .vpc_event.toBeContinued{border-left-style:none;border-top-left-radius:0;border-bottom-left-radius:0}#persian-calendar #vpc_calendar .vpc_week .vpc_event.toBeContinued:not(.continued) .vpc_event-start-time{display:block}#persian-calendar #vpc_calendar .vpc_week .vpc_event.toBeContinued.span1 .vpc_event-end-date{display:none}#persian-calendar #vpc_calendar .vpc_week .vpc_event.toBeContinued .vpc_event-end-date