@event-calendar/core 5.2.0 → 5.2.1
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 +3 -3
- package/dist/index.css +1 -1
- package/dist/index.js +30 -22
- package/package.json +1 -1
- package/src/lib/chunks.js +19 -17
- package/src/plugins/day-grid/derived.js +1 -1
- package/src/plugins/list/Day.svelte +1 -1
- package/src/plugins/resource-timeline/derived.js +2 -2
- package/src/plugins/resource-timeline/lib.js +5 -2
- package/src/plugins/time-grid/derived.js +2 -2
- package/src/plugins/time-grid/lib.js +6 -2
package/README.md
CHANGED
|
@@ -246,8 +246,8 @@ This bundle contains a version of the calendar that includes all plugins and is
|
|
|
246
246
|
|
|
247
247
|
The first step is to include the following lines of code in the `<head>` section of your page:
|
|
248
248
|
```html
|
|
249
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.
|
|
250
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.
|
|
249
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.1/dist/event-calendar.min.css">
|
|
250
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.1/dist/event-calendar.min.js"></script>
|
|
251
251
|
```
|
|
252
252
|
|
|
253
253
|
<details>
|
|
@@ -342,7 +342,7 @@ When hidden with `false`, all-day events will not be displayed in `timeGrid`/`re
|
|
|
342
342
|
<details>
|
|
343
343
|
<summary>Default</summary>
|
|
344
344
|
|
|
345
|
-
`{close: 'Close', dayGridMonth: 'month', listDay: 'list', listMonth: 'list', listWeek: 'list', listYear: 'list', resourceTimeGridDay: 'resources', resourceTimeGridWeek: 'resources', resourceTimelineDay: 'timeline', resourceTimelineMonth: 'timeline', resourceTimelineWeek: 'timeline', timeGridDay: 'day', timeGridWeek: 'week', today: 'today'}`
|
|
345
|
+
`{close: 'Close', dayGridDay: 'day', dayGridMonth: 'month', dayGridWeek: 'week', listDay: 'list', listMonth: 'list', listWeek: 'list', listYear: 'list', resourceTimeGridDay: 'resources', resourceTimeGridWeek: 'resources', resourceTimelineDay: 'timeline', resourceTimelineMonth: 'timeline', resourceTimelineWeek: 'timeline', timeGridDay: 'day', timeGridWeek: 'week', today: 'today'}`
|
|
346
346
|
> Views override the default value as follows:
|
|
347
347
|
> - dayGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
|
|
348
348
|
> - dayGridMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
|
package/dist/index.css
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* EventCalendar v5.2.
|
|
2
|
+
* EventCalendar v5.2.1
|
|
3
3
|
* https://github.com/vkurko/calendar
|
|
4
4
|
*/
|
|
5
5
|
import { untrack, getAbortSignal, tick, getContext, setContext, onMount, mount, unmount } from "svelte";
|
|
@@ -473,8 +473,6 @@ function ghostEvent(display) {
|
|
|
473
473
|
function pointerEvent(display) {
|
|
474
474
|
return display === "pointer";
|
|
475
475
|
}
|
|
476
|
-
const ids = /* @__PURE__ */ new WeakMap();
|
|
477
|
-
let idCounter = 1;
|
|
478
476
|
function createEventChunk(event, start, end) {
|
|
479
477
|
start = event.start > start ? event.start : start;
|
|
480
478
|
end = event.end < end ? event.end : end;
|
|
@@ -482,20 +480,10 @@ function createEventChunk(event, start, end) {
|
|
|
482
480
|
start,
|
|
483
481
|
end,
|
|
484
482
|
event,
|
|
485
|
-
get id() {
|
|
486
|
-
let id = ids.get(event);
|
|
487
|
-
if (!id) {
|
|
488
|
-
id = idCounter++;
|
|
489
|
-
ids.set(event, id);
|
|
490
|
-
}
|
|
491
|
-
delete this.id;
|
|
492
|
-
this.id = `${id}-${start.getTime()}`;
|
|
493
|
-
return this.id;
|
|
494
|
-
},
|
|
495
483
|
zeroDuration: datesEqual(start, end)
|
|
496
484
|
};
|
|
497
485
|
}
|
|
498
|
-
function createAllDayChunks(event, days) {
|
|
486
|
+
function createAllDayChunks(event, days, withId = true) {
|
|
499
487
|
let dates = [];
|
|
500
488
|
let lastEnd;
|
|
501
489
|
let gridColumn;
|
|
@@ -513,6 +501,9 @@ function createAllDayChunks(event, days) {
|
|
|
513
501
|
if (dates.length) {
|
|
514
502
|
let chunk = createEventChunk(event, dates[0], lastEnd);
|
|
515
503
|
assign(chunk, { gridColumn, gridRow, dates });
|
|
504
|
+
if (withId) {
|
|
505
|
+
assignChunkId(chunk);
|
|
506
|
+
}
|
|
516
507
|
return [chunk];
|
|
517
508
|
}
|
|
518
509
|
return [];
|
|
@@ -561,6 +552,17 @@ function repositionEvent$1(chunk, height2, top = 1) {
|
|
|
561
552
|
assign(chunk, { top, bottom });
|
|
562
553
|
return top;
|
|
563
554
|
}
|
|
555
|
+
const ids = /* @__PURE__ */ new WeakMap();
|
|
556
|
+
let idCounter = 1;
|
|
557
|
+
function assignChunkId(chunk) {
|
|
558
|
+
let { event, gridColumn, gridRow } = chunk;
|
|
559
|
+
let id = ids.get(event);
|
|
560
|
+
if (!id) {
|
|
561
|
+
id = idCounter++;
|
|
562
|
+
ids.set(event, id);
|
|
563
|
+
}
|
|
564
|
+
chunk.id = `${id}-${gridColumn}-${gridRow}`;
|
|
565
|
+
}
|
|
564
566
|
function intl(mainState, option) {
|
|
565
567
|
return () => {
|
|
566
568
|
let { options: { locale } } = mainState;
|
|
@@ -1909,7 +1911,7 @@ function iEventChunks$2(mainState, viewState) {
|
|
|
1909
1911
|
}
|
|
1910
1912
|
untrack(() => {
|
|
1911
1913
|
for (let days of grid2) {
|
|
1912
|
-
iChunks = iChunks.concat(createAllDayChunks(event, days));
|
|
1914
|
+
iChunks = iChunks.concat(createAllDayChunks(event, days, false));
|
|
1913
1915
|
}
|
|
1914
1916
|
});
|
|
1915
1917
|
}
|
|
@@ -3675,7 +3677,7 @@ function Day$2($$anchor, $$props) {
|
|
|
3675
3677
|
$.attach(time_1, () => contentFrom($.get(intlListDaySide).format($$props.date)));
|
|
3676
3678
|
$.reset(h4);
|
|
3677
3679
|
var node_1 = $.sibling(h4, 2);
|
|
3678
|
-
$.each(node_1, 17, () => $.get(chunks), (chunk) => chunk.
|
|
3680
|
+
$.each(node_1, 17, () => $.get(chunks), (chunk) => chunk.event, ($$anchor4, chunk) => {
|
|
3679
3681
|
Event$2($$anchor4, {
|
|
3680
3682
|
get chunk() {
|
|
3681
3683
|
return $.get(chunk);
|
|
@@ -3816,7 +3818,7 @@ function initViewComponent$3(mainState) {
|
|
|
3816
3818
|
mainState.features = ["list"];
|
|
3817
3819
|
return View$2;
|
|
3818
3820
|
}
|
|
3819
|
-
function createChunks$1(event, days) {
|
|
3821
|
+
function createChunks$1(event, days, withId = true) {
|
|
3820
3822
|
let chunks = [];
|
|
3821
3823
|
for (let { gridColumn, gridRow, resource, start, end, disabled } of days) {
|
|
3822
3824
|
if (!disabled && eventIntersects(event, start, end, resource)) {
|
|
@@ -3828,6 +3830,9 @@ function createChunks$1(event, days) {
|
|
|
3828
3830
|
height: (chunk.end - chunk.start) / 1e3,
|
|
3829
3831
|
maxHeight: (end - chunk.start) / 1e3
|
|
3830
3832
|
});
|
|
3833
|
+
if (withId) {
|
|
3834
|
+
assignChunkId(chunk);
|
|
3835
|
+
}
|
|
3831
3836
|
chunks.push(chunk);
|
|
3832
3837
|
}
|
|
3833
3838
|
}
|
|
@@ -4019,9 +4024,9 @@ function iEventChunks$1(mainState, viewState) {
|
|
|
4019
4024
|
untrack(() => {
|
|
4020
4025
|
for (let days of grid2) {
|
|
4021
4026
|
if (event.allDay) {
|
|
4022
|
-
allDayIChunks = allDayIChunks.concat(createAllDayChunks(event, days));
|
|
4027
|
+
allDayIChunks = allDayIChunks.concat(createAllDayChunks(event, days, false));
|
|
4023
4028
|
} else {
|
|
4024
|
-
iChunks = iChunks.concat(createChunks$1(event, days));
|
|
4029
|
+
iChunks = iChunks.concat(createChunks$1(event, days, false));
|
|
4025
4030
|
}
|
|
4026
4031
|
}
|
|
4027
4032
|
});
|
|
@@ -5041,7 +5046,7 @@ function initViewComponent$2(mainState) {
|
|
|
5041
5046
|
setExtensions(mainState);
|
|
5042
5047
|
return View_1;
|
|
5043
5048
|
}
|
|
5044
|
-
function createChunks(event, days, monthView2) {
|
|
5049
|
+
function createChunks(event, days, monthView2, withId = true) {
|
|
5045
5050
|
let dates = [];
|
|
5046
5051
|
let firstStart;
|
|
5047
5052
|
let lastEnd;
|
|
@@ -5079,6 +5084,9 @@ function createChunks(event, days, monthView2) {
|
|
|
5079
5084
|
if (dates.length) {
|
|
5080
5085
|
let chunk = createEventChunk(event, firstStart, lastEnd);
|
|
5081
5086
|
assign(chunk, { gridColumn, gridRow, dates, left, width });
|
|
5087
|
+
if (withId) {
|
|
5088
|
+
assignChunkId(chunk);
|
|
5089
|
+
}
|
|
5082
5090
|
return [chunk];
|
|
5083
5091
|
}
|
|
5084
5092
|
return [];
|
|
@@ -5178,7 +5186,7 @@ function eventChunks(mainState, viewState) {
|
|
|
5178
5186
|
function iEventChunks(mainState, viewState) {
|
|
5179
5187
|
return () => {
|
|
5180
5188
|
let { iEvents } = mainState;
|
|
5181
|
-
let { grid: grid2 } = viewState;
|
|
5189
|
+
let { grid: grid2, monthView: monthView2 } = viewState;
|
|
5182
5190
|
let iChunks = [];
|
|
5183
5191
|
for (let [, event] of iEvents) {
|
|
5184
5192
|
if (!event) {
|
|
@@ -5186,7 +5194,7 @@ function iEventChunks(mainState, viewState) {
|
|
|
5186
5194
|
}
|
|
5187
5195
|
untrack(() => {
|
|
5188
5196
|
for (let days of grid2) {
|
|
5189
|
-
iChunks = iChunks.concat(createChunks(event, days));
|
|
5197
|
+
iChunks = iChunks.concat(createChunks(event, days, monthView2, false));
|
|
5190
5198
|
}
|
|
5191
5199
|
});
|
|
5192
5200
|
}
|
package/package.json
CHANGED
package/src/lib/chunks.js
CHANGED
|
@@ -2,13 +2,9 @@ import {datesEqual} from './date.js';
|
|
|
2
2
|
import {eventIntersects} from './events.js';
|
|
3
3
|
import {assign} from './utils.js';
|
|
4
4
|
|
|
5
|
-
// Storage of unique event identifiers for generating chunk ids
|
|
6
|
-
const ids = new WeakMap();
|
|
7
|
-
let idCounter = 1;
|
|
8
|
-
|
|
9
5
|
/**
|
|
10
6
|
* @returns {{
|
|
11
|
-
* id
|
|
7
|
+
* id?: String, // this can be used as key in Svelte keyed each block
|
|
12
8
|
* start: Date,
|
|
13
9
|
* end: Date,
|
|
14
10
|
* event: Object,
|
|
@@ -32,21 +28,10 @@ let idCounter = 1;
|
|
|
32
28
|
export function createEventChunk(event, start, end) {
|
|
33
29
|
start = event.start > start ? event.start : start;
|
|
34
30
|
end = event.end < end ? event.end : end;
|
|
35
|
-
|
|
36
31
|
return {
|
|
37
32
|
start,
|
|
38
33
|
end,
|
|
39
34
|
event,
|
|
40
|
-
get id() {
|
|
41
|
-
let id = ids.get(event);
|
|
42
|
-
if (!id) {
|
|
43
|
-
id = idCounter++;
|
|
44
|
-
ids.set(event, id);
|
|
45
|
-
}
|
|
46
|
-
delete this.id;
|
|
47
|
-
this.id = `${id}-${start.getTime()}`;
|
|
48
|
-
return this.id;
|
|
49
|
-
},
|
|
50
35
|
zeroDuration: datesEqual(start, end)
|
|
51
36
|
};
|
|
52
37
|
}
|
|
@@ -54,7 +39,7 @@ export function createEventChunk(event, start, end) {
|
|
|
54
39
|
/**
|
|
55
40
|
* Create event chunk for month view and all-day slot in week view
|
|
56
41
|
*/
|
|
57
|
-
export function createAllDayChunks(event, days) {
|
|
42
|
+
export function createAllDayChunks(event, days, withId = true) {
|
|
58
43
|
let dates = [];
|
|
59
44
|
let lastEnd;
|
|
60
45
|
let gridColumn;
|
|
@@ -73,6 +58,9 @@ export function createAllDayChunks(event, days) {
|
|
|
73
58
|
let chunk = createEventChunk(event, dates[0], lastEnd);
|
|
74
59
|
// Chunk layout
|
|
75
60
|
assign(chunk, {gridColumn, gridRow, dates});
|
|
61
|
+
if (withId) {
|
|
62
|
+
assignChunkId(chunk);
|
|
63
|
+
}
|
|
76
64
|
|
|
77
65
|
return [chunk];
|
|
78
66
|
}
|
|
@@ -131,3 +119,17 @@ export function repositionEvent(chunk, height, top = 1) {
|
|
|
131
119
|
|
|
132
120
|
return top;
|
|
133
121
|
}
|
|
122
|
+
|
|
123
|
+
// Storage of unique event identifiers for generating chunk ids
|
|
124
|
+
const ids = new WeakMap();
|
|
125
|
+
let idCounter = 1;
|
|
126
|
+
|
|
127
|
+
export function assignChunkId(chunk) {
|
|
128
|
+
let {event, gridColumn, gridRow} = chunk;
|
|
129
|
+
let id = ids.get(event);
|
|
130
|
+
if (!id) {
|
|
131
|
+
id = idCounter++;
|
|
132
|
+
ids.set(event, id);
|
|
133
|
+
}
|
|
134
|
+
chunk.id = `${id}-${gridColumn}-${gridRow}`;
|
|
135
|
+
}
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
<time {datetime} {@attach contentFrom(intlListDay.format(date))}></time>
|
|
39
39
|
<time class="{theme.daySide}" {datetime} {@attach contentFrom(intlListDaySide.format(date))}></time>
|
|
40
40
|
</h4>
|
|
41
|
-
{#each chunks as chunk (chunk.
|
|
41
|
+
{#each chunks as chunk (chunk.event)}
|
|
42
42
|
<Event {chunk}/>
|
|
43
43
|
{/each}
|
|
44
44
|
</BaseDay>
|
|
@@ -74,7 +74,7 @@ export function iEventChunks(mainState, viewState) {
|
|
|
74
74
|
return () => {
|
|
75
75
|
// Dependencies
|
|
76
76
|
let {iEvents} = mainState;
|
|
77
|
-
let {grid} = viewState;
|
|
77
|
+
let {grid, monthView} = viewState;
|
|
78
78
|
|
|
79
79
|
let iChunks = [];
|
|
80
80
|
|
|
@@ -84,7 +84,7 @@ export function iEventChunks(mainState, viewState) {
|
|
|
84
84
|
}
|
|
85
85
|
untrack(() => {
|
|
86
86
|
for (let days of grid) {
|
|
87
|
-
iChunks = iChunks.concat(createChunks(event, days));
|
|
87
|
+
iChunks = iChunks.concat(createChunks(event, days, monthView, false));
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {assign, createDuration, createEventChunk, eventIntersects, max, min} from '#lib';
|
|
1
|
+
import {assign, assignChunkId, createDuration, createEventChunk, eventIntersects, max, min} from '#lib';
|
|
2
2
|
|
|
3
|
-
export function createChunks(event, days, monthView) {
|
|
3
|
+
export function createChunks(event, days, monthView, withId = true) {
|
|
4
4
|
let dates = [];
|
|
5
5
|
let firstStart;
|
|
6
6
|
let lastEnd;
|
|
@@ -39,6 +39,9 @@ export function createChunks(event, days, monthView) {
|
|
|
39
39
|
let chunk = createEventChunk(event, firstStart, lastEnd);
|
|
40
40
|
// Chunk layout
|
|
41
41
|
assign(chunk, {gridColumn, gridRow, dates, left, width});
|
|
42
|
+
if (withId) {
|
|
43
|
+
assignChunkId(chunk);
|
|
44
|
+
}
|
|
42
45
|
|
|
43
46
|
return [chunk];
|
|
44
47
|
}
|
|
@@ -87,9 +87,9 @@ export function iEventChunks(mainState, viewState) {
|
|
|
87
87
|
untrack(() => {
|
|
88
88
|
for (let days of grid) {
|
|
89
89
|
if (event.allDay) {
|
|
90
|
-
allDayIChunks = allDayIChunks.concat(createAllDayChunks(event, days));
|
|
90
|
+
allDayIChunks = allDayIChunks.concat(createAllDayChunks(event, days, false));
|
|
91
91
|
} else {
|
|
92
|
-
iChunks = iChunks.concat(createChunks(event, days));
|
|
92
|
+
iChunks = iChunks.concat(createChunks(event, days, false));
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
addDuration, assign, cloneDate, createEventChunk, DAY_IN_SECONDS, eventIntersects, isFunction,
|
|
2
|
+
addDuration, assign, assignChunkId, cloneDate, createEventChunk, DAY_IN_SECONDS, eventIntersects, isFunction,
|
|
3
|
+
subtractDay
|
|
3
4
|
} from '#lib';
|
|
4
5
|
|
|
5
|
-
export function createChunks(event, days) {
|
|
6
|
+
export function createChunks(event, days, withId = true) {
|
|
6
7
|
let chunks = [];
|
|
7
8
|
for (let {gridColumn, gridRow, resource, start, end, disabled} of days) {
|
|
8
9
|
if (!disabled && eventIntersects(event, start, end, resource)) {
|
|
@@ -15,6 +16,9 @@ export function createChunks(event, days) {
|
|
|
15
16
|
height: (chunk.end - chunk.start) / 1000,
|
|
16
17
|
maxHeight: (end - chunk.start) / 1000
|
|
17
18
|
});
|
|
19
|
+
if (withId) {
|
|
20
|
+
assignChunkId(chunk);
|
|
21
|
+
}
|
|
18
22
|
chunks.push(chunk);
|
|
19
23
|
}
|
|
20
24
|
}
|