@event-calendar/core 4.7.1 → 5.0.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 +29 -51
- package/dist/index.css +627 -731
- package/dist/index.js +2499 -3191
- package/package.json +2 -2
- package/src/Auxiliary.svelte +2 -13
- package/src/Buttons.svelte +62 -52
- package/src/Calendar.svelte +9 -3
- package/src/lib/a11y.js +2 -2
- package/src/lib/attachments.js +61 -0
- package/src/lib/chunks.js +117 -0
- package/src/lib/components/BaseDay.svelte +50 -0
- package/src/lib/components/BaseEvent.svelte +3 -3
- package/src/lib/components/ColHead.svelte +34 -0
- package/src/lib/components/DayHeader.svelte +14 -0
- package/src/lib/components/InteractableEvent.svelte +1 -3
- package/src/lib/components/index.js +3 -0
- package/src/lib/date.js +1 -1
- package/src/lib/dom.js +0 -4
- package/src/lib/events.js +10 -134
- package/src/lib/index.js +3 -2
- package/src/lib/{times.js → slots.js} +14 -19
- package/src/lib/stores.js +0 -33
- package/src/lib/utils.js +11 -2
- package/src/lib/view.js +0 -4
- package/src/plugins/day-grid/Day.svelte +36 -129
- package/src/plugins/day-grid/Event.svelte +42 -41
- package/src/plugins/day-grid/Popup.svelte +65 -48
- package/src/plugins/day-grid/View.svelte +76 -4
- package/src/plugins/day-grid/index.js +5 -5
- package/src/plugins/day-grid/lib.js +61 -0
- package/src/plugins/day-grid/stores.js +2 -20
- package/src/plugins/interaction/Action.svelte +37 -43
- package/src/plugins/interaction/Auxiliary.svelte +4 -4
- package/src/plugins/interaction/Pointer.svelte +8 -12
- package/src/plugins/interaction/Resizer.svelte +2 -2
- package/src/plugins/interaction/lib/utils.js +1 -5
- package/src/plugins/list/Day.svelte +8 -24
- package/src/plugins/list/View.svelte +39 -2
- package/src/plugins/resource-time-grid/Label.svelte +2 -2
- package/src/plugins/resource-time-grid/View.svelte +38 -82
- package/src/plugins/resource-time-grid/index.js +18 -10
- package/src/plugins/resource-time-grid/lib.js +31 -0
- package/src/plugins/resource-time-grid/options.js +10 -0
- package/src/plugins/resource-time-grid/stores.js +34 -0
- package/src/plugins/resource-timeline/Day.svelte +10 -73
- package/src/plugins/resource-timeline/Event.svelte +14 -23
- package/src/plugins/resource-timeline/Header.svelte +5 -5
- package/src/plugins/resource-timeline/Label.svelte +4 -12
- package/src/plugins/resource-timeline/NowIndicator.svelte +33 -28
- package/src/plugins/resource-timeline/View.svelte +129 -14
- package/src/plugins/resource-timeline/index.js +26 -23
- package/src/plugins/resource-timeline/lib.js +115 -118
- package/src/plugins/resource-timeline/stores.js +11 -7
- package/src/plugins/time-grid/AllDayEvent.svelte +31 -0
- package/src/plugins/time-grid/Day.svelte +11 -99
- package/src/plugins/time-grid/Event.svelte +18 -20
- package/src/plugins/time-grid/NowIndicator.svelte +32 -10
- package/src/plugins/time-grid/View.svelte +127 -35
- package/src/plugins/time-grid/index.js +10 -8
- package/src/plugins/time-grid/lib.js +142 -0
- package/src/plugins/time-grid/options.js +57 -0
- package/src/plugins/time-grid/stores.js +41 -8
- package/src/storage/options.js +4 -39
- package/src/storage/state.js +1 -4
- package/src/storage/stores.js +42 -11
- package/src/styles/days.css +91 -0
- package/src/styles/events.css +180 -0
- package/src/styles/index.css +126 -0
- package/src/styles/now-indicator.css +35 -0
- package/src/styles/popup.css +30 -0
- package/src/styles/sidebar.css +59 -0
- package/src/styles/slots.css +42 -0
- package/src/styles/theme.css +68 -0
- package/src/styles/toolbar.css +80 -0
- package/src/lib/actions.js +0 -52
- package/src/plugins/day-grid/Body.svelte +0 -54
- package/src/plugins/day-grid/Header.svelte +0 -20
- package/src/plugins/day-grid/Week.svelte +0 -60
- package/src/plugins/list/Body.svelte +0 -44
- package/src/plugins/resource-timeline/Body.svelte +0 -67
- package/src/plugins/resource-timeline/Days.svelte +0 -72
- package/src/plugins/resource-timeline/Sidebar.svelte +0 -35
- package/src/plugins/time-grid/Body.svelte +0 -43
- package/src/plugins/time-grid/Section.svelte +0 -29
- package/src/plugins/time-grid/all-day/Day.svelte +0 -65
- package/src/plugins/time-grid/all-day/Event.svelte +0 -37
- package/src/plugins/time-grid/all-day/Week.svelte +0 -65
- package/src/plugins/time-grid/utils.js +0 -58
- package/src/styles/day-grid.scss +0 -51
- package/src/styles/index.scss +0 -553
- package/src/styles/theme.scss +0 -95
- package/src/styles/time-grid.scss +0 -83
- package/src/styles/timeline.scss +0 -152
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {getContext, untrack} from 'svelte';
|
|
3
|
-
import {observeResize} from '#lib';
|
|
4
|
-
import Section from './Section.svelte';
|
|
5
|
-
|
|
6
|
-
let {children} = $props();
|
|
7
|
-
|
|
8
|
-
let {
|
|
9
|
-
_bodyEl, _viewDates, _slotTimeLimits, _times, _recheckScrollable, scrollTime, slotDuration, slotHeight, theme
|
|
10
|
-
} = getContext('state');
|
|
11
|
-
|
|
12
|
-
let el = $state();
|
|
13
|
-
|
|
14
|
-
$effect(() => {
|
|
15
|
-
$_bodyEl = el;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
$effect(() => {
|
|
19
|
-
$_viewDates;
|
|
20
|
-
$scrollTime;
|
|
21
|
-
untrack(scrollToTime);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
function scrollToTime() {
|
|
25
|
-
el.scrollTop = (($scrollTime.seconds - $_slotTimeLimits.min.seconds) / $slotDuration.seconds - 0.5) * $slotHeight;
|
|
26
|
-
}
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<div
|
|
30
|
-
bind:this={el}
|
|
31
|
-
class="{$theme.body}"
|
|
32
|
-
use:observeResize={() => $_recheckScrollable = true}
|
|
33
|
-
>
|
|
34
|
-
<div class="{$theme.content}">
|
|
35
|
-
<Section {children}>
|
|
36
|
-
{#snippet lines()}
|
|
37
|
-
{#each $_times as time}
|
|
38
|
-
<div class="{$theme.line}{time[2] ? '' : ' ' + $theme.minor}"></div>
|
|
39
|
-
{/each}
|
|
40
|
-
{/snippet}
|
|
41
|
-
</Section>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {getContext} from 'svelte';
|
|
3
|
-
import {setContent} from '#lib';
|
|
4
|
-
import {createAllDayContent} from './utils.js';
|
|
5
|
-
|
|
6
|
-
let {children, lines} = $props();
|
|
7
|
-
|
|
8
|
-
let {allDayContent, slotLabelInterval, theme, _times} = getContext('state');
|
|
9
|
-
|
|
10
|
-
let allDayText = $derived(createAllDayContent($allDayContent));
|
|
11
|
-
let showAllTimes = $derived($slotLabelInterval && $slotLabelInterval.seconds <= 0);
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<div class="{$theme.sidebar}">
|
|
15
|
-
<div class="{$theme.sidebarTitle}" use:setContent={allDayText}></div>
|
|
16
|
-
{#each $_times as time, i}
|
|
17
|
-
<time
|
|
18
|
-
class="{$theme.time}{(i || showAllTimes) && time[2] ? '' : ' ' + $theme.minor}"
|
|
19
|
-
datetime="{time[0]}"
|
|
20
|
-
use:setContent={time[1]}
|
|
21
|
-
></time>
|
|
22
|
-
{/each}
|
|
23
|
-
</div>
|
|
24
|
-
<div class="{$theme.days}" role="row">
|
|
25
|
-
<div class="{$theme.lines}">{#if lines}{@render lines()}{/if}</div>
|
|
26
|
-
{#if children}
|
|
27
|
-
{@render children()}
|
|
28
|
-
{/if}
|
|
29
|
-
</div>
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {getContext, onMount} from 'svelte';
|
|
3
|
-
import {datesEqual, outsideRange, runReposition, setPayload} from '#lib';
|
|
4
|
-
import Event from './Event.svelte';
|
|
5
|
-
|
|
6
|
-
let {date, chunks, bgChunks, longChunks, iChunks = [], resource = undefined} = $props();
|
|
7
|
-
|
|
8
|
-
let {highlightedDates, theme, validRange, _interaction, _today} = getContext('state');
|
|
9
|
-
|
|
10
|
-
let el = $state();
|
|
11
|
-
let refs = [];
|
|
12
|
-
|
|
13
|
-
let dayChunks = $derived(chunks.filter(chunk => datesEqual(chunk.date, date)));
|
|
14
|
-
let dayBgChunks = $derived(bgChunks.filter(bgChunk => datesEqual(bgChunk.date, date)));
|
|
15
|
-
|
|
16
|
-
let isToday = $derived(datesEqual(date, $_today));
|
|
17
|
-
let highlight = $derived($highlightedDates.some(d => datesEqual(d, date)));
|
|
18
|
-
let disabled = $derived(outsideRange(date, $validRange));
|
|
19
|
-
|
|
20
|
-
// dateFromPoint
|
|
21
|
-
onMount(() => {
|
|
22
|
-
setPayload(el, () => ({
|
|
23
|
-
allDay: true,
|
|
24
|
-
date,
|
|
25
|
-
resource,
|
|
26
|
-
dayEl: el,
|
|
27
|
-
disabled
|
|
28
|
-
}));
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export function reposition() {
|
|
32
|
-
if (!disabled) {
|
|
33
|
-
runReposition(refs, dayChunks);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
</script>
|
|
37
|
-
|
|
38
|
-
<div
|
|
39
|
-
bind:this={el}
|
|
40
|
-
class="{$theme.day} {$theme.weekdays?.[date.getUTCDay()]}{isToday ? ' ' + $theme.today : ''}{highlight ? ' ' + $theme.highlight : ''}{disabled ? ' ' + $theme.disabled : ''}"
|
|
41
|
-
role="cell"
|
|
42
|
-
onpointerdown={!disabled ? $_interaction.action?.select : undefined}
|
|
43
|
-
>
|
|
44
|
-
<div class="{$theme.bgEvents}">
|
|
45
|
-
{#if !disabled}
|
|
46
|
-
{#each dayBgChunks as chunk (chunk.event)}
|
|
47
|
-
<Event {chunk}/>
|
|
48
|
-
{/each}
|
|
49
|
-
{/if}
|
|
50
|
-
</div>
|
|
51
|
-
<!-- Drag, Resize & Select -->
|
|
52
|
-
{#if iChunks[0] && datesEqual(iChunks[0].date, date) && !disabled}
|
|
53
|
-
<div class="{$theme.events} {$theme.preview}">
|
|
54
|
-
<Event chunk={iChunks[0]}/>
|
|
55
|
-
</div>
|
|
56
|
-
{/if}
|
|
57
|
-
<div class="{$theme.events}">
|
|
58
|
-
{#if !disabled}
|
|
59
|
-
{#each dayChunks as chunk, i (chunk.event)}
|
|
60
|
-
<!-- svelte-ignore binding_property_non_reactive -->
|
|
61
|
-
<Event {chunk} {longChunks} bind:this={refs[i]}/>
|
|
62
|
-
{/each}
|
|
63
|
-
{/if}
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {ancestor, bgEvent, height, rect, repositionEvent} from '#lib';
|
|
3
|
-
import {InteractableEvent} from '#components';
|
|
4
|
-
|
|
5
|
-
let {chunk, longChunks = {}} = $props();
|
|
6
|
-
|
|
7
|
-
let el = $state();
|
|
8
|
-
let margin = $state(1);
|
|
9
|
-
let event = $derived(chunk.event);
|
|
10
|
-
let display = $derived(chunk.event.display);
|
|
11
|
-
|
|
12
|
-
// Style
|
|
13
|
-
let styles = $derived(style => {
|
|
14
|
-
if (bgEvent(display)) {
|
|
15
|
-
style['width'] = `calc(${chunk.days * 100}% + ${(chunk.days - 1)}px)`;
|
|
16
|
-
} else {
|
|
17
|
-
style['width'] = `calc(${chunk.days * 100}% + ${(chunk.days - 1) * 7}px)`;
|
|
18
|
-
style['margin-top'] = `${event._margin ?? margin}px`;
|
|
19
|
-
}
|
|
20
|
-
return style;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export function reposition() {
|
|
24
|
-
if (!el) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
margin = repositionEvent(chunk, longChunks, height(el));
|
|
28
|
-
}
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<InteractableEvent
|
|
32
|
-
bind:el
|
|
33
|
-
{chunk}
|
|
34
|
-
{styles}
|
|
35
|
-
axis="x"
|
|
36
|
-
forceMargin={() => rect(el).top - rect(ancestor(el, 1)).top}
|
|
37
|
-
/>
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {getContext, untrack} from 'svelte';
|
|
3
|
-
import {
|
|
4
|
-
addDay, bgEvent, cloneDate, createEventChunk, eventIntersects, limitToRange, prepareEventChunks, runReposition
|
|
5
|
-
} from '#lib';
|
|
6
|
-
import Day from './Day.svelte';
|
|
7
|
-
|
|
8
|
-
let {dates, resource = undefined} = $props();
|
|
9
|
-
|
|
10
|
-
let {_filteredEvents, _iEvents, eventOrder, hiddenDays, resources, filterEventsWithResources,
|
|
11
|
-
validRange} = getContext('state');
|
|
12
|
-
|
|
13
|
-
let refs = [];
|
|
14
|
-
|
|
15
|
-
let start = $derived(limitToRange(dates[0], $validRange));
|
|
16
|
-
let end = $derived(addDay(cloneDate(limitToRange(dates.at(-1), $validRange))));
|
|
17
|
-
|
|
18
|
-
let resourceFilter = $derived(resource ?? (
|
|
19
|
-
$filterEventsWithResources ? $resources : undefined
|
|
20
|
-
));
|
|
21
|
-
|
|
22
|
-
let [chunks, bgChunks, longChunks] = $derived.by(() => {
|
|
23
|
-
let chunks = [];
|
|
24
|
-
let bgChunks = [];
|
|
25
|
-
for (let event of $_filteredEvents) {
|
|
26
|
-
if (event.allDay && eventIntersects(event, start, end, resourceFilter)) {
|
|
27
|
-
let chunk = createEventChunk(event, start, end);
|
|
28
|
-
if (bgEvent(event.display)) {
|
|
29
|
-
bgChunks.push(chunk);
|
|
30
|
-
} else {
|
|
31
|
-
chunks.push(chunk);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
prepareEventChunks(bgChunks, $hiddenDays, $eventOrder);
|
|
36
|
-
let longChunks = prepareEventChunks(chunks, $hiddenDays, $eventOrder);
|
|
37
|
-
return [chunks, bgChunks, longChunks];
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
function reposition() {
|
|
41
|
-
runReposition(refs, dates);
|
|
42
|
-
}
|
|
43
|
-
$effect(() => {
|
|
44
|
-
chunks;
|
|
45
|
-
untrack(reposition);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
let iChunks = $derived($_iEvents.map(event => {
|
|
49
|
-
let chunk;
|
|
50
|
-
if (event && event.allDay && eventIntersects(event, start, end, resource)) {
|
|
51
|
-
chunk = createEventChunk(event, start, end);
|
|
52
|
-
prepareEventChunks([chunk], $hiddenDays, $eventOrder);
|
|
53
|
-
} else {
|
|
54
|
-
chunk = null;
|
|
55
|
-
}
|
|
56
|
-
return chunk;
|
|
57
|
-
}));
|
|
58
|
-
</script>
|
|
59
|
-
|
|
60
|
-
{#each dates as date, i}
|
|
61
|
-
<!-- svelte-ignore binding_property_non_reactive -->
|
|
62
|
-
<Day {date} {chunks} {bgChunks} {longChunks} {iChunks} {resource} bind:this={refs[i]} />
|
|
63
|
-
{/each}
|
|
64
|
-
|
|
65
|
-
<svelte:window on:resize={reposition}/>
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {isFunction, sortEventChunks} from '#lib';
|
|
2
|
-
|
|
3
|
-
export function groupEventChunks(chunks, $eventOrder) {
|
|
4
|
-
if (!chunks.length) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
sortEventChunks(chunks, $eventOrder);
|
|
9
|
-
|
|
10
|
-
// Group
|
|
11
|
-
let group = {
|
|
12
|
-
columns: [],
|
|
13
|
-
end: chunks[0].end
|
|
14
|
-
};
|
|
15
|
-
for (let chunk of chunks) {
|
|
16
|
-
let c = 0;
|
|
17
|
-
if (chunk.start < group.end) {
|
|
18
|
-
for (; c < group.columns.length; ++c) {
|
|
19
|
-
if (group.columns[c].at(-1).end <= chunk.start) {
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (chunk.end > group.end) {
|
|
24
|
-
group.end = chunk.end;
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
group = {
|
|
28
|
-
columns: [],
|
|
29
|
-
end: chunk.end
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (group.columns.length < c + 1) {
|
|
34
|
-
group.columns.push([]);
|
|
35
|
-
}
|
|
36
|
-
group.columns[c].push(chunk);
|
|
37
|
-
|
|
38
|
-
chunk.group = group;
|
|
39
|
-
chunk.column = c;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function createAllDayContent(allDayContent) {
|
|
44
|
-
let text = 'all-day';
|
|
45
|
-
let content;
|
|
46
|
-
if (allDayContent) {
|
|
47
|
-
content = isFunction(allDayContent) ? allDayContent({text}) : allDayContent;
|
|
48
|
-
if (typeof content === 'string') {
|
|
49
|
-
content = {html: content};
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
content = {
|
|
53
|
-
html: text
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return content;
|
|
58
|
-
}
|
package/src/styles/day-grid.scss
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
.ec-day-grid {
|
|
2
|
-
.ec-body {
|
|
3
|
-
flex: 1 1 auto;
|
|
4
|
-
|
|
5
|
-
.ec-day {
|
|
6
|
-
min-height: 5em;
|
|
7
|
-
position: relative;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.ec-content {
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
height: 100%;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.ec-uniform {
|
|
17
|
-
.ec-content {
|
|
18
|
-
overflow: hidden; // remove scrolling due to hidden events
|
|
19
|
-
}
|
|
20
|
-
.ec-days {
|
|
21
|
-
flex: 1 1 0%; // % is required to work properly for both auto and fixed calendar height
|
|
22
|
-
min-height: 0;
|
|
23
|
-
}
|
|
24
|
-
.ec-day {
|
|
25
|
-
min-height: 0;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.ec-day:first-child {
|
|
30
|
-
border-left: none;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.ec-day-head {
|
|
34
|
-
display: flex;
|
|
35
|
-
flex-direction: row-reverse;
|
|
36
|
-
justify-content: space-between;
|
|
37
|
-
border: none;
|
|
38
|
-
padding: 4px 4px 3px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.ec-day-foot {
|
|
42
|
-
position: absolute;
|
|
43
|
-
bottom: 0;
|
|
44
|
-
padding: 2px;
|
|
45
|
-
font-size: .85em;
|
|
46
|
-
|
|
47
|
-
a {
|
|
48
|
-
cursor: pointer;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|