@event-calendar/core 4.5.2 → 4.7.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 +68 -5
- package/dist/index.css +1 -1
- package/dist/index.js +223 -264
- package/package.json +1 -1
- package/src/lib/events.js +21 -5
- package/src/plugins/day-grid/Week.svelte +5 -5
- package/src/plugins/list/Day.svelte +2 -2
- package/src/plugins/resource-timeline/Days.svelte +5 -6
- package/src/plugins/resource-timeline/lib.js +2 -2
- package/src/plugins/time-grid/Day.svelte +2 -2
- package/src/plugins/time-grid/all-day/Day.svelte +1 -1
- package/src/plugins/time-grid/all-day/Week.svelte +6 -5
- package/src/plugins/time-grid/utils.js +2 -2
- package/src/storage/options.js +4 -0
- package/src/storage/state.js +3 -3
package/package.json
CHANGED
package/src/lib/events.js
CHANGED
|
@@ -66,9 +66,25 @@ export function createEventChunk(event, start, end) {
|
|
|
66
66
|
return chunk;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export function sortEventChunks(chunks) {
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
export function sortEventChunks(chunks, eventOrder) {
|
|
70
|
+
if (isFunction(eventOrder)) {
|
|
71
|
+
chunks.sort((a, b) => eventOrder(
|
|
72
|
+
_toChunkWithLocalDates(a),
|
|
73
|
+
_toChunkWithLocalDates(b)
|
|
74
|
+
));
|
|
75
|
+
} else {
|
|
76
|
+
// Sort by start date (all-day events always on top)
|
|
77
|
+
chunks.sort((a, b) => a.start - b.start || b.event.allDay - a.event.allDay);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function _toChunkWithLocalDates(chunk) {
|
|
82
|
+
return {
|
|
83
|
+
...chunk,
|
|
84
|
+
start: toLocalDate(chunk.start),
|
|
85
|
+
end: toLocalDate(chunk.end),
|
|
86
|
+
event: toEventWithLocalDates(chunk.event)
|
|
87
|
+
};
|
|
72
88
|
}
|
|
73
89
|
|
|
74
90
|
export function createEventContent(chunk, displayEventEnd, eventContent, theme, _intlEventTime, _view) {
|
|
@@ -156,11 +172,11 @@ function _cloneEvent(event, dateFn) {
|
|
|
156
172
|
/**
|
|
157
173
|
* Prepare event chunks for month view and all-day slot in week view
|
|
158
174
|
*/
|
|
159
|
-
export function prepareEventChunks(chunks, hiddenDays) {
|
|
175
|
+
export function prepareEventChunks(chunks, hiddenDays, eventOrder) {
|
|
160
176
|
let longChunks = {};
|
|
161
177
|
|
|
162
178
|
if (chunks.length) {
|
|
163
|
-
sortEventChunks(chunks);
|
|
179
|
+
sortEventChunks(chunks, eventOrder);
|
|
164
180
|
|
|
165
181
|
let prevChunk;
|
|
166
182
|
for (let chunk of chunks) {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
let {dates} = $props();
|
|
10
10
|
|
|
11
|
-
let {_filteredEvents, _iEvents,
|
|
12
|
-
|
|
11
|
+
let {_filteredEvents, _iEvents, resources, eventOrder, filterEventsWithResources, hiddenDays, theme,
|
|
12
|
+
validRange} = getContext('state');
|
|
13
13
|
|
|
14
14
|
let refs = [];
|
|
15
15
|
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
prepareEventChunks(bgChunks, $hiddenDays);
|
|
35
|
-
let longChunks = prepareEventChunks(chunks, $hiddenDays);
|
|
34
|
+
prepareEventChunks(bgChunks, $hiddenDays, $eventOrder);
|
|
35
|
+
let longChunks = prepareEventChunks(chunks, $hiddenDays, $eventOrder);
|
|
36
36
|
return [chunks, bgChunks, longChunks];
|
|
37
37
|
});
|
|
38
38
|
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
let chunk;
|
|
41
41
|
if (event && eventIntersects(event, start, end)) {
|
|
42
42
|
chunk = createEventChunk(event, start, end);
|
|
43
|
-
prepareEventChunks([chunk], $hiddenDays);
|
|
43
|
+
prepareEventChunks([chunk], $hiddenDays, $eventOrder);
|
|
44
44
|
} else {
|
|
45
45
|
chunk = null;
|
|
46
46
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
let {date} = $props();
|
|
10
10
|
|
|
11
11
|
let {_filteredEvents, _interaction, _intlListDay, _intlListDaySide, _today,
|
|
12
|
-
resources, filterEventsWithResources, highlightedDates, theme, validRange} = getContext('state');
|
|
12
|
+
resources, eventOrder, filterEventsWithResources, highlightedDates, theme, validRange} = getContext('state');
|
|
13
13
|
|
|
14
14
|
let el = $state();
|
|
15
15
|
let isToday = $derived(datesEqual(date, $_today));
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
chunks.push(chunk);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
sortEventChunks(chunks);
|
|
31
|
+
sortEventChunks(chunks, $eventOrder);
|
|
32
32
|
}
|
|
33
33
|
return chunks;
|
|
34
34
|
});
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
let {resource} = $props();
|
|
11
11
|
|
|
12
|
-
let {
|
|
13
|
-
|
|
14
|
-
} = getContext('state');
|
|
12
|
+
let {_viewDates, _filteredEvents, _iEvents, _dayTimeLimits, _daysHs, _resHs,
|
|
13
|
+
eventOrder, slotDuration, theme, validRange} = getContext('state');
|
|
15
14
|
|
|
16
15
|
let refs = [];
|
|
17
16
|
|
|
@@ -43,8 +42,8 @@
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
[bgChunks] = prepareEventChunks(bgChunks, $_viewDates, $_dayTimeLimits, $slotDuration);
|
|
47
|
-
[chunks, longChunks] = prepareEventChunks(chunks, $_viewDates, $_dayTimeLimits, $slotDuration);
|
|
45
|
+
[bgChunks] = prepareEventChunks(bgChunks, $_viewDates, $_dayTimeLimits, $slotDuration, $eventOrder);
|
|
46
|
+
[chunks, longChunks] = prepareEventChunks(chunks, $_viewDates, $_dayTimeLimits, $slotDuration, $eventOrder);
|
|
48
47
|
return [chunks, bgChunks, longChunks];
|
|
49
48
|
});
|
|
50
49
|
|
|
@@ -52,7 +51,7 @@
|
|
|
52
51
|
let chunk;
|
|
53
52
|
if (event && eventIntersects(event, start, end, resource)) {
|
|
54
53
|
chunk = createEventChunk(event, start, end);
|
|
55
|
-
[[chunk]] = prepareEventChunks([chunk], $_viewDates, $_dayTimeLimits, $slotDuration);
|
|
54
|
+
[[chunk]] = prepareEventChunks([chunk], $_viewDates, $_dayTimeLimits, $slotDuration, $eventOrder);
|
|
56
55
|
} else {
|
|
57
56
|
chunk = null;
|
|
58
57
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {addDay, addDuration, cloneDate, createDuration, datesEqual, sortEventChunks, toSeconds} from '#lib';
|
|
2
2
|
|
|
3
|
-
export function prepareEventChunks(chunks, $_viewDates, $_dayTimeLimits, $slotDuration) {
|
|
3
|
+
export function prepareEventChunks(chunks, $_viewDates, $_dayTimeLimits, $slotDuration, $eventOrder) {
|
|
4
4
|
let longChunks = {};
|
|
5
5
|
let filteredChunks = [];
|
|
6
6
|
|
|
7
7
|
if (chunks.length) {
|
|
8
|
-
sortEventChunks(chunks);
|
|
8
|
+
sortEventChunks(chunks, $eventOrder);
|
|
9
9
|
|
|
10
10
|
let step = toSeconds($slotDuration);
|
|
11
11
|
let prevChunk;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
let {date, resource = undefined} = $props();
|
|
12
12
|
|
|
13
13
|
let {_filteredEvents, _iEvents, highlightedDates, nowIndicator, slotDuration, slotHeight, filterEventsWithResources,
|
|
14
|
-
theme, resources, validRange, _interaction, _today, _slotTimeLimits} = getContext('state');
|
|
14
|
+
eventOrder, theme, resources, validRange, _interaction, _today, _slotTimeLimits} = getContext('state');
|
|
15
15
|
|
|
16
16
|
let el = $state();
|
|
17
17
|
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
groupEventChunks(chunks);
|
|
42
|
+
groupEventChunks(chunks, $eventOrder);
|
|
43
43
|
return [chunks, bgChunks];
|
|
44
44
|
});
|
|
45
45
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {getContext, onMount} from 'svelte';
|
|
3
|
-
import {datesEqual, outsideRange, runReposition, setPayload} from '
|
|
3
|
+
import {datesEqual, outsideRange, runReposition, setPayload} from '#lib';
|
|
4
4
|
import Event from './Event.svelte';
|
|
5
5
|
|
|
6
6
|
let {date, chunks, bgChunks, longChunks, iChunks = [], resource = undefined} = $props();
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import {getContext, untrack} from 'svelte';
|
|
3
3
|
import {
|
|
4
4
|
addDay, bgEvent, cloneDate, createEventChunk, eventIntersects, limitToRange, prepareEventChunks, runReposition
|
|
5
|
-
} from '
|
|
5
|
+
} from '#lib';
|
|
6
6
|
import Day from './Day.svelte';
|
|
7
7
|
|
|
8
8
|
let {dates, resource = undefined} = $props();
|
|
9
9
|
|
|
10
|
-
let {_filteredEvents, _iEvents, hiddenDays, resources, filterEventsWithResources,
|
|
10
|
+
let {_filteredEvents, _iEvents, eventOrder, hiddenDays, resources, filterEventsWithResources,
|
|
11
|
+
validRange} = getContext('state');
|
|
11
12
|
|
|
12
13
|
let refs = [];
|
|
13
14
|
|
|
@@ -31,8 +32,8 @@
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
|
-
prepareEventChunks(bgChunks, $hiddenDays);
|
|
35
|
-
let longChunks = prepareEventChunks(chunks, $hiddenDays);
|
|
35
|
+
prepareEventChunks(bgChunks, $hiddenDays, $eventOrder);
|
|
36
|
+
let longChunks = prepareEventChunks(chunks, $hiddenDays, $eventOrder);
|
|
36
37
|
return [chunks, bgChunks, longChunks];
|
|
37
38
|
});
|
|
38
39
|
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
let chunk;
|
|
49
50
|
if (event && event.allDay && eventIntersects(event, start, end, resource)) {
|
|
50
51
|
chunk = createEventChunk(event, start, end);
|
|
51
|
-
prepareEventChunks([chunk], $hiddenDays);
|
|
52
|
+
prepareEventChunks([chunk], $hiddenDays, $eventOrder);
|
|
52
53
|
} else {
|
|
53
54
|
chunk = null;
|
|
54
55
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {isFunction, sortEventChunks} from '#lib';
|
|
2
2
|
|
|
3
|
-
export function groupEventChunks(chunks) {
|
|
3
|
+
export function groupEventChunks(chunks, $eventOrder) {
|
|
4
4
|
if (!chunks.length) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
sortEventChunks(chunks);
|
|
8
|
+
sortEventChunks(chunks, $eventOrder);
|
|
9
9
|
|
|
10
10
|
// Group
|
|
11
11
|
let group = {
|
package/src/storage/options.js
CHANGED
|
@@ -2,6 +2,9 @@ import {
|
|
|
2
2
|
createDate, createDuration, createEvents, createEventSources, createResources, createDateRange, keys, setMidnight
|
|
3
3
|
} from '#lib';
|
|
4
4
|
|
|
5
|
+
// Options where initial value is passed to the function
|
|
6
|
+
export const specialOptions = ['buttonText', 'customButtons', 'theme'];
|
|
7
|
+
|
|
5
8
|
export function createOptions(plugins) {
|
|
6
9
|
let options = {
|
|
7
10
|
allDayContent: undefined,
|
|
@@ -33,6 +36,7 @@ export function createOptions(plugins) {
|
|
|
33
36
|
eventFilter: undefined, // ec option
|
|
34
37
|
eventMouseEnter: undefined,
|
|
35
38
|
eventMouseLeave: undefined,
|
|
39
|
+
eventOrder: undefined,
|
|
36
40
|
eventSources: [],
|
|
37
41
|
eventTextColor: undefined,
|
|
38
42
|
eventTimeFormat: {
|
package/src/storage/state.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {get, writable} from 'svelte/store';
|
|
2
2
|
import {tick} from 'svelte';
|
|
3
|
-
import {createOptions, createParsers} from './options.js';
|
|
3
|
+
import {createOptions, createParsers, specialOptions} from './options.js';
|
|
4
4
|
import {activeRange, currentRange, dayGrid, events, now, today, view as view2, viewDates, viewTitle, filteredEvents} from './stores.js';
|
|
5
5
|
import {identity, intl, intlRange, isFunction, keys, toViewWithLocalDates} from '#lib';
|
|
6
6
|
|
|
@@ -86,7 +86,7 @@ export default class {
|
|
|
86
86
|
|
|
87
87
|
this[key] = {
|
|
88
88
|
// Set value in all views
|
|
89
|
-
set:
|
|
89
|
+
set: specialOptions.includes(key)
|
|
90
90
|
? value => {
|
|
91
91
|
if (isFunction(value)) {
|
|
92
92
|
let result = value(defOpts[key]);
|
|
@@ -145,7 +145,7 @@ function mergeOpts(...args) {
|
|
|
145
145
|
let result = {};
|
|
146
146
|
for (let opts of args) {
|
|
147
147
|
let override = {};
|
|
148
|
-
for (let key of
|
|
148
|
+
for (let key of specialOptions) {
|
|
149
149
|
if (isFunction(opts[key])) {
|
|
150
150
|
override[key] = opts[key](result[key]);
|
|
151
151
|
}
|