@event-calendar/core 3.4.0 → 3.6.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 +53 -25
- package/index.js +97 -78
- package/package.json +2 -2
- package/src/Auxiliary.svelte +2 -3
- package/src/Calendar.svelte +0 -7
- package/src/lib/debounce.js +2 -2
- package/src/lib/dom.js +5 -0
- package/src/lib/events.js +16 -10
- package/src/lib/resources.js +2 -1
- package/src/lib/stores.js +3 -3
- package/src/lib/times.js +2 -3
- package/src/lib/utils.js +16 -0
- package/src/storage/options.js +1 -0
- package/src/storage/state.js +5 -5
- package/src/storage/stores.js +5 -5
package/README.md
CHANGED
|
@@ -61,6 +61,7 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
|
|
|
61
61
|
- [eventStartEditable](#eventstarteditable)
|
|
62
62
|
- [eventTextColor](#eventtextcolor)
|
|
63
63
|
- [eventTimeFormat](#eventtimeformat)
|
|
64
|
+
- [filterEventsWithResources](#filtereventswithresources)
|
|
64
65
|
- [filterResourcesWithEvents](#filterresourceswithevents)
|
|
65
66
|
- [firstDay](#firstday)
|
|
66
67
|
- [flexibleSlotTimeLimits](#flexibleslottimelimits)
|
|
@@ -143,7 +144,7 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
|
|
|
143
144
|
- [Browser support](#browser-support)
|
|
144
145
|
|
|
145
146
|
## Usage
|
|
146
|
-
###
|
|
147
|
+
### Pure JavaScript / Svelte component
|
|
147
148
|
The first step is to install the Event Calendar `core` package:
|
|
148
149
|
```bash
|
|
149
150
|
npm install --save-dev @event-calendar/core
|
|
@@ -161,27 +162,12 @@ You must use at least one plugin that provides a view. The following plugins are
|
|
|
161
162
|
* `@event-calendar/time-grid`
|
|
162
163
|
* `@event-calendar/interaction` (doesn't provide a view)
|
|
163
164
|
|
|
164
|
-
Then, in your
|
|
165
|
-
```html
|
|
166
|
-
<script>
|
|
167
|
-
import Calendar from '@event-calendar/core';
|
|
168
|
-
import TimeGrid from '@event-calendar/time-grid';
|
|
169
|
-
|
|
170
|
-
let plugins = [TimeGrid];
|
|
171
|
-
let options = {
|
|
172
|
-
view: 'timeGridWeek',
|
|
173
|
-
events: [
|
|
174
|
-
// your list of events
|
|
175
|
-
]
|
|
176
|
-
};
|
|
177
|
-
</script>
|
|
178
|
-
|
|
179
|
-
<Calendar {plugins} {options} />
|
|
180
|
-
```
|
|
181
|
-
Or in ES6 module:
|
|
165
|
+
Then, in your JavaScript module:
|
|
182
166
|
```js
|
|
183
167
|
import Calendar from '@event-calendar/core';
|
|
184
168
|
import TimeGrid from '@event-calendar/time-grid';
|
|
169
|
+
// Import CSS if your build tool supports it
|
|
170
|
+
import '@event-calendar/core/index.css';
|
|
185
171
|
|
|
186
172
|
let ec = new Calendar({
|
|
187
173
|
target: document.getElementById('ec'),
|
|
@@ -196,16 +182,29 @@ let ec = new Calendar({
|
|
|
196
182
|
}
|
|
197
183
|
});
|
|
198
184
|
```
|
|
199
|
-
|
|
200
|
-
```
|
|
201
|
-
|
|
185
|
+
Or in your Svelte component, use the calendar like this:
|
|
186
|
+
```html
|
|
187
|
+
<script>
|
|
188
|
+
import Calendar from '@event-calendar/core';
|
|
189
|
+
import TimeGrid from '@event-calendar/time-grid';
|
|
190
|
+
|
|
191
|
+
let plugins = [TimeGrid];
|
|
192
|
+
let options = {
|
|
193
|
+
view: 'timeGridWeek',
|
|
194
|
+
events: [
|
|
195
|
+
// your list of events
|
|
196
|
+
]
|
|
197
|
+
};
|
|
198
|
+
</script>
|
|
199
|
+
|
|
200
|
+
<Calendar {plugins} {options} />
|
|
202
201
|
```
|
|
203
202
|
|
|
204
203
|
### Pre-built browser ready bundle
|
|
205
204
|
Include the following lines of code in the `<head>` section of your page:
|
|
206
205
|
```html
|
|
207
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.
|
|
208
|
-
<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.6.0/event-calendar.min.css">
|
|
207
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.6.0/event-calendar.min.js"></script>
|
|
209
208
|
```
|
|
210
209
|
|
|
211
210
|
<details>
|
|
@@ -220,7 +219,7 @@ Include the following lines of code in the `<head>` section of your page:
|
|
|
220
219
|
|
|
221
220
|
</details>
|
|
222
221
|
|
|
223
|
-
Then initialize the calendar
|
|
222
|
+
Then initialize the calendar like this:
|
|
224
223
|
```js
|
|
225
224
|
let ec = new EventCalendar(document.getElementById('ec'), {
|
|
226
225
|
view: 'timeGridWeek',
|
|
@@ -1506,6 +1505,12 @@ Sets the default text color for events on the calendar.
|
|
|
1506
1505
|
|
|
1507
1506
|
You can use any of the CSS color formats such `'#f00'`, `'#ff0000'`, `'rgb(255,0,0)'`, or `'red'`.
|
|
1508
1507
|
|
|
1508
|
+
### filterEventsWithResources
|
|
1509
|
+
- Type `boolean`
|
|
1510
|
+
- Default `false`
|
|
1511
|
+
|
|
1512
|
+
Determines whether events that do not belong to the current array of [resources](#resources) should be hidden in `dayGrid`/`timeGrid`/`list` views.
|
|
1513
|
+
|
|
1509
1514
|
### filterResourcesWithEvents
|
|
1510
1515
|
- Type `boolean`
|
|
1511
1516
|
- Default `false`
|
|
@@ -2387,9 +2392,12 @@ Using this method, you can, for example, find out on which day a click occurred
|
|
|
2387
2392
|
|
|
2388
2393
|
### destroy()
|
|
2389
2394
|
- Return value `undefined`
|
|
2395
|
+
- Not available in Svelte
|
|
2390
2396
|
|
|
2391
2397
|
Destroys the calendar, removing all DOM elements, event handlers, and internal data.
|
|
2392
2398
|
|
|
2399
|
+
Please note that this method is not available in Svelte. Instead, the calendar is destroyed gracefully when the component containing it is destroyed.
|
|
2400
|
+
|
|
2393
2401
|
### getView()
|
|
2394
2402
|
- Return value `View`
|
|
2395
2403
|
|
|
@@ -2815,6 +2823,16 @@ The title of the resource. See [Content](#content)
|
|
|
2815
2823
|
</td>
|
|
2816
2824
|
<td>Default text color for this resource's events</td>
|
|
2817
2825
|
</tr>
|
|
2826
|
+
<tr>
|
|
2827
|
+
<td>
|
|
2828
|
+
|
|
2829
|
+
`extendedProps`
|
|
2830
|
+
</td>
|
|
2831
|
+
<td>
|
|
2832
|
+
|
|
2833
|
+
A plain object holding miscellaneous properties specified during parsing in the explicitly given `extendedProps` field
|
|
2834
|
+
</td>
|
|
2835
|
+
</tr>
|
|
2818
2836
|
</table>
|
|
2819
2837
|
|
|
2820
2838
|
### Parsing resource from a plain object
|
|
@@ -2862,6 +2880,16 @@ Here are all admissible fields for the resource’s input object:
|
|
|
2862
2880
|
`string` Sets the default text color for this resource's events just like the calendar-wide [eventTextColor](#eventtextcolor) option. Default `undefined`
|
|
2863
2881
|
</td>
|
|
2864
2882
|
</tr>
|
|
2883
|
+
<tr>
|
|
2884
|
+
<td>
|
|
2885
|
+
|
|
2886
|
+
`extendedProps`
|
|
2887
|
+
</td>
|
|
2888
|
+
<td>
|
|
2889
|
+
|
|
2890
|
+
`object` A plain object with any miscellaneous properties. It will be directly transferred to the `extendedProps` property of the Resource object. Default `{}`
|
|
2891
|
+
</td>
|
|
2892
|
+
</tr>
|
|
2865
2893
|
</table>
|
|
2866
2894
|
|
|
2867
2895
|
## View object
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getContext, setContext, beforeUpdate, afterUpdate } from 'svelte';
|
|
1
|
+
import { SvelteComponent, init, safe_not_equal, ensure_array_like, empty, insert, noop as noop$1, detach, destroy_each, component_subscribe, set_store_value, element, text, attr, append, listen as listen$1, set_data, is_function, action_destroyer, run_all, transition_in, group_outros, check_outros, transition_out, space, create_component, mount_component, destroy_component, construct_svelte_component, set_style } from 'svelte/internal';
|
|
2
|
+
import { tick, getContext, setContext, beforeUpdate, afterUpdate } from 'svelte';
|
|
3
3
|
import { derived, get, writable, readable } from 'svelte/store';
|
|
4
4
|
|
|
5
5
|
function keyEnter(fn) {
|
|
@@ -227,25 +227,6 @@ function _fromISOString(str) {
|
|
|
227
227
|
));
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
function debounce(fn, handle, queueStore) {
|
|
231
|
-
queueStore.update(queue => queue.set(handle, fn));
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function flushDebounce(queue) {
|
|
235
|
-
run_all(queue);
|
|
236
|
-
queue.clear();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function task(fn, handle, tasks) {
|
|
240
|
-
handle ??= fn;
|
|
241
|
-
if (!tasks.has(handle)) {
|
|
242
|
-
tasks.set(handle, setTimeout(() => {
|
|
243
|
-
tasks.delete(handle);
|
|
244
|
-
fn();
|
|
245
|
-
}));
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
230
|
function assign(...args) {
|
|
250
231
|
return Object.assign(...args);
|
|
251
232
|
}
|
|
@@ -278,6 +259,41 @@ function isArray(value) {
|
|
|
278
259
|
return Array.isArray(value);
|
|
279
260
|
}
|
|
280
261
|
|
|
262
|
+
function isFunction(value) {
|
|
263
|
+
return typeof value === 'function';
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function run(fn) {
|
|
267
|
+
return fn();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function runAll(fns) {
|
|
271
|
+
fns.forEach(run);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function noop() {}
|
|
275
|
+
|
|
276
|
+
const identity = (x) => x;
|
|
277
|
+
|
|
278
|
+
function debounce(fn, handle, queueStore) {
|
|
279
|
+
queueStore.update(queue => queue.set(handle, fn));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function flushDebounce(queue) {
|
|
283
|
+
runAll(queue);
|
|
284
|
+
queue.clear();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function task(fn, handle, tasks) {
|
|
288
|
+
handle ??= fn;
|
|
289
|
+
if (!tasks.has(handle)) {
|
|
290
|
+
tasks.set(handle, setTimeout(() => {
|
|
291
|
+
tasks.delete(handle);
|
|
292
|
+
fn();
|
|
293
|
+
}));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
281
297
|
function createElement(tag, className, content, attrs = []) {
|
|
282
298
|
let el = document.createElement(tag);
|
|
283
299
|
el.className = className;
|
|
@@ -342,6 +358,11 @@ function getElementWithPayload(x, y, root = document) {
|
|
|
342
358
|
return null;
|
|
343
359
|
}
|
|
344
360
|
|
|
361
|
+
function listen(node, event, handler, options) {
|
|
362
|
+
node.addEventListener(event, handler, options);
|
|
363
|
+
return () => node.removeEventListener(event, handler, options);
|
|
364
|
+
}
|
|
365
|
+
|
|
345
366
|
function createView(view, _viewTitle, _currentRange, _activeRange) {
|
|
346
367
|
return {
|
|
347
368
|
type: view,
|
|
@@ -447,7 +468,7 @@ function createEventContent(chunk, displayEventEnd, eventContent, theme, _intlEv
|
|
|
447
468
|
let content;
|
|
448
469
|
|
|
449
470
|
if (eventContent) {
|
|
450
|
-
content =
|
|
471
|
+
content = isFunction(eventContent)
|
|
451
472
|
? eventContent({
|
|
452
473
|
event: toEventWithLocalDates(chunk.event),
|
|
453
474
|
timeText,
|
|
@@ -489,7 +510,7 @@ function createTimeElement(timeText, chunk, theme) {
|
|
|
489
510
|
function createEventClasses(eventClassNames, event, _view) {
|
|
490
511
|
let result = event.classNames;
|
|
491
512
|
if (eventClassNames) {
|
|
492
|
-
if (
|
|
513
|
+
if (isFunction(eventClassNames)) {
|
|
493
514
|
eventClassNames = eventClassNames({
|
|
494
515
|
event: toEventWithLocalDates(event),
|
|
495
516
|
view: toViewWithLocalDates(_view)
|
|
@@ -613,17 +634,24 @@ function runReposition(refs, data) {
|
|
|
613
634
|
}
|
|
614
635
|
|
|
615
636
|
/**
|
|
616
|
-
* Check whether the event intersects with the given date range and
|
|
637
|
+
* Check whether the event intersects with the given date range and resources
|
|
617
638
|
* @param event
|
|
618
639
|
* @param start
|
|
619
640
|
* @param end
|
|
620
|
-
* @param
|
|
641
|
+
* @param resources
|
|
621
642
|
* @return boolean
|
|
622
643
|
*/
|
|
623
|
-
function eventIntersects(event, start, end,
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
644
|
+
function eventIntersects(event, start, end, resources) {
|
|
645
|
+
if (event.start < end && event.end > start) {
|
|
646
|
+
if (resources) {
|
|
647
|
+
if (!isArray(resources)) {
|
|
648
|
+
resources = [resources];
|
|
649
|
+
}
|
|
650
|
+
return resources.some(resource => event.resourceIds.includes(resource.id));
|
|
651
|
+
}
|
|
652
|
+
return true;
|
|
653
|
+
}
|
|
654
|
+
return false;
|
|
627
655
|
}
|
|
628
656
|
|
|
629
657
|
function helperEvent(display) {
|
|
@@ -679,7 +707,8 @@ function createResources(input) {
|
|
|
679
707
|
id: String(resource.id),
|
|
680
708
|
title: resource.title || '',
|
|
681
709
|
eventBackgroundColor: resource.eventBackgroundColor,
|
|
682
|
-
eventTextColor: resource.eventTextColor
|
|
710
|
+
eventTextColor: resource.eventTextColor,
|
|
711
|
+
extendedProps: resource.extendedProps ?? {}
|
|
683
712
|
}));
|
|
684
713
|
}
|
|
685
714
|
|
|
@@ -697,7 +726,7 @@ function findResource(event, resources) {
|
|
|
697
726
|
|
|
698
727
|
function intl(locale, format) {
|
|
699
728
|
return derived([locale, format], ([$locale, $format]) => {
|
|
700
|
-
let intl =
|
|
729
|
+
let intl = isFunction($format)
|
|
701
730
|
? {format: $format}
|
|
702
731
|
: new Intl.DateTimeFormat($locale, $format);
|
|
703
732
|
return {
|
|
@@ -709,7 +738,7 @@ function intl(locale, format) {
|
|
|
709
738
|
function intlRange(locale, format) {
|
|
710
739
|
return derived([locale, format], ([$locale, $format]) => {
|
|
711
740
|
let formatRange;
|
|
712
|
-
if (
|
|
741
|
+
if (isFunction($format)) {
|
|
713
742
|
formatRange = $format;
|
|
714
743
|
} else {
|
|
715
744
|
let intl = new Intl.DateTimeFormat($locale, $format);
|
|
@@ -815,7 +844,7 @@ function createSlotTimeLimits($slotMinTime, $slotMaxTime, $flexibleSlotTimeLimit
|
|
|
815
844
|
// If slotMaxTime goes past midnight, then extend it back by a maximum of 24 hours
|
|
816
845
|
let minMin = createDuration(min(toSeconds(min$1), max(0, toSeconds(max$1) - DAY_IN_SECONDS)));
|
|
817
846
|
let maxMax = createDuration(max(toSeconds(max$1), toSeconds(minMin) + DAY_IN_SECONDS));
|
|
818
|
-
let filter =
|
|
847
|
+
let filter = isFunction($flexibleSlotTimeLimits?.eventFilter)
|
|
819
848
|
? $flexibleSlotTimeLimits.eventFilter
|
|
820
849
|
: event => !bgEvent(event.display);
|
|
821
850
|
loop: for (let date of $_viewDates) {
|
|
@@ -884,6 +913,7 @@ function createOptions(plugins) {
|
|
|
884
913
|
hour: 'numeric',
|
|
885
914
|
minute: '2-digit'
|
|
886
915
|
},
|
|
916
|
+
filterEventsWithResources: false,
|
|
887
917
|
filterResourcesWithEvents: false,
|
|
888
918
|
firstDay: 0,
|
|
889
919
|
flexibleSlotTimeLimits: false, // ec option
|
|
@@ -1114,11 +1144,11 @@ function events(state) {
|
|
|
1114
1144
|
// Create new abort controller
|
|
1115
1145
|
abortController = new AbortController();
|
|
1116
1146
|
// Call loading hook
|
|
1117
|
-
if (
|
|
1147
|
+
if (isFunction($loading) && !fetching) {
|
|
1118
1148
|
$loading(true);
|
|
1119
1149
|
}
|
|
1120
1150
|
let stopLoading = () => {
|
|
1121
|
-
if (--fetching === 0 &&
|
|
1151
|
+
if (--fetching === 0 && isFunction($loading)) {
|
|
1122
1152
|
$loading(false);
|
|
1123
1153
|
}
|
|
1124
1154
|
};
|
|
@@ -1135,7 +1165,7 @@ function events(state) {
|
|
|
1135
1165
|
let endStr = toISOString($_activeRange.end);
|
|
1136
1166
|
// Loop over event sources
|
|
1137
1167
|
for (let source of $eventSources) {
|
|
1138
|
-
if (
|
|
1168
|
+
if (isFunction(source.events)) {
|
|
1139
1169
|
// Events as a function
|
|
1140
1170
|
let result = source.events({
|
|
1141
1171
|
start: toLocalDate($_activeRange.start),
|
|
@@ -1149,7 +1179,7 @@ function events(state) {
|
|
|
1149
1179
|
} else {
|
|
1150
1180
|
// Events as a JSON feed
|
|
1151
1181
|
// Prepare params
|
|
1152
|
-
let params =
|
|
1182
|
+
let params = isFunction(source.extraParams) ? source.extraParams() : assign({}, source.extraParams);
|
|
1153
1183
|
params.start = startStr;
|
|
1154
1184
|
params.end = endStr;
|
|
1155
1185
|
params = new URLSearchParams(params);
|
|
@@ -1277,7 +1307,7 @@ class State {
|
|
|
1277
1307
|
// Set value in all views
|
|
1278
1308
|
set: ['buttonText', 'theme'].includes(key)
|
|
1279
1309
|
? value => {
|
|
1280
|
-
if (
|
|
1310
|
+
if (isFunction(value)) {
|
|
1281
1311
|
let result = value(defOpts[key]);
|
|
1282
1312
|
opts[key] = result;
|
|
1283
1313
|
set(set === _set ? result : value);
|
|
@@ -1299,7 +1329,7 @@ class State {
|
|
|
1299
1329
|
if (newView === view) {
|
|
1300
1330
|
// switch view component
|
|
1301
1331
|
this._viewComponent.set(component);
|
|
1302
|
-
if (
|
|
1332
|
+
if (isFunction(opts.viewDidMount)) {
|
|
1303
1333
|
tick().then(() => opts.viewDidMount(get(this._view)));
|
|
1304
1334
|
}
|
|
1305
1335
|
// update store values
|
|
@@ -1333,7 +1363,7 @@ function mergeOpts(...args) {
|
|
|
1333
1363
|
for (let opts of args) {
|
|
1334
1364
|
let override = {};
|
|
1335
1365
|
for (let key of ['buttonText', 'theme']) {
|
|
1336
|
-
if (
|
|
1366
|
+
if (isFunction(opts[key])) {
|
|
1337
1367
|
override[key] = opts[key](result[key]);
|
|
1338
1368
|
}
|
|
1339
1369
|
}
|
|
@@ -1356,7 +1386,7 @@ function validKey(key, state) {
|
|
|
1356
1386
|
return state.hasOwnProperty(key) && key[0] !== '_';
|
|
1357
1387
|
}
|
|
1358
1388
|
|
|
1359
|
-
/* packages/core/src/Buttons.svelte generated by Svelte v4.2.
|
|
1389
|
+
/* packages/core/src/Buttons.svelte generated by Svelte v4.2.19 */
|
|
1360
1390
|
|
|
1361
1391
|
function get_each_context$2(ctx, list, i) {
|
|
1362
1392
|
const child_ctx = ctx.slice();
|
|
@@ -1391,7 +1421,7 @@ function create_if_block_5(ctx) {
|
|
|
1391
1421
|
append(button_1, t);
|
|
1392
1422
|
|
|
1393
1423
|
if (!mounted) {
|
|
1394
|
-
dispose = listen(button_1, "click", click_handler_1);
|
|
1424
|
+
dispose = listen$1(button_1, "click", click_handler_1);
|
|
1395
1425
|
mounted = true;
|
|
1396
1426
|
}
|
|
1397
1427
|
},
|
|
@@ -1437,7 +1467,7 @@ function create_if_block_4(ctx) {
|
|
|
1437
1467
|
|
|
1438
1468
|
if (!mounted) {
|
|
1439
1469
|
dispose = [
|
|
1440
|
-
listen(button_1, "click", function () {
|
|
1470
|
+
listen$1(button_1, "click", function () {
|
|
1441
1471
|
if (is_function(/*$customButtons*/ ctx[6][/*button*/ ctx[25]].click)) /*$customButtons*/ ctx[6][/*button*/ ctx[25]].click.apply(this, arguments);
|
|
1442
1472
|
}),
|
|
1443
1473
|
action_destroyer(setContent_action = setContent.call(null, button_1, /*$customButtons*/ ctx[6][/*button*/ ctx[25]].text))
|
|
@@ -1489,7 +1519,7 @@ function create_if_block_3(ctx) {
|
|
|
1489
1519
|
append(button_1, t);
|
|
1490
1520
|
|
|
1491
1521
|
if (!mounted) {
|
|
1492
|
-
dispose = listen(button_1, "click", /*click_handler*/ ctx[21]);
|
|
1522
|
+
dispose = listen$1(button_1, "click", /*click_handler*/ ctx[21]);
|
|
1493
1523
|
mounted = true;
|
|
1494
1524
|
}
|
|
1495
1525
|
},
|
|
@@ -1540,7 +1570,7 @@ function create_if_block_2(ctx) {
|
|
|
1540
1570
|
append(button_1, i);
|
|
1541
1571
|
|
|
1542
1572
|
if (!mounted) {
|
|
1543
|
-
dispose = listen(button_1, "click", /*next*/ ctx[19]);
|
|
1573
|
+
dispose = listen$1(button_1, "click", /*next*/ ctx[19]);
|
|
1544
1574
|
mounted = true;
|
|
1545
1575
|
}
|
|
1546
1576
|
},
|
|
@@ -1597,7 +1627,7 @@ function create_if_block_1(ctx) {
|
|
|
1597
1627
|
append(button_1, i);
|
|
1598
1628
|
|
|
1599
1629
|
if (!mounted) {
|
|
1600
|
-
dispose = listen(button_1, "click", /*prev*/ ctx[18]);
|
|
1630
|
+
dispose = listen$1(button_1, "click", /*prev*/ ctx[18]);
|
|
1601
1631
|
mounted = true;
|
|
1602
1632
|
}
|
|
1603
1633
|
},
|
|
@@ -1768,8 +1798,8 @@ function create_fragment$3(ctx) {
|
|
|
1768
1798
|
each_blocks.length = each_value.length;
|
|
1769
1799
|
}
|
|
1770
1800
|
},
|
|
1771
|
-
i: noop,
|
|
1772
|
-
o: noop,
|
|
1801
|
+
i: noop$1,
|
|
1802
|
+
o: noop$1,
|
|
1773
1803
|
d(detaching) {
|
|
1774
1804
|
if (detaching) {
|
|
1775
1805
|
detach(each_1_anchor);
|
|
@@ -1858,7 +1888,7 @@ class Buttons extends SvelteComponent {
|
|
|
1858
1888
|
}
|
|
1859
1889
|
}
|
|
1860
1890
|
|
|
1861
|
-
/* packages/core/src/Toolbar.svelte generated by Svelte v4.2.
|
|
1891
|
+
/* packages/core/src/Toolbar.svelte generated by Svelte v4.2.19 */
|
|
1862
1892
|
|
|
1863
1893
|
function get_each_context$1(ctx, list, i) {
|
|
1864
1894
|
const child_ctx = ctx.slice();
|
|
@@ -2250,7 +2280,7 @@ class Toolbar extends SvelteComponent {
|
|
|
2250
2280
|
}
|
|
2251
2281
|
}
|
|
2252
2282
|
|
|
2253
|
-
/* packages/core/src/Auxiliary.svelte generated by Svelte v4.2.
|
|
2283
|
+
/* packages/core/src/Auxiliary.svelte generated by Svelte v4.2.19 */
|
|
2254
2284
|
|
|
2255
2285
|
function get_each_context(ctx, list, i) {
|
|
2256
2286
|
const child_ctx = ctx.slice();
|
|
@@ -2258,7 +2288,7 @@ function get_each_context(ctx, list, i) {
|
|
|
2258
2288
|
return child_ctx;
|
|
2259
2289
|
}
|
|
2260
2290
|
|
|
2261
|
-
// (
|
|
2291
|
+
// (24:0) {#each $_auxiliary as component}
|
|
2262
2292
|
function create_each_block(ctx) {
|
|
2263
2293
|
let switch_instance;
|
|
2264
2294
|
let switch_instance_anchor;
|
|
@@ -2426,7 +2456,7 @@ function instance$1($$self, $$props, $$invalidate) {
|
|
|
2426
2456
|
let debounceHandle = {};
|
|
2427
2457
|
|
|
2428
2458
|
function runDatesSet(_activeRange) {
|
|
2429
|
-
if (
|
|
2459
|
+
if (isFunction($datesSet)) {
|
|
2430
2460
|
debounce(
|
|
2431
2461
|
() => $datesSet({
|
|
2432
2462
|
start: toLocalDate(_activeRange.start),
|
|
@@ -2458,7 +2488,7 @@ class Auxiliary extends SvelteComponent {
|
|
|
2458
2488
|
}
|
|
2459
2489
|
}
|
|
2460
2490
|
|
|
2461
|
-
/* packages/core/src/Calendar.svelte generated by Svelte v4.2.
|
|
2491
|
+
/* packages/core/src/Calendar.svelte generated by Svelte v4.2.19 */
|
|
2462
2492
|
|
|
2463
2493
|
function create_fragment(ctx) {
|
|
2464
2494
|
let div;
|
|
@@ -2513,7 +2543,7 @@ function create_fragment(ctx) {
|
|
|
2513
2543
|
current = true;
|
|
2514
2544
|
|
|
2515
2545
|
if (!mounted) {
|
|
2516
|
-
dispose = listen(window, "resize", /*recheckScrollable*/ ctx[20]);
|
|
2546
|
+
dispose = listen$1(window, "resize", /*recheckScrollable*/ ctx[20]);
|
|
2517
2547
|
mounted = true;
|
|
2518
2548
|
}
|
|
2519
2549
|
},
|
|
@@ -2601,21 +2631,20 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
2601
2631
|
let $_viewComponent;
|
|
2602
2632
|
let { plugins = [] } = $$props;
|
|
2603
2633
|
let { options = {} } = $$props;
|
|
2604
|
-
let component = get_current_component();
|
|
2605
2634
|
let state = new State(plugins, options);
|
|
2606
2635
|
setContext('state', state);
|
|
2607
2636
|
let { _viewComponent, _bodyEl, _interaction, _iClass, _events, _queue, _queue2, _tasks, _scrollable, date, duration, hiddenDays, height, theme, view } = state;
|
|
2608
2637
|
component_subscribe($$self, _viewComponent, value => $$invalidate(5, $_viewComponent = value));
|
|
2609
|
-
component_subscribe($$self, _bodyEl, value => $$invalidate(
|
|
2610
|
-
component_subscribe($$self, _interaction, value => $$invalidate(
|
|
2638
|
+
component_subscribe($$self, _bodyEl, value => $$invalidate(36, $_bodyEl = value));
|
|
2639
|
+
component_subscribe($$self, _interaction, value => $$invalidate(42, $_interaction = value));
|
|
2611
2640
|
component_subscribe($$self, _iClass, value => $$invalidate(2, $_iClass = value));
|
|
2612
|
-
component_subscribe($$self, _events, value => $$invalidate(
|
|
2613
|
-
component_subscribe($$self, _queue, value => $$invalidate(
|
|
2614
|
-
component_subscribe($$self, _queue2, value => $$invalidate(
|
|
2641
|
+
component_subscribe($$self, _events, value => $$invalidate(43, $_events = value));
|
|
2642
|
+
component_subscribe($$self, _queue, value => $$invalidate(38, $_queue = value));
|
|
2643
|
+
component_subscribe($$self, _queue2, value => $$invalidate(37, $_queue2 = value));
|
|
2615
2644
|
component_subscribe($$self, _scrollable, value => $$invalidate(0, $_scrollable = value));
|
|
2616
|
-
component_subscribe($$self, date, value => $$invalidate(
|
|
2617
|
-
component_subscribe($$self, duration, value => $$invalidate(
|
|
2618
|
-
component_subscribe($$self, hiddenDays, value => $$invalidate(
|
|
2645
|
+
component_subscribe($$self, date, value => $$invalidate(41, $date = value));
|
|
2646
|
+
component_subscribe($$self, duration, value => $$invalidate(40, $duration = value));
|
|
2647
|
+
component_subscribe($$self, hiddenDays, value => $$invalidate(39, $hiddenDays = value));
|
|
2619
2648
|
component_subscribe($$self, height, value => $$invalidate(3, $height = value));
|
|
2620
2649
|
component_subscribe($$self, theme, value => $$invalidate(1, $theme = value));
|
|
2621
2650
|
component_subscribe($$self, view, value => $$invalidate(4, $view = value));
|
|
@@ -2704,10 +2733,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
2704
2733
|
return null;
|
|
2705
2734
|
}
|
|
2706
2735
|
|
|
2707
|
-
function destroy() {
|
|
2708
|
-
destroy_component(component, true);
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
2736
|
function next() {
|
|
2712
2737
|
set_store_value(date, $date = nextDate($date, $duration), $date);
|
|
2713
2738
|
return this;
|
|
@@ -2781,7 +2806,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
2781
2806
|
getView,
|
|
2782
2807
|
unselect,
|
|
2783
2808
|
dateFromPoint,
|
|
2784
|
-
destroy,
|
|
2785
2809
|
next,
|
|
2786
2810
|
prev
|
|
2787
2811
|
];
|
|
@@ -2811,9 +2835,8 @@ class Calendar extends SvelteComponent {
|
|
|
2811
2835
|
getView: 31,
|
|
2812
2836
|
unselect: 32,
|
|
2813
2837
|
dateFromPoint: 33,
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
prev: 36
|
|
2838
|
+
next: 34,
|
|
2839
|
+
prev: 35
|
|
2817
2840
|
},
|
|
2818
2841
|
null,
|
|
2819
2842
|
[-1, -1]
|
|
@@ -2864,17 +2887,13 @@ class Calendar extends SvelteComponent {
|
|
|
2864
2887
|
return this.$$.ctx[33];
|
|
2865
2888
|
}
|
|
2866
2889
|
|
|
2867
|
-
get destroy() {
|
|
2868
|
-
return this.$$.ctx[34];
|
|
2869
|
-
}
|
|
2870
|
-
|
|
2871
2890
|
get next() {
|
|
2872
|
-
return this.$$.ctx[
|
|
2891
|
+
return this.$$.ctx[34];
|
|
2873
2892
|
}
|
|
2874
2893
|
|
|
2875
2894
|
get prev() {
|
|
2876
|
-
return this.$$.ctx[
|
|
2895
|
+
return this.$$.ctx[35];
|
|
2877
2896
|
}
|
|
2878
2897
|
}
|
|
2879
2898
|
|
|
2880
|
-
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, isArray, keyEnter, keys, listView, max, min, nextClosestDay, nextDate, noTimePart, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, prevDate, previewEvent, rect, repositionEvent, resourceBackgroundColor, resourceTextColor, runReposition, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, task, themeView, timelineView, toEventWithLocalDates, toISOString, toLocalDate, toSeconds, toViewWithLocalDates, viewResources };
|
|
2899
|
+
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, 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@event-calendar/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"title": "Event Calendar Core package",
|
|
5
5
|
"description": "Full-sized drag & drop event calendar with resource & timeline views",
|
|
6
6
|
"keywords": [
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"svelte": "^4.2.
|
|
31
|
+
"svelte": "^4.2.19"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/Auxiliary.svelte
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {getContext} from 'svelte';
|
|
3
|
-
import {
|
|
4
|
-
import {debounce, toISOString, toLocalDate, toViewWithLocalDates} from './lib.js';
|
|
3
|
+
import {debounce, toISOString, toLocalDate, toViewWithLocalDates, isFunction} from './lib.js';
|
|
5
4
|
|
|
6
5
|
let {datesSet, _auxiliary, _activeRange, _queue, _view} = getContext('state');
|
|
7
6
|
|
|
@@ -10,7 +9,7 @@
|
|
|
10
9
|
|
|
11
10
|
let debounceHandle = {};
|
|
12
11
|
function runDatesSet(_activeRange) {
|
|
13
|
-
if (
|
|
12
|
+
if (isFunction($datesSet)) {
|
|
14
13
|
debounce(() => $datesSet({
|
|
15
14
|
start: toLocalDate(_activeRange.start),
|
|
16
15
|
end: toLocalDate(_activeRange.end),
|
package/src/Calendar.svelte
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import '../index.css';
|
|
3
3
|
import {setContext, beforeUpdate, afterUpdate} from 'svelte';
|
|
4
|
-
import {destroy_component, get_current_component} from 'svelte/internal';
|
|
5
4
|
import {get} from 'svelte/store';
|
|
6
5
|
import {diff} from './storage/options';
|
|
7
6
|
import State from './storage/state';
|
|
@@ -24,8 +23,6 @@
|
|
|
24
23
|
export let plugins = [];
|
|
25
24
|
export let options = {};
|
|
26
25
|
|
|
27
|
-
let component = get_current_component();
|
|
28
|
-
|
|
29
26
|
let state = new State(plugins, options);
|
|
30
27
|
setContext('state', state);
|
|
31
28
|
|
|
@@ -114,10 +111,6 @@
|
|
|
114
111
|
return null;
|
|
115
112
|
}
|
|
116
113
|
|
|
117
|
-
export function destroy() {
|
|
118
|
-
destroy_component(component, true);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
114
|
export function next() {
|
|
122
115
|
$date = nextDate($date, $duration);
|
|
123
116
|
return this;
|
package/src/lib/debounce.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {runAll} from './utils.js';
|
|
2
2
|
|
|
3
3
|
export function debounce(fn, handle, queueStore) {
|
|
4
4
|
queueStore.update(queue => queue.set(handle, fn));
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function flushDebounce(queue) {
|
|
8
|
-
|
|
8
|
+
runAll(queue);
|
|
9
9
|
queue.clear();
|
|
10
10
|
}
|
|
11
11
|
|
package/src/lib/dom.js
CHANGED
|
@@ -63,3 +63,8 @@ export function getElementWithPayload(x, y, root = document) {
|
|
|
63
63
|
}
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
export function listen(node, event, handler, options) {
|
|
68
|
+
node.addEventListener(event, handler, options);
|
|
69
|
+
return () => node.removeEventListener(event, handler, options);
|
|
70
|
+
}
|
package/src/lib/events.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {addDay, datesEqual, createDate, cloneDate, setMidnight, toLocalDate, toISOString, noTimePart, copyTime} from './date';
|
|
2
2
|
import {createElement} from './dom';
|
|
3
|
-
import {assign, isArray} from './utils';
|
|
3
|
+
import {assign, isArray, isFunction} from './utils';
|
|
4
4
|
import {toViewWithLocalDates} from './view';
|
|
5
|
-
import {is_function} from 'svelte/internal';
|
|
6
5
|
|
|
7
6
|
let eventId = 1;
|
|
8
7
|
export function createEvents(input) {
|
|
@@ -79,7 +78,7 @@ export function createEventContent(chunk, displayEventEnd, eventContent, theme,
|
|
|
79
78
|
let content;
|
|
80
79
|
|
|
81
80
|
if (eventContent) {
|
|
82
|
-
content =
|
|
81
|
+
content = isFunction(eventContent)
|
|
83
82
|
? eventContent({
|
|
84
83
|
event: toEventWithLocalDates(chunk.event),
|
|
85
84
|
timeText,
|
|
@@ -121,7 +120,7 @@ function createTimeElement(timeText, chunk, theme) {
|
|
|
121
120
|
export function createEventClasses(eventClassNames, event, _view) {
|
|
122
121
|
let result = event.classNames;
|
|
123
122
|
if (eventClassNames) {
|
|
124
|
-
if (
|
|
123
|
+
if (isFunction(eventClassNames)) {
|
|
125
124
|
eventClassNames = eventClassNames({
|
|
126
125
|
event: toEventWithLocalDates(event),
|
|
127
126
|
view: toViewWithLocalDates(_view)
|
|
@@ -245,17 +244,24 @@ export function runReposition(refs, data) {
|
|
|
245
244
|
}
|
|
246
245
|
|
|
247
246
|
/**
|
|
248
|
-
* Check whether the event intersects with the given date range and
|
|
247
|
+
* Check whether the event intersects with the given date range and resources
|
|
249
248
|
* @param event
|
|
250
249
|
* @param start
|
|
251
250
|
* @param end
|
|
252
|
-
* @param
|
|
251
|
+
* @param resources
|
|
253
252
|
* @return boolean
|
|
254
253
|
*/
|
|
255
|
-
export function eventIntersects(event, start, end,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
export function eventIntersects(event, start, end, resources) {
|
|
255
|
+
if (event.start < end && event.end > start) {
|
|
256
|
+
if (resources) {
|
|
257
|
+
if (!isArray(resources)) {
|
|
258
|
+
resources = [resources];
|
|
259
|
+
}
|
|
260
|
+
return resources.some(resource => event.resourceIds.includes(resource.id));
|
|
261
|
+
}
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
return false;
|
|
259
265
|
}
|
|
260
266
|
|
|
261
267
|
export function helperEvent(display) {
|
package/src/lib/resources.js
CHANGED
|
@@ -3,7 +3,8 @@ export function createResources(input) {
|
|
|
3
3
|
id: String(resource.id),
|
|
4
4
|
title: resource.title || '',
|
|
5
5
|
eventBackgroundColor: resource.eventBackgroundColor,
|
|
6
|
-
eventTextColor: resource.eventTextColor
|
|
6
|
+
eventTextColor: resource.eventTextColor,
|
|
7
|
+
extendedProps: resource.extendedProps ?? {}
|
|
7
8
|
}));
|
|
8
9
|
}
|
|
9
10
|
|
package/src/lib/stores.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {derived} from 'svelte/store';
|
|
2
|
-
import {
|
|
2
|
+
import {isFunction} from './utils.js';
|
|
3
3
|
import {toLocalDate} from './date';
|
|
4
4
|
import {createResources} from './resources.js';
|
|
5
5
|
|
|
6
6
|
export function intl(locale, format) {
|
|
7
7
|
return derived([locale, format], ([$locale, $format]) => {
|
|
8
|
-
let intl =
|
|
8
|
+
let intl = isFunction($format)
|
|
9
9
|
? {format: $format}
|
|
10
10
|
: new Intl.DateTimeFormat($locale, $format);
|
|
11
11
|
return {
|
|
@@ -17,7 +17,7 @@ export function intl(locale, format) {
|
|
|
17
17
|
export function intlRange(locale, format) {
|
|
18
18
|
return derived([locale, format], ([$locale, $format]) => {
|
|
19
19
|
let formatRange;
|
|
20
|
-
if (
|
|
20
|
+
if (isFunction($format)) {
|
|
21
21
|
formatRange = $format;
|
|
22
22
|
} else {
|
|
23
23
|
let intl = new Intl.DateTimeFormat($locale, $format);
|
package/src/lib/times.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {is_function} from 'svelte/internal';
|
|
2
1
|
import {addDuration, cloneDate, createDuration, DAY_IN_SECONDS, toISOString, toSeconds} from './date.js';
|
|
3
|
-
import {max as maxFn, min as minFn} from './utils.js';
|
|
2
|
+
import {max as maxFn, min as minFn, isFunction} from './utils.js';
|
|
4
3
|
import {bgEvent} from './events.js';
|
|
5
4
|
|
|
6
5
|
export function createTimes(date, $slotDuration, $_slotTimeLimits, $_intlSlotLabel) {
|
|
@@ -32,7 +31,7 @@ export function createSlotTimeLimits($slotMinTime, $slotMaxTime, $flexibleSlotTi
|
|
|
32
31
|
// If slotMaxTime goes past midnight, then extend it back by a maximum of 24 hours
|
|
33
32
|
let minMin = createDuration(minFn(toSeconds(min), maxFn(0, toSeconds(max) - DAY_IN_SECONDS)));
|
|
34
33
|
let maxMax = createDuration(maxFn(toSeconds(max), toSeconds(minMin) + DAY_IN_SECONDS));
|
|
35
|
-
let filter =
|
|
34
|
+
let filter = isFunction($flexibleSlotTimeLimits?.eventFilter)
|
|
36
35
|
? $flexibleSlotTimeLimits.eventFilter
|
|
37
36
|
: event => !bgEvent(event.display);
|
|
38
37
|
loop: for (let date of $_viewDates) {
|
package/src/lib/utils.js
CHANGED
|
@@ -29,3 +29,19 @@ export function symbol() {
|
|
|
29
29
|
export function isArray(value) {
|
|
30
30
|
return Array.isArray(value);
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
export function isFunction(value) {
|
|
34
|
+
return typeof value === 'function';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function run(fn) {
|
|
38
|
+
return fn();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function runAll(fns) {
|
|
42
|
+
fns.forEach(run);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function noop() {}
|
|
46
|
+
|
|
47
|
+
export const identity = (x) => x;
|
package/src/storage/options.js
CHANGED
package/src/storage/state.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {get, writable} from 'svelte/store';
|
|
2
|
-
import {
|
|
2
|
+
import {tick} from 'svelte';
|
|
3
3
|
import {createOptions, createParsers} from './options';
|
|
4
4
|
import {
|
|
5
5
|
activeRange,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
viewTitle,
|
|
13
13
|
view as view2 // hack to avoid a runtime error in SvelteKit dev mode (ReferenceError: view is not defined)
|
|
14
14
|
} from './stores';
|
|
15
|
-
import {keys, intl, intlRange} from '../lib.js';
|
|
15
|
+
import {keys, intl, intlRange, isFunction, identity} from '../lib.js';
|
|
16
16
|
|
|
17
17
|
export default class {
|
|
18
18
|
constructor(plugins, input) {
|
|
@@ -97,7 +97,7 @@ export default class {
|
|
|
97
97
|
// Set value in all views
|
|
98
98
|
set: ['buttonText', 'theme'].includes(key)
|
|
99
99
|
? value => {
|
|
100
|
-
if (
|
|
100
|
+
if (isFunction(value)) {
|
|
101
101
|
let result = value(defOpts[key]);
|
|
102
102
|
opts[key] = result;
|
|
103
103
|
set(set === _set ? result : value);
|
|
@@ -119,7 +119,7 @@ export default class {
|
|
|
119
119
|
if (newView === view) {
|
|
120
120
|
// switch view component
|
|
121
121
|
this._viewComponent.set(component);
|
|
122
|
-
if (
|
|
122
|
+
if (isFunction(opts.viewDidMount)) {
|
|
123
123
|
tick().then(() => opts.viewDidMount(get(this._view)));
|
|
124
124
|
}
|
|
125
125
|
// update store values
|
|
@@ -153,7 +153,7 @@ function mergeOpts(...args) {
|
|
|
153
153
|
for (let opts of args) {
|
|
154
154
|
let override = {};
|
|
155
155
|
for (let key of ['buttonText', 'theme']) {
|
|
156
|
-
if (
|
|
156
|
+
if (isFunction(opts[key])) {
|
|
157
157
|
override[key] = opts[key](result[key]);
|
|
158
158
|
}
|
|
159
159
|
}
|
package/src/storage/stores.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {derived, writable, readable, get} from 'svelte/store';
|
|
2
|
-
import {
|
|
2
|
+
import {isFunction} from '../lib/utils.js';
|
|
3
3
|
import {
|
|
4
4
|
DAY_IN_SECONDS,
|
|
5
5
|
assign,
|
|
@@ -127,11 +127,11 @@ export function events(state) {
|
|
|
127
127
|
// Create new abort controller
|
|
128
128
|
abortController = new AbortController();
|
|
129
129
|
// Call loading hook
|
|
130
|
-
if (
|
|
130
|
+
if (isFunction($loading) && !fetching) {
|
|
131
131
|
$loading(true);
|
|
132
132
|
}
|
|
133
133
|
let stopLoading = () => {
|
|
134
|
-
if (--fetching === 0 &&
|
|
134
|
+
if (--fetching === 0 && isFunction($loading)) {
|
|
135
135
|
$loading(false);
|
|
136
136
|
}
|
|
137
137
|
};
|
|
@@ -148,7 +148,7 @@ export function events(state) {
|
|
|
148
148
|
let endStr = toISOString($_activeRange.end);
|
|
149
149
|
// Loop over event sources
|
|
150
150
|
for (let source of $eventSources) {
|
|
151
|
-
if (
|
|
151
|
+
if (isFunction(source.events)) {
|
|
152
152
|
// Events as a function
|
|
153
153
|
let result = source.events({
|
|
154
154
|
start: toLocalDate($_activeRange.start),
|
|
@@ -162,7 +162,7 @@ export function events(state) {
|
|
|
162
162
|
} else {
|
|
163
163
|
// Events as a JSON feed
|
|
164
164
|
// Prepare params
|
|
165
|
-
let params =
|
|
165
|
+
let params = isFunction(source.extraParams) ? source.extraParams() : assign({}, source.extraParams);
|
|
166
166
|
params.start = startStr;
|
|
167
167
|
params.end = endStr;
|
|
168
168
|
params = new URLSearchParams(params);
|