@event-calendar/core 5.1.0 → 5.1.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 +14 -2
- package/dist/index.css +1 -1
- package/dist/index.js +29 -15
- package/package.json +1 -1
- package/src/Calendar.svelte +6 -1
- package/src/storage/options.svelte.js +6 -5
package/README.md
CHANGED
|
@@ -246,8 +246,8 @@ This bundle contains a version of the calendar that includes all plugins and is
|
|
|
246
246
|
|
|
247
247
|
The first step is to include the following lines of code in the `<head>` section of your page:
|
|
248
248
|
```html
|
|
249
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1.
|
|
250
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1.
|
|
249
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1.2/dist/event-calendar.min.css">
|
|
250
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1.2/dist/event-calendar.min.js"></script>
|
|
251
251
|
```
|
|
252
252
|
|
|
253
253
|
<details>
|
|
@@ -2490,6 +2490,18 @@ The mounted [View](#view-object) object
|
|
|
2490
2490
|
|
|
2491
2491
|
You can specify options that apply only to specific views. To do so provide separate options objects within the `views` option, keyed by the name of the view.
|
|
2492
2492
|
|
|
2493
|
+
If you want to create a custom view, you can use the `type` property to inherit options from a standard view.
|
|
2494
|
+
|
|
2495
|
+
```js
|
|
2496
|
+
views: {
|
|
2497
|
+
resourceTimelineThreeDays: {
|
|
2498
|
+
type: 'resourceTimelineDay',
|
|
2499
|
+
duration: {days: 3}
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
```
|
|
2503
|
+
|
|
2504
|
+
|
|
2493
2505
|
### weekNumberContent
|
|
2494
2506
|
- Type `Content` or `function`
|
|
2495
2507
|
- Default `undefined`
|
package/dist/index.css
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* EventCalendar v5.1.
|
|
2
|
+
* EventCalendar v5.1.2
|
|
3
3
|
* https://github.com/vkurko/calendar
|
|
4
4
|
*/
|
|
5
5
|
import { untrack, getAbortSignal, tick, getContext, setContext, onMount, mount, unmount } from "svelte";
|
|
@@ -845,8 +845,8 @@ function optionsState(mainState, plugins, userOptions) {
|
|
|
845
845
|
let parsers = createParsers(plugins);
|
|
846
846
|
defOptions = parseOptions(defOptions, parsers);
|
|
847
847
|
userOptions = parseOptions(userOptions, parsers);
|
|
848
|
-
let
|
|
849
|
-
let
|
|
848
|
+
let defViewsOptions = extractOption(defOptions, "views") ?? {};
|
|
849
|
+
let userViewsOptions = extractOption(userOptions, "views") ?? {};
|
|
850
850
|
let options = new SvelteMap();
|
|
851
851
|
setOptions(options, defOptions);
|
|
852
852
|
let setters = {};
|
|
@@ -855,10 +855,11 @@ function optionsState(mainState, plugins, userOptions) {
|
|
|
855
855
|
if (userOptions.view) {
|
|
856
856
|
options.set("view", userOptions.view);
|
|
857
857
|
}
|
|
858
|
-
let views = /* @__PURE__ */ new Set([...keys(
|
|
858
|
+
let views = /* @__PURE__ */ new Set([...keys(defViewsOptions), ...keys(userViewsOptions)]);
|
|
859
859
|
for (let view2 of views) {
|
|
860
|
-
let
|
|
861
|
-
let
|
|
860
|
+
let userViewOptions = userViewsOptions[view2] ?? {};
|
|
861
|
+
let defOpts = mergeOpts(defOptions, defViewsOptions[view2] ?? defViewsOptions[userViewOptions.type] ?? {});
|
|
862
|
+
let opts = mergeOpts(defOpts, userOptions, userViewOptions);
|
|
862
863
|
let component = extractOption(opts, "component");
|
|
863
864
|
delete opts.view;
|
|
864
865
|
for (let key of keys(opts)) {
|
|
@@ -1701,6 +1702,7 @@ function Calendar($$anchor, $$props) {
|
|
|
1701
1702
|
function addEvent(event) {
|
|
1702
1703
|
event = createEvents([event])[0];
|
|
1703
1704
|
$.get(events).push(event);
|
|
1705
|
+
mainState.events = [...$.get(events)];
|
|
1704
1706
|
return toEventWithLocalDates(event);
|
|
1705
1707
|
}
|
|
1706
1708
|
function updateEvent(event) {
|
|
@@ -1709,6 +1711,7 @@ function Calendar($$anchor, $$props) {
|
|
|
1709
1711
|
if (idx >= 0) {
|
|
1710
1712
|
event = createEvents([event])[0];
|
|
1711
1713
|
$.get(events)[idx] = event;
|
|
1714
|
+
mainState.events = [...$.get(events)];
|
|
1712
1715
|
return toEventWithLocalDates(event);
|
|
1713
1716
|
}
|
|
1714
1717
|
return null;
|
|
@@ -1718,6 +1721,7 @@ function Calendar($$anchor, $$props) {
|
|
|
1718
1721
|
let idx = $.get(events).findIndex((event) => event.id === id);
|
|
1719
1722
|
if (idx >= 0) {
|
|
1720
1723
|
$.get(events).splice(idx, 1);
|
|
1724
|
+
mainState.events = [...$.get(events)];
|
|
1721
1725
|
}
|
|
1722
1726
|
return this;
|
|
1723
1727
|
}
|
|
@@ -1765,17 +1769,27 @@ function Calendar($$anchor, $$props) {
|
|
|
1765
1769
|
var node = $.child(div);
|
|
1766
1770
|
Toolbar(node, {});
|
|
1767
1771
|
var node_1 = $.sibling(node, 2);
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1772
|
+
{
|
|
1773
|
+
var consequent = ($$anchor2) => {
|
|
1774
|
+
var fragment = $.comment();
|
|
1775
|
+
var node_2 = $.first_child(fragment);
|
|
1776
|
+
$.component(node_2, () => $.get(View2), ($$anchor3, View_12) => {
|
|
1777
|
+
View_12($$anchor3, {});
|
|
1778
|
+
});
|
|
1779
|
+
$.append($$anchor2, fragment);
|
|
1780
|
+
};
|
|
1781
|
+
$.if(node_1, ($$render) => {
|
|
1782
|
+
if ($.get(View2)) $$render(consequent);
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
var node_3 = $.sibling(node_1, 2);
|
|
1786
|
+
$.each(node_3, 17, () => $.get(auxComponents), $.index, ($$anchor2, AuxComponent) => {
|
|
1787
|
+
var fragment_1 = $.comment();
|
|
1788
|
+
var node_4 = $.first_child(fragment_1);
|
|
1789
|
+
$.component(node_4, () => $.get(AuxComponent), ($$anchor3, AuxComponent_1) => {
|
|
1776
1790
|
AuxComponent_1($$anchor3, {});
|
|
1777
1791
|
});
|
|
1778
|
-
$.append($$anchor2,
|
|
1792
|
+
$.append($$anchor2, fragment_1);
|
|
1779
1793
|
});
|
|
1780
1794
|
$.reset(div);
|
|
1781
1795
|
$.template_effect(
|
package/package.json
CHANGED
package/src/Calendar.svelte
CHANGED
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
export function addEvent(event) {
|
|
65
65
|
event = createEvents([event])[0];
|
|
66
66
|
events.push(event);
|
|
67
|
+
mainState.events = [...events];
|
|
67
68
|
return toEventWithLocalDates(event);
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -73,6 +74,7 @@
|
|
|
73
74
|
if (idx >= 0) {
|
|
74
75
|
event = createEvents([event])[0];
|
|
75
76
|
events[idx] = event;
|
|
77
|
+
mainState.events = [...events];
|
|
76
78
|
return toEventWithLocalDates(event);
|
|
77
79
|
}
|
|
78
80
|
return null;
|
|
@@ -83,6 +85,7 @@
|
|
|
83
85
|
let idx = events.findIndex(event => event.id === id);
|
|
84
86
|
if (idx >= 0) {
|
|
85
87
|
events.splice(idx, 1);
|
|
88
|
+
mainState.events = [...events];
|
|
86
89
|
}
|
|
87
90
|
return this;
|
|
88
91
|
}
|
|
@@ -128,7 +131,9 @@
|
|
|
128
131
|
role="{features.includes('list') ? 'list' : 'table'}"
|
|
129
132
|
>
|
|
130
133
|
<Toolbar/>
|
|
131
|
-
|
|
134
|
+
{#if View} <!-- temporary fix for https://github.com/sveltejs/kit/issues/15109 -->
|
|
135
|
+
<View/>
|
|
136
|
+
{/if}
|
|
132
137
|
{#each auxComponents as AuxComponent}
|
|
133
138
|
<AuxComponent/>
|
|
134
139
|
{/each}
|
|
@@ -139,8 +139,8 @@ export function optionsState(mainState, plugins, userOptions) {
|
|
|
139
139
|
userOptions = parseOptions(userOptions, parsers);
|
|
140
140
|
|
|
141
141
|
// Extract view-specific options
|
|
142
|
-
let
|
|
143
|
-
let
|
|
142
|
+
let defViewsOptions = extractOption(defOptions, 'views') ?? {};
|
|
143
|
+
let userViewsOptions = extractOption(userOptions, 'views') ?? {};
|
|
144
144
|
|
|
145
145
|
// Create options state
|
|
146
146
|
let options = new SvelteMap();
|
|
@@ -155,10 +155,11 @@ export function optionsState(mainState, plugins, userOptions) {
|
|
|
155
155
|
options.set('view', userOptions.view);
|
|
156
156
|
}
|
|
157
157
|
// Set options for each view
|
|
158
|
-
let views = new Set([...keys(
|
|
158
|
+
let views = new Set([...keys(defViewsOptions), ...keys(userViewsOptions)]);
|
|
159
159
|
for (let view of views) {
|
|
160
|
-
let
|
|
161
|
-
let
|
|
160
|
+
let userViewOptions = userViewsOptions[view] ?? {};
|
|
161
|
+
let defOpts = mergeOpts(defOptions, defViewsOptions[view] ?? defViewsOptions[userViewOptions.type] ?? {});
|
|
162
|
+
let opts = mergeOpts(defOpts, userOptions, userViewOptions);
|
|
162
163
|
let component = extractOption(opts, 'component');
|
|
163
164
|
// View has been set
|
|
164
165
|
delete opts.view;
|