@event-calendar/core
Advanced tools
Comparing version 0.0.1-beta.3 to 0.0.1
198
index.js
import { is_function, tick, SvelteComponent, init, safe_not_equal, empty, insert, detach, noop, destroy_each, component_subscribe, set_store_value, element, text, attr, append, listen, set_data, space, transition_in, group_outros, transition_out, check_outros, create_component, mount_component, destroy_component, set_style } from 'svelte/internal'; | ||
import { getContext, setContext } from 'svelte'; | ||
import { derived, writable, get } from 'svelte/store'; | ||
import { setMidnight, createDate, createDuration, createEvents, createEventSources, cloneDate, prevClosestDay, addDuration, nextClosestDay, DAY_IN_SECONDS, subtractDay, derived2, addDay, createView, assign, toISOString, writable2, intl, intlRange, subtractDuration, toEventWithLocalDates, toViewWithLocalDates } from '@event-calendar/common'; | ||
import { setMidnight, createDate, createDuration, createEvents, createEventSources, assign, cloneDate, prevClosestDay, addDuration, nextClosestDay, DAY_IN_SECONDS, subtractDay, derived2, addDay, createView, toISOString, writable2, intl, intlRange, subtractDuration, toEventWithLocalDates, toViewWithLocalDates } from '@event-calendar/common'; | ||
function createOptions(input, plugins) { | ||
function createOptions(plugins) { | ||
let options = { | ||
@@ -93,3 +93,3 @@ buttonText: { | ||
}, | ||
view: input.view || undefined, // set initial view based on input | ||
view: undefined, | ||
viewDidMount: undefined, | ||
@@ -101,3 +101,3 @@ views: {} | ||
if ('createOptions' in plugin) { | ||
plugin.createOptions(options, input); | ||
plugin.createOptions(options); | ||
} | ||
@@ -134,2 +134,17 @@ } | ||
let prev; | ||
function diff(options) { | ||
let diff = []; | ||
if (prev) { | ||
for (let name of Object.keys(options)) { | ||
if (options[name] !== prev[name]) { | ||
diff.push([name, options[name]]); | ||
} | ||
} | ||
} | ||
prev = assign({}, options); | ||
return diff; | ||
} | ||
function activeRange(state) { | ||
@@ -286,7 +301,7 @@ return derived( | ||
class State { | ||
constructor(input) { | ||
let plugins = input.plugins || []; | ||
constructor(plugins, input) { | ||
plugins = plugins || []; | ||
// Create options | ||
let options = createOptions(input, plugins); | ||
let options = createOptions(plugins); | ||
let mutators = createMutators(options, plugins); | ||
@@ -321,2 +336,7 @@ | ||
if (input.view) { | ||
// Set initial view based on input | ||
this.view.set(input.view); | ||
} | ||
// Set options for each view | ||
@@ -368,5 +388,5 @@ let views = new Set([...Object.keys(options.views), ...Object.keys(input.views || {})]); | ||
/* packages/core/src/Buttons.svelte generated by Svelte v3.31.2 */ | ||
/* packages/core/src/Buttons.svelte generated by Svelte v3.35.0 */ | ||
function get_each_context(ctx, list, i) { | ||
function get_each_context$1(ctx, list, i) { | ||
const child_ctx = ctx.slice(); | ||
@@ -378,3 +398,3 @@ child_ctx[23] = list[i]; | ||
// (38:1) {:else} | ||
function create_else_block(ctx) { | ||
function create_else_block$1(ctx) { | ||
let button; | ||
@@ -585,3 +605,3 @@ let t_value = /*$buttonText*/ ctx[5][/*button*/ ctx[23]] + ""; | ||
// (29:1) {#if button == ''} | ||
function create_if_block(ctx) { | ||
function create_if_block$1(ctx) { | ||
return { c: noop, m: noop, p: noop, d: noop }; | ||
@@ -591,7 +611,7 @@ } | ||
// (28:0) {#each buttons as button} | ||
function create_each_block(ctx) { | ||
function create_each_block$1(ctx) { | ||
let if_block_anchor; | ||
function select_block_type(ctx, dirty) { | ||
if (/*button*/ ctx[23] == "") return create_if_block; | ||
if (/*button*/ ctx[23] == "") return create_if_block$1; | ||
if (/*button*/ ctx[23] == "title") return create_if_block_1; | ||
@@ -601,3 +621,3 @@ if (/*button*/ ctx[23] == "prev") return create_if_block_2; | ||
if (/*button*/ ctx[23] === "today") return create_if_block_4; | ||
return create_else_block; | ||
return create_else_block$1; | ||
} | ||
@@ -637,3 +657,3 @@ | ||
function create_fragment(ctx) { | ||
function create_fragment$2(ctx) { | ||
let each_1_anchor; | ||
@@ -644,3 +664,3 @@ let each_value = /*buttons*/ ctx[0]; | ||
for (let i = 0; i < each_value.length; i += 1) { | ||
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); | ||
each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i)); | ||
} | ||
@@ -669,3 +689,3 @@ | ||
for (i = 0; i < each_value.length; i += 1) { | ||
const child_ctx = get_each_context(ctx, each_value, i); | ||
const child_ctx = get_each_context$1(ctx, each_value, i); | ||
@@ -675,3 +695,3 @@ if (each_blocks[i]) { | ||
} else { | ||
each_blocks[i] = create_each_block(child_ctx); | ||
each_blocks[i] = create_each_block$1(child_ctx); | ||
each_blocks[i].c(); | ||
@@ -698,3 +718,3 @@ each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); | ||
function instance($$self, $$props, $$invalidate) { | ||
function instance$2($$self, $$props, $$invalidate) { | ||
let $_currentRange; | ||
@@ -745,3 +765,3 @@ let $date; | ||
if ($$self.$$.dirty & /*$_currentRange*/ 262144) { | ||
$$invalidate(1, isToday = today >= $_currentRange.start && today < $_currentRange.end || null); | ||
$$invalidate(1, isToday = today >= $_currentRange.start && today < $_currentRange.end || null); | ||
} | ||
@@ -778,9 +798,9 @@ }; | ||
super(); | ||
init(this, options, instance, create_fragment, safe_not_equal, { buttons: 0 }); | ||
init(this, options, instance$2, create_fragment$2, safe_not_equal, { buttons: 0 }); | ||
} | ||
} | ||
/* packages/core/src/Toolbar.svelte generated by Svelte v3.31.2 */ | ||
/* packages/core/src/Toolbar.svelte generated by Svelte v3.35.0 */ | ||
function get_each_context$1(ctx, list, i) { | ||
function get_each_context(ctx, list, i) { | ||
const child_ctx = ctx.slice(); | ||
@@ -798,3 +818,3 @@ child_ctx[5] = list[i]; | ||
// (28:4) {:else} | ||
function create_else_block$1(ctx) { | ||
function create_else_block(ctx) { | ||
let buttons; | ||
@@ -833,3 +853,3 @@ let current; | ||
// (24:4) {#if buttons.length > 1} | ||
function create_if_block$1(ctx) { | ||
function create_if_block(ctx) { | ||
let div; | ||
@@ -883,3 +903,3 @@ let buttons; | ||
let current; | ||
const if_block_creators = [create_if_block$1, create_else_block$1]; | ||
const if_block_creators = [create_if_block, create_else_block]; | ||
const if_blocks = []; | ||
@@ -949,3 +969,3 @@ | ||
// (21:1) {#each Object.keys(sections) as key} | ||
function create_each_block$1(ctx) { | ||
function create_each_block(ctx) { | ||
let div; | ||
@@ -1046,3 +1066,3 @@ let t; | ||
for (let i = 0; i < each_value.length; i += 1) { | ||
each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i)); | ||
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); | ||
} | ||
@@ -1079,3 +1099,3 @@ | ||
for (i = 0; i < each_value.length; i += 1) { | ||
const child_ctx = get_each_context$1(ctx, each_value, i); | ||
const child_ctx = get_each_context(ctx, each_value, i); | ||
@@ -1086,3 +1106,3 @@ if (each_blocks[i]) { | ||
} else { | ||
each_blocks[i] = create_each_block$1(child_ctx); | ||
each_blocks[i] = create_each_block(child_ctx); | ||
each_blocks[i].c(); | ||
@@ -1142,3 +1162,3 @@ transition_in(each_blocks[i], 1); | ||
if ($$self.$$.dirty & /*sections, $headerToolbar*/ 17) { | ||
{ | ||
{ | ||
for (let key of Object.keys(sections)) { | ||
@@ -1161,5 +1181,5 @@ $$invalidate(0, sections[key] = $headerToolbar[key].split(" ").map(group => group.split(",")), sections); | ||
/* packages/core/src/Calendar.svelte generated by Svelte v3.31.2 */ | ||
/* packages/core/src/Calendar.svelte generated by Svelte v3.35.0 */ | ||
function create_fragment$2(ctx) { | ||
function create_fragment(ctx) { | ||
let div; | ||
@@ -1252,8 +1272,9 @@ let toolbar; | ||
function instance$2($$self, $$props, $$invalidate) { | ||
function instance($$self, $$props, $$invalidate) { | ||
let $theme; | ||
let $height; | ||
let $_viewComponent; | ||
let { options } = $$props; | ||
let state = new State(options); | ||
let { plugins = [] } = $$props; | ||
let { options = {} } = $$props; | ||
let state = new State(plugins, options); | ||
setContext("state", state); | ||
@@ -1273,2 +1294,4 @@ let { _viewComponent, height, theme } = state; | ||
} | ||
return this; | ||
} | ||
@@ -1284,2 +1307,3 @@ | ||
state._fetchedRange.set({ start: undefined, end: undefined }); | ||
return this; | ||
} | ||
@@ -1299,2 +1323,3 @@ | ||
state._events.update(events => events.concat(state.events.mutate([event]))); | ||
return this; | ||
} | ||
@@ -1313,2 +1338,4 @@ | ||
}); | ||
return this; | ||
} | ||
@@ -1318,2 +1345,3 @@ | ||
state._events.update(events => events.filter(event => event.id != eventId)); | ||
return this; | ||
} | ||
@@ -1326,5 +1354,15 @@ | ||
$$self.$$set = $$props => { | ||
if ("options" in $$props) $$invalidate(6, options = $$props.options); | ||
if ("plugins" in $$props) $$invalidate(6, plugins = $$props.plugins); | ||
if ("options" in $$props) $$invalidate(7, options = $$props.options); | ||
}; | ||
$$self.$$.update = () => { | ||
if ($$self.$$.dirty & /*options*/ 128) { | ||
// Reactively update options that did change | ||
for (let [name, value] of diff(options)) { | ||
setOption(name, value); | ||
} | ||
} | ||
}; | ||
return [ | ||
@@ -1337,2 +1375,3 @@ $theme, | ||
theme, | ||
plugins, | ||
options, | ||
@@ -1354,12 +1393,13 @@ setOption, | ||
init(this, options, instance$2, create_fragment$2, safe_not_equal, { | ||
options: 6, | ||
setOption: 7, | ||
getOption: 8, | ||
refetchEvents: 9, | ||
getEventById: 10, | ||
addEvent: 11, | ||
updateEvent: 12, | ||
removeEvent: 13, | ||
getView: 14 | ||
init(this, options, instance, create_fragment, safe_not_equal, { | ||
plugins: 6, | ||
options: 7, | ||
setOption: 8, | ||
getOption: 9, | ||
refetchEvents: 10, | ||
getEventById: 11, | ||
addEvent: 12, | ||
updateEvent: 13, | ||
removeEvent: 14, | ||
getView: 15 | ||
}); | ||
@@ -1369,80 +1409,34 @@ } | ||
get setOption() { | ||
return this.$$.ctx[7]; | ||
return this.$$.ctx[8]; | ||
} | ||
get getOption() { | ||
return this.$$.ctx[8]; | ||
return this.$$.ctx[9]; | ||
} | ||
get refetchEvents() { | ||
return this.$$.ctx[9]; | ||
return this.$$.ctx[10]; | ||
} | ||
get getEventById() { | ||
return this.$$.ctx[10]; | ||
return this.$$.ctx[11]; | ||
} | ||
get addEvent() { | ||
return this.$$.ctx[11]; | ||
return this.$$.ctx[12]; | ||
} | ||
get updateEvent() { | ||
return this.$$.ctx[12]; | ||
return this.$$.ctx[13]; | ||
} | ||
get removeEvent() { | ||
return this.$$.ctx[13]; | ||
return this.$$.ctx[14]; | ||
} | ||
get getView() { | ||
return this.$$.ctx[14]; | ||
return this.$$.ctx[15]; | ||
} | ||
} | ||
class index { | ||
#cal; | ||
constructor(el, options) { | ||
this.#cal = new Calendar({ | ||
target: el, | ||
props: { | ||
options | ||
} | ||
}); | ||
} | ||
setOption(name, value) { | ||
this.#cal.setOption(name, value); | ||
return this; | ||
} | ||
getOption(name) { | ||
return this.#cal.getOption(name); | ||
} | ||
refetchEvents() { | ||
this.#cal.refetchEvents(); | ||
return this; | ||
} | ||
addEvent(event) { | ||
this.#cal.addEvent(event); | ||
return this; | ||
} | ||
updateEvent(event, create) { | ||
this.#cal.updateEvent(event, create); | ||
return this; | ||
} | ||
removeEvent(eventId) { | ||
this.#cal.removeEvent(eventId); | ||
return this; | ||
} | ||
get view() { | ||
return this.#cal.getView(); | ||
} | ||
} | ||
export default index; | ||
export default Calendar; |
{ | ||
"name": "@event-calendar/core", | ||
"version": "0.0.1-beta.3", | ||
"version": "0.0.1", | ||
"title": "EventCalendar Core Package", | ||
@@ -20,5 +20,5 @@ "description": "Full-sized event calendar with resource view", | ||
"dependencies": { | ||
"@event-calendar/common": "~0.0.1-beta.3", | ||
"svelte": "^3.31.2" | ||
"@event-calendar/common": "~0.0.1", | ||
"svelte": "^3.35.0" | ||
} | ||
} |
@@ -1,5 +0,5 @@ | ||
# EventCalendar Core Package | ||
# Event Calendar core package | ||
Full-sized JavaScript event calendar with resource view. | ||
Inspired by [FullCalendar](https://fullcalendar.io/) and implements the same options. | ||
Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Possible typosquat attack
Supply chain riskThere is a package with a similar name that is downloaded much more often.
Did you mean |
---|
@fullcalendar/core |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86471
0
1233
Updatedsvelte@^3.35.0