@event-calendar/core 0.13.3 → 0.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +17 -1
- package/package.json +2 -2
- package/src/storage/state.js +4 -0
- package/src/storage/stores.js +16 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
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';
|
|
2
2
|
import { getContext, setContext } from 'svelte';
|
|
3
|
-
import { derived, writable, get } from 'svelte/store';
|
|
3
|
+
import { derived, writable, readable, get } from 'svelte/store';
|
|
4
4
|
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 } from '@event-calendar/common';
|
|
5
5
|
|
|
6
6
|
function createOptions(plugins) {
|
|
@@ -344,6 +344,20 @@ function events(state) {
|
|
|
344
344
|
return _events;
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
function now() {
|
|
348
|
+
return readable(createDate(), set => {
|
|
349
|
+
let interval = setInterval(() => {
|
|
350
|
+
set(createDate());
|
|
351
|
+
}, 1000);
|
|
352
|
+
|
|
353
|
+
return () => clearInterval(interval);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function today(state) {
|
|
358
|
+
return derived(state._now, $_now => setMidnight(cloneDate($_now)));
|
|
359
|
+
}
|
|
360
|
+
|
|
347
361
|
class State {
|
|
348
362
|
constructor(plugins, input) {
|
|
349
363
|
plugins = plugins || [];
|
|
@@ -362,6 +376,8 @@ class State {
|
|
|
362
376
|
this._activeRange = activeRange(this);
|
|
363
377
|
this._fetchedRange = writable({start: undefined, end: undefined});
|
|
364
378
|
this._events = events(this);
|
|
379
|
+
this._now = now();
|
|
380
|
+
this._today = today(this);
|
|
365
381
|
this._intlEventTime = intl(this.locale, this.eventTimeFormat);
|
|
366
382
|
this._intlSlotLabel = intl(this.locale, this.slotLabelFormat);
|
|
367
383
|
this._intlDayHeader = intl(this.locale, this.dayHeaderFormat);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@event-calendar/core",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.4",
|
|
4
4
|
"title": "Event Calendar Core package",
|
|
5
5
|
"description": "Full-sized drag & drop event calendar with resource view",
|
|
6
6
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"./package.json": "./package.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@event-calendar/common": "~0.13.
|
|
37
|
+
"@event-calendar/common": "~0.13.4",
|
|
38
38
|
"svelte": "^3.51.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/storage/state.js
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
activeRange,
|
|
6
6
|
currentRange,
|
|
7
7
|
events,
|
|
8
|
+
now,
|
|
9
|
+
today,
|
|
8
10
|
viewDates,
|
|
9
11
|
viewTitle,
|
|
10
12
|
view as view2 // hack to avoid a runtime error in SvelteKit dev mode (ReferenceError: view is not defined)
|
|
@@ -30,6 +32,8 @@ export default class {
|
|
|
30
32
|
this._activeRange = activeRange(this);
|
|
31
33
|
this._fetchedRange = writable({start: undefined, end: undefined});
|
|
32
34
|
this._events = events(this);
|
|
35
|
+
this._now = now();
|
|
36
|
+
this._today = today(this);
|
|
33
37
|
this._intlEventTime = intl(this.locale, this.eventTimeFormat);
|
|
34
38
|
this._intlSlotLabel = intl(this.locale, this.slotLabelFormat);
|
|
35
39
|
this._intlDayHeader = intl(this.locale, this.dayHeaderFormat);
|
package/src/storage/stores.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {derived, writable} from 'svelte/store';
|
|
1
|
+
import {derived, writable, readable} from 'svelte/store';
|
|
2
2
|
import {is_function, noop, tick} from 'svelte/internal';
|
|
3
3
|
import {
|
|
4
4
|
DAY_IN_SECONDS,
|
|
5
5
|
cloneDate,
|
|
6
|
+
createDate,
|
|
6
7
|
addDuration,
|
|
7
8
|
addDay,
|
|
8
9
|
subtractDay,
|
|
@@ -204,3 +205,17 @@ export function events(state) {
|
|
|
204
205
|
|
|
205
206
|
return _events;
|
|
206
207
|
}
|
|
208
|
+
|
|
209
|
+
export function now() {
|
|
210
|
+
return readable(createDate(), set => {
|
|
211
|
+
let interval = setInterval(() => {
|
|
212
|
+
set(createDate());
|
|
213
|
+
}, 1000);
|
|
214
|
+
|
|
215
|
+
return () => clearInterval(interval);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function today(state) {
|
|
220
|
+
return derived(state._now, $_now => setMidnight(cloneDate($_now)));
|
|
221
|
+
}
|