@artesa/fullcalendar-vue
Advanced tools
Comparing version
@@ -1,7 +0,5 @@ | ||
import Vue from 'vue'; | ||
import { NormalizedScopedSlot } from 'vue/types/vnode'; | ||
import { PluginDef } from '@fullcalendar/core'; | ||
export declare function wrapVDomGenerator(vDomGenerator: NormalizedScopedSlot): (props: any) => { | ||
vue: import("vue/types/vnode").ScopedSlotChildren; | ||
export declare function wrapVDomGenerator(vDomGenerator: any): (props: any) => { | ||
vue: any; | ||
}; | ||
export declare function createVueContentTypePlugin(parent: Vue): PluginDef; | ||
export declare function createVueContentTypePlugin(appContext: any): PluginDef; |
@@ -1,2 +0,3 @@ | ||
import Vue from 'vue'; | ||
import { h } from 'vue'; | ||
import { createApp } from 'vue-demi'; | ||
import { createPlugin } from '@fullcalendar/core'; | ||
@@ -11,45 +12,48 @@ /* | ||
} | ||
export function createVueContentTypePlugin(parent) { | ||
export function createVueContentTypePlugin(appContext) { | ||
return createPlugin({ | ||
contentTypeHandlers: { | ||
vue: function () { return buildVDomHandler(parent); }, // looks for the `vue` key | ||
vue: () => buildVDomHandler(appContext), // looks for the `vue` key | ||
} | ||
}); | ||
} | ||
function buildVDomHandler(parent) { | ||
var currentEl; | ||
var v; // the Vue instance | ||
function buildVDomHandler(appContext) { | ||
let currentEl; | ||
let app; | ||
let componentInstance; | ||
function render(el, vDomContent) { | ||
if (currentEl !== el) { | ||
if (currentEl && v) { // if changing elements, recreate the vue | ||
v.$destroy(); | ||
if (currentEl && app) { // if changing elements, recreate the vue | ||
app.unmount(); | ||
} | ||
currentEl = el; | ||
} | ||
if (!v) { | ||
v = initVue(vDomContent, parent); | ||
if (!app) { | ||
app = initApp(vDomContent, appContext); | ||
// vue's mount method *replaces* the given element. create an artificial inner el | ||
var innerEl = document.createElement('span'); | ||
let innerEl = document.createElement('span'); | ||
el.appendChild(innerEl); | ||
v.$mount(innerEl); | ||
componentInstance = app.mount(innerEl); | ||
} | ||
else { | ||
v.content = vDomContent; | ||
componentInstance.content = vDomContent; | ||
} | ||
} | ||
function destroy() { | ||
if (v) { // needed? | ||
v.$destroy(); | ||
if (app) { // needed? | ||
app.unmount(); | ||
} | ||
} | ||
return { render: render, destroy: destroy }; | ||
return { render, destroy }; | ||
} | ||
function initVue(initialContent, parent) { | ||
return new Vue({ | ||
parent: parent, | ||
data: { | ||
content: initialContent, | ||
function initApp(initialContent, appContext) { | ||
// TODO: do something with appContext | ||
return createApp({ | ||
data() { | ||
return { | ||
content: initialContent, | ||
}; | ||
}, | ||
render: function (h) { | ||
var content = this.content; | ||
render() { | ||
let { content } = this; | ||
// the slot result can be an array, but the returned value of a vue component's | ||
@@ -56,0 +60,0 @@ // render method must be a single node. |
@@ -1,17 +0,8 @@ | ||
import Vue from 'vue'; | ||
import { Calendar, CalendarOptions } from '@fullcalendar/core'; | ||
declare const FullCalendar: import("vue/types/vue").ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, any>>, { | ||
renderId: number; | ||
}, { | ||
getApi: typeof getApi; | ||
buildOptions: typeof buildOptions; | ||
}, unknown, { | ||
options: CalendarOptions; | ||
}, {}>; | ||
declare function buildOptions(this: { | ||
$options: any; | ||
}, suppliedOptions: CalendarOptions, parent: Vue): CalendarOptions; | ||
declare function getApi(this: { | ||
$options: any; | ||
}): Calendar; | ||
declare const FullCalendar: import("vue/types/v3-define-component").DefineComponent<Readonly<{ | ||
[x: string]: any; | ||
}>, {}, {}, import("vue").ComponentComputedOptions, import("vue").ComponentMethodOptions, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<Readonly<{ | ||
[x: string]: any; | ||
}>>>, { | ||
[x: string]: any; | ||
}>; | ||
export default FullCalendar; |
@@ -1,3 +0,2 @@ | ||
import { __assign } from "tslib"; | ||
import Vue from 'vue'; | ||
import { h, defineComponent } from 'vue'; | ||
import { Calendar } from '@fullcalendar/core'; | ||
@@ -7,3 +6,3 @@ import { OPTION_IS_COMPLEX } from './options'; | ||
import { wrapVDomGenerator, createVueContentTypePlugin } from './custom-content-type'; | ||
var FullCalendar = Vue.extend({ | ||
const FullCalendar = defineComponent({ | ||
props: { | ||
@@ -13,4 +12,4 @@ options: Object | ||
data: initData, | ||
render: function (createElement) { | ||
return createElement('div', { | ||
render() { | ||
return h('div', { | ||
// when renderId is changed, Vue will trigger a real-DOM async rerender, calling beforeUpdate/updated | ||
@@ -20,17 +19,20 @@ attrs: { 'data-fc-render-id': this.renderId } | ||
}, | ||
mounted: function () { | ||
var internal = this.$options; | ||
internal.scopedSlotOptions = mapHash(this.$scopedSlots, wrapVDomGenerator); // needed for buildOptions | ||
var calendar = new Calendar(this.$el, this.buildOptions(this.options, this)); | ||
internal.calendar = calendar; | ||
mounted() { | ||
// store internal data (slotOptions, calendar) | ||
// https://github.com/vuejs/vue/issues/1988#issuecomment-163013818 | ||
this.slotOptions = mapHash(this.$slots, wrapVDomGenerator); // needed for buildOptions | ||
let calendarOptions = this.buildOptions(this.options, this.$.appContext); | ||
let calendar = new Calendar(this.$el, calendarOptions); | ||
this.calendar = calendar; | ||
calendar.render(); | ||
}, | ||
methods: { | ||
getApi: getApi, | ||
buildOptions: buildOptions, | ||
getApi, | ||
buildOptions, | ||
}, | ||
beforeUpdate: function () { | ||
beforeUpdate() { | ||
this.getApi().resumeRendering(); // the watcher handlers paused it | ||
}, | ||
beforeDestroy: function () { | ||
// @ts-ignore | ||
beforeUnmount() { | ||
this.getApi().destroy(); | ||
@@ -40,2 +42,3 @@ }, | ||
}); | ||
export default FullCalendar; | ||
function initData() { | ||
@@ -46,15 +49,17 @@ return { | ||
} | ||
function buildOptions(suppliedOptions, parent) { | ||
var internal = this.$options; | ||
function buildOptions(suppliedOptions, appContext) { | ||
suppliedOptions = suppliedOptions || {}; | ||
return __assign(__assign(__assign({}, internal.scopedSlotOptions), suppliedOptions), { plugins: (suppliedOptions.plugins || []).concat([ | ||
createVueContentTypePlugin(parent) | ||
]) }); | ||
return { | ||
...this.slotOptions, | ||
...suppliedOptions, | ||
plugins: (suppliedOptions.plugins || []).concat([ | ||
createVueContentTypePlugin(appContext) | ||
]) | ||
}; | ||
} | ||
function getApi() { | ||
var internal = this.$options; | ||
return internal.calendar; | ||
return this.calendar; | ||
} | ||
function buildWatchers() { | ||
var watchers = { | ||
let watchers = { | ||
// watches changes of ALL options and their nested objects, | ||
@@ -64,36 +69,30 @@ // but this is only a means to be notified of top-level non-complex options changes. | ||
deep: true, | ||
handler: function (options) { | ||
var calendar = this.getApi(); | ||
handler(options) { | ||
let calendar = this.getApi(); | ||
calendar.pauseRendering(); | ||
calendar.resetOptions(this.buildOptions(options, this)); | ||
this.renderId++; // will queue a rerender | ||
let calendarOptions = this.buildOptions(options, this.$.appContext); | ||
calendar.resetOptions(calendarOptions)(this).renderId++; // will queue a rerender | ||
} | ||
} | ||
}; | ||
var _loop_1 = function (complexOptionName) { | ||
for (let complexOptionName in OPTION_IS_COMPLEX) { | ||
// handlers called when nested objects change | ||
watchers["options.".concat(complexOptionName)] = { | ||
watchers[`options.${complexOptionName}`] = { | ||
deep: true, | ||
handler: function (val) { | ||
var _a; | ||
handler(val) { | ||
// unfortunately the handler is called with undefined if new props were set, but the complex one wasn't ever set | ||
if (val !== undefined) { | ||
var calendar = this.getApi(); | ||
let calendar = this.getApi(); | ||
calendar.pauseRendering(); | ||
calendar.resetOptions((_a = {}, | ||
calendar.resetOptions({ | ||
// the only reason we shallow-copy is to trick FC into knowing there's a nested change. | ||
// TODO: future versions of FC will more gracefully handle event option-changes that are same-reference. | ||
_a[complexOptionName] = shallowCopy(val), | ||
_a), true); | ||
this.renderId++; // will queue a rerender | ||
[complexOptionName]: shallowCopy(val) | ||
}, true)(this).renderId++; // will queue a rerender | ||
} | ||
} | ||
}; | ||
}; | ||
for (var complexOptionName in OPTION_IS_COMPLEX) { | ||
_loop_1(complexOptionName); | ||
} | ||
return watchers; | ||
} | ||
export default FullCalendar; | ||
//# sourceMappingURL=FullCalendar.js.map |
@@ -5,11 +5,7 @@ 'use strict'; | ||
var tslib = require('tslib'); | ||
var Vue = require('vue'); | ||
var vue = require('vue'); | ||
var core = require('@fullcalendar/core'); | ||
var vueDemi = require('vue-demi'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); | ||
var OPTION_IS_COMPLEX = { | ||
const OPTION_IS_COMPLEX = { | ||
headerToolbar: true, | ||
@@ -32,3 +28,3 @@ footerToolbar: true, | ||
else if (val) { // non-null | ||
val = tslib.__assign({}, val); | ||
val = { ...val }; | ||
} | ||
@@ -39,4 +35,4 @@ } | ||
function mapHash(input, func) { | ||
var output = {}; | ||
for (var key in input) { | ||
const output = {}; | ||
for (const key in input) { | ||
if (input.hasOwnProperty(key)) { | ||
@@ -57,45 +53,48 @@ output[key] = func(input[key], key); | ||
} | ||
function createVueContentTypePlugin(parent) { | ||
function createVueContentTypePlugin(appContext) { | ||
return core.createPlugin({ | ||
contentTypeHandlers: { | ||
vue: function () { return buildVDomHandler(parent); }, // looks for the `vue` key | ||
vue: () => buildVDomHandler(), // looks for the `vue` key | ||
} | ||
}); | ||
} | ||
function buildVDomHandler(parent) { | ||
var currentEl; | ||
var v; // the Vue instance | ||
function buildVDomHandler(appContext) { | ||
let currentEl; | ||
let app; | ||
let componentInstance; | ||
function render(el, vDomContent) { | ||
if (currentEl !== el) { | ||
if (currentEl && v) { // if changing elements, recreate the vue | ||
v.$destroy(); | ||
if (currentEl && app) { // if changing elements, recreate the vue | ||
app.unmount(); | ||
} | ||
currentEl = el; | ||
} | ||
if (!v) { | ||
v = initVue(vDomContent, parent); | ||
if (!app) { | ||
app = initApp(vDomContent); | ||
// vue's mount method *replaces* the given element. create an artificial inner el | ||
var innerEl = document.createElement('span'); | ||
let innerEl = document.createElement('span'); | ||
el.appendChild(innerEl); | ||
v.$mount(innerEl); | ||
componentInstance = app.mount(innerEl); | ||
} | ||
else { | ||
v.content = vDomContent; | ||
componentInstance.content = vDomContent; | ||
} | ||
} | ||
function destroy() { | ||
if (v) { // needed? | ||
v.$destroy(); | ||
if (app) { // needed? | ||
app.unmount(); | ||
} | ||
} | ||
return { render: render, destroy: destroy }; | ||
return { render, destroy }; | ||
} | ||
function initVue(initialContent, parent) { | ||
return new Vue__default["default"]({ | ||
parent: parent, | ||
data: { | ||
content: initialContent, | ||
function initApp(initialContent, appContext) { | ||
// TODO: do something with appContext | ||
return vueDemi.createApp({ | ||
data() { | ||
return { | ||
content: initialContent, | ||
}; | ||
}, | ||
render: function (h) { | ||
var content = this.content; | ||
render() { | ||
let { content } = this; | ||
// the slot result can be an array, but the returned value of a vue component's | ||
@@ -107,3 +106,3 @@ // render method must be a single node. | ||
else { | ||
return h('span', {}, content); | ||
return vue.h('span', {}, content); | ||
} | ||
@@ -114,3 +113,3 @@ } | ||
var FullCalendar = Vue__default["default"].extend({ | ||
const FullCalendar = vue.defineComponent({ | ||
props: { | ||
@@ -120,4 +119,4 @@ options: Object | ||
data: initData, | ||
render: function (createElement) { | ||
return createElement('div', { | ||
render() { | ||
return vue.h('div', { | ||
// when renderId is changed, Vue will trigger a real-DOM async rerender, calling beforeUpdate/updated | ||
@@ -127,17 +126,20 @@ attrs: { 'data-fc-render-id': this.renderId } | ||
}, | ||
mounted: function () { | ||
var internal = this.$options; | ||
internal.scopedSlotOptions = mapHash(this.$scopedSlots, wrapVDomGenerator); // needed for buildOptions | ||
var calendar = new core.Calendar(this.$el, this.buildOptions(this.options, this)); | ||
internal.calendar = calendar; | ||
mounted() { | ||
// store internal data (slotOptions, calendar) | ||
// https://github.com/vuejs/vue/issues/1988#issuecomment-163013818 | ||
this.slotOptions = mapHash(this.$slots, wrapVDomGenerator); // needed for buildOptions | ||
let calendarOptions = this.buildOptions(this.options, this.$.appContext); | ||
let calendar = new core.Calendar(this.$el, calendarOptions); | ||
this.calendar = calendar; | ||
calendar.render(); | ||
}, | ||
methods: { | ||
getApi: getApi, | ||
buildOptions: buildOptions, | ||
getApi, | ||
buildOptions, | ||
}, | ||
beforeUpdate: function () { | ||
beforeUpdate() { | ||
this.getApi().resumeRendering(); // the watcher handlers paused it | ||
}, | ||
beforeDestroy: function () { | ||
// @ts-ignore | ||
beforeUnmount() { | ||
this.getApi().destroy(); | ||
@@ -152,15 +154,17 @@ }, | ||
} | ||
function buildOptions(suppliedOptions, parent) { | ||
var internal = this.$options; | ||
function buildOptions(suppliedOptions, appContext) { | ||
suppliedOptions = suppliedOptions || {}; | ||
return tslib.__assign(tslib.__assign(tslib.__assign({}, internal.scopedSlotOptions), suppliedOptions), { plugins: (suppliedOptions.plugins || []).concat([ | ||
createVueContentTypePlugin(parent) | ||
]) }); | ||
return { | ||
...this.slotOptions, | ||
...suppliedOptions, | ||
plugins: (suppliedOptions.plugins || []).concat([ | ||
createVueContentTypePlugin() | ||
]) | ||
}; | ||
} | ||
function getApi() { | ||
var internal = this.$options; | ||
return internal.calendar; | ||
return this.calendar; | ||
} | ||
function buildWatchers() { | ||
var watchers = { | ||
let watchers = { | ||
// watches changes of ALL options and their nested objects, | ||
@@ -170,32 +174,27 @@ // but this is only a means to be notified of top-level non-complex options changes. | ||
deep: true, | ||
handler: function (options) { | ||
var calendar = this.getApi(); | ||
handler(options) { | ||
let calendar = this.getApi(); | ||
calendar.pauseRendering(); | ||
calendar.resetOptions(this.buildOptions(options, this)); | ||
this.renderId++; // will queue a rerender | ||
let calendarOptions = this.buildOptions(options, this.$.appContext); | ||
calendar.resetOptions(calendarOptions)(this).renderId++; // will queue a rerender | ||
} | ||
} | ||
}; | ||
var _loop_1 = function (complexOptionName) { | ||
for (let complexOptionName in OPTION_IS_COMPLEX) { | ||
// handlers called when nested objects change | ||
watchers["options.".concat(complexOptionName)] = { | ||
watchers[`options.${complexOptionName}`] = { | ||
deep: true, | ||
handler: function (val) { | ||
var _a; | ||
handler(val) { | ||
// unfortunately the handler is called with undefined if new props were set, but the complex one wasn't ever set | ||
if (val !== undefined) { | ||
var calendar = this.getApi(); | ||
let calendar = this.getApi(); | ||
calendar.pauseRendering(); | ||
calendar.resetOptions((_a = {}, | ||
calendar.resetOptions({ | ||
// the only reason we shallow-copy is to trick FC into knowing there's a nested change. | ||
// TODO: future versions of FC will more gracefully handle event option-changes that are same-reference. | ||
_a[complexOptionName] = shallowCopy(val), | ||
_a), true); | ||
this.renderId++; // will queue a rerender | ||
[complexOptionName]: shallowCopy(val) | ||
}, true)(this).renderId++; // will queue a rerender | ||
} | ||
} | ||
}; | ||
}; | ||
for (var complexOptionName in OPTION_IS_COMPLEX) { | ||
_loop_1(complexOptionName); | ||
} | ||
@@ -205,34 +204,3 @@ return watchers; | ||
/* | ||
Registers the component globally if appropriate. | ||
This modules exposes the component AND an install function. | ||
Derived from: | ||
https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html | ||
*/ | ||
var installed = false; | ||
// declare install function executed by Vue.use() | ||
function install(Vue) { | ||
if (!installed) { | ||
installed = true; | ||
Vue.component('FullCalendar', FullCalendar); | ||
} | ||
} | ||
// detect a globally availble version of Vue (eg. in browser via <script> tag) | ||
var GlobalVue; | ||
if (typeof globalThis !== 'undefined') { | ||
GlobalVue = globalThis.Vue; | ||
} | ||
else { | ||
GlobalVue = window.Vue; | ||
} | ||
// auto-install if possible | ||
if (GlobalVue) { | ||
GlobalVue.use({ | ||
install: install | ||
}); | ||
} | ||
exports["default"] = FullCalendar; | ||
exports.install = install; | ||
Object.keys(core).forEach(function (k) { | ||
@@ -239,0 +207,0 @@ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { |
@@ -1,5 +0,3 @@ | ||
import { VueConstructor } from 'vue'; | ||
import FullCalendarComponent from './FullCalendar'; | ||
export declare function install(Vue: VueConstructor): void; | ||
export default FullCalendarComponent; | ||
export * from '@fullcalendar/core'; |
@@ -8,29 +8,3 @@ var FullCalendarVue = (function (exports, Vue, core) { | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var OPTION_IS_COMPLEX = { | ||
const OPTION_IS_COMPLEX = { | ||
headerToolbar: true, | ||
@@ -53,3 +27,3 @@ footerToolbar: true, | ||
else if (val) { // non-null | ||
val = __assign({}, val); | ||
val = { ...val }; | ||
} | ||
@@ -60,4 +34,4 @@ } | ||
function mapHash(input, func) { | ||
var output = {}; | ||
for (var key in input) { | ||
const output = {}; | ||
for (const key in input) { | ||
if (input.hasOwnProperty(key)) { | ||
@@ -70,2 +44,42 @@ output[key] = func(input[key], key); | ||
// createApp polyfill | ||
function createApp(rootComponent, rootProps) { | ||
var vm; | ||
var provide = {}; | ||
var app = { | ||
config: Vue__default["default"].config, | ||
use: Vue__default["default"].use.bind(Vue__default["default"]), | ||
mixin: Vue__default["default"].mixin.bind(Vue__default["default"]), | ||
component: Vue__default["default"].component.bind(Vue__default["default"]), | ||
provide: function (key, value) { | ||
provide[key] = value; | ||
return this | ||
}, | ||
directive: function (name, dir) { | ||
if (dir) { | ||
Vue__default["default"].directive(name, dir); | ||
return app | ||
} else { | ||
return Vue__default["default"].directive(name) | ||
} | ||
}, | ||
mount: function (el, hydrating) { | ||
if (!vm) { | ||
vm = new Vue__default["default"](Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) })); | ||
vm.$mount(el, hydrating); | ||
return vm | ||
} else { | ||
return vm | ||
} | ||
}, | ||
unmount: function () { | ||
if (vm) { | ||
vm.$destroy(); | ||
vm = undefined; | ||
} | ||
}, | ||
}; | ||
return app | ||
} | ||
/* | ||
@@ -79,45 +93,48 @@ wrap it in an object with a `vue` key, which the custom content-type handler system will look for | ||
} | ||
function createVueContentTypePlugin(parent) { | ||
function createVueContentTypePlugin(appContext) { | ||
return core.createPlugin({ | ||
contentTypeHandlers: { | ||
vue: function () { return buildVDomHandler(parent); }, // looks for the `vue` key | ||
vue: () => buildVDomHandler(), // looks for the `vue` key | ||
} | ||
}); | ||
} | ||
function buildVDomHandler(parent) { | ||
var currentEl; | ||
var v; // the Vue instance | ||
function buildVDomHandler(appContext) { | ||
let currentEl; | ||
let app; | ||
let componentInstance; | ||
function render(el, vDomContent) { | ||
if (currentEl !== el) { | ||
if (currentEl && v) { // if changing elements, recreate the vue | ||
v.$destroy(); | ||
if (currentEl && app) { // if changing elements, recreate the vue | ||
app.unmount(); | ||
} | ||
currentEl = el; | ||
} | ||
if (!v) { | ||
v = initVue(vDomContent, parent); | ||
if (!app) { | ||
app = initApp(vDomContent); | ||
// vue's mount method *replaces* the given element. create an artificial inner el | ||
var innerEl = document.createElement('span'); | ||
let innerEl = document.createElement('span'); | ||
el.appendChild(innerEl); | ||
v.$mount(innerEl); | ||
componentInstance = app.mount(innerEl); | ||
} | ||
else { | ||
v.content = vDomContent; | ||
componentInstance.content = vDomContent; | ||
} | ||
} | ||
function destroy() { | ||
if (v) { // needed? | ||
v.$destroy(); | ||
if (app) { // needed? | ||
app.unmount(); | ||
} | ||
} | ||
return { render: render, destroy: destroy }; | ||
return { render, destroy }; | ||
} | ||
function initVue(initialContent, parent) { | ||
return new Vue__default["default"]({ | ||
parent: parent, | ||
data: { | ||
content: initialContent, | ||
function initApp(initialContent, appContext) { | ||
// TODO: do something with appContext | ||
return createApp({ | ||
data() { | ||
return { | ||
content: initialContent, | ||
}; | ||
}, | ||
render: function (h) { | ||
var content = this.content; | ||
render() { | ||
let { content } = this; | ||
// the slot result can be an array, but the returned value of a vue component's | ||
@@ -129,3 +146,3 @@ // render method must be a single node. | ||
else { | ||
return h('span', {}, content); | ||
return Vue.h('span', {}, content); | ||
} | ||
@@ -136,3 +153,3 @@ } | ||
var FullCalendar = Vue__default["default"].extend({ | ||
const FullCalendar = Vue.defineComponent({ | ||
props: { | ||
@@ -142,4 +159,4 @@ options: Object | ||
data: initData, | ||
render: function (createElement) { | ||
return createElement('div', { | ||
render() { | ||
return Vue.h('div', { | ||
// when renderId is changed, Vue will trigger a real-DOM async rerender, calling beforeUpdate/updated | ||
@@ -149,17 +166,20 @@ attrs: { 'data-fc-render-id': this.renderId } | ||
}, | ||
mounted: function () { | ||
var internal = this.$options; | ||
internal.scopedSlotOptions = mapHash(this.$scopedSlots, wrapVDomGenerator); // needed for buildOptions | ||
var calendar = new core.Calendar(this.$el, this.buildOptions(this.options, this)); | ||
internal.calendar = calendar; | ||
mounted() { | ||
// store internal data (slotOptions, calendar) | ||
// https://github.com/vuejs/vue/issues/1988#issuecomment-163013818 | ||
this.slotOptions = mapHash(this.$slots, wrapVDomGenerator); // needed for buildOptions | ||
let calendarOptions = this.buildOptions(this.options, this.$.appContext); | ||
let calendar = new core.Calendar(this.$el, calendarOptions); | ||
this.calendar = calendar; | ||
calendar.render(); | ||
}, | ||
methods: { | ||
getApi: getApi, | ||
buildOptions: buildOptions, | ||
getApi, | ||
buildOptions, | ||
}, | ||
beforeUpdate: function () { | ||
beforeUpdate() { | ||
this.getApi().resumeRendering(); // the watcher handlers paused it | ||
}, | ||
beforeDestroy: function () { | ||
// @ts-ignore | ||
beforeUnmount() { | ||
this.getApi().destroy(); | ||
@@ -174,15 +194,17 @@ }, | ||
} | ||
function buildOptions(suppliedOptions, parent) { | ||
var internal = this.$options; | ||
function buildOptions(suppliedOptions, appContext) { | ||
suppliedOptions = suppliedOptions || {}; | ||
return __assign(__assign(__assign({}, internal.scopedSlotOptions), suppliedOptions), { plugins: (suppliedOptions.plugins || []).concat([ | ||
createVueContentTypePlugin(parent) | ||
]) }); | ||
return { | ||
...this.slotOptions, | ||
...suppliedOptions, | ||
plugins: (suppliedOptions.plugins || []).concat([ | ||
createVueContentTypePlugin() | ||
]) | ||
}; | ||
} | ||
function getApi() { | ||
var internal = this.$options; | ||
return internal.calendar; | ||
return this.calendar; | ||
} | ||
function buildWatchers() { | ||
var watchers = { | ||
let watchers = { | ||
// watches changes of ALL options and their nested objects, | ||
@@ -192,32 +214,27 @@ // but this is only a means to be notified of top-level non-complex options changes. | ||
deep: true, | ||
handler: function (options) { | ||
var calendar = this.getApi(); | ||
handler(options) { | ||
let calendar = this.getApi(); | ||
calendar.pauseRendering(); | ||
calendar.resetOptions(this.buildOptions(options, this)); | ||
this.renderId++; // will queue a rerender | ||
let calendarOptions = this.buildOptions(options, this.$.appContext); | ||
calendar.resetOptions(calendarOptions)(this).renderId++; // will queue a rerender | ||
} | ||
} | ||
}; | ||
var _loop_1 = function (complexOptionName) { | ||
for (let complexOptionName in OPTION_IS_COMPLEX) { | ||
// handlers called when nested objects change | ||
watchers["options.".concat(complexOptionName)] = { | ||
watchers[`options.${complexOptionName}`] = { | ||
deep: true, | ||
handler: function (val) { | ||
var _a; | ||
handler(val) { | ||
// unfortunately the handler is called with undefined if new props were set, but the complex one wasn't ever set | ||
if (val !== undefined) { | ||
var calendar = this.getApi(); | ||
let calendar = this.getApi(); | ||
calendar.pauseRendering(); | ||
calendar.resetOptions((_a = {}, | ||
calendar.resetOptions({ | ||
// the only reason we shallow-copy is to trick FC into knowing there's a nested change. | ||
// TODO: future versions of FC will more gracefully handle event option-changes that are same-reference. | ||
_a[complexOptionName] = shallowCopy(val), | ||
_a), true); | ||
this.renderId++; // will queue a rerender | ||
[complexOptionName]: shallowCopy(val) | ||
}, true)(this).renderId++; // will queue a rerender | ||
} | ||
} | ||
}; | ||
}; | ||
for (var complexOptionName in OPTION_IS_COMPLEX) { | ||
_loop_1(complexOptionName); | ||
} | ||
@@ -227,34 +244,3 @@ return watchers; | ||
/* | ||
Registers the component globally if appropriate. | ||
This modules exposes the component AND an install function. | ||
Derived from: | ||
https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html | ||
*/ | ||
var installed = false; | ||
// declare install function executed by Vue.use() | ||
function install(Vue) { | ||
if (!installed) { | ||
installed = true; | ||
Vue.component('FullCalendar', FullCalendar); | ||
} | ||
} | ||
// detect a globally availble version of Vue (eg. in browser via <script> tag) | ||
var GlobalVue; | ||
if (typeof globalThis !== 'undefined') { | ||
GlobalVue = globalThis.Vue; | ||
} | ||
else { | ||
GlobalVue = window.Vue; | ||
} | ||
// auto-install if possible | ||
if (GlobalVue) { | ||
GlobalVue.use({ | ||
install: install | ||
}); | ||
} | ||
exports["default"] = FullCalendar; | ||
exports.install = install; | ||
Object.keys(core).forEach(function (k) { | ||
@@ -261,0 +247,0 @@ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { |
@@ -1,1 +0,1 @@ | ||
var FullCalendarVue=function(e,n,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(n),i=function(){return(i=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)},u={headerToolbar:!0,footerToolbar:!0,events:!0,eventSources:!0,resources:!0};function a(e){return function(n){return{vue:e(n)}}}function s(e){return t.createPlugin({contentTypeHandlers:{vue:function(){return function(e){var n,t;return{render:function(r,i){if(n!==r&&(n&&t&&t.$destroy(),n=r),t)t.content=i;else{t=function(e,n){return new o.default({parent:n,data:{content:e},render:function(e){var n=this.content;return 1===n.length?n[0]:e("span",{},n)}})}(i,e);var u=document.createElement("span");r.appendChild(u),t.$mount(u)}},destroy:function(){t&&t.$destroy()}}}(e)}}})}var c=o.default.extend({props:{options:Object},data:function(){return{renderId:0}},render:function(e){return e("div",{attrs:{"data-fc-render-id":this.renderId}})},mounted:function(){var e=this.$options;e.scopedSlotOptions=function(e,n){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=n(e[r],r));return t}(this.$scopedSlots,a);var n=new t.Calendar(this.$el,this.buildOptions(this.options,this));e.calendar=n,n.render()},methods:{getApi:function(){return this.$options.calendar},buildOptions:function(e,n){var t=this.$options;return e=e||{},i(i(i({},t.scopedSlotOptions),e),{plugins:(e.plugins||[]).concat([s(n)])})}},beforeUpdate:function(){this.getApi().resumeRendering()},beforeDestroy:function(){this.getApi().destroy()},watch:function(){var e={options:{deep:!0,handler:function(e){var n=this.getApi();n.pauseRendering(),n.resetOptions(this.buildOptions(e,this)),this.renderId++}}},n=function(n){e["options.".concat(n)]={deep:!0,handler:function(e){var t;if(void 0!==e){var r=this.getApi();r.pauseRendering(),r.resetOptions(((t={})[n]=function(e){return"object"==typeof e&&(Array.isArray(e)?e=Array.prototype.slice.call(e):e&&(e=i({},e))),e}(e),t),!0),this.renderId++}}}};for(var t in u)n(t);return e}()});var d,l=!1;function f(e){l||(l=!0,e.component("FullCalendar",c))}return(d="undefined"!=typeof globalThis?globalThis.Vue:window.Vue)&&d.use({install:f}),e.default=c,e.install=f,Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0}),e}({},Vue,FullCalendar); | ||
var FullCalendarVue=function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(t);const o={headerToolbar:!0,footerToolbar:!0,events:!0,eventSources:!0,resources:!0};function u(e){return"object"==typeof e&&(Array.isArray(e)?e=Array.prototype.slice.call(e):e&&(e={...e})),e}function s(e){return function(t){return{vue:e(t)}}}function d(e){return n.createPlugin({contentTypeHandlers:{vue:()=>function(e){let n,r,o;return{render:function(e,u){if(n!==e&&(n&&r&&r.unmount(),n=e),r)o.content=u;else{s=u,r=function(e,t){var n,r={},o={config:i.default.config,use:i.default.use.bind(i.default),mixin:i.default.mixin.bind(i.default),component:i.default.component.bind(i.default),provide:function(e,t){return r[e]=t,this},directive:function(e,t){return t?(i.default.directive(e,t),o):i.default.directive(e)},mount:function(o,u){return n||((n=new i.default(Object.assign({propsData:t},e,{provide:Object.assign(r,e.provide)}))).$mount(o,u),n)},unmount:function(){n&&(n.$destroy(),n=void 0)}};return o}({data:()=>({content:s}),render(){let{content:e}=this;return 1===e.length?e[0]:t.h("span",{},e)}});let n=document.createElement("span");e.appendChild(n),o=r.mount(n)}var s},destroy:function(){r&&r.unmount()}}}()}})}const a=t.defineComponent({props:{options:Object},data:function(){return{renderId:0}},render(){return t.h("div",{attrs:{"data-fc-render-id":this.renderId}})},mounted(){this.slotOptions=function(e,t){const n={};for(const r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r],r));return n}(this.$slots,s);let e=this.buildOptions(this.options,this.$.appContext),t=new n.Calendar(this.$el,e);this.calendar=t,t.render()},methods:{getApi:function(){return this.calendar},buildOptions:function(e,t){return e=e||{},{...this.slotOptions,...e,plugins:(e.plugins||[]).concat([d()])}}},beforeUpdate(){this.getApi().resumeRendering()},beforeUnmount(){this.getApi().destroy()},watch:function(){let e={options:{deep:!0,handler(e){let t=this.getApi();t.pauseRendering();let n=this.buildOptions(e,this.$.appContext);t.resetOptions(n)(this).renderId++}}};for(let t in o)e["options."+t]={deep:!0,handler(e){if(void 0!==e){let n=this.getApi();n.pauseRendering(),n.resetOptions({[t]:u(e)},!0)(this).renderId++}}};return e}()});return e.default=a,Object.keys(n).forEach((function(t){"default"===t||e.hasOwnProperty(t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),Object.defineProperty(e,"__esModule",{value:!0}),e}({},Vue,FullCalendar); |
import FullCalendarComponent from './FullCalendar'; | ||
/* | ||
Registers the component globally if appropriate. | ||
This modules exposes the component AND an install function. | ||
Derived from: | ||
https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html | ||
*/ | ||
var installed = false; | ||
// declare install function executed by Vue.use() | ||
export function install(Vue) { | ||
if (!installed) { | ||
installed = true; | ||
Vue.component('FullCalendar', FullCalendarComponent); | ||
} | ||
} | ||
// detect a globally availble version of Vue (eg. in browser via <script> tag) | ||
var GlobalVue; | ||
if (typeof globalThis !== 'undefined') { | ||
GlobalVue = globalThis.Vue; | ||
} | ||
else { | ||
GlobalVue = window.Vue; | ||
} | ||
// auto-install if possible | ||
if (GlobalVue) { | ||
GlobalVue.use({ | ||
install: install | ||
}); | ||
} | ||
// to allow use as module (npm/webpack/etc.) export component | ||
export default FullCalendarComponent; | ||
@@ -33,0 +3,0 @@ // so can access any of the utils/types from this lib |
@@ -1,2 +0,2 @@ | ||
export var OPTION_IS_COMPLEX = { | ||
export const OPTION_IS_COMPLEX = { | ||
headerToolbar: true, | ||
@@ -3,0 +3,0 @@ footerToolbar: true, |
// TODO: add types! | ||
import { __assign } from "tslib"; | ||
/* | ||
@@ -12,3 +11,3 @@ works with objects and arrays | ||
else if (val) { // non-null | ||
val = __assign({}, val); | ||
val = { ...val }; | ||
} | ||
@@ -19,4 +18,4 @@ } | ||
export function mapHash(input, func) { | ||
var output = {}; | ||
for (var key in input) { | ||
const output = {}; | ||
for (const key in input) { | ||
if (input.hasOwnProperty(key)) { | ||
@@ -23,0 +22,0 @@ output[key] = func(input[key], key); |
{ | ||
"name": "@artesa/fullcalendar-vue", | ||
"version": "5.12.0", | ||
"version": "5.13.0", | ||
"title": "FullCalendar Vue 2 Component", | ||
@@ -23,4 +23,4 @@ "description": "An official FullCalendar component for Vue 2", | ||
"minify": "terser --compress --mangle --comments false --output dist/main.global.min.js -- dist/main.global.js", | ||
"test": "concurrently 'webpack --watch' 'karma start karma.config.js'", | ||
"test:ci": "webpack && karma start karma.config.js --browsers ChromeHeadless --single-run --no-auto-watch", | ||
"test": "wtr --watch", | ||
"test:ci": "wtr", | ||
"ci": "./scripts/ci.sh" | ||
@@ -30,3 +30,3 @@ }, | ||
"@fullcalendar/core": "~5.11.2", | ||
"tslib": "^2.1.0" | ||
"tslib": "^2.0.3" | ||
}, | ||
@@ -41,23 +41,25 @@ "peerDependencies": { | ||
"@babel/runtime": "^7.12.1", | ||
"@esm-bundle/chai": "^4.3.4", | ||
"@fullcalendar/daygrid": "~5.11.2", | ||
"@rollup/plugin-alias": "^3.1.2", | ||
"@rollup/plugin-node-resolve": "^8.4.0", | ||
"@rollup/plugin-replace": "^2.4.2", | ||
"@types/estree": "^0.0.45", | ||
"@types/node": "14.10.0", | ||
"@vue/test-utils": "^1.0.3", | ||
"babel-loader": "^8.1.0", | ||
"concurrently": "^5.3.0", | ||
"css-loader": "^4.3.0", | ||
"karma": "^6.3.2", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-jasmine": "^4.0.1", | ||
"karma-sourcemap-loader": "^0.3.8", | ||
"karma-spec-reporter": "^0.0.32", | ||
"@vue/compiler-dom": "^3.0.11", | ||
"@vue/compiler-sfc": "^3.0.11", | ||
"@vue/test-utils": "next", | ||
"@web/dev-server-rollup": "^0.3.4", | ||
"@web/test-runner": "^0.13.5", | ||
"postcss": "^8.3.0", | ||
"rollup": "^2.21.0", | ||
"rollup-plugin-postcss": "^4.0.0", | ||
"rollup-plugin-vue": "next", | ||
"source-map-loader": "^1.1.1", | ||
"style-loader": "^2.0.0", | ||
"terser": "^4.8.0", | ||
"typescript": "^4.0.5", | ||
"vue": "^2.7.8", | ||
"vue": "^2.6.12", | ||
"vue-demi": "^0.13.7", | ||
"vue-loader": "^15.9.5", | ||
"vue-template-compiler": "^2.7.8", | ||
"vue-template-compiler": "^2.6.12", | ||
"webpack": "^5.7.0", | ||
@@ -64,0 +66,0 @@ "webpack-cli": "^4.1.0" |
@@ -1,5 +0,9 @@ | ||
import Vue, { VNode } from 'vue' | ||
import { NormalizedScopedSlot } from 'vue/types/vnode' | ||
import { ComponentPublicInstance, VNode, h } from 'vue' | ||
import { createApp, App } from 'vue-demi' | ||
import { createPlugin, PluginDef } from '@fullcalendar/core' | ||
interface RootComponentData { | ||
content: VNode[] | ||
} | ||
type RootComponentInstance = ComponentPublicInstance<{}, {}, RootComponentData> | ||
@@ -9,3 +13,3 @@ /* | ||
*/ | ||
export function wrapVDomGenerator(vDomGenerator: NormalizedScopedSlot) { | ||
export function wrapVDomGenerator(vDomGenerator: any) { | ||
return function(props: any) { | ||
@@ -16,19 +20,19 @@ return { vue: vDomGenerator(props) } | ||
export function createVueContentTypePlugin(parent: Vue): PluginDef { | ||
export function createVueContentTypePlugin(appContext: any): PluginDef { | ||
return createPlugin({ | ||
contentTypeHandlers: { | ||
vue: () => buildVDomHandler(parent), // looks for the `vue` key | ||
vue: () => buildVDomHandler(appContext), // looks for the `vue` key | ||
} | ||
}); | ||
}) | ||
} | ||
function buildVDomHandler(parent: Vue) { | ||
function buildVDomHandler(appContext: any) { | ||
let currentEl: HTMLElement | ||
let v: ReturnType<typeof initVue> // the Vue instance | ||
let app: App | ||
let componentInstance: RootComponentInstance | ||
function render(el: HTMLElement, vDomContent: VNode[]) { // the handler | ||
if (currentEl !== el) { | ||
if (currentEl && v) { // if changing elements, recreate the vue | ||
v.$destroy() | ||
if (currentEl && app) { // if changing elements, recreate the vue | ||
app.unmount() | ||
} | ||
@@ -38,4 +42,4 @@ currentEl = el | ||
if (!v) { | ||
v = initVue(vDomContent, parent) | ||
if (!app) { | ||
app = initApp(vDomContent, appContext) | ||
@@ -45,5 +49,6 @@ // vue's mount method *replaces* the given element. create an artificial inner el | ||
el.appendChild(innerEl) | ||
v.$mount(innerEl) | ||
componentInstance = app.mount(innerEl) as any as RootComponentInstance | ||
} else { | ||
v.content = vDomContent | ||
componentInstance.content = vDomContent | ||
} | ||
@@ -53,4 +58,4 @@ } | ||
function destroy() { | ||
if (v) { // needed? | ||
v.$destroy() | ||
if (app) { // needed? | ||
app.unmount() | ||
} | ||
@@ -62,9 +67,11 @@ } | ||
function initVue(initialContent: VNode[], parent: Vue) { | ||
return new Vue({ | ||
parent, | ||
data: { | ||
content: initialContent, | ||
function initApp(initialContent: VNode[], appContext: any): App { | ||
// TODO: do something with appContext | ||
return createApp({ | ||
data() { | ||
return { | ||
content: initialContent, | ||
} as RootComponentData | ||
}, | ||
render(h) { | ||
render() { | ||
let { content } = this | ||
@@ -76,3 +83,2 @@ | ||
return content[0] | ||
} else { | ||
@@ -79,0 +85,0 @@ return h('span', {}, content) |
@@ -1,3 +0,2 @@ | ||
import Vue, { PropType } from 'vue' | ||
import { NormalizedScopedSlot } from 'vue/types/vnode' | ||
import Vue, { PropType, h, defineComponent } from 'vue' | ||
import { Calendar, CalendarOptions } from '@fullcalendar/core' | ||
@@ -8,11 +7,4 @@ import { OPTION_IS_COMPLEX } from './options' | ||
const FullCalendar = defineComponent({ | ||
interface FullCalendarInternal { | ||
calendar: Calendar | ||
scopedSlotOptions: { [name: string]: NormalizedScopedSlot } | ||
} | ||
const FullCalendar = Vue.extend({ | ||
props: { | ||
@@ -24,6 +16,6 @@ options: Object as PropType<CalendarOptions> | ||
render(createElement) { | ||
return createElement('div', { | ||
render() { | ||
return h('div', { | ||
// when renderId is changed, Vue will trigger a real-DOM async rerender, calling beforeUpdate/updated | ||
attrs: { 'data-fc-render-id': this.renderId } | ||
attrs: { 'data-fc-render-id': (this as any).renderId } | ||
}) | ||
@@ -33,7 +25,8 @@ }, | ||
mounted() { | ||
let internal = this.$options as FullCalendarInternal | ||
internal.scopedSlotOptions = mapHash(this.$scopedSlots, wrapVDomGenerator) // needed for buildOptions | ||
let calendar = new Calendar(this.$el as HTMLElement, this.buildOptions(this.options, this)) | ||
internal.calendar = calendar | ||
// store internal data (slotOptions, calendar) | ||
// https://github.com/vuejs/vue/issues/1988#issuecomment-163013818 | ||
(this as any).slotOptions = mapHash((this as any).$slots, wrapVDomGenerator) // needed for buildOptions | ||
let calendarOptions = (this as any).buildOptions((this as any).options, (this as any).$.appContext) | ||
let calendar = new Calendar((this as any).$el as HTMLElement, calendarOptions) | ||
;(this as any).calendar = calendar | ||
calendar.render() | ||
@@ -48,7 +41,8 @@ }, | ||
beforeUpdate() { | ||
this.getApi().resumeRendering() // the watcher handlers paused it | ||
(this as any).getApi().resumeRendering() // the watcher handlers paused it | ||
}, | ||
beforeDestroy() { | ||
this.getApi().destroy() | ||
// @ts-ignore | ||
beforeUnmount() { | ||
(this as any).getApi().destroy() | ||
}, | ||
@@ -59,3 +53,5 @@ | ||
export default FullCalendar | ||
function initData() { | ||
@@ -68,10 +64,13 @@ return { | ||
function buildOptions(this: { $options: any }, suppliedOptions: CalendarOptions, parent: Vue): CalendarOptions { | ||
let internal = this.$options as FullCalendarInternal | ||
function buildOptions( | ||
this: any, | ||
suppliedOptions: CalendarOptions | undefined, | ||
appContext: any, | ||
): CalendarOptions { | ||
suppliedOptions = suppliedOptions || {} | ||
return { | ||
...internal.scopedSlotOptions, | ||
...(this as any).slotOptions, | ||
...suppliedOptions, // spread will pull out the values from the options getter functions | ||
plugins: (suppliedOptions.plugins || []).concat([ | ||
createVueContentTypePlugin(parent) | ||
createVueContentTypePlugin(appContext) | ||
]) | ||
@@ -82,5 +81,4 @@ } | ||
function getApi(this: { $options: any }) { | ||
let internal = this.$options as FullCalendarInternal | ||
return internal.calendar | ||
function getApi(this: any) { | ||
return (this as any).calendar | ||
} | ||
@@ -101,6 +99,9 @@ | ||
handler(this: FullCalendarInstance, options: CalendarOptions) { | ||
let calendar = this.getApi() | ||
let calendar = (this as any).getApi() | ||
calendar.pauseRendering() | ||
calendar.resetOptions(this.buildOptions(options, this)) | ||
this.renderId++ // will queue a rerender | ||
let calendarOptions = (this as any).buildOptions(options, (this as any).$.appContext) | ||
calendar.resetOptions(calendarOptions) | ||
(this as any).renderId++ // will queue a rerender | ||
} | ||
@@ -120,3 +121,3 @@ } | ||
let calendar = this.getApi() | ||
let calendar = (this as any).getApi() | ||
calendar.pauseRendering() | ||
@@ -129,3 +130,3 @@ calendar.resetOptions({ | ||
this.renderId++ // will queue a rerender | ||
(this as any).renderId++ // will queue a rerender | ||
} | ||
@@ -138,4 +139,1 @@ } | ||
} | ||
export default FullCalendar |
@@ -1,38 +0,3 @@ | ||
import { VueConstructor } from 'vue' | ||
import FullCalendarComponent from './FullCalendar' | ||
/* | ||
Registers the component globally if appropriate. | ||
This modules exposes the component AND an install function. | ||
Derived from: | ||
https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html | ||
*/ | ||
let installed = false | ||
// declare install function executed by Vue.use() | ||
export function install(Vue: VueConstructor) { | ||
if (!installed) { | ||
installed = true | ||
Vue.component('FullCalendar', FullCalendarComponent) | ||
} | ||
} | ||
// detect a globally availble version of Vue (eg. in browser via <script> tag) | ||
let GlobalVue: VueConstructor | undefined | ||
if (typeof globalThis !== 'undefined') { | ||
GlobalVue = globalThis.Vue | ||
} else { | ||
GlobalVue = window.Vue | ||
} | ||
// auto-install if possible | ||
if (GlobalVue) { | ||
GlobalVue.use({ | ||
install | ||
}) | ||
} | ||
// to allow use as module (npm/webpack/etc.) export component | ||
export default FullCalendarComponent | ||
@@ -39,0 +4,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40018
-9.5%29
7.41%845
-10.3%Updated