@event-calendar/core 0.13.3 → 0.14.0
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/README.md +76 -29
- package/index.js +68 -31
- package/package.json +2 -2
- package/src/Calendar.svelte +11 -2
- package/src/storage/state.js +5 -0
- package/src/storage/stores.js +16 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ See [demo](https://vkurko.github.io/calendar/).
|
|
|
4
4
|
|
|
5
5
|
Full-sized drag & drop JavaScript event calendar with resource view:
|
|
6
6
|
|
|
7
|
-
* Lightweight (
|
|
7
|
+
* Lightweight (55kb [br](https://en.wikipedia.org/wiki/Brotli) compressed `modern` version)
|
|
8
8
|
* Zero-dependency (pre-built bundle)
|
|
9
9
|
* Used by [Bookly](https://wordpress.org/plugins/bookly-responsive-appointment-booking-tool/)
|
|
10
10
|
|
|
@@ -182,6 +182,10 @@ let ec = new Calendar({
|
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
```
|
|
185
|
+
The CSS is located at `@event-calendar/core/index.css`. If your build tool supports CSS processing, you can import it like this:
|
|
186
|
+
```js
|
|
187
|
+
import '@event-calendar/core/index.css';
|
|
188
|
+
```
|
|
185
189
|
|
|
186
190
|
### Pre-built browser ready bundle
|
|
187
191
|
Include the following lines of code in the `<head>` section of your page:
|
|
@@ -234,7 +238,7 @@ In Svelte, you can simply update the original `options` object.
|
|
|
234
238
|
|
|
235
239
|
Defines the content that is displayed as a title of the `all-day` slot.
|
|
236
240
|
|
|
237
|
-
This value can be either a string containing
|
|
241
|
+
This value can be either a string containing text `'...'`, an object containing the HTML string `{html: '<p>...</p>'}`, an object containing an array of DOM nodes `{domNodes: [node1, node2, ...]}` or a function that returns any of the above formats:
|
|
238
242
|
|
|
239
243
|
```js
|
|
240
244
|
function (arg) {
|
|
@@ -284,9 +288,9 @@ This value can be either a JavaScript Date object, or an ISO8601 date string lik
|
|
|
284
288
|
Callback function that is triggered when the user clicks on a date or a time.
|
|
285
289
|
|
|
286
290
|
```js
|
|
287
|
-
function (
|
|
291
|
+
function (info) {}
|
|
288
292
|
```
|
|
289
|
-
`
|
|
293
|
+
`info` is an object with the following properties:
|
|
290
294
|
<table>
|
|
291
295
|
<tr>
|
|
292
296
|
<td>
|
|
@@ -305,6 +309,15 @@ function (dateClickInfo) {}
|
|
|
305
309
|
<tr>
|
|
306
310
|
<td>
|
|
307
311
|
|
|
312
|
+
`allDay`
|
|
313
|
+
</td>
|
|
314
|
+
<td>
|
|
315
|
+
|
|
316
|
+
`true` or `false`. Determines if the click has occurred in the `all-day` slot. Clicks in month and list views are treated as all-day too</td>
|
|
317
|
+
</tr>
|
|
318
|
+
<tr>
|
|
319
|
+
<td>
|
|
320
|
+
|
|
308
321
|
`dayEl`
|
|
309
322
|
</td>
|
|
310
323
|
<td>HTML element that represents the whole-day that was clicked on</td>
|
|
@@ -502,9 +515,9 @@ You can use any of the CSS color formats such `'#f00'`, `'#ff0000'`, `'rgb(255,0
|
|
|
502
515
|
Callback function that is triggered when the user clicks an event.
|
|
503
516
|
|
|
504
517
|
```js
|
|
505
|
-
function (
|
|
518
|
+
function (info) { }
|
|
506
519
|
```
|
|
507
|
-
`
|
|
520
|
+
`info` is an object with the following properties:
|
|
508
521
|
<table>
|
|
509
522
|
<tr>
|
|
510
523
|
<td>
|
|
@@ -554,14 +567,14 @@ This is currently an alias for the `eventBackgroundColor`.
|
|
|
554
567
|
|
|
555
568
|
Defines the content that is rendered inside an event’s element.
|
|
556
569
|
|
|
557
|
-
This value can be either a string containing
|
|
570
|
+
This value can be either a string containing text `'...'`, an object containing the HTML string `{html: '<p>...</p>'}`, an object containing an array of DOM nodes `{domNodes: [node1, node2, ...]}` or a function that returns any of the above formats:
|
|
558
571
|
|
|
559
572
|
```js
|
|
560
|
-
function (
|
|
573
|
+
function (info) {
|
|
561
574
|
// return string or object
|
|
562
575
|
}
|
|
563
576
|
```
|
|
564
|
-
`
|
|
577
|
+
`info` is an object with the following properties:
|
|
565
578
|
<table>
|
|
566
579
|
<tr>
|
|
567
580
|
<td>
|
|
@@ -599,9 +612,9 @@ The current [View](#view-object) object
|
|
|
599
612
|
Callback function that is triggered right after the element has been added to the DOM. If the event data changes, this is not called again.
|
|
600
613
|
|
|
601
614
|
```js
|
|
602
|
-
function (
|
|
615
|
+
function (info) { }
|
|
603
616
|
```
|
|
604
|
-
`
|
|
617
|
+
`info` is an object with the following properties:
|
|
605
618
|
<table>
|
|
606
619
|
<tr>
|
|
607
620
|
<td>
|
|
@@ -840,9 +853,9 @@ If not specified, it falls back to [longPressDelay](#longpressdelay).
|
|
|
840
853
|
Callback function that is triggered when the user hovers over an event with the cursor (mouse pointer).
|
|
841
854
|
|
|
842
855
|
```js
|
|
843
|
-
function (
|
|
856
|
+
function (info) { }
|
|
844
857
|
```
|
|
845
|
-
`
|
|
858
|
+
`info` is an object with the following properties:
|
|
846
859
|
<table>
|
|
847
860
|
<tr>
|
|
848
861
|
<td>
|
|
@@ -887,9 +900,9 @@ The current [View](#view-object) object
|
|
|
887
900
|
Callback function that is triggered when the cursor (mouse pointer) is moved out of an event.
|
|
888
901
|
|
|
889
902
|
```js
|
|
890
|
-
function (
|
|
903
|
+
function (info) { }
|
|
891
904
|
```
|
|
892
|
-
`
|
|
905
|
+
`info` is an object with the following properties:
|
|
893
906
|
<table>
|
|
894
907
|
<tr>
|
|
895
908
|
<td>
|
|
@@ -1400,7 +1413,7 @@ Tells the calendar that visible dates should start from the [firstDay](#firstday
|
|
|
1400
1413
|
|
|
1401
1414
|
Defines the text that is displayed instead of the default `+2 more` created by the [dayMaxEvents](#daymaxevents) option.
|
|
1402
1415
|
|
|
1403
|
-
This value can be either a string containing
|
|
1416
|
+
This value can be either a string containing text `'...'`, an object containing the HTML string `{html: '<p>...</p>'}`, an object containing an array of DOM nodes `{domNodes: [node1, node2, ...]}` or a function that returns any of the above formats:
|
|
1404
1417
|
|
|
1405
1418
|
```js
|
|
1406
1419
|
function (arg) {
|
|
@@ -1435,9 +1448,9 @@ The default text like `+2 more`
|
|
|
1435
1448
|
Callback function that is triggered when the user clicks _No events_ area in list view.
|
|
1436
1449
|
|
|
1437
1450
|
```js
|
|
1438
|
-
function (
|
|
1451
|
+
function (info) { }
|
|
1439
1452
|
```
|
|
1440
|
-
`
|
|
1453
|
+
`info` is an object with the following properties:
|
|
1441
1454
|
<table>
|
|
1442
1455
|
<tr>
|
|
1443
1456
|
<td>
|
|
@@ -1464,7 +1477,7 @@ The current [View](#view-object) object
|
|
|
1464
1477
|
|
|
1465
1478
|
Defines the text that is displayed in list view when there are no events to display.
|
|
1466
1479
|
|
|
1467
|
-
This value can be either a string containing
|
|
1480
|
+
This value can be either a string containing text `'...'`, an object containing the HTML string `{html: '<p>...</p>'}`, an object containing an array of DOM nodes `{domNodes: [node1, node2, ...]}` or a function that returns any of the above formats:
|
|
1468
1481
|
|
|
1469
1482
|
```js
|
|
1470
1483
|
function () {
|
|
@@ -1497,9 +1510,9 @@ Array of plain objects that will be parsed into [Resource](#resource-object) obj
|
|
|
1497
1510
|
Callback function that is triggered when a date/time selection is made.
|
|
1498
1511
|
|
|
1499
1512
|
```js
|
|
1500
|
-
function (
|
|
1513
|
+
function (info) { }
|
|
1501
1514
|
```
|
|
1502
|
-
`
|
|
1515
|
+
`info` is an object with the following properties:
|
|
1503
1516
|
<table>
|
|
1504
1517
|
<tr>
|
|
1505
1518
|
<td>
|
|
@@ -1536,7 +1549,7 @@ function (selectInfo) { }
|
|
|
1536
1549
|
</td>
|
|
1537
1550
|
<td>
|
|
1538
1551
|
|
|
1539
|
-
|
|
1552
|
+
`true` or `false`. Determines if the selection has occurred in the `all-day` slot</td>
|
|
1540
1553
|
</tr>
|
|
1541
1554
|
<tr>
|
|
1542
1555
|
<td>
|
|
@@ -1591,7 +1604,7 @@ If not specified, it falls back to [longPressDelay](#longpressdelay).
|
|
|
1591
1604
|
|
|
1592
1605
|
### selectMinDistance
|
|
1593
1606
|
- Type `integer`
|
|
1594
|
-
- Default `
|
|
1607
|
+
- Default `5`
|
|
1595
1608
|
|
|
1596
1609
|
Defines how many pixels the user’s mouse must move before the selection begins.
|
|
1597
1610
|
|
|
@@ -1779,9 +1792,9 @@ The view that is displayed in the calendar. Can be `'dayGridMonth'`, `'listDay'`
|
|
|
1779
1792
|
Callback function that is triggered right after the view has been added to the DOM.
|
|
1780
1793
|
|
|
1781
1794
|
```js
|
|
1782
|
-
function (
|
|
1795
|
+
function (info) { }
|
|
1783
1796
|
```
|
|
1784
|
-
`
|
|
1797
|
+
`info` is an object with the following properties:
|
|
1785
1798
|
<table>
|
|
1786
1799
|
<tr>
|
|
1787
1800
|
<td>
|
|
@@ -1927,7 +1940,7 @@ Here are all properties that exist in Event object:
|
|
|
1927
1940
|
</td>
|
|
1928
1941
|
<td>
|
|
1929
1942
|
|
|
1930
|
-
|
|
1943
|
+
`true` or `false`. Determines if the event is shown in the `all-day` slot</td>
|
|
1931
1944
|
</tr>
|
|
1932
1945
|
<tr>
|
|
1933
1946
|
<td>
|
|
@@ -1953,11 +1966,18 @@ Boolean (`true` or `false`). Determines if the event is shown in the `all-day` s
|
|
|
1953
1966
|
<tr>
|
|
1954
1967
|
<td>
|
|
1955
1968
|
|
|
1969
|
+
`titleHTML`
|
|
1970
|
+
</td>
|
|
1971
|
+
<td>The HTML version of the title</td>
|
|
1972
|
+
</tr>
|
|
1973
|
+
<tr>
|
|
1974
|
+
<td>
|
|
1975
|
+
|
|
1956
1976
|
`editable`
|
|
1957
1977
|
</td>
|
|
1958
1978
|
<td>
|
|
1959
1979
|
|
|
1960
|
-
|
|
1980
|
+
`true`, `false` or `undefined`. The value overriding the [editable](#editable) setting for this specific event
|
|
1961
1981
|
</td>
|
|
1962
1982
|
</tr>
|
|
1963
1983
|
<tr>
|
|
@@ -1967,7 +1987,7 @@ Boolean (`true` or `false`) or `undefined`. The value overriding the [editable](
|
|
|
1967
1987
|
</td>
|
|
1968
1988
|
<td>
|
|
1969
1989
|
|
|
1970
|
-
|
|
1990
|
+
`true`, `false` or `undefined`. The value overriding the [eventStartEditable](#eventstarteditable) setting for this specific event
|
|
1971
1991
|
</td>
|
|
1972
1992
|
</tr>
|
|
1973
1993
|
<tr>
|
|
@@ -1977,7 +1997,7 @@ Boolean (`true` or `false`) or `undefined`. The value overriding the [eventStart
|
|
|
1977
1997
|
</td>
|
|
1978
1998
|
<td>
|
|
1979
1999
|
|
|
1980
|
-
|
|
2000
|
+
`true`, `false` or `undefined`. The value overriding the [eventDurationEditable](#eventdurationeditable) setting for this specific event
|
|
1981
2001
|
</td>
|
|
1982
2002
|
</tr>
|
|
1983
2003
|
<tr>
|
|
@@ -2092,6 +2112,16 @@ Here are all admissible fields for the event’s input object:
|
|
|
2092
2112
|
<tr>
|
|
2093
2113
|
<td>
|
|
2094
2114
|
|
|
2115
|
+
`titleHTML`
|
|
2116
|
+
</td>
|
|
2117
|
+
<td>
|
|
2118
|
+
|
|
2119
|
+
`string` The HTML version of the title to be displayed instead of the text version. Default `''`
|
|
2120
|
+
</td>
|
|
2121
|
+
</tr>
|
|
2122
|
+
<tr>
|
|
2123
|
+
<td>
|
|
2124
|
+
|
|
2095
2125
|
`editable`
|
|
2096
2126
|
</td>
|
|
2097
2127
|
<td>
|
|
@@ -2220,6 +2250,13 @@ Here are all properties that exist in Resource object:
|
|
|
2220
2250
|
</td>
|
|
2221
2251
|
<td>The title of the resource</td>
|
|
2222
2252
|
</tr>
|
|
2253
|
+
<tr>
|
|
2254
|
+
<td>
|
|
2255
|
+
|
|
2256
|
+
`titleHTML`
|
|
2257
|
+
</td>
|
|
2258
|
+
<td>The HTML version of the title</td>
|
|
2259
|
+
</tr>
|
|
2223
2260
|
</table>
|
|
2224
2261
|
|
|
2225
2262
|
### Parsing resource from a plain object
|
|
@@ -2247,6 +2284,16 @@ Here are all admissible fields for the resource’s input object:
|
|
|
2247
2284
|
`string` Text that will be displayed on the resource when it is rendered. Default `''`
|
|
2248
2285
|
</td>
|
|
2249
2286
|
</tr>
|
|
2287
|
+
<tr>
|
|
2288
|
+
<td>
|
|
2289
|
+
|
|
2290
|
+
`titleHTML`
|
|
2291
|
+
</td>
|
|
2292
|
+
<td>
|
|
2293
|
+
|
|
2294
|
+
`string` The HTML version of the title to be displayed instead of the text version. Default `''`
|
|
2295
|
+
</td>
|
|
2296
|
+
</tr>
|
|
2250
2297
|
</table>
|
|
2251
2298
|
|
|
2252
2299
|
## View object
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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';
|
|
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';
|
|
3
|
+
import { derived, writable, readable, get } from 'svelte/store';
|
|
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, ignore } from '@event-calendar/common';
|
|
5
5
|
|
|
6
6
|
function createOptions(plugins) {
|
|
7
7
|
let options = {
|
|
@@ -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,9 @@ 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);
|
|
381
|
+
this._ignoreClick = writable(false);
|
|
365
382
|
this._intlEventTime = intl(this.locale, this.eventTimeFormat);
|
|
366
383
|
this._intlSlotLabel = intl(this.locale, this.slotLabelFormat);
|
|
367
384
|
this._intlDayHeader = intl(this.locale, this.dayHeaderFormat);
|
|
@@ -1232,6 +1249,8 @@ function create_fragment(ctx) {
|
|
|
1232
1249
|
let switch_instance1;
|
|
1233
1250
|
let div_class_value;
|
|
1234
1251
|
let current;
|
|
1252
|
+
let mounted;
|
|
1253
|
+
let dispose;
|
|
1235
1254
|
toolbar = new Toolbar({});
|
|
1236
1255
|
var switch_value = /*$_viewComponent*/ ctx[5];
|
|
1237
1256
|
|
|
@@ -1278,6 +1297,11 @@ function create_fragment(ctx) {
|
|
|
1278
1297
|
append(div, t1);
|
|
1279
1298
|
if (switch_instance1) mount_component(switch_instance1, div, null);
|
|
1280
1299
|
current = true;
|
|
1300
|
+
|
|
1301
|
+
if (!mounted) {
|
|
1302
|
+
dispose = listen(window, "click", /*handleClick*/ ctx[16], true);
|
|
1303
|
+
mounted = true;
|
|
1304
|
+
}
|
|
1281
1305
|
},
|
|
1282
1306
|
p(ctx, dirty) {
|
|
1283
1307
|
if (switch_value !== (switch_value = /*$_viewComponent*/ ctx[5])) {
|
|
@@ -1354,11 +1378,14 @@ function create_fragment(ctx) {
|
|
|
1354
1378
|
destroy_component(toolbar);
|
|
1355
1379
|
if (switch_instance0) destroy_component(switch_instance0);
|
|
1356
1380
|
if (switch_instance1) destroy_component(switch_instance1);
|
|
1381
|
+
mounted = false;
|
|
1382
|
+
dispose();
|
|
1357
1383
|
}
|
|
1358
1384
|
};
|
|
1359
1385
|
}
|
|
1360
1386
|
|
|
1361
1387
|
function instance($$self, $$props, $$invalidate) {
|
|
1388
|
+
let $_ignoreClick;
|
|
1362
1389
|
let $events;
|
|
1363
1390
|
let $_events;
|
|
1364
1391
|
let $eventSources;
|
|
@@ -1372,14 +1399,15 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1372
1399
|
let { options = {} } = $$props;
|
|
1373
1400
|
let state = new State(plugins, options);
|
|
1374
1401
|
setContext('state', state);
|
|
1375
|
-
let { _viewComponent, _viewClass, _interaction, _iClass, _events, events, eventSources, height, theme } = state;
|
|
1402
|
+
let { _viewComponent, _viewClass, _ignoreClick, _interaction, _iClass, _events, events, eventSources, height, theme } = state;
|
|
1376
1403
|
component_subscribe($$self, _viewComponent, value => $$invalidate(5, $_viewComponent = value));
|
|
1377
1404
|
component_subscribe($$self, _viewClass, value => $$invalidate(2, $_viewClass = value));
|
|
1405
|
+
component_subscribe($$self, _ignoreClick, value => $$invalidate(29, $_ignoreClick = value));
|
|
1378
1406
|
component_subscribe($$self, _interaction, value => $$invalidate(0, $_interaction = value));
|
|
1379
1407
|
component_subscribe($$self, _iClass, value => $$invalidate(3, $_iClass = value));
|
|
1380
|
-
component_subscribe($$self, _events, value => $$invalidate(
|
|
1381
|
-
component_subscribe($$self, events, value => $$invalidate(
|
|
1382
|
-
component_subscribe($$self, eventSources, value => $$invalidate(
|
|
1408
|
+
component_subscribe($$self, _events, value => $$invalidate(31, $_events = value));
|
|
1409
|
+
component_subscribe($$self, events, value => $$invalidate(30, $events = value));
|
|
1410
|
+
component_subscribe($$self, eventSources, value => $$invalidate(32, $eventSources = value));
|
|
1383
1411
|
component_subscribe($$self, height, value => $$invalidate(4, $height = value));
|
|
1384
1412
|
component_subscribe($$self, theme, value => $$invalidate(1, $theme = value));
|
|
1385
1413
|
|
|
@@ -1465,13 +1493,20 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1465
1493
|
}
|
|
1466
1494
|
}
|
|
1467
1495
|
|
|
1496
|
+
function handleClick(jsEvent) {
|
|
1497
|
+
if ($_ignoreClick) {
|
|
1498
|
+
ignore(jsEvent);
|
|
1499
|
+
set_store_value(_ignoreClick, $_ignoreClick = false, $_ignoreClick);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1468
1503
|
$$self.$$set = $$props => {
|
|
1469
|
-
if ('plugins' in $$props) $$invalidate(
|
|
1470
|
-
if ('options' in $$props) $$invalidate(
|
|
1504
|
+
if ('plugins' in $$props) $$invalidate(17, plugins = $$props.plugins);
|
|
1505
|
+
if ('options' in $$props) $$invalidate(18, options = $$props.options);
|
|
1471
1506
|
};
|
|
1472
1507
|
|
|
1473
1508
|
$$self.$$.update = () => {
|
|
1474
|
-
if ($$self.$$.dirty[0] & /*options*/
|
|
1509
|
+
if ($$self.$$.dirty[0] & /*options*/ 262144) {
|
|
1475
1510
|
// Reactively update options that did change
|
|
1476
1511
|
for (let [name, value] of diff(options)) {
|
|
1477
1512
|
setOption(name, value);
|
|
@@ -1488,6 +1523,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1488
1523
|
$_viewComponent,
|
|
1489
1524
|
_viewComponent,
|
|
1490
1525
|
_viewClass,
|
|
1526
|
+
_ignoreClick,
|
|
1491
1527
|
_interaction,
|
|
1492
1528
|
_iClass,
|
|
1493
1529
|
_events,
|
|
@@ -1495,6 +1531,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1495
1531
|
eventSources,
|
|
1496
1532
|
height,
|
|
1497
1533
|
theme,
|
|
1534
|
+
handleClick,
|
|
1498
1535
|
plugins,
|
|
1499
1536
|
options,
|
|
1500
1537
|
setOption,
|
|
@@ -1521,18 +1558,18 @@ class Calendar extends SvelteComponent {
|
|
|
1521
1558
|
create_fragment,
|
|
1522
1559
|
safe_not_equal,
|
|
1523
1560
|
{
|
|
1524
|
-
plugins:
|
|
1525
|
-
options:
|
|
1526
|
-
setOption:
|
|
1527
|
-
getOption:
|
|
1528
|
-
refetchEvents:
|
|
1529
|
-
getEvents:
|
|
1530
|
-
getEventById:
|
|
1531
|
-
addEvent:
|
|
1532
|
-
updateEvent:
|
|
1533
|
-
removeEventById:
|
|
1534
|
-
getView:
|
|
1535
|
-
unselect:
|
|
1561
|
+
plugins: 17,
|
|
1562
|
+
options: 18,
|
|
1563
|
+
setOption: 19,
|
|
1564
|
+
getOption: 20,
|
|
1565
|
+
refetchEvents: 21,
|
|
1566
|
+
getEvents: 22,
|
|
1567
|
+
getEventById: 23,
|
|
1568
|
+
addEvent: 24,
|
|
1569
|
+
updateEvent: 25,
|
|
1570
|
+
removeEventById: 26,
|
|
1571
|
+
getView: 27,
|
|
1572
|
+
unselect: 28
|
|
1536
1573
|
},
|
|
1537
1574
|
null,
|
|
1538
1575
|
[-1, -1]
|
|
@@ -1540,43 +1577,43 @@ class Calendar extends SvelteComponent {
|
|
|
1540
1577
|
}
|
|
1541
1578
|
|
|
1542
1579
|
get setOption() {
|
|
1543
|
-
return this.$$.ctx[
|
|
1580
|
+
return this.$$.ctx[19];
|
|
1544
1581
|
}
|
|
1545
1582
|
|
|
1546
1583
|
get getOption() {
|
|
1547
|
-
return this.$$.ctx[
|
|
1584
|
+
return this.$$.ctx[20];
|
|
1548
1585
|
}
|
|
1549
1586
|
|
|
1550
1587
|
get refetchEvents() {
|
|
1551
|
-
return this.$$.ctx[
|
|
1588
|
+
return this.$$.ctx[21];
|
|
1552
1589
|
}
|
|
1553
1590
|
|
|
1554
1591
|
get getEvents() {
|
|
1555
|
-
return this.$$.ctx[
|
|
1592
|
+
return this.$$.ctx[22];
|
|
1556
1593
|
}
|
|
1557
1594
|
|
|
1558
1595
|
get getEventById() {
|
|
1559
|
-
return this.$$.ctx[
|
|
1596
|
+
return this.$$.ctx[23];
|
|
1560
1597
|
}
|
|
1561
1598
|
|
|
1562
1599
|
get addEvent() {
|
|
1563
|
-
return this.$$.ctx[
|
|
1600
|
+
return this.$$.ctx[24];
|
|
1564
1601
|
}
|
|
1565
1602
|
|
|
1566
1603
|
get updateEvent() {
|
|
1567
|
-
return this.$$.ctx[
|
|
1604
|
+
return this.$$.ctx[25];
|
|
1568
1605
|
}
|
|
1569
1606
|
|
|
1570
1607
|
get removeEventById() {
|
|
1571
|
-
return this.$$.ctx[
|
|
1608
|
+
return this.$$.ctx[26];
|
|
1572
1609
|
}
|
|
1573
1610
|
|
|
1574
1611
|
get getView() {
|
|
1575
|
-
return this.$$.ctx[
|
|
1612
|
+
return this.$$.ctx[27];
|
|
1576
1613
|
}
|
|
1577
1614
|
|
|
1578
1615
|
get unselect() {
|
|
1579
|
-
return this.$$.ctx[
|
|
1616
|
+
return this.$$.ctx[28];
|
|
1580
1617
|
}
|
|
1581
1618
|
}
|
|
1582
1619
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@event-calendar/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
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.
|
|
37
|
+
"@event-calendar/common": "~0.14.0",
|
|
38
38
|
"svelte": "^3.51.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/Calendar.svelte
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import {diff} from './storage/options';
|
|
6
6
|
import State from './storage/state';
|
|
7
7
|
import Toolbar from './Toolbar.svelte';
|
|
8
|
-
import {assign, toEventWithLocalDates, toViewWithLocalDates} from '@event-calendar/common';
|
|
8
|
+
import {assign, toEventWithLocalDates, toViewWithLocalDates, ignore} from '@event-calendar/common';
|
|
9
9
|
|
|
10
10
|
export let plugins = [];
|
|
11
11
|
export let options = {};
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
let state = new State(plugins, options);
|
|
14
14
|
setContext('state', state);
|
|
15
15
|
|
|
16
|
-
let {_viewComponent, _viewClass, _interaction, _iClass, _events,
|
|
16
|
+
let {_viewComponent, _viewClass, _ignoreClick, _interaction, _iClass, _events,
|
|
17
|
+
events, eventSources, height, theme} = state;
|
|
17
18
|
|
|
18
19
|
// Reactively update options that did change
|
|
19
20
|
$: for (let [name, value] of diff(options)) {
|
|
@@ -93,6 +94,13 @@
|
|
|
93
94
|
$events = func($events);
|
|
94
95
|
}
|
|
95
96
|
}
|
|
97
|
+
|
|
98
|
+
function handleClick(jsEvent) {
|
|
99
|
+
if ($_ignoreClick) {
|
|
100
|
+
ignore(jsEvent);
|
|
101
|
+
$_ignoreClick = false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
96
104
|
</script>
|
|
97
105
|
|
|
98
106
|
<div
|
|
@@ -103,3 +111,4 @@
|
|
|
103
111
|
<svelte:component this={$_viewComponent}/>
|
|
104
112
|
<svelte:component this={$_interaction.component}/>
|
|
105
113
|
</div>
|
|
114
|
+
<svelte:window on:click|capture={handleClick}/>
|
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,9 @@ 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);
|
|
37
|
+
this._ignoreClick = writable(false);
|
|
33
38
|
this._intlEventTime = intl(this.locale, this.eventTimeFormat);
|
|
34
39
|
this._intlSlotLabel = intl(this.locale, this.slotLabelFormat);
|
|
35
40
|
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
|
+
}
|