@event-calendar/core 3.6.2 → 3.7.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 +31 -3
- package/index.css +12 -0
- package/index.js +48 -22
- package/package.json +1 -1
- package/src/Calendar.svelte +2 -1
- package/src/lib/dom.js +1 -14
- package/src/lib/payload.js +14 -0
- package/src/lib/resources.js +35 -7
- package/src/lib/stores.js +2 -1
- package/src/lib.js +1 -0
- package/src/styles/index.scss +13 -0
package/README.md
CHANGED
|
@@ -203,8 +203,8 @@ Or in your Svelte component, use the calendar like this:
|
|
|
203
203
|
### Pre-built browser ready bundle
|
|
204
204
|
Include the following lines of code in the `<head>` section of your page:
|
|
205
205
|
```html
|
|
206
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.
|
|
207
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.
|
|
206
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.7.1/event-calendar.min.css">
|
|
207
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.7.1/event-calendar.min.js"></script>
|
|
208
208
|
```
|
|
209
209
|
|
|
210
210
|
<details>
|
|
@@ -2095,7 +2095,7 @@ Defines the time slot width in pixels in `ResourceTimeline` views. When changing
|
|
|
2095
2095
|
|
|
2096
2096
|
### theme
|
|
2097
2097
|
- Type `object` or `function`
|
|
2098
|
-
- Default `{allDay: 'ec-all-day', active: 'ec-active', bgEvent: 'ec-bg-event', bgEvents: 'ec-bg-events', body: 'ec-body', button: 'ec-button', buttonGroup: 'ec-button-group', calendar: 'ec', compact: 'ec-compact', container: 'ec-container', content: 'ec-content', day: 'ec-day', dayHead: 'ec-day-head', dayFoot: 'ec-day-foot', days: 'ec-days', daySide: 'ec-day-side', draggable: 'ec-draggable', dragging: 'ec-dragging', event: 'ec-event', eventBody: 'ec-event-body', eventTag: 'ec-event-tag', eventTime: 'ec-event-time', eventTitle: 'ec-event-title', events: 'ec-events', extra: 'ec-extra', ghost: 'ec-ghost', handle: 'ec-handle', header: 'ec-header', hiddenScroll: 'ec-hidden-scroll', highlight: 'ec-highlight', icon: 'ec-icon', line: 'ec-line', lines: 'ec-lines', main: 'ec-main', noEvents: 'ec-no-events', nowIndicator: 'ec-now-indicator', otherMonth: 'ec-other-month', pointer: 'ec-pointer', popup: 'ec-popup', preview: 'ec-preview', resizer: 'ec-resizer', resizingX: 'ec-resizing-x', resizingY: 'ec-resizing-y', resource: 'ec-resource', selecting: 'ec-selecting', sidebar: 'ec-sidebar', sidebarTitle: 'ec-sidebar-title', today: 'ec-today', time: 'ec-time', times: 'ec-times', title: 'ec-title', toolbar: 'ec-toolbar', view: 'ec-timeline ec-resource-week-view', weekdays: ['ec-sun', 'ec-mon', 'ec-tue', 'ec-wed', 'ec-thu', 'ec-fri', 'ec-sat'], withScroll: 'ec-with-scroll', uniform: 'ec-uniform'}`
|
|
2098
|
+
- Default `{allDay: 'ec-all-day', active: 'ec-active', bgEvent: 'ec-bg-event', bgEvents: 'ec-bg-events', body: 'ec-body', button: 'ec-button', buttonGroup: 'ec-button-group', calendar: 'ec', compact: 'ec-compact', container: 'ec-container', content: 'ec-content', day: 'ec-day', dayHead: 'ec-day-head', dayFoot: 'ec-day-foot', days: 'ec-days', daySide: 'ec-day-side', draggable: 'ec-draggable', dragging: 'ec-dragging', event: 'ec-event', eventBody: 'ec-event-body', eventTag: 'ec-event-tag', eventTime: 'ec-event-time', eventTitle: 'ec-event-title', events: 'ec-events', expander: 'ec-expander', extra: 'ec-extra', ghost: 'ec-ghost', handle: 'ec-handle', header: 'ec-header', hiddenScroll: 'ec-hidden-scroll', highlight: 'ec-highlight', icon: 'ec-icon', line: 'ec-line', lines: 'ec-lines', main: 'ec-main', noEvents: 'ec-no-events', nowIndicator: 'ec-now-indicator', otherMonth: 'ec-other-month', pointer: 'ec-pointer', popup: 'ec-popup', preview: 'ec-preview', resizer: 'ec-resizer', resizingX: 'ec-resizing-x', resizingY: 'ec-resizing-y', resource: 'ec-resource', selecting: 'ec-selecting', sidebar: 'ec-sidebar', sidebarTitle: 'ec-sidebar-title', today: 'ec-today', time: 'ec-time', times: 'ec-times', title: 'ec-title', toolbar: 'ec-toolbar', view: 'ec-timeline ec-resource-week-view', weekdays: ['ec-sun', 'ec-mon', 'ec-tue', 'ec-wed', 'ec-thu', 'ec-fri', 'ec-sat'], withScroll: 'ec-with-scroll', uniform: 'ec-uniform'}`
|
|
2099
2099
|
> Views override the default value as follows:
|
|
2100
2100
|
> - dayGridMonth `theme => ({...theme, view: 'ec-day-grid ec-month-view'})`
|
|
2101
2101
|
> - listDay `theme => ({...theme, view: 'ec-list ec-day-view'})`
|
|
@@ -2890,8 +2890,36 @@ Here are all admissible fields for the resource’s input object:
|
|
|
2890
2890
|
`object` A plain object with any miscellaneous properties. It will be directly transferred to the `extendedProps` property of the Resource object. Default `{}`
|
|
2891
2891
|
</td>
|
|
2892
2892
|
</tr>
|
|
2893
|
+
<tr>
|
|
2894
|
+
<td>
|
|
2895
|
+
|
|
2896
|
+
`children`
|
|
2897
|
+
</td>
|
|
2898
|
+
<td>Nested resources. See below</td>
|
|
2899
|
+
</tr>
|
|
2893
2900
|
</table>
|
|
2894
2901
|
|
|
2902
|
+
The `timeline` views support displaying nested resources. Nested resources can be collapsed or expanded using an additional button that appears before the parent resource name. To pass nested resources, use the `children` field:
|
|
2903
|
+
|
|
2904
|
+
```js
|
|
2905
|
+
resources: [
|
|
2906
|
+
{
|
|
2907
|
+
id: 1,
|
|
2908
|
+
title: 'Resource A',
|
|
2909
|
+
children: [
|
|
2910
|
+
{
|
|
2911
|
+
id: 11,
|
|
2912
|
+
title: 'Resource A1'
|
|
2913
|
+
},
|
|
2914
|
+
{
|
|
2915
|
+
id: 12,
|
|
2916
|
+
title: 'Resource A2'
|
|
2917
|
+
}
|
|
2918
|
+
]
|
|
2919
|
+
}
|
|
2920
|
+
]
|
|
2921
|
+
```
|
|
2922
|
+
|
|
2895
2923
|
## View object
|
|
2896
2924
|
A View object contains information about a calendar view, such as title and date range.
|
|
2897
2925
|
|
package/index.css
CHANGED
|
@@ -359,6 +359,17 @@
|
|
|
359
359
|
z-index: 1;
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
.ec-expander {
|
|
363
|
+
margin-right: 0.25em;
|
|
364
|
+
width: 1.25em;
|
|
365
|
+
}
|
|
366
|
+
.ec-expander .ec-button {
|
|
367
|
+
line-height: normal;
|
|
368
|
+
padding: 0;
|
|
369
|
+
aspect-ratio: 1;
|
|
370
|
+
height: 1.25em;
|
|
371
|
+
}
|
|
372
|
+
|
|
362
373
|
.ec-button-group {
|
|
363
374
|
display: inline-flex;
|
|
364
375
|
}
|
|
@@ -582,6 +593,7 @@
|
|
|
582
593
|
white-space: nowrap;
|
|
583
594
|
margin: 0 0 1px 0;
|
|
584
595
|
flex-shrink: 0;
|
|
596
|
+
max-height: 100%;
|
|
585
597
|
}
|
|
586
598
|
.ec-day-grid .ec-event-time, .ec-timeline .ec-event-time {
|
|
587
599
|
margin: 0 3px 0 0;
|
package/index.js
CHANGED
|
@@ -294,6 +294,19 @@ function task(fn, handle, tasks) {
|
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
let payloadProp = symbol();
|
|
298
|
+
function setPayload(obj, payload) {
|
|
299
|
+
obj[payloadProp] = payload;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function hasPayload(obj) {
|
|
303
|
+
return !!obj?.[payloadProp];
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function getPayload(obj) {
|
|
307
|
+
return obj[payloadProp];
|
|
308
|
+
}
|
|
309
|
+
|
|
297
310
|
function createElement(tag, className, content, attrs = []) {
|
|
298
311
|
let el = document.createElement(tag);
|
|
299
312
|
el.className = className;
|
|
@@ -329,19 +342,6 @@ function height(el) {
|
|
|
329
342
|
return rect(el).height;
|
|
330
343
|
}
|
|
331
344
|
|
|
332
|
-
let payloadProp = symbol();
|
|
333
|
-
function setPayload(el, payload) {
|
|
334
|
-
el[payloadProp] = payload;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
function hasPayload(el) {
|
|
338
|
-
return !!el?.[payloadProp];
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function getPayload(el) {
|
|
342
|
-
return el[payloadProp];
|
|
343
|
-
}
|
|
344
|
-
|
|
345
345
|
function getElementWithPayload(x, y, root = document) {
|
|
346
346
|
for (let el of root.elementsFromPoint(x, y)) {
|
|
347
347
|
if (hasPayload(el)) {
|
|
@@ -703,13 +703,39 @@ function themeView(view) {
|
|
|
703
703
|
}
|
|
704
704
|
|
|
705
705
|
function createResources(input) {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
706
|
+
let result = [];
|
|
707
|
+
_createResources(input, 0, result);
|
|
708
|
+
return result;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function _createResources(input, level, flat) {
|
|
712
|
+
let result = [];
|
|
713
|
+
for (let item of input) {
|
|
714
|
+
let resource = createResource(item);
|
|
715
|
+
result.push(resource);
|
|
716
|
+
flat.push(resource);
|
|
717
|
+
let payload = {
|
|
718
|
+
level,
|
|
719
|
+
children: [],
|
|
720
|
+
expanded: true,
|
|
721
|
+
hidden: false
|
|
722
|
+
};
|
|
723
|
+
setPayload(resource, payload);
|
|
724
|
+
if (item.children) {
|
|
725
|
+
payload.children = _createResources(item.children, level + 1, flat);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return result;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
function createResource(input) {
|
|
732
|
+
return {
|
|
733
|
+
id: String(input.id),
|
|
734
|
+
title: input.title || '',
|
|
735
|
+
eventBackgroundColor: input.eventBackgroundColor,
|
|
736
|
+
eventTextColor: input.eventTextColor,
|
|
737
|
+
extendedProps: input.extendedProps ?? {}
|
|
738
|
+
};
|
|
713
739
|
}
|
|
714
740
|
|
|
715
741
|
function resourceBackgroundColor(event, resources) {
|
|
@@ -788,7 +814,7 @@ function viewResources(state) {
|
|
|
788
814
|
return derived(
|
|
789
815
|
[state.resources, state.filterResourcesWithEvents, state._events, state._activeRange],
|
|
790
816
|
([$resources, $filterResourcesWithEvents, $_events, $_activeRange]) => {
|
|
791
|
-
let result = $resources;
|
|
817
|
+
let result = $resources.filter(resource => !getPayload(resource).hidden);
|
|
792
818
|
|
|
793
819
|
if ($filterResourcesWithEvents) {
|
|
794
820
|
result = $resources.filter(resource => {
|
|
@@ -2906,4 +2932,4 @@ class index extends Calendar {
|
|
|
2906
2932
|
}
|
|
2907
2933
|
}
|
|
2908
2934
|
|
|
2909
|
-
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, index as default, eventIntersects, floor, flushDebounce, getElementWithPayload, getPayload, ghostEvent, hasPayload, hasYScroll, height, helperEvent, identity, intl, intlRange, isArray, isFunction, keyEnter, keys, listView, listen, max, min, nextClosestDay, nextDate, noTimePart, noop, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, prevDate, previewEvent, rect, repositionEvent, resourceBackgroundColor, resourceTextColor, run, runAll, runReposition, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, task, themeView, timelineView, toEventWithLocalDates, toISOString, toLocalDate, toSeconds, toViewWithLocalDates, viewResources };
|
|
2935
|
+
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, createResource, createResources, createSlotTimeLimits, createTimes, createView, datesEqual, debounce, index as default, eventIntersects, floor, flushDebounce, getElementWithPayload, getPayload, ghostEvent, hasPayload, hasYScroll, height, helperEvent, identity, intl, intlRange, isArray, isFunction, keyEnter, keys, listView, listen, max, min, nextClosestDay, nextDate, noTimePart, noop, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, prevDate, previewEvent, rect, repositionEvent, resourceBackgroundColor, resourceTextColor, run, runAll, runReposition, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, task, themeView, timelineView, toEventWithLocalDates, toISOString, toLocalDate, toSeconds, toViewWithLocalDates, viewResources };
|
package/package.json
CHANGED
package/src/Calendar.svelte
CHANGED
package/src/lib/dom.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {hasPayload} from './payload.js';
|
|
2
2
|
|
|
3
3
|
export function createElement(tag, className, content, attrs = []) {
|
|
4
4
|
let el = document.createElement(tag);
|
|
@@ -35,19 +35,6 @@ export function height(el) {
|
|
|
35
35
|
return rect(el).height;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
let payloadProp = symbol();
|
|
39
|
-
export function setPayload(el, payload) {
|
|
40
|
-
el[payloadProp] = payload;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function hasPayload(el) {
|
|
44
|
-
return !!el?.[payloadProp];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function getPayload(el) {
|
|
48
|
-
return el[payloadProp];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
38
|
export function getElementWithPayload(x, y, root = document) {
|
|
52
39
|
for (let el of root.elementsFromPoint(x, y)) {
|
|
53
40
|
if (hasPayload(el)) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {symbol} from './utils.js';
|
|
2
|
+
|
|
3
|
+
let payloadProp = symbol();
|
|
4
|
+
export function setPayload(obj, payload) {
|
|
5
|
+
obj[payloadProp] = payload;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function hasPayload(obj) {
|
|
9
|
+
return !!obj?.[payloadProp];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getPayload(obj) {
|
|
13
|
+
return obj[payloadProp];
|
|
14
|
+
}
|
package/src/lib/resources.js
CHANGED
|
@@ -1,11 +1,39 @@
|
|
|
1
|
+
import {setPayload} from './payload.js';
|
|
2
|
+
|
|
1
3
|
export function createResources(input) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
let result = [];
|
|
5
|
+
_createResources(input, 0, result);
|
|
6
|
+
return result;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function _createResources(input, level, flat) {
|
|
10
|
+
let result = [];
|
|
11
|
+
for (let item of input) {
|
|
12
|
+
let resource = createResource(item);
|
|
13
|
+
result.push(resource);
|
|
14
|
+
flat.push(resource);
|
|
15
|
+
let payload = {
|
|
16
|
+
level,
|
|
17
|
+
children: [],
|
|
18
|
+
expanded: true,
|
|
19
|
+
hidden: false
|
|
20
|
+
};
|
|
21
|
+
setPayload(resource, payload);
|
|
22
|
+
if (item.children) {
|
|
23
|
+
payload.children = _createResources(item.children, level + 1, flat);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createResource(input) {
|
|
30
|
+
return {
|
|
31
|
+
id: String(input.id),
|
|
32
|
+
title: input.title || '',
|
|
33
|
+
eventBackgroundColor: input.eventBackgroundColor,
|
|
34
|
+
eventTextColor: input.eventTextColor,
|
|
35
|
+
extendedProps: input.extendedProps ?? {}
|
|
36
|
+
};
|
|
9
37
|
}
|
|
10
38
|
|
|
11
39
|
export function resourceBackgroundColor(event, resources) {
|
package/src/lib/stores.js
CHANGED
|
@@ -2,6 +2,7 @@ import {derived} from 'svelte/store';
|
|
|
2
2
|
import {isFunction} from './utils.js';
|
|
3
3
|
import {toLocalDate} from './date';
|
|
4
4
|
import {createResources} from './resources.js';
|
|
5
|
+
import {getPayload} from './payload.js';
|
|
5
6
|
|
|
6
7
|
export function intl(locale, format) {
|
|
7
8
|
return derived([locale, format], ([$locale, $format]) => {
|
|
@@ -67,7 +68,7 @@ export function viewResources(state) {
|
|
|
67
68
|
return derived(
|
|
68
69
|
[state.resources, state.filterResourcesWithEvents, state._events, state._activeRange],
|
|
69
70
|
([$resources, $filterResourcesWithEvents, $_events, $_activeRange]) => {
|
|
70
|
-
let result = $resources;
|
|
71
|
+
let result = $resources.filter(resource => !getPayload(resource).hidden);
|
|
71
72
|
|
|
72
73
|
if ($filterResourcesWithEvents) {
|
|
73
74
|
result = $resources.filter(resource => {
|
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/payload.js';
|
|
8
9
|
export * from './lib/resources.js';
|
|
9
10
|
export * from './lib/stores.js';
|
|
10
11
|
export * from './lib/times.js';
|
package/src/styles/index.scss
CHANGED
|
@@ -96,6 +96,18 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
.ec-expander {
|
|
100
|
+
margin-right: .25em;
|
|
101
|
+
width: 1.25em;
|
|
102
|
+
|
|
103
|
+
.ec-button {
|
|
104
|
+
line-height: normal;
|
|
105
|
+
padding: 0;
|
|
106
|
+
aspect-ratio: 1;
|
|
107
|
+
height: 1.25em;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
99
111
|
.ec-button-group {
|
|
100
112
|
display: inline-flex;
|
|
101
113
|
|
|
@@ -359,6 +371,7 @@
|
|
|
359
371
|
white-space: nowrap;
|
|
360
372
|
margin: 0 0 1px 0;
|
|
361
373
|
flex-shrink: 0;
|
|
374
|
+
max-height: 100%;
|
|
362
375
|
|
|
363
376
|
.ec-day-grid &,
|
|
364
377
|
.ec-timeline & {
|