@event-calendar/core 5.0.6 → 5.1.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 +15 -4
- package/dist/index.css +2 -2
- package/dist/index.js +2203 -2122
- package/package.json +2 -2
- package/src/Buttons.svelte +36 -37
- package/src/Calendar.svelte +37 -37
- package/src/Toolbar.svelte +4 -4
- package/src/lib/components/BaseDay.svelte +13 -10
- package/src/lib/components/BaseEvent.svelte +17 -17
- package/src/lib/components/ColHead.svelte +6 -6
- package/src/lib/components/DayHeader.svelte +3 -3
- package/src/lib/components/InteractableEvent.svelte +7 -8
- package/src/lib/derived.js +80 -0
- package/src/lib/index.js +1 -2
- package/src/lib/slots.js +16 -16
- package/src/lib/utils.js +4 -9
- package/src/lib/view.js +0 -8
- package/src/plugins/day-grid/Day.svelte +25 -23
- package/src/plugins/day-grid/Event.svelte +15 -13
- package/src/plugins/day-grid/Popup.svelte +12 -12
- package/src/plugins/day-grid/View.svelte +24 -33
- package/src/plugins/day-grid/derived.js +102 -0
- package/src/plugins/day-grid/index.js +47 -36
- package/src/plugins/day-grid/state.svelte.js +19 -0
- package/src/plugins/interaction/Action.svelte +108 -76
- package/src/plugins/interaction/Auxiliary.svelte +9 -38
- package/src/plugins/interaction/Pointer.svelte +12 -17
- package/src/plugins/interaction/Resizer.svelte +9 -7
- package/src/plugins/interaction/effects.js +37 -0
- package/src/plugins/interaction/index.js +44 -38
- package/src/plugins/interaction/lib/utils.js +1 -1
- package/src/plugins/interaction/state.svelte.js +12 -0
- package/src/plugins/list/Day.svelte +8 -7
- package/src/plugins/list/Event.svelte +3 -3
- package/src/plugins/list/View.svelte +17 -16
- package/src/plugins/list/index.js +51 -43
- package/src/plugins/list/state.svelte.js +8 -0
- package/src/plugins/resource-time-grid/Label.svelte +8 -8
- package/src/plugins/resource-time-grid/View.svelte +38 -17
- package/src/plugins/resource-time-grid/derived.js +67 -0
- package/src/plugins/resource-time-grid/index.js +34 -28
- package/src/plugins/resource-time-grid/state.svelte.js +21 -0
- package/src/plugins/resource-timeline/Day.svelte +9 -4
- package/src/plugins/resource-timeline/Event.svelte +7 -6
- package/src/plugins/resource-timeline/Expander.svelte +7 -6
- package/src/plugins/resource-timeline/NowIndicator.svelte +10 -11
- package/src/plugins/resource-timeline/View.svelte +45 -60
- package/src/plugins/resource-timeline/derived.js +167 -0
- package/src/plugins/resource-timeline/index.js +17 -21
- package/src/plugins/resource-timeline/lib.js +4 -65
- package/src/plugins/resource-timeline/state.svelte.js +18 -0
- package/src/plugins/time-grid/Day.svelte +7 -2
- package/src/plugins/time-grid/Event.svelte +6 -6
- package/src/plugins/time-grid/NowIndicator.svelte +10 -9
- package/src/plugins/time-grid/View.svelte +46 -55
- package/src/plugins/time-grid/derived.js +162 -0
- package/src/plugins/time-grid/index.js +31 -25
- package/src/plugins/time-grid/lib.js +18 -74
- package/src/plugins/time-grid/options.js +21 -16
- package/src/plugins/time-grid/state.svelte.js +44 -0
- package/src/storage/derived.js +144 -0
- package/src/storage/effects.js +156 -0
- package/src/storage/options.svelte.js +275 -0
- package/src/storage/state.svelte.js +69 -0
- package/src/styles/events.css +1 -1
- package/src/Auxiliary.svelte +0 -47
- package/src/lib/debounce.js +0 -20
- package/src/lib/stores.js +0 -63
- package/src/plugins/day-grid/lib.js +0 -61
- package/src/plugins/day-grid/stores.js +0 -5
- package/src/plugins/resource-time-grid/lib.js +0 -31
- package/src/plugins/resource-time-grid/stores.js +0 -34
- package/src/plugins/resource-timeline/Header.svelte +0 -44
- package/src/plugins/resource-timeline/Label.svelte +0 -38
- package/src/plugins/resource-timeline/stores.js +0 -48
- package/src/plugins/time-grid/stores.js +0 -49
- package/src/storage/options.js +0 -136
- package/src/storage/state.js +0 -168
- package/src/storage/stores.js +0 -234
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {btnTextDay, btnTextWeek, themeView} from '#lib';
|
|
1
|
+
import {assign, btnTextDay, btnTextWeek, themeView} from '#lib';
|
|
2
|
+
import {setExtensions} from '../time-grid/lib.js';
|
|
2
3
|
import {createTROptions, createTRROptions, createTRRParsers} from '../time-grid/options.js';
|
|
3
|
-
import {createTRRStores, createTRStores} from '../time-grid/stores.js';
|
|
4
4
|
import {createRROptions} from './options.js';
|
|
5
|
-
import {createRRStores} from './stores.js';
|
|
6
5
|
import View from './View.svelte';
|
|
7
6
|
|
|
8
7
|
export default {
|
|
@@ -10,34 +9,41 @@ export default {
|
|
|
10
9
|
createTROptions(options);
|
|
11
10
|
createTRROptions(options);
|
|
12
11
|
createRROptions(options);
|
|
13
|
-
options
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
options.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
assign(options, {
|
|
13
|
+
datesAboveResources: false,
|
|
14
|
+
// Common options
|
|
15
|
+
view: 'resourceTimeGridWeek'
|
|
16
|
+
});
|
|
17
|
+
assign(options.buttonText, {
|
|
18
|
+
resourceTimeGridDay: 'resources',
|
|
19
|
+
resourceTimeGridWeek: 'resources'
|
|
20
|
+
});
|
|
21
|
+
assign(options.theme, {
|
|
22
|
+
colGroup: 'ec-col-group'
|
|
23
|
+
});
|
|
24
|
+
assign(options.views, {
|
|
25
|
+
resourceTimeGridDay: {
|
|
26
|
+
buttonText: btnTextDay,
|
|
27
|
+
component: initViewComponent,
|
|
28
|
+
dayHeaderFormat: {weekday: 'long'},
|
|
29
|
+
duration: {days: 1},
|
|
30
|
+
theme: themeView('ec-resource ec-time-grid ec-day-view')
|
|
31
|
+
},
|
|
32
|
+
resourceTimeGridWeek: {
|
|
33
|
+
buttonText: btnTextWeek,
|
|
34
|
+
component: initViewComponent,
|
|
35
|
+
duration: {weeks: 1},
|
|
36
|
+
theme: themeView('ec-resource ec-time-grid ec-week-view')
|
|
37
|
+
}
|
|
38
|
+
});
|
|
32
39
|
},
|
|
33
40
|
|
|
34
41
|
createParsers(parsers) {
|
|
35
42
|
createTRRParsers(parsers);
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
createStores(state) {
|
|
39
|
-
createTRRStores(state);
|
|
40
|
-
createTRStores(state);
|
|
41
|
-
createRRStores(state);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
function initViewComponent(mainState) {
|
|
47
|
+
setExtensions(mainState);
|
|
48
|
+
return View;
|
|
49
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {TRRState, TRState} from '../time-grid/state.svelte.js';
|
|
2
|
+
import {grid, viewResources} from './derived.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ResourceTimeGrid + ResourceTimeline
|
|
6
|
+
*/
|
|
7
|
+
export function RRState(Base){
|
|
8
|
+
return class extends Base {
|
|
9
|
+
constructor(mainState) {
|
|
10
|
+
super(mainState);
|
|
11
|
+
this.viewResources = $derived.by(viewResources(mainState));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default class ViewState extends RRState(TRState(TRRState())) {
|
|
17
|
+
constructor(mainState) {
|
|
18
|
+
super(mainState);
|
|
19
|
+
this.grid = $derived.by(grid(mainState, this));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -5,21 +5,26 @@
|
|
|
5
5
|
|
|
6
6
|
let {day, noIeb, noBeb} = $props();
|
|
7
7
|
|
|
8
|
-
let {
|
|
8
|
+
let {options: {slotWidth}} = $derived(getContext('state'));
|
|
9
|
+
let {monthView, snap} = $derived(getContext('view-state'));
|
|
9
10
|
|
|
10
11
|
let {dayStart: date, start, resource, disabled, highlight} = $derived(day);
|
|
11
12
|
|
|
12
13
|
let el = $state();
|
|
13
14
|
|
|
14
15
|
function dateFromPoint(x, y) {
|
|
15
|
-
if (
|
|
16
|
+
if (monthView) {
|
|
16
17
|
return date;
|
|
17
18
|
} else {
|
|
18
19
|
let dayRect = rect(el);
|
|
19
20
|
let scaleX = dayRect.width / el.offsetWidth;
|
|
20
|
-
return addDuration(
|
|
21
|
+
return addDuration(
|
|
22
|
+
cloneDate(start),
|
|
23
|
+
snap.duration,
|
|
24
|
+
floor((isRtl() ? dayRect.right - x : x - dayRect.left) / (slotWidth * snap.ratio * scaleX))
|
|
25
|
+
);
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
</script>
|
|
24
29
|
|
|
25
|
-
<BaseDay bind:el allDay={
|
|
30
|
+
<BaseDay bind:el allDay={monthView} {date} {resource} {dateFromPoint} {disabled} {highlight} {noIeb} {noBeb}/>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {getContext} from 'svelte';
|
|
3
|
-
import {height,
|
|
3
|
+
import {height, toSeconds} from '#lib';
|
|
4
4
|
import {repositionEvent} from './lib.js';
|
|
5
5
|
import {InteractableEvent} from '#components';
|
|
6
6
|
|
|
7
7
|
let {chunk} = $props();
|
|
8
8
|
|
|
9
|
-
let {slotDuration, slotWidth
|
|
9
|
+
let {options: {slotDuration, slotWidth}} = $derived(getContext('state'));
|
|
10
|
+
let {monthView} = $derived(getContext('view-state'));
|
|
10
11
|
|
|
11
12
|
let el = $state();
|
|
12
13
|
let margin = $state(0);
|
|
@@ -15,10 +16,10 @@
|
|
|
15
16
|
let styles = $derived(style => {
|
|
16
17
|
style['grid-column'] = `${chunk.gridColumn} / span ${chunk.dates.length}`;
|
|
17
18
|
style['grid-row'] = chunk.gridRow;
|
|
18
|
-
if (
|
|
19
|
-
let left = chunk.left / toSeconds(
|
|
19
|
+
if (!monthView) {
|
|
20
|
+
let left = chunk.left / toSeconds(slotDuration) * slotWidth;
|
|
20
21
|
style['inset-inline-start'] = `${left}px`;
|
|
21
|
-
style['inline-size'] = `${chunk.width / toSeconds(
|
|
22
|
+
style['inline-size'] = `${chunk.width / toSeconds(slotDuration) * slotWidth}px`;
|
|
22
23
|
}
|
|
23
24
|
let marginTop = margin;
|
|
24
25
|
if (event._margin) {
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
export function reposition() {
|
|
36
|
-
margin = repositionEvent(chunk, height(el),
|
|
37
|
+
margin = repositionEvent(chunk, height(el), monthView);
|
|
37
38
|
}
|
|
38
39
|
</script>
|
|
39
40
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {getContext} from 'svelte';
|
|
3
|
-
import {getPayload
|
|
3
|
+
import {getPayload} from '#lib';
|
|
4
4
|
|
|
5
5
|
let {resource} = $props();
|
|
6
6
|
|
|
7
|
-
let {
|
|
7
|
+
let {options} = $derived(getContext('state'));
|
|
8
|
+
let {resources, theme} = $derived(options);
|
|
8
9
|
|
|
9
10
|
let payload = $state.raw({});
|
|
10
11
|
let expanded = $state(true);
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
expanded = !expanded;
|
|
19
20
|
payload.expanded = expanded;
|
|
20
21
|
toggle(payload.children, expanded);
|
|
21
|
-
resources
|
|
22
|
+
options.resources = [...resources];
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
function toggle(children, expand) {
|
|
@@ -33,12 +34,12 @@
|
|
|
33
34
|
</script>
|
|
34
35
|
|
|
35
36
|
{#each Array(payload.level) as level}
|
|
36
|
-
<span class="{
|
|
37
|
+
<span class="{theme.expander}"></span>
|
|
37
38
|
{/each}
|
|
38
39
|
|
|
39
|
-
<span class="{
|
|
40
|
+
<span class="{theme.expander}">
|
|
40
41
|
{#if payload.children?.length}
|
|
41
|
-
<button class="{
|
|
42
|
+
<button class="{theme.button}" {onclick}>
|
|
42
43
|
{#if expanded}−{:else}+{/if}
|
|
43
44
|
</button>
|
|
44
45
|
{/if}
|
|
@@ -2,41 +2,40 @@
|
|
|
2
2
|
import {getContext} from 'svelte';
|
|
3
3
|
import {datesEqual, toSeconds, intersectionObserver, isRtl} from '#lib';
|
|
4
4
|
|
|
5
|
-
let {
|
|
6
|
-
|
|
7
|
-
let {_mainEl, _now, _today, _sidebarWidth, slotDuration, slotWidth, theme} = getContext('state');
|
|
5
|
+
let {mainEl, now, today, options: {slotDuration, slotWidth, theme}} = $derived(getContext('state'));
|
|
6
|
+
let {grid, sidebarWidth} = $derived(getContext('view-state'));
|
|
8
7
|
|
|
9
8
|
// Layout
|
|
10
9
|
let {gridColumn, start, end} = $derived.by(() => {
|
|
11
10
|
for (let day of grid[0]) {
|
|
12
|
-
if (datesEqual(day.dayStart,
|
|
11
|
+
if (datesEqual(day.dayStart, today)) {
|
|
13
12
|
return day;
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
return {};
|
|
17
16
|
});
|
|
18
17
|
let left = $derived.by(() => {
|
|
19
|
-
if (
|
|
18
|
+
if (now < start || now > end) {
|
|
20
19
|
return null;
|
|
21
20
|
}
|
|
22
|
-
let step = toSeconds(
|
|
23
|
-
return (
|
|
21
|
+
let step = toSeconds(slotDuration);
|
|
22
|
+
return (now - start) / 1000 / step * slotWidth;
|
|
24
23
|
});
|
|
25
24
|
|
|
26
25
|
// Observe intersections
|
|
27
26
|
let observerOptions = $derived({
|
|
28
|
-
root:
|
|
29
|
-
rootMargin: isRtl() ? `0px -${
|
|
27
|
+
root: mainEl,
|
|
28
|
+
rootMargin: isRtl() ? `0px -${sidebarWidth + 1}px 0px 0px` : `0px 0px 0px -${sidebarWidth + 1}px`,
|
|
30
29
|
threshold: 0.0,
|
|
31
30
|
});
|
|
32
31
|
function onIntersect(el, entry) {
|
|
33
|
-
el.classList.toggle(
|
|
32
|
+
el.classList.toggle(theme.hidden, !entry.isIntersecting);
|
|
34
33
|
}
|
|
35
34
|
</script>
|
|
36
35
|
|
|
37
36
|
{#if gridColumn && left !== null}
|
|
38
37
|
<div {@attach intersectionObserver(onIntersect, observerOptions)}
|
|
39
|
-
class="{
|
|
38
|
+
class="{theme.nowIndicator}"
|
|
40
39
|
style:grid-column="{gridColumn + 1}"
|
|
41
40
|
style:grid-row="2 / span {grid.length}"
|
|
42
41
|
style:inset-inline-start="{left}px"
|
|
@@ -1,57 +1,42 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import {getContext, tick} from 'svelte';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "#lib";
|
|
7
|
-
import {createGrid, createEventChunks, createIEventChunks, getSlotTimeLimits} from './lib.js';
|
|
2
|
+
import {getContext, setContext, tick} from 'svelte';
|
|
3
|
+
import {max, resizeObserver, runReposition, contentFrom, toSeconds, datesEqual, min, isRtl} from '#lib';
|
|
4
|
+
import {getSlotTimeLimits} from './lib.js';
|
|
5
|
+
import ViewState from './state.svelte.js';
|
|
8
6
|
import {ColHead, DayHeader} from '#components';
|
|
7
|
+
import Label from '../resource-time-grid/Label.svelte';
|
|
9
8
|
import Day from './Day.svelte';
|
|
10
9
|
import Event from './Event.svelte';
|
|
11
|
-
import Label from './Label.svelte';
|
|
12
10
|
import Expander from './Expander.svelte';
|
|
13
11
|
import NowIndicator from './NowIndicator.svelte';
|
|
14
12
|
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
let mainState = getContext('state');
|
|
14
|
+
let viewState = new ViewState(mainState);
|
|
15
|
+
setContext('view-state', viewState);
|
|
18
16
|
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let {chunks, bgChunks} = $derived(createEventChunks($_filteredEvents, grid));
|
|
23
|
-
let iChunks = $derived(createIEventChunks($_iEvents, grid));
|
|
17
|
+
let {mainEl, today, viewDates, options: {columnWidth, nowIndicator, scrollTime, slotDuration, slotHeight, slotWidth, theme}} = $derived(mainState);
|
|
18
|
+
let {chunks, bgChunks, iChunks, daySlots, dayTimeLimits, grid, monthView, nestedResources, sidebarWidth,
|
|
19
|
+
slotLabelPeriodicity, viewResources} = $derived(viewState);
|
|
24
20
|
|
|
25
|
-
$
|
|
26
|
-
$_activeRangeExt = ({start, end}) => {
|
|
27
|
-
if ($slotMaxTime.days || $slotMaxTime.seconds > DAY_IN_SECONDS) {
|
|
28
|
-
addDuration(subtractDay(end), $slotMaxTime);
|
|
29
|
-
let start2 = subtractDay(cloneDate(end));
|
|
30
|
-
if (start2 < start) {
|
|
31
|
-
start = start2;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return {start, end};
|
|
35
|
-
};
|
|
36
|
-
});
|
|
21
|
+
let headerHeight = $state(0);
|
|
37
22
|
|
|
38
23
|
// Handle scrollTime
|
|
39
24
|
$effect(() => {
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
viewDates;
|
|
26
|
+
scrollTime;
|
|
42
27
|
tick().then(scrollToTime);
|
|
43
28
|
});
|
|
44
29
|
function scrollToTime() {
|
|
45
|
-
if (
|
|
30
|
+
if (monthView) {
|
|
46
31
|
return;
|
|
47
32
|
}
|
|
48
33
|
let scrollLeft = 0;
|
|
49
|
-
let todayOutOfView =
|
|
50
|
-
for (let date of
|
|
51
|
-
let slotTimeLimits = getSlotTimeLimits(
|
|
52
|
-
if (todayOutOfView || datesEqual(date,
|
|
34
|
+
let todayOutOfView = today < viewDates[0] || today > viewDates.at(-1);
|
|
35
|
+
for (let date of viewDates) {
|
|
36
|
+
let slotTimeLimits = getSlotTimeLimits(dayTimeLimits, date);
|
|
37
|
+
if (todayOutOfView || datesEqual(date, today)) {
|
|
53
38
|
scrollLeft += max(
|
|
54
|
-
min(toSeconds(
|
|
39
|
+
min(toSeconds(scrollTime), toSeconds(slotTimeLimits.max)) - toSeconds(slotTimeLimits.min),
|
|
55
40
|
0
|
|
56
41
|
);
|
|
57
42
|
break;
|
|
@@ -59,7 +44,7 @@
|
|
|
59
44
|
scrollLeft += toSeconds(slotTimeLimits.max) - toSeconds(slotTimeLimits.min);
|
|
60
45
|
}
|
|
61
46
|
}
|
|
62
|
-
|
|
47
|
+
mainEl.scrollLeft = scrollLeft / toSeconds(slotDuration) * slotWidth * (isRtl() ? -1 : 1);
|
|
63
48
|
}
|
|
64
49
|
|
|
65
50
|
// Events reposition
|
|
@@ -71,32 +56,32 @@
|
|
|
71
56
|
</script>
|
|
72
57
|
|
|
73
58
|
<section
|
|
74
|
-
bind:this={
|
|
75
|
-
class="{
|
|
59
|
+
bind:this={mainState.mainEl}
|
|
60
|
+
class="{theme.main}"
|
|
76
61
|
style:--ec-grid-cols="{grid[0].length}"
|
|
77
|
-
style:--ec-grid-rows="{grid.length > 1 ? `repeat(${grid.length - 1}, auto)` : ''}
|
|
78
|
-
style:--ec-col-width="{
|
|
79
|
-
style:--ec-slot-label-periodicity="{
|
|
80
|
-
style:--ec-slot-height="{
|
|
81
|
-
style:--ec-slot-width="{
|
|
62
|
+
style:--ec-grid-rows="{grid.length > 1 ? `repeat(${grid.length - 1}, auto)` : ''} 1fr"
|
|
63
|
+
style:--ec-col-width="{columnWidth ?? 'minmax(4em, 1fr)'}"
|
|
64
|
+
style:--ec-slot-label-periodicity="{slotLabelPeriodicity}"
|
|
65
|
+
style:--ec-slot-height="{slotHeight}px"
|
|
66
|
+
style:--ec-slot-width="{slotWidth}px"
|
|
82
67
|
style:--ec-header-height="{headerHeight}px"
|
|
83
|
-
style:--ec-sidebar-width="{
|
|
68
|
+
style:--ec-sidebar-width="{sidebarWidth}px"
|
|
84
69
|
{@attach resizeObserver(reposition)}
|
|
85
70
|
>
|
|
86
|
-
<header bind:offsetHeight={headerHeight} class="{
|
|
87
|
-
<aside class="{
|
|
88
|
-
<div class="{
|
|
71
|
+
<header bind:offsetHeight={headerHeight} class="{theme.header}">
|
|
72
|
+
<aside class="{theme.sidebar}" bind:offsetWidth={viewState.sidebarWidth}></aside>
|
|
73
|
+
<div class="{theme.grid}" role="row">
|
|
89
74
|
{#each grid[0] as {dayStart: date, disabled, highlight}, i}
|
|
90
75
|
<ColHead {date} colIndex={1 + i} {disabled} {highlight}>
|
|
91
76
|
<DayHeader {date}/>
|
|
92
77
|
</ColHead>
|
|
93
78
|
{/each}
|
|
94
|
-
{#if
|
|
79
|
+
{#if !monthView}
|
|
95
80
|
{#each grid[0] as {dayStart: date, disabled, highlight}}
|
|
96
|
-
<ColHead {date} className={
|
|
97
|
-
{#each
|
|
81
|
+
<ColHead {date} className={theme.slots} {disabled} {highlight} ariaHidden>
|
|
82
|
+
{#each daySlots[date.getTime()] as slot}
|
|
98
83
|
<div
|
|
99
|
-
class="{
|
|
84
|
+
class="{theme.slot}"
|
|
100
85
|
style:--ec-slot-label-periodicity={slot[2]}
|
|
101
86
|
>
|
|
102
87
|
<time
|
|
@@ -111,25 +96,25 @@
|
|
|
111
96
|
</div>
|
|
112
97
|
</header>
|
|
113
98
|
|
|
114
|
-
<div class="{
|
|
115
|
-
<aside class="{
|
|
116
|
-
{#each
|
|
117
|
-
<div class="{
|
|
118
|
-
{#if
|
|
99
|
+
<div class="{theme.body}" role="rowgroup">
|
|
100
|
+
<aside class="{theme.sidebar}">
|
|
101
|
+
{#each viewResources as resource}
|
|
102
|
+
<div class="{theme.rowHead}" role="rowheader">
|
|
103
|
+
{#if nestedResources}
|
|
119
104
|
<Expander {resource} />
|
|
120
105
|
{/if}
|
|
121
106
|
<Label {resource}/>
|
|
122
107
|
</div>
|
|
123
108
|
{/each}
|
|
124
109
|
</aside>
|
|
125
|
-
<div class="{
|
|
110
|
+
<div class="{theme.grid}" role="row">
|
|
126
111
|
{#each grid as days, i}
|
|
127
112
|
{#each days as day, j}
|
|
128
113
|
<Day {day} noIeb={j + 1 === days.length} noBeb={i + 1 === grid.length}/>
|
|
129
114
|
{/each}
|
|
130
115
|
{/each}
|
|
131
116
|
</div>
|
|
132
|
-
<div class="{
|
|
117
|
+
<div class="{theme.events}">
|
|
133
118
|
{#each chunks as chunk, i}
|
|
134
119
|
<!-- svelte-ignore binding_property_non_reactive -->
|
|
135
120
|
<Event bind:this={refs[i]} {chunk}/>
|
|
@@ -143,7 +128,7 @@
|
|
|
143
128
|
</div>
|
|
144
129
|
</div>
|
|
145
130
|
|
|
146
|
-
{#if
|
|
147
|
-
<NowIndicator
|
|
131
|
+
{#if nowIndicator && !monthView}
|
|
132
|
+
<NowIndicator/>
|
|
148
133
|
{/if}
|
|
149
134
|
</section>
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import {untrack} from 'svelte';
|
|
2
|
+
import {
|
|
3
|
+
addDay, addDuration, bgEvent, cloneDate, createSlots, createSlotTimeLimits, datesEqual, getPayload, outsideRange,
|
|
4
|
+
toSeconds
|
|
5
|
+
} from '#lib';
|
|
6
|
+
import {createChunks, prepareChunks} from './lib.js';
|
|
7
|
+
|
|
8
|
+
export function grid(mainState, viewState) {
|
|
9
|
+
return () => {
|
|
10
|
+
// Dependencies
|
|
11
|
+
let {viewDates, options: {highlightedDates, validRange}} = mainState;
|
|
12
|
+
let {dayTimeLimits, viewResources} = viewState;
|
|
13
|
+
|
|
14
|
+
let grid = [];
|
|
15
|
+
|
|
16
|
+
untrack(() => {
|
|
17
|
+
let gridRow = 1
|
|
18
|
+
for (let resource of viewResources) {
|
|
19
|
+
let days = [];
|
|
20
|
+
let gridColumn = 1;
|
|
21
|
+
for (let date of viewDates) {
|
|
22
|
+
let slotTimeLimits = dayTimeLimits[date.getTime()];
|
|
23
|
+
days.push({
|
|
24
|
+
gridColumn,
|
|
25
|
+
gridRow,
|
|
26
|
+
resource,
|
|
27
|
+
start: addDuration(cloneDate(date), slotTimeLimits.min),
|
|
28
|
+
end: addDuration(cloneDate(date), slotTimeLimits.max),
|
|
29
|
+
dayStart: date,
|
|
30
|
+
dayEnd: addDay(cloneDate(date)),
|
|
31
|
+
disabled: outsideRange(date, validRange),
|
|
32
|
+
highlight: highlightedDates.some(d => datesEqual(d, date))
|
|
33
|
+
});
|
|
34
|
+
++gridColumn;
|
|
35
|
+
}
|
|
36
|
+
grid.push(days);
|
|
37
|
+
++gridRow;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return grid;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function eventChunks(mainState, viewState) {
|
|
46
|
+
return () => {
|
|
47
|
+
// Dependencies
|
|
48
|
+
let {filteredEvents} = mainState;
|
|
49
|
+
let {grid} = viewState;
|
|
50
|
+
|
|
51
|
+
let chunks = [];
|
|
52
|
+
let bgChunks = [];
|
|
53
|
+
|
|
54
|
+
untrack(() => {
|
|
55
|
+
for (let event of filteredEvents) {
|
|
56
|
+
for (let days of grid) {
|
|
57
|
+
if (bgEvent(event.display)) {
|
|
58
|
+
bgChunks = bgChunks.concat(createChunks(event, days));
|
|
59
|
+
} else {
|
|
60
|
+
chunks = chunks.concat(createChunks(event, days));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
prepareChunks(chunks);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return {chunks, bgChunks};
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function iEventChunks(mainState, viewState) {
|
|
72
|
+
return () => {
|
|
73
|
+
// Dependencies
|
|
74
|
+
let {iEvents} = mainState;
|
|
75
|
+
let {grid} = viewState;
|
|
76
|
+
|
|
77
|
+
let iChunks = [];
|
|
78
|
+
|
|
79
|
+
for (let [, event] of iEvents) {
|
|
80
|
+
if (!event) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
untrack(() => {
|
|
84
|
+
for (let days of grid) {
|
|
85
|
+
iChunks = iChunks.concat(createChunks(event, days));
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return iChunks;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// slotTimeLimits per day
|
|
95
|
+
export function dayTimeLimits(mainState) {
|
|
96
|
+
return () => {
|
|
97
|
+
// Dependencies
|
|
98
|
+
let {filteredEvents, viewDates, options: {flexibleSlotTimeLimits, slotMinTime, slotMaxTime}} = mainState;
|
|
99
|
+
|
|
100
|
+
let dayTimeLimits = {};
|
|
101
|
+
|
|
102
|
+
untrack(() => {
|
|
103
|
+
for (let date of viewDates) {
|
|
104
|
+
dayTimeLimits[date.getTime()] = createSlotTimeLimits(
|
|
105
|
+
slotMinTime,
|
|
106
|
+
slotMaxTime,
|
|
107
|
+
flexibleSlotTimeLimits,
|
|
108
|
+
[date],
|
|
109
|
+
filteredEvents
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return dayTimeLimits;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function daySlots(mainState, viewState) {
|
|
119
|
+
return () => {
|
|
120
|
+
// Dependencies
|
|
121
|
+
let {viewDates, options: {slotDuration}} = mainState;
|
|
122
|
+
let {dayTimeLimits, intlSlotLabel, slotLabelPeriodicity} = viewState;
|
|
123
|
+
|
|
124
|
+
let slots = {};
|
|
125
|
+
|
|
126
|
+
untrack(() => {
|
|
127
|
+
for (let date of viewDates) {
|
|
128
|
+
let key = date.getTime();
|
|
129
|
+
slots[key] = key in dayTimeLimits
|
|
130
|
+
? createSlots(date, slotDuration, slotLabelPeriodicity, dayTimeLimits[key], intlSlotLabel)
|
|
131
|
+
: [];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return slots;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function nestedResources(mainState) {
|
|
140
|
+
return () => {
|
|
141
|
+
// Dependencies
|
|
142
|
+
let {options: {resources}} = mainState;
|
|
143
|
+
|
|
144
|
+
let nested;
|
|
145
|
+
|
|
146
|
+
untrack(() => {
|
|
147
|
+
nested = resources.some(resource => getPayload(resource).children.length);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
return nested;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function monthView(mainState) {
|
|
155
|
+
return () => {
|
|
156
|
+
// Dependencies
|
|
157
|
+
let {options: {slotDuration}} = mainState;
|
|
158
|
+
|
|
159
|
+
let monthView;
|
|
160
|
+
|
|
161
|
+
untrack(() => {
|
|
162
|
+
monthView = !toSeconds(slotDuration);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
return monthView;
|
|
166
|
+
};
|
|
167
|
+
}
|