@event-calendar/core 3.0.1 → 3.0.2
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 +2 -2
- package/index.css +1 -0
- package/index.js +44 -1
- package/package.json +1 -1
- package/src/lib/resources.js +9 -0
- package/src/lib/stores.js +32 -0
- package/src/lib.js +1 -0
- package/src/storage/options.js +12 -1
- package/src/styles/timeline.scss +1 -0
package/README.md
CHANGED
|
@@ -202,8 +202,8 @@ import '@event-calendar/core/index.css';
|
|
|
202
202
|
### Pre-built browser ready bundle
|
|
203
203
|
Include the following lines of code in the `<head>` section of your page:
|
|
204
204
|
```html
|
|
205
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.0.
|
|
206
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.0.
|
|
205
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.0.2/event-calendar.min.css">
|
|
206
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.0.2/event-calendar.min.js"></script>
|
|
207
207
|
```
|
|
208
208
|
|
|
209
209
|
<details>
|
package/index.css
CHANGED
package/index.js
CHANGED
|
@@ -631,6 +631,16 @@ function themeView(view) {
|
|
|
631
631
|
return theme => ({...theme, view});
|
|
632
632
|
}
|
|
633
633
|
|
|
634
|
+
function createResources(input) {
|
|
635
|
+
return input.map(resource => ({
|
|
636
|
+
id: String(resource.id),
|
|
637
|
+
title: resource.title || '',
|
|
638
|
+
titleHTML: resource.titleHTML || '',
|
|
639
|
+
eventBackgroundColor: resource.eventBackgroundColor,
|
|
640
|
+
eventTextColor: resource.eventTextColor
|
|
641
|
+
}));
|
|
642
|
+
}
|
|
643
|
+
|
|
634
644
|
function intl(locale, format) {
|
|
635
645
|
return derived([locale, format], ([$locale, $format]) => {
|
|
636
646
|
let intl = is_function($format)
|
|
@@ -691,6 +701,37 @@ function _getParts(source, parts) {
|
|
|
691
701
|
return result;
|
|
692
702
|
}
|
|
693
703
|
|
|
704
|
+
function viewResources(state) {
|
|
705
|
+
return derived(
|
|
706
|
+
[state.resources, state.filterResourcesWithEvents, state._events, state._activeRange],
|
|
707
|
+
([$resources, $filterResourcesWithEvents, $_events, $_activeRange]) => {
|
|
708
|
+
let result = $resources;
|
|
709
|
+
|
|
710
|
+
if ($filterResourcesWithEvents) {
|
|
711
|
+
result = $resources.filter(resource => {
|
|
712
|
+
for (let event of $_events) {
|
|
713
|
+
if (
|
|
714
|
+
event.display !== 'background' &&
|
|
715
|
+
event.resourceIds.includes(resource.id) &&
|
|
716
|
+
event.start < $_activeRange.end &&
|
|
717
|
+
event.end > $_activeRange.start
|
|
718
|
+
) {
|
|
719
|
+
return true;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return false;
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (!result.length) {
|
|
727
|
+
result = createResources([{}]);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
return result;
|
|
731
|
+
}
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
|
|
694
735
|
function createTimes(date, $slotDuration, $_slotTimeLimits, $_intlSlotLabel, $_intlDayHeaderAL) {
|
|
695
736
|
date = cloneDate(date);
|
|
696
737
|
let compact = $slotDuration.seconds < 3600;
|
|
@@ -790,6 +831,7 @@ function createOptions(plugins) {
|
|
|
790
831
|
hour: 'numeric',
|
|
791
832
|
minute: '2-digit'
|
|
792
833
|
},
|
|
834
|
+
filterResourcesWithEvents: false,
|
|
793
835
|
firstDay: 0,
|
|
794
836
|
flexibleSlotTimeLimits: false, // ec option
|
|
795
837
|
headerToolbar: {
|
|
@@ -884,6 +926,7 @@ function createParsers(plugins) {
|
|
|
884
926
|
eventSources: createEventSources,
|
|
885
927
|
hiddenDays: days => [...new Set(days)],
|
|
886
928
|
highlightedDates: dates => dates.map(createDate),
|
|
929
|
+
resources: createResources,
|
|
887
930
|
scrollTime: createDuration,
|
|
888
931
|
slotDuration: createDuration,
|
|
889
932
|
slotMaxTime: createDuration,
|
|
@@ -2743,4 +2786,4 @@ class Calendar extends SvelteComponent {
|
|
|
2743
2786
|
}
|
|
2744
2787
|
}
|
|
2745
2788
|
|
|
2746
|
-
export { DAY_IN_SECONDS, addDay, addDuration, ancestor, assign, bgEvent, btnTextDay, btnTextMonth, btnTextWeek, btnTextYear, ceil, cloneDate, cloneEvent, copyTime, createDate, createDuration, createElement, createEventChunk, createEventClasses, createEventContent, createEventSources, createEvents, createSlotTimeLimits, createTimes, createView, datesEqual, debounce, Calendar as default, eventIntersects, floor, flushDebounce, getElementWithPayload, getPayload, ghostEvent, hasPayload, hasYScroll, height, helperEvent, intl, intlRange, keyEnter, keys, listView, max, min, nextClosestDay, noTimePart, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, previewEvent, rect, repositionEvent, runReposition, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, task, themeView, timelineView, toEventWithLocalDates, toISOString, toLocalDate, toSeconds, toViewWithLocalDates };
|
|
2789
|
+
export { DAY_IN_SECONDS, addDay, addDuration, ancestor, assign, bgEvent, btnTextDay, btnTextMonth, btnTextWeek, btnTextYear, ceil, cloneDate, cloneEvent, copyTime, createDate, createDuration, createElement, createEventChunk, createEventClasses, createEventContent, createEventSources, createEvents, createResources, createSlotTimeLimits, createTimes, createView, datesEqual, debounce, Calendar as default, eventIntersects, floor, flushDebounce, getElementWithPayload, getPayload, ghostEvent, hasPayload, hasYScroll, height, helperEvent, intl, intlRange, keyEnter, keys, listView, max, min, nextClosestDay, noTimePart, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, previewEvent, rect, repositionEvent, runReposition, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, task, themeView, timelineView, toEventWithLocalDates, toISOString, toLocalDate, toSeconds, toViewWithLocalDates, viewResources };
|
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function createResources(input) {
|
|
2
|
+
return input.map(resource => ({
|
|
3
|
+
id: String(resource.id),
|
|
4
|
+
title: resource.title || '',
|
|
5
|
+
titleHTML: resource.titleHTML || '',
|
|
6
|
+
eventBackgroundColor: resource.eventBackgroundColor,
|
|
7
|
+
eventTextColor: resource.eventTextColor
|
|
8
|
+
}));
|
|
9
|
+
}
|
package/src/lib/stores.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {derived} from 'svelte/store';
|
|
2
2
|
import {is_function} from 'svelte/internal';
|
|
3
3
|
import {toLocalDate} from './date';
|
|
4
|
+
import {createResources} from './resources.js';
|
|
4
5
|
|
|
5
6
|
export function intl(locale, format) {
|
|
6
7
|
return derived([locale, format], ([$locale, $format]) => {
|
|
@@ -61,3 +62,34 @@ function _getParts(source, parts) {
|
|
|
61
62
|
}
|
|
62
63
|
return result;
|
|
63
64
|
}
|
|
65
|
+
|
|
66
|
+
export function viewResources(state) {
|
|
67
|
+
return derived(
|
|
68
|
+
[state.resources, state.filterResourcesWithEvents, state._events, state._activeRange],
|
|
69
|
+
([$resources, $filterResourcesWithEvents, $_events, $_activeRange]) => {
|
|
70
|
+
let result = $resources;
|
|
71
|
+
|
|
72
|
+
if ($filterResourcesWithEvents) {
|
|
73
|
+
result = $resources.filter(resource => {
|
|
74
|
+
for (let event of $_events) {
|
|
75
|
+
if (
|
|
76
|
+
event.display !== 'background' &&
|
|
77
|
+
event.resourceIds.includes(resource.id) &&
|
|
78
|
+
event.start < $_activeRange.end &&
|
|
79
|
+
event.end > $_activeRange.start
|
|
80
|
+
) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!result.length) {
|
|
89
|
+
result = createResources([{}]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
package/src/lib.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from './lib/debounce.js';
|
|
|
5
5
|
export * from './lib/dom.js';
|
|
6
6
|
export * from './lib/events.js';
|
|
7
7
|
export * from './lib/options.js';
|
|
8
|
+
export * from './lib/resources.js';
|
|
8
9
|
export * from './lib/stores.js';
|
|
9
10
|
export * from './lib/times.js';
|
|
10
11
|
export * from './lib/utils.js';
|
package/src/storage/options.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
assign,
|
|
3
|
+
createDate,
|
|
4
|
+
createDuration,
|
|
5
|
+
keys,
|
|
6
|
+
setMidnight,
|
|
7
|
+
createEvents,
|
|
8
|
+
createEventSources,
|
|
9
|
+
createResources
|
|
10
|
+
} from '../lib.js';
|
|
2
11
|
|
|
3
12
|
export function createOptions(plugins) {
|
|
4
13
|
let options = {
|
|
@@ -36,6 +45,7 @@ export function createOptions(plugins) {
|
|
|
36
45
|
hour: 'numeric',
|
|
37
46
|
minute: '2-digit'
|
|
38
47
|
},
|
|
48
|
+
filterResourcesWithEvents: false,
|
|
39
49
|
firstDay: 0,
|
|
40
50
|
flexibleSlotTimeLimits: false, // ec option
|
|
41
51
|
headerToolbar: {
|
|
@@ -130,6 +140,7 @@ export function createParsers(plugins) {
|
|
|
130
140
|
eventSources: createEventSources,
|
|
131
141
|
hiddenDays: days => [...new Set(days)],
|
|
132
142
|
highlightedDates: dates => dates.map(createDate),
|
|
143
|
+
resources: createResources,
|
|
133
144
|
scrollTime: createDuration,
|
|
134
145
|
slotDuration: createDuration,
|
|
135
146
|
slotMaxTime: createDuration,
|