Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@event-calendar/core

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@event-calendar/core - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

83

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, assign, cloneDate, prevClosestDay, addDuration, nextClosestDay, DAY_IN_SECONDS, subtractDay, derived2, addDay, createView, 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, toLocalDate, toISOString, writable2, intl, intlRange, subtractDuration, toEventWithLocalDates, toViewWithLocalDates } from '@event-calendar/common';

@@ -254,37 +254,52 @@ function createOptions(plugins) {

}
let stopLoading = () => {
if (--fetching === 0 && is_function($loading)) {
$loading(false);
}
};
let events = [];
// Prepare handlers
let failure = e => stopLoading();
let success = data => {
events = events.concat(createEvents(data));
set(events);
stopLoading();
};
// Loop over event sources
for (let source of $eventSources) {
// Prepare params
let params = is_function(source.extraParams) ? source.extraParams() : assign({}, source.extraParams);
params.start = toISOString($_activeRange.start);
params.end = toISOString($_activeRange.end);
params = new URLSearchParams(params);
// Prepare fetch
let url = source.url, headers = {}, body;
if (['GET', 'HEAD'].includes(source.method)) {
url += (url.includes('?') ? '&' : '?') + params;
} else {
headers['content-type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
body = String(params); // Safari 10.1 doesn't convert to string automatically
if (is_function(source.events)) {
// Events as a function
let result = source.events({
start: toLocalDate($_activeRange.start),
end: toLocalDate($_activeRange.end)
}, success, failure);
if (result !== undefined) {
Promise.resolve(result).then(success, failure);
}
} else if ('url' in source) {
// Events as a JSON feed
// Prepare params
let params = is_function(source.extraParams) ? source.extraParams() : assign({}, source.extraParams);
params.start = toISOString($_activeRange.start);
params.end = toISOString($_activeRange.end);
params = new URLSearchParams(params);
// Prepare fetch
let url = source.url, headers = {}, body;
if (['GET', 'HEAD'].includes(source.method)) {
url += (url.includes('?') ? '&' : '?') + params;
} else {
headers['content-type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
body = String(params); // Safari 10.1 doesn't convert to string automatically
}
// Do the fetch
fetch(url, {method: source.method, headers, body, signal: abortController.signal, credentials: 'same-origin'})
.then(response => response.json())
.then(success)
.catch(failure);
}
// Do the fetch
fetch(url, {method: source.method, headers, body, signal: abortController.signal, credentials: 'same-origin'})
.then(response => response.json())
.then(data => {
events = events.concat(createEvents(data));
set(events);
if (--fetching === 0 && is_function($loading)) {
$loading(false);
}
})
.catch(e => {
if (--fetching === 0 && is_function($loading)) {
$loading(false);
}
});
++fetching;
// Save current range for future requests
$_fetchedRange.start = $_activeRange.start;
$_fetchedRange.end = $_activeRange.end;
}
// Save current range for future requests
$_fetchedRange.start = $_activeRange.start;
$_fetchedRange.end = $_activeRange.end;
}

@@ -396,3 +411,3 @@ }),

/* packages/core/src/Buttons.svelte generated by Svelte v3.38.2 */
/* packages/core/src/Buttons.svelte generated by Svelte v3.38.3 */

