@event-calendar/core
Advanced tools
Comparing version 0.16.1 to 0.17.0
118
index.js
@@ -1,5 +0,5 @@ | ||
import { is_function, tick, noop, identity, SvelteComponent, init, safe_not_equal, empty, insert, destroy_each, detach, component_subscribe, set_store_value, element, text, attr, append, listen, set_data, transition_in, group_outros, check_outros, transition_out, space, create_component, mount_component, destroy_component, construct_svelte_component, set_style } from 'svelte/internal'; | ||
import { getContext, setContext } from 'svelte'; | ||
import { is_function, noop, identity, tick, SvelteComponent, init, safe_not_equal, empty, insert, destroy_each, detach, component_subscribe, set_store_value, element, text, attr, append, listen, set_data, transition_in, group_outros, check_outros, transition_out, space, create_component, mount_component, destroy_component, construct_svelte_component, set_style, get_current_component } from 'svelte/internal'; | ||
import { getContext, setContext, beforeUpdate } from 'svelte'; | ||
import { derived, writable, readable, get } from 'svelte/store'; | ||
import { assign, setMidnight, createDate, createDuration, createEvents, createEventSources, cloneDate, prevClosestDay, nextClosestDay, DAY_IN_SECONDS, addDuration, subtractDay, toLocalDate, toISOString, derived2, addDay, createView, writable2, intl, intlRange, subtractDuration, toEventWithLocalDates, toViewWithLocalDates, hasFn, runFn, ignore } from '@event-calendar/common'; | ||
import { assign, setMidnight, createDate, createDuration, createEvents, createEventSources, cloneDate, prevClosestDay, nextClosestDay, DAY_IN_SECONDS, addDuration, subtractDay, debounce, toLocalDate, toISOString, derived2, addDay, createView, writable2, intl, intlRange, subtractDuration, flushDebounce, toEventWithLocalDates, toViewWithLocalDates, hasFn, runFn, ignore } from '@event-calendar/common'; | ||
@@ -182,8 +182,8 @@ function createOptions(plugins) { | ||
let debounce = 0; | ||
derived([_activeRange, state.datesSet], ([$_activeRange, $datesSet]) => { | ||
if ($datesSet && !debounce) { | ||
++debounce; | ||
tick().then(() => { | ||
--debounce; | ||
let debounceHandle = {}; | ||
derived([_activeRange, state.datesSet], values => { | ||
let [, $datesSet] = values; | ||
if ($datesSet) { | ||
debounce(() => { | ||
let [$_activeRange, $datesSet] = values; | ||
$datesSet({ | ||
@@ -195,3 +195,3 @@ start: toLocalDate($_activeRange.start), | ||
}); | ||
}); | ||
}, debounceHandle, state._queue); | ||
} | ||
@@ -266,5 +266,7 @@ }).subscribe(noop); | ||
let fetching = 0; | ||
let debounceHandle = {}; | ||
derived( | ||
[state.events, state.eventSources, state._activeRange, state._fetchedRange, state.lazyFetching, state.loading], | ||
([$events, $eventSources, $_activeRange, $_fetchedRange, $lazyFetching, $loading], set) => { | ||
(values, set) => debounce(() => { | ||
let [$events, $eventSources, $_activeRange, $_fetchedRange, $lazyFetching, $loading] = values; | ||
if (!$eventSources.length) { | ||
@@ -342,3 +344,3 @@ set($events); | ||
} | ||
}, | ||
}, debounceHandle, state._queue), | ||
[] | ||
@@ -378,2 +380,3 @@ ).subscribe(_events.set); | ||
// Private stores | ||
this._queue = writable(new Map()); // debounce queue | ||
this._currentRange = currentRange(this); | ||
@@ -434,2 +437,3 @@ this._activeRange = activeRange(this); | ||
}); | ||
// Process options | ||
for (let key of Object.keys(opts)) { | ||
@@ -1307,3 +1311,3 @@ if (this.hasOwnProperty(key) && key[0] !== '_') { | ||
if (!mounted) { | ||
dispose = listen(window, "click", /*handleClick*/ ctx[16], true); | ||
dispose = listen(window, "click", /*handleClick*/ ctx[17], true); | ||
mounted = true; | ||
@@ -1394,2 +1398,3 @@ } | ||
function instance($$self, $$props, $$invalidate) { | ||
let $_queue; | ||
let $_ignoreClick; | ||
@@ -1407,13 +1412,15 @@ let $events; | ||
let { options = {} } = $$props; | ||
let component = get_current_component(); | ||
let state = new State(plugins, options); | ||
setContext('state', state); | ||
let { _viewComponent, _viewClass, _ignoreClick, _interaction, _iClass, _events, events, eventSources, height, theme } = state; | ||
let { _viewComponent, _viewClass, _ignoreClick, _interaction, _iClass, _events, _queue, events, eventSources, height, theme } = state; | ||
component_subscribe($$self, _viewComponent, value => $$invalidate(5, $_viewComponent = value)); | ||
component_subscribe($$self, _viewClass, value => $$invalidate(2, $_viewClass = value)); | ||
component_subscribe($$self, _ignoreClick, value => $$invalidate(30, $_ignoreClick = value)); | ||
component_subscribe($$self, _ignoreClick, value => $$invalidate(33, $_ignoreClick = value)); | ||
component_subscribe($$self, _interaction, value => $$invalidate(0, $_interaction = value)); | ||
component_subscribe($$self, _iClass, value => $$invalidate(3, $_iClass = value)); | ||
component_subscribe($$self, _events, value => $$invalidate(32, $_events = value)); | ||
component_subscribe($$self, events, value => $$invalidate(31, $events = value)); | ||
component_subscribe($$self, eventSources, value => $$invalidate(33, $eventSources = value)); | ||
component_subscribe($$self, _events, value => $$invalidate(35, $_events = value)); | ||
component_subscribe($$self, _queue, value => $$invalidate(32, $_queue = value)); | ||
component_subscribe($$self, events, value => $$invalidate(34, $events = value)); | ||
component_subscribe($$self, eventSources, value => $$invalidate(36, $eventSources = value)); | ||
component_subscribe($$self, height, value => $$invalidate(4, $height = value)); | ||
@@ -1448,7 +1455,7 @@ component_subscribe($$self, theme, value => $$invalidate(1, $theme = value)); | ||
function getEvents() { | ||
return get(state._events).map(toEventWithLocalDates); | ||
return $_events.map(toEventWithLocalDates); | ||
} | ||
function getEventById(id) { | ||
for (let event of get(state._events)) { | ||
for (let event of $_events) { | ||
if (event.id == id) { | ||
@@ -1510,2 +1517,6 @@ return toEventWithLocalDates(event); | ||
function destroy() { | ||
destroy_component(component, true); | ||
} | ||
function updateEvents(func) { | ||
@@ -1526,9 +1537,13 @@ if ($eventSources.length) { | ||
beforeUpdate(() => { | ||
flushDebounce($_queue); | ||
}); | ||
$$self.$$set = $$props => { | ||
if ('plugins' in $$props) $$invalidate(17, plugins = $$props.plugins); | ||
if ('options' in $$props) $$invalidate(18, options = $$props.options); | ||
if ('plugins' in $$props) $$invalidate(18, plugins = $$props.plugins); | ||
if ('options' in $$props) $$invalidate(19, options = $$props.options); | ||
}; | ||
$$self.$$.update = () => { | ||
if ($$self.$$.dirty[0] & /*options*/ 262144) { | ||
if ($$self.$$.dirty[0] & /*options*/ 524288) { | ||
// Reactively update options that did change | ||
@@ -1554,2 +1569,3 @@ for (let [name, value] of diff(options)) { | ||
_events, | ||
_queue, | ||
events, | ||
@@ -1572,3 +1588,4 @@ eventSources, | ||
unselect, | ||
dateFromPoint | ||
dateFromPoint, | ||
destroy | ||
]; | ||
@@ -1588,15 +1605,16 @@ } | ||
{ | ||
plugins: 17, | ||
options: 18, | ||
setOption: 19, | ||
getOption: 20, | ||
refetchEvents: 21, | ||
getEvents: 22, | ||
getEventById: 23, | ||
addEvent: 24, | ||
updateEvent: 25, | ||
removeEventById: 26, | ||
getView: 27, | ||
unselect: 28, | ||
dateFromPoint: 29 | ||
plugins: 18, | ||
options: 19, | ||
setOption: 20, | ||
getOption: 21, | ||
refetchEvents: 22, | ||
getEvents: 23, | ||
getEventById: 24, | ||
addEvent: 25, | ||
updateEvent: 26, | ||
removeEventById: 27, | ||
getView: 28, | ||
unselect: 29, | ||
dateFromPoint: 30, | ||
destroy: 31 | ||
}, | ||
@@ -1609,46 +1627,50 @@ null, | ||
get setOption() { | ||
return this.$$.ctx[19]; | ||
return this.$$.ctx[20]; | ||
} | ||
get getOption() { | ||
return this.$$.ctx[20]; | ||
return this.$$.ctx[21]; | ||
} | ||
get refetchEvents() { | ||
return this.$$.ctx[21]; | ||
return this.$$.ctx[22]; | ||
} | ||
get getEvents() { | ||
return this.$$.ctx[22]; | ||
return this.$$.ctx[23]; | ||
} | ||
get getEventById() { | ||
return this.$$.ctx[23]; | ||
return this.$$.ctx[24]; | ||
} | ||
get addEvent() { | ||
return this.$$.ctx[24]; | ||
return this.$$.ctx[25]; | ||
} | ||
get updateEvent() { | ||
return this.$$.ctx[25]; | ||
return this.$$.ctx[26]; | ||
} | ||
get removeEventById() { | ||
return this.$$.ctx[26]; | ||
return this.$$.ctx[27]; | ||
} | ||
get getView() { | ||
return this.$$.ctx[27]; | ||
return this.$$.ctx[28]; | ||
} | ||
get unselect() { | ||
return this.$$.ctx[28]; | ||
return this.$$.ctx[29]; | ||
} | ||
get dateFromPoint() { | ||
return this.$$.ctx[29]; | ||
return this.$$.ctx[30]; | ||
} | ||
get destroy() { | ||
return this.$$.ctx[31]; | ||
} | ||
} | ||
export { Calendar as default }; |
{ | ||
"name": "@event-calendar/core", | ||
"version": "0.16.1", | ||
"version": "0.17.0", | ||
"title": "Event Calendar Core package", | ||
@@ -40,5 +40,5 @@ "description": "Full-sized drag & drop event calendar with resource view", | ||
"dependencies": { | ||
"@event-calendar/common": "~0.16.1", | ||
"@event-calendar/common": "~0.17.0", | ||
"svelte": "^3.55.1" | ||
} | ||
} |
@@ -120,2 +120,3 @@ # Event Calendar [![](https://data.jsdelivr.com/v1/package/npm/@event-calendar/build/badge)](https://www.jsdelivr.com/package/npm/@event-calendar/build) [![npm](https://img.shields.io/npm/dm/@event-calendar/core?color=red&label=npm&style=flat-square)](https://www.npmjs.com/package/@event-calendar/core) [![Sponsor](https://img.shields.io/badge/Sponsor-$10-blue.svg?style=flat-square&logo=paypal)](https://www.paypal.me/vkurko/10usd) | ||
- [dateFromPoint](#datefrompoint-x-y-) | ||
- [destroy](#destroy) | ||
- [getView](#getview) | ||
@@ -195,4 +196,4 @@ - [unselect](#unselect-1) | ||
```html | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.16.1/event-calendar.min.css"> | ||
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.16.1/event-calendar.min.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.17.0/event-calendar.min.css"> | ||
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.17.0/event-calendar.min.js"></script> | ||
``` | ||
@@ -2006,2 +2007,7 @@ | ||
### destroy() | ||
- Return value `undefined` | ||
Destroys the calendar, removing all DOM elements, event handlers, and internal data. | ||
### getView() | ||
@@ -2008,0 +2014,0 @@ - Return value `View` |
@@ -31,2 +31,3 @@ import {writable} from 'svelte/store'; | ||
// Private stores | ||
this._queue = writable(new Map()); // debounce queue | ||
this._currentRange = currentRange(this); | ||
@@ -87,2 +88,3 @@ this._activeRange = activeRange(this); | ||
}); | ||
// Process options | ||
for (let key of Object.keys(opts)) { | ||
@@ -89,0 +91,0 @@ if (this.hasOwnProperty(key) && key[0] !== '_') { |
import {derived, writable, readable} from 'svelte/store'; | ||
import {is_function, noop, tick} from 'svelte/internal'; | ||
import {is_function, noop} from 'svelte/internal'; | ||
import { | ||
@@ -14,3 +14,4 @@ DAY_IN_SECONDS, | ||
setMidnight, | ||
toLocalDate | ||
toLocalDate, | ||
debounce | ||
} from '@event-calendar/common'; | ||
@@ -45,8 +46,8 @@ import {derived2} from '@event-calendar/common'; | ||
let debounce = 0; | ||
derived([_activeRange, state.datesSet], ([$_activeRange, $datesSet]) => { | ||
if ($datesSet && !debounce) { | ||
++debounce; | ||
tick().then(() => { | ||
--debounce; | ||
let debounceHandle = {}; | ||
derived([_activeRange, state.datesSet], values => { | ||
let [, $datesSet] = values; | ||
if ($datesSet) { | ||
debounce(() => { | ||
let [$_activeRange, $datesSet] = values; | ||
$datesSet({ | ||
@@ -58,3 +59,3 @@ start: toLocalDate($_activeRange.start), | ||
}); | ||
}); | ||
}, debounceHandle, state._queue); | ||
} | ||
@@ -129,5 +130,7 @@ }).subscribe(noop); | ||
let fetching = 0; | ||
let debounceHandle = {}; | ||
derived( | ||
[state.events, state.eventSources, state._activeRange, state._fetchedRange, state.lazyFetching, state.loading], | ||
([$events, $eventSources, $_activeRange, $_fetchedRange, $lazyFetching, $loading], set) => { | ||
(values, set) => debounce(() => { | ||
let [$events, $eventSources, $_activeRange, $_fetchedRange, $lazyFetching, $loading] = values; | ||
if (!$eventSources.length) { | ||
@@ -205,3 +208,3 @@ set($events); | ||
} | ||
}, | ||
}, debounceHandle, state._queue), | ||
[] | ||
@@ -208,0 +211,0 @@ ).subscribe(_events.set); |
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
144288
2408
2455
+ Added@event-calendar/common@0.17.1(transitive)
- Removed@event-calendar/common@0.16.1(transitive)