@fullcalendar/vue
Version:
The official Vue 2 component for FullCalendar
1 lines • 3.25 kB
JavaScript
this.FullCalendar=this.FullCalendar||{},this.FullCalendar.Vue=function(e,t,n,s){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(t);const l={headerToolbar:!0,footerToolbar:!0,events:!0,eventSources:!0,resources:!0},o="undefined"!=typeof document?document.createDocumentFragment():null,d=i.default.extend({render(e){return e("aside",{style:{display:"none"}},this.$slots.default||[])},mounted(){o&&o.appendChild(this.$el)},beforeDestroy(){o&&o.removeChild(this.$el)}}),a="undefined"!=typeof document?document.createDocumentFragment():null,u=i.default.extend({props:{inPlaceOf:"undefined"!=typeof Element?Element:Object,reportEl:Function,elTag:String,elClasses:Array,elStyle:Object,elAttrs:Object},render(e){return e(this.elTag,{class:this.elClasses,style:this.elStyle,attrs:this.elAttrs},this.$slots.default||[])},mounted(){p(this.$el,this.inPlaceOf),this.inPlaceOf.style.display="none",this.reportEl(this.$el)},updated(){a&&this.inPlaceOf.parentNode!==a&&(p(this.$el,this.inPlaceOf),this.reportEl(this.$el))},beforeDestroy(){a&&this.inPlaceOf.parentNode===a&&a.removeChild(this.inPlaceOf),this.reportEl(null)}});function p(e,t){var n;null===(n=t.parentNode)||void 0===n||n.insertBefore(e,t.nextSibling),a&&a.appendChild(t)}const h=i.default.extend({props:{options:Object},data:()=>({renderId:0,customRenderingMap:new Map}),methods:{getApi(){return this.calendar},buildOptions(e){return Object.assign(Object.assign({},e),{customRenderingMetaMap:c(this.$scopedSlots),handleCustomRendering:this.handleCustomRendering,customRenderingReplaces:!0})}},render(e){const t=[];for(const n of this.customRenderingMap.values()){const s="function"==typeof n.generatorMeta?n.generatorMeta(n.renderProps):n.generatorMeta;t.push(e("div",{key:n.id},[e(u,{key:n.id,props:{inPlaceOf:n.containerEl,reportEl:n.reportNewContainerEl,elTag:n.elTag,elClasses:n.elClasses,elStyle:n.elStyle,elAttrs:n.elAttrs}},s)]))}return e("div",{attrs:{"data-fc-render-id":this.renderId}},[e(d,t)])},mounted(){const e=new s.CustomRenderingStore;this.handleCustomRendering=e.handle.bind(e);const t=this.buildOptions(this.options),r=new n.Calendar(this.$el,t);this.calendar=r,r.render(),e.subscribe((e=>{this.customRenderingMap=e,this.renderId++,this.needCustomRenderingResize=!0}))},beforeUpdate(){this.getApi().resumeRendering()},updated(){this.needCustomRenderingResize&&(this.needCustomRenderingResize=!1,this.getApi().updateSize())},beforeDestroy(){this.getApi().destroy()},watch:function(){let e={options:{deep:!0,handler(e){let t=this.getApi();t.pauseRendering();let n=this.buildOptions(e);t.resetOptions(n),this.renderId++}}};for(let t in l)e[`options.${t}`]={deep:!0,handler(e){if(void 0!==e){let n=this.getApi();n.pauseRendering(),n.resetOptions({[t]:e},[t]),this.renderId++}}};return e}()});function c(e){const t={};for(const s in e)t[(n=s,n.split("-").map(((e,t)=>t?function(e){return e.charAt(0).toUpperCase()+e.slice(1)}(e):e)).join(""))]=e[s];var n;return t}let f,g=!1;function m(e){g||(g=!0,e.component("FullCalendar",h))}return f="undefined"!=typeof globalThis?globalThis.Vue:window.Vue,f&&f.use({install:m}),e.default=h,e.install=m,Object.defineProperty(e,"__esModule",{value:!0}),e}({},Vue,FullCalendar,FullCalendar.Internal);