@@ -800,3 +815,3 @@ function get_each_context$1(ctx, list, i) {

/* packages/core/src/Toolbar.svelte generated by Svelte v3.38.2 */
/* packages/core/src/Toolbar.svelte generated by Svelte v3.38.3 */

@@ -1171,3 +1186,3 @@ function get_each_context(ctx, list, i) {

/* packages/core/src/Calendar.svelte generated by Svelte v3.38.2 */
/* packages/core/src/Calendar.svelte generated by Svelte v3.38.3 */

@@ -1174,0 +1189,0 @@ function create_fragment(ctx) {

{
"name": "@event-calendar/core",
"version": "0.1.2",
"version": "0.2.0",
"title": "Event Calendar Core package",

@@ -21,5 +21,5 @@ "description": "Full-sized event calendar with resource view",

"dependencies": {
"@event-calendar/common": "~0.1.2",
"svelte": "^3.38.2"
"@event-calendar/common": "~0.2.0",
"svelte": "^3.38.3"
}
}

@@ -1,2 +0,2 @@

# Event Calendar
# Event Calendar [![](https://data.jsdelivr.com/v1/package/npm/@event-calendar/build/badge)](https://www.jsdelivr.com/package/npm/@event-calendar/build)

@@ -20,54 +20,54 @@ See [demo](https://vkurko.github.io/calendar/).

<tr><td>
- [buttonText](#buttontext)
- [date](#date)
- [dateClick](#dateclick)
- [dayHeaderFormat](#dayheaderformat)
- [displayEventEnd](#displayeventend)
- [duration](#duration)
- [editable](#editable)
- [events](#events)
- [eventBackgroundColor](#eventbackgroundcolor)
- [eventClick](#eventclick)
- [eventColor](#eventcolor)
- [eventContent](#eventcontent)
- [eventDidMount](#eventdidmount)
- [eventDragMinDistance](#eventdragmindistance)
- [eventDragStart](#eventdragstart)
- [eventDragStop](#eventdragstop)
- [buttonText](#buttontext)
- [date](#date)
- [dateClick](#dateclick)
- [dayHeaderFormat](#dayheaderformat)
- [displayEventEnd](#displayeventend)
- [duration](#duration)
- [editable](#editable)
- [events](#events)
- [eventBackgroundColor](#eventbackgroundcolor)
- [eventClick](#eventclick)
- [eventColor](#eventcolor)
- [eventContent](#eventcontent)
- [eventDidMount](#eventdidmount)
- [eventDragMinDistance](#eventdragmindistance)
- [eventDragStart](#eventdragstart)
- [eventDragStop](#eventdragstop)
</td><td>
- [eventDrop](#eventdrop)
- [eventMouseEnter](#eventmouseenter)
- [eventMouseLeave](#eventmouseleave)
- [eventSources](#eventsources)
- [eventStartEditable](#eventstarteditable)
- [eventTimeFormat](#eventtimeformat)
- [firstDay](#firstday)
- [flexibleSlotTimeLimits](#flexibleslottimelimits)
- [headerToolbar](#headertoolbar)
- [height](#height)
- [hiddenDays](#hiddendays)
- [hideResourcesWithNoEvents](#hideresourceswithnoevents)
- [highlightedDates](#highlighteddates)
- [lazyFetching](#lazyfetching)
- [listDayFormat](#listdayformat)
- [listDaySideFormat](#listdaysideformat)
- [eventDrop](#eventdrop)
- [eventMouseEnter](#eventmouseenter)
- [eventMouseLeave](#eventmouseleave)
- [eventSources](#eventsources)
- [eventStartEditable](#eventstarteditable)
- [eventTimeFormat](#eventtimeformat)
- [firstDay](#firstday)
- [flexibleSlotTimeLimits](#flexibleslottimelimits)
- [headerToolbar](#headertoolbar)
- [height](#height)
- [hiddenDays](#hiddendays)
- [hideResourcesWithNoEvents](#hideresourceswithnoevents)
- [highlightedDates](#highlighteddates)
- [lazyFetching](#lazyfetching)
- [listDayFormat](#listdayformat)
- [listDaySideFormat](#listdaysideformat)
</td><td>
- [loading](#loading)
- [locale](#locale)
- [monthMode](#monthmode)
- [noEventsClick](#noeventsclick)
- [noEventsContent](#noeventscontent)
- [resources](#resources)
- [scrollTime](#scrolltime)
- [slotDuration](#slotduration)
- [slotLabelFormat](#slotlabelformat)
- [slotMaxTime](#slotmaxtime)
- [slotMinTime](#slotmintime)
- [theme](#theme)
- [view](#view)
- [viewDidMount](#viewdidmount)
- [views](#views)
- [loading](#loading)
- [locale](#locale)
- [monthMode](#monthmode)
- [noEventsClick](#noeventsclick)
- [noEventsContent](#noeventscontent)
- [resources](#resources)
- [scrollTime](#scrolltime)
- [slotDuration](#slotduration)
- [slotLabelFormat](#slotlabelformat)
- [slotMaxTime](#slotmaxtime)
- [slotMinTime](#slotmintime)
- [theme](#theme)
- [view](#view)
- [viewDidMount](#viewdidmount)
- [views](#views)
</td></tr>

@@ -726,3 +726,5 @@ </table>

`EventSource` should be an object with the following properties:
`EventSource` should be an object with one of the following sets of properties:
###### 1. Fetch events from a URL
<table>

@@ -761,2 +763,43 @@ <tr>

###### 2. Execute custom function
<table>
<tr>
<td>
`events`
</td>
<td>
A custom function that is executed whenever the Event Calendar needs new event data.
```js
function(fetchInfo, successCallback, failureCallback) { }
```
`fetchInfo` is an object with the following properties:
<table>
<tr>
<td>
`start`
</td>
<td>JavaScript Date object for the beginning of the range the calendar needs events for</td>
</tr>
<tr>
<td>
`end`
</td>
<td>JavaScript Date object for the end of the range the calendar needs events for. Note: This value is exclusive</td>
</tr>
</table>
The `successCallback` function must be called by the custom function with an array of parsable [Event](#event-object) objects.
If there is any failure (e.g., if an AJAX request fails), then call the `failureCallback` instead. It accepts an argument with information about the failure.
Instead of calling `successCallback` and `failureCallback`, you may return the resulting array of events or return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) (or [thenable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)) object instead.
</td>
</tr>
</table>
### eventStartEditable

@@ -763,0 +806,0 @@ - Type `boolean`

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc