@event-calendar/core 0.16.1 → 0.17.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 -4
- package/index.css +5 -3
- package/index.js +70 -48
- package/package.json +2 -2
- package/src/Calendar.svelte +17 -5
- package/src/index.scss +7 -4
- package/src/storage/state.js +2 -0
- package/src/storage/stores.js +14 -11
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Event Calendar [](https://www.jsdelivr.com/package/npm/@event-calendar/build) [](https://www.npmjs.com/package/@event-calendar/core)
|
|
1
|
+
# Event Calendar [](https://www.jsdelivr.com/package/npm/@event-calendar/build) [](https://www.npmjs.com/package/@event-calendar/core)
|
|
2
2
|
|
|
3
3
|
See [demo](https://vkurko.github.io/calendar/) and [changelog](CHANGELOG.md).
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ Full-sized drag & drop JavaScript event calendar with resource view:
|
|
|
6
6
|
|
|
7
7
|
* Lightweight (37kb [br](https://en.wikipedia.org/wiki/Brotli) compressed)
|
|
8
8
|
* Zero-dependency (pre-built bundle)
|
|
9
|
-
* Used
|
|
9
|
+
* Used on over 60,000 websites with [Bookly](https://wordpress.org/plugins/bookly-responsive-appointment-booking-tool/)
|
|
10
10
|
|
|
11
11
|
Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options.
|
|
12
12
|
|
|
@@ -117,6 +117,7 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
|
|
|
117
117
|
</td><td>
|
|
118
118
|
|
|
119
119
|
- [dateFromPoint](#datefrompoint-x-y-)
|
|
120
|
+
- [destroy](#destroy)
|
|
120
121
|
- [getView](#getview)
|
|
121
122
|
- [unselect](#unselect-1)
|
|
122
123
|
</td></tr>
|
|
@@ -191,8 +192,8 @@ import '@event-calendar/core/index.css';
|
|
|
191
192
|
### Pre-built browser ready bundle
|
|
192
193
|
Include the following lines of code in the `<head>` section of your page:
|
|
193
194
|
```html
|
|
194
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.
|
|
195
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.
|
|
195
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.17.1/event-calendar.min.css">
|
|
196
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.17.1/event-calendar.min.js"></script>
|
|
196
197
|
```
|
|
197
198
|
|
|
198
199
|
<details>
|
|
@@ -475,6 +476,7 @@ Determines whether to display an event’s end time.
|
|
|
475
476
|
### dragScroll
|
|
476
477
|
- Type `boolean`
|
|
477
478
|
- Default `true`
|
|
479
|
+
- Requires `Interaction` plugin
|
|
478
480
|
|
|
479
481
|
Determines whether the calendar should automatically scroll during the event drag-and-drop when the mouse crosses the edge.
|
|
480
482
|
|
|
@@ -499,6 +501,7 @@ This should be a value that can be parsed into a [Duration](#duration-object) ob
|
|
|
499
501
|
### editable
|
|
500
502
|
- Type `boolean`
|
|
501
503
|
- Default `false`
|
|
504
|
+
- Requires `Interaction` plugin
|
|
502
505
|
|
|
503
506
|
Determines whether the events on the calendar can be dragged and resized (both at the same time).
|
|
504
507
|
|
|
@@ -667,12 +670,14 @@ The current [View](#view-object) object
|
|
|
667
670
|
### eventDragMinDistance
|
|
668
671
|
- Type `integer`
|
|
669
672
|
- Default `5`
|
|
673
|
+
- Requires `Interaction` plugin
|
|
670
674
|
|
|
671
675
|
Defines how many pixels the user’s mouse must move before the event dragging begins.
|
|
672
676
|
|
|
673
677
|
### eventDragStart
|
|
674
678
|
- Type `function`
|
|
675
679
|
- Default `undefined`
|
|
680
|
+
- Requires `Interaction` plugin
|
|
676
681
|
|
|
677
682
|
Callback function that is triggered when the event dragging begins.
|
|
678
683
|
|
|
@@ -713,6 +718,7 @@ The current [View](#view-object) object
|
|
|
713
718
|
### eventDragStop
|
|
714
719
|
- Type `function`
|
|
715
720
|
- Default `undefined`
|
|
721
|
+
- Requires `Interaction` plugin
|
|
716
722
|
|
|
717
723
|
Callback function that is triggered when the event dragging stops.
|
|
718
724
|
|
|
@@ -755,6 +761,7 @@ The current [View](#view-object) object
|
|
|
755
761
|
### eventDrop
|
|
756
762
|
- Type `function`
|
|
757
763
|
- Default `undefined`
|
|
764
|
+
- Requires `Interaction` plugin
|
|
758
765
|
|
|
759
766
|
Callback function that is triggered when dragging stops, and the event has moved to a different day/time.
|
|
760
767
|
|
|
@@ -847,12 +854,14 @@ The current [View](#view-object) object
|
|
|
847
854
|
### eventDurationEditable
|
|
848
855
|
- Type `boolean`
|
|
849
856
|
- Default `true`
|
|
857
|
+
- Requires `Interaction` plugin
|
|
850
858
|
|
|
851
859
|
Determines whether calendar events can be resized.
|
|
852
860
|
|
|
853
861
|
### eventLongPressDelay
|
|
854
862
|
- Type `integer`
|
|
855
863
|
- Default `undefined`
|
|
864
|
+
- Requires `Interaction` plugin
|
|
856
865
|
|
|
857
866
|
For touch devices, the amount of time (in milliseconds) the user must hold down a tap before the event becomes draggable/resizable.
|
|
858
867
|
|
|
@@ -955,6 +964,7 @@ The current [View](#view-object) object
|
|
|
955
964
|
### eventResize
|
|
956
965
|
- Type `function`
|
|
957
966
|
- Default `undefined`
|
|
967
|
+
- Requires `Interaction` plugin
|
|
958
968
|
|
|
959
969
|
Callback function that is triggered when resizing stops, and the duration of the event has changed.
|
|
960
970
|
|
|
@@ -1027,6 +1037,7 @@ The current [View](#view-object) object
|
|
|
1027
1037
|
### eventResizeStart
|
|
1028
1038
|
- Type `function`
|
|
1029
1039
|
- Default `undefined`
|
|
1040
|
+
- Requires `Interaction` plugin
|
|
1030
1041
|
|
|
1031
1042
|
Callback function that is triggered when the event resizing begins.
|
|
1032
1043
|
|
|
@@ -1067,6 +1078,7 @@ The current [View](#view-object) object
|
|
|
1067
1078
|
### eventResizeStop
|
|
1068
1079
|
- Type `function`
|
|
1069
1080
|
- Default `undefined`
|
|
1081
|
+
- Requires `Interaction` plugin
|
|
1070
1082
|
|
|
1071
1083
|
Callback function that is triggered when the event resizing stops.
|
|
1072
1084
|
|
|
@@ -1208,6 +1220,7 @@ Instead of calling `successCallback` and `failureCallback`, you may return the r
|
|
|
1208
1220
|
### eventStartEditable
|
|
1209
1221
|
- Type `boolean`
|
|
1210
1222
|
- Default `true`
|
|
1223
|
+
- Requires `Interaction` plugin
|
|
1211
1224
|
|
|
1212
1225
|
Determines whether the events on the calendar can be dragged.
|
|
1213
1226
|
|
|
@@ -1506,6 +1519,7 @@ Enables a marker indicating the current time in `timeGrid`/`resourceTimeGrid` vi
|
|
|
1506
1519
|
### pointer
|
|
1507
1520
|
- Type `boolean`
|
|
1508
1521
|
- Default `false`
|
|
1522
|
+
- Requires `Interaction` plugin
|
|
1509
1523
|
|
|
1510
1524
|
Enables mouse cursor pointer in `timeGrid`/`resourceTimeGrid` views.
|
|
1511
1525
|
|
|
@@ -1589,6 +1603,7 @@ The associated [Resource](#resource-object) object
|
|
|
1589
1603
|
### select
|
|
1590
1604
|
- Type `function`
|
|
1591
1605
|
- Default `undefined`
|
|
1606
|
+
- Requires `Interaction` plugin
|
|
1592
1607
|
|
|
1593
1608
|
Callback function that is triggered when a date/time selection is made.
|
|
1594
1609
|
|
|
@@ -1666,12 +1681,14 @@ If the current view is a resource view, the [Resource](#resource-object) object
|
|
|
1666
1681
|
### selectable
|
|
1667
1682
|
- Type `boolean`
|
|
1668
1683
|
- Default `false`
|
|
1684
|
+
- Requires `Interaction` plugin
|
|
1669
1685
|
|
|
1670
1686
|
Determines whether the user is allowed to highlight multiple days or time slots by clicking and moving the pointer.
|
|
1671
1687
|
|
|
1672
1688
|
### selectBackgroundColor
|
|
1673
1689
|
- Type `string`
|
|
1674
1690
|
- Default `undefined`
|
|
1691
|
+
- Requires `Interaction` plugin
|
|
1675
1692
|
|
|
1676
1693
|
Sets the background color for the event indicating the current selection. See [selectable](#selectable).
|
|
1677
1694
|
|
|
@@ -1680,6 +1697,7 @@ You can use any of the CSS color formats such `'#f00'`, `'#ff0000'`, `'rgb(255,0
|
|
|
1680
1697
|
### selectLongPressDelay
|
|
1681
1698
|
- Type `integer`
|
|
1682
1699
|
- Default `undefined`
|
|
1700
|
+
- Requires `Interaction` plugin
|
|
1683
1701
|
|
|
1684
1702
|
For touch devices, the amount of time (in milliseconds) the user must hold down a tap before the date becomes selectable.
|
|
1685
1703
|
|
|
@@ -1688,6 +1706,7 @@ If not specified, it falls back to [longPressDelay](#longpressdelay).
|
|
|
1688
1706
|
### selectMinDistance
|
|
1689
1707
|
- Type `integer`
|
|
1690
1708
|
- Default `5`
|
|
1709
|
+
- Requires `Interaction` plugin
|
|
1691
1710
|
|
|
1692
1711
|
Defines how many pixels the user’s mouse must move before the selection begins.
|
|
1693
1712
|
|
|
@@ -1810,6 +1829,7 @@ function (date) {
|
|
|
1810
1829
|
### unselect
|
|
1811
1830
|
- Type `function`
|
|
1812
1831
|
- Default `undefined`
|
|
1832
|
+
- Requires `Interaction` plugin
|
|
1813
1833
|
|
|
1814
1834
|
Callback function that is triggered when the current selection is cleared.
|
|
1815
1835
|
|
|
@@ -1851,12 +1871,14 @@ The current [View](#view-object) object
|
|
|
1851
1871
|
### unselectAuto
|
|
1852
1872
|
- Type `boolean`
|
|
1853
1873
|
- Default `true`
|
|
1874
|
+
- Requires `Interaction` plugin
|
|
1854
1875
|
|
|
1855
1876
|
Determines whether clicking elsewhere on the page will clear the current selection. See [selectable](#selectable).
|
|
1856
1877
|
|
|
1857
1878
|
### unselectCancel
|
|
1858
1879
|
- Type `string`
|
|
1859
1880
|
- Default `''`
|
|
1881
|
+
- Requires `Interaction` plugin
|
|
1860
1882
|
|
|
1861
1883
|
A CSS selector that specifies elements that will ignore the [unselectAuto](#unselectauto) option.
|
|
1862
1884
|
|
|
@@ -2001,6 +2023,11 @@ Using this method, you can, for example, find out on which day a click occurred
|
|
|
2001
2023
|
|
|
2002
2024
|
</details>
|
|
2003
2025
|
|
|
2026
|
+
### destroy()
|
|
2027
|
+
- Return value `undefined`
|
|
2028
|
+
|
|
2029
|
+
Destroys the calendar, removing all DOM elements, event handlers, and internal data.
|
|
2030
|
+
|
|
2004
2031
|
### getView()
|
|
2005
2032
|
- Return value `View`
|
|
2006
2033
|
|
package/index.css
CHANGED
|
@@ -199,7 +199,6 @@
|
|
|
199
199
|
height: 100%;
|
|
200
200
|
}
|
|
201
201
|
.ec-month .ec-uniform .ec-content {
|
|
202
|
-
/* Remove scroll because of hidden events */
|
|
203
202
|
overflow: hidden;
|
|
204
203
|
}
|
|
205
204
|
.ec-list .ec-content {
|
|
@@ -221,8 +220,8 @@
|
|
|
221
220
|
flex: 1 0 auto;
|
|
222
221
|
}
|
|
223
222
|
.ec-month .ec-uniform .ec-days {
|
|
224
|
-
flex: 1 1 0
|
|
225
|
-
min-height:
|
|
223
|
+
flex: 1 1 0%;
|
|
224
|
+
min-height: 0;
|
|
226
225
|
}
|
|
227
226
|
|
|
228
227
|
.ec-day {
|
|
@@ -238,6 +237,9 @@
|
|
|
238
237
|
min-height: 5em;
|
|
239
238
|
position: relative;
|
|
240
239
|
}
|
|
240
|
+
.ec-month .ec-uniform .ec-day {
|
|
241
|
+
min-height: 0;
|
|
242
|
+
}
|
|
241
243
|
.ec-month .ec-day:first-child {
|
|
242
244
|
border-left: none;
|
|
243
245
|
}
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { is_function,
|
|
2
|
-
import { getContext, setContext } from 'svelte';
|
|
1
|
+
import { is_function, noop, identity, tick, SvelteComponent, init, safe_not_equal, empty, insert, destroy_each, detach, component_subscribe, set_store_value, element, text, attr, append, listen, set_data, transition_in, group_outros, check_outros, transition_out, space, create_component, mount_component, destroy_component, construct_svelte_component, set_style, get_current_component } from 'svelte/internal';
|
|
2
|
+
import { getContext, setContext, beforeUpdate } from 'svelte';
|
|
3
3
|
import { derived, writable, readable, get } from 'svelte/store';
|
|
4
|
-
import { assign, setMidnight, createDate, createDuration, createEvents, createEventSources, cloneDate, prevClosestDay, nextClosestDay, DAY_IN_SECONDS, addDuration, subtractDay, toLocalDate, toISOString, derived2, addDay, createView, writable2, intl, intlRange, subtractDuration, toEventWithLocalDates, toViewWithLocalDates, hasFn, runFn, ignore } from '@event-calendar/common';
|
|
4
|
+
import { assign, setMidnight, createDate, createDuration, createEvents, createEventSources, cloneDate, prevClosestDay, nextClosestDay, DAY_IN_SECONDS, addDuration, subtractDay, debounce, toLocalDate, toISOString, derived2, addDay, createView, writable2, intl, intlRange, subtractDuration, flushDebounce, toEventWithLocalDates, toViewWithLocalDates, hasFn, runFn, ignore } from '@event-calendar/common';
|
|
5
5
|
|
|
6
6
|
function createOptions(plugins) {
|
|
7
7
|
let options = {
|
|
@@ -179,19 +179,19 @@ function activeRange(state) {
|
|
|
179
179
|
}
|
|
180
180
|
);
|
|
181
181
|
|
|
182
|
-
let
|
|
183
|
-
derived([_activeRange, state.datesSet],
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
let debounceHandle = {};
|
|
183
|
+
derived([_activeRange, state.datesSet], values => {
|
|
184
|
+
let [, $datesSet] = values;
|
|
185
|
+
if ($datesSet) {
|
|
186
|
+
debounce(() => {
|
|
187
|
+
let [$_activeRange, $datesSet] = values;
|
|
188
188
|
$datesSet({
|
|
189
189
|
start: toLocalDate($_activeRange.start),
|
|
190
190
|
end: toLocalDate($_activeRange.end),
|
|
191
191
|
startStr: toISOString($_activeRange.start),
|
|
192
192
|
endStr: toISOString($_activeRange.end)
|
|
193
193
|
});
|
|
194
|
-
});
|
|
194
|
+
}, debounceHandle, state._queue);
|
|
195
195
|
}
|
|
196
196
|
}).subscribe(noop);
|
|
197
197
|
|
|
@@ -261,9 +261,11 @@ function events(state) {
|
|
|
261
261
|
let _events = writable([]);
|
|
262
262
|
let abortController;
|
|
263
263
|
let fetching = 0;
|
|
264
|
+
let debounceHandle = {};
|
|
264
265
|
derived(
|
|
265
266
|
[state.events, state.eventSources, state._activeRange, state._fetchedRange, state.lazyFetching, state.loading],
|
|
266
|
-
(
|
|
267
|
+
(values, set) => debounce(() => {
|
|
268
|
+
let [$events, $eventSources, $_activeRange, $_fetchedRange, $lazyFetching, $loading] = values;
|
|
267
269
|
if (!$eventSources.length) {
|
|
268
270
|
set($events);
|
|
269
271
|
return;
|
|
@@ -336,7 +338,7 @@ function events(state) {
|
|
|
336
338
|
$_fetchedRange.start = $_activeRange.start;
|
|
337
339
|
$_fetchedRange.end = $_activeRange.end;
|
|
338
340
|
}
|
|
339
|
-
},
|
|
341
|
+
}, debounceHandle, state._queue),
|
|
340
342
|
[]
|
|
341
343
|
).subscribe(_events.set);
|
|
342
344
|
|
|
@@ -371,6 +373,7 @@ class State {
|
|
|
371
373
|
}
|
|
372
374
|
|
|
373
375
|
// Private stores
|
|
376
|
+
this._queue = writable(new Map()); // debounce queue
|
|
374
377
|
this._currentRange = currentRange(this);
|
|
375
378
|
this._activeRange = activeRange(this);
|
|
376
379
|
this._fetchedRange = writable({start: undefined, end: undefined});
|
|
@@ -426,6 +429,7 @@ class State {
|
|
|
426
429
|
}
|
|
427
430
|
}
|
|
428
431
|
});
|
|
432
|
+
// Process options
|
|
429
433
|
for (let key of Object.keys(opts)) {
|
|
430
434
|
if (this.hasOwnProperty(key) && key[0] !== '_') {
|
|
431
435
|
let {set, _set, ...rest} = this[key];
|
|
@@ -1298,7 +1302,7 @@ function create_fragment(ctx) {
|
|
|
1298
1302
|
current = true;
|
|
1299
1303
|
|
|
1300
1304
|
if (!mounted) {
|
|
1301
|
-
dispose = listen(window, "click", /*handleClick*/ ctx[
|
|
1305
|
+
dispose = listen(window, "click", /*handleClick*/ ctx[17], true);
|
|
1302
1306
|
mounted = true;
|
|
1303
1307
|
}
|
|
1304
1308
|
},
|
|
@@ -1384,6 +1388,7 @@ function create_fragment(ctx) {
|
|
|
1384
1388
|
}
|
|
1385
1389
|
|
|
1386
1390
|
function instance($$self, $$props, $$invalidate) {
|
|
1391
|
+
let $_queue;
|
|
1387
1392
|
let $_ignoreClick;
|
|
1388
1393
|
let $events;
|
|
1389
1394
|
let $_events;
|
|
@@ -1396,17 +1401,19 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1396
1401
|
let $_viewComponent;
|
|
1397
1402
|
let { plugins = [] } = $$props;
|
|
1398
1403
|
let { options = {} } = $$props;
|
|
1404
|
+
let component = get_current_component();
|
|
1399
1405
|
let state = new State(plugins, options);
|
|
1400
1406
|
setContext('state', state);
|
|
1401
|
-
let { _viewComponent, _viewClass, _ignoreClick, _interaction, _iClass, _events, events, eventSources, height, theme } = state;
|
|
1407
|
+
let { _viewComponent, _viewClass, _ignoreClick, _interaction, _iClass, _events, _queue, events, eventSources, height, theme } = state;
|
|
1402
1408
|
component_subscribe($$self, _viewComponent, value => $$invalidate(5, $_viewComponent = value));
|
|
1403
1409
|
component_subscribe($$self, _viewClass, value => $$invalidate(2, $_viewClass = value));
|
|
1404
|
-
component_subscribe($$self, _ignoreClick, value => $$invalidate(
|
|
1410
|
+
component_subscribe($$self, _ignoreClick, value => $$invalidate(33, $_ignoreClick = value));
|
|
1405
1411
|
component_subscribe($$self, _interaction, value => $$invalidate(0, $_interaction = value));
|
|
1406
1412
|
component_subscribe($$self, _iClass, value => $$invalidate(3, $_iClass = value));
|
|
1407
|
-
component_subscribe($$self, _events, value => $$invalidate(
|
|
1408
|
-
component_subscribe($$self,
|
|
1409
|
-
component_subscribe($$self,
|
|
1413
|
+
component_subscribe($$self, _events, value => $$invalidate(35, $_events = value));
|
|
1414
|
+
component_subscribe($$self, _queue, value => $$invalidate(32, $_queue = value));
|
|
1415
|
+
component_subscribe($$self, events, value => $$invalidate(34, $events = value));
|
|
1416
|
+
component_subscribe($$self, eventSources, value => $$invalidate(36, $eventSources = value));
|
|
1410
1417
|
component_subscribe($$self, height, value => $$invalidate(4, $height = value));
|
|
1411
1418
|
component_subscribe($$self, theme, value => $$invalidate(1, $theme = value));
|
|
1412
1419
|
|
|
@@ -1436,11 +1443,11 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1436
1443
|
}
|
|
1437
1444
|
|
|
1438
1445
|
function getEvents() {
|
|
1439
|
-
return
|
|
1446
|
+
return $_events.map(toEventWithLocalDates);
|
|
1440
1447
|
}
|
|
1441
1448
|
|
|
1442
1449
|
function getEventById(id) {
|
|
1443
|
-
for (let event of
|
|
1450
|
+
for (let event of $_events) {
|
|
1444
1451
|
if (event.id == id) {
|
|
1445
1452
|
return toEventWithLocalDates(event);
|
|
1446
1453
|
}
|
|
@@ -1497,6 +1504,10 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1497
1504
|
return null;
|
|
1498
1505
|
}
|
|
1499
1506
|
|
|
1507
|
+
function destroy() {
|
|
1508
|
+
destroy_component(component, true);
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1500
1511
|
function updateEvents(func) {
|
|
1501
1512
|
if ($eventSources.length) {
|
|
1502
1513
|
set_store_value(_events, $_events = func($_events), $_events);
|
|
@@ -1512,13 +1523,17 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1512
1523
|
}
|
|
1513
1524
|
}
|
|
1514
1525
|
|
|
1526
|
+
beforeUpdate(() => {
|
|
1527
|
+
flushDebounce($_queue);
|
|
1528
|
+
});
|
|
1529
|
+
|
|
1515
1530
|
$$self.$$set = $$props => {
|
|
1516
|
-
if ('plugins' in $$props) $$invalidate(
|
|
1517
|
-
if ('options' in $$props) $$invalidate(
|
|
1531
|
+
if ('plugins' in $$props) $$invalidate(18, plugins = $$props.plugins);
|
|
1532
|
+
if ('options' in $$props) $$invalidate(19, options = $$props.options);
|
|
1518
1533
|
};
|
|
1519
1534
|
|
|
1520
1535
|
$$self.$$.update = () => {
|
|
1521
|
-
if ($$self.$$.dirty[0] & /*options*/
|
|
1536
|
+
if ($$self.$$.dirty[0] & /*options*/ 524288) {
|
|
1522
1537
|
// Reactively update options that did change
|
|
1523
1538
|
for (let [name, value] of diff(options)) {
|
|
1524
1539
|
setOption(name, value);
|
|
@@ -1539,6 +1554,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1539
1554
|
_interaction,
|
|
1540
1555
|
_iClass,
|
|
1541
1556
|
_events,
|
|
1557
|
+
_queue,
|
|
1542
1558
|
events,
|
|
1543
1559
|
eventSources,
|
|
1544
1560
|
height,
|
|
@@ -1556,7 +1572,8 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1556
1572
|
removeEventById,
|
|
1557
1573
|
getView,
|
|
1558
1574
|
unselect,
|
|
1559
|
-
dateFromPoint
|
|
1575
|
+
dateFromPoint,
|
|
1576
|
+
destroy
|
|
1560
1577
|
];
|
|
1561
1578
|
}
|
|
1562
1579
|
|
|
@@ -1571,19 +1588,20 @@ class Calendar extends SvelteComponent {
|
|
|
1571
1588
|
create_fragment,
|
|
1572
1589
|
safe_not_equal,
|
|
1573
1590
|
{
|
|
1574
|
-
plugins:
|
|
1575
|
-
options:
|
|
1576
|
-
setOption:
|
|
1577
|
-
getOption:
|
|
1578
|
-
refetchEvents:
|
|
1579
|
-
getEvents:
|
|
1580
|
-
getEventById:
|
|
1581
|
-
addEvent:
|
|
1582
|
-
updateEvent:
|
|
1583
|
-
removeEventById:
|
|
1584
|
-
getView:
|
|
1585
|
-
unselect:
|
|
1586
|
-
dateFromPoint:
|
|
1591
|
+
plugins: 18,
|
|
1592
|
+
options: 19,
|
|
1593
|
+
setOption: 20,
|
|
1594
|
+
getOption: 21,
|
|
1595
|
+
refetchEvents: 22,
|
|
1596
|
+
getEvents: 23,
|
|
1597
|
+
getEventById: 24,
|
|
1598
|
+
addEvent: 25,
|
|
1599
|
+
updateEvent: 26,
|
|
1600
|
+
removeEventById: 27,
|
|
1601
|
+
getView: 28,
|
|
1602
|
+
unselect: 29,
|
|
1603
|
+
dateFromPoint: 30,
|
|
1604
|
+
destroy: 31
|
|
1587
1605
|
},
|
|
1588
1606
|
null,
|
|
1589
1607
|
[-1, -1]
|
|
@@ -1591,47 +1609,51 @@ class Calendar extends SvelteComponent {
|
|
|
1591
1609
|
}
|
|
1592
1610
|
|
|
1593
1611
|
get setOption() {
|
|
1594
|
-
return this.$$.ctx[
|
|
1612
|
+
return this.$$.ctx[20];
|
|
1595
1613
|
}
|
|
1596
1614
|
|
|
1597
1615
|
get getOption() {
|
|
1598
|
-
return this.$$.ctx[
|
|
1616
|
+
return this.$$.ctx[21];
|
|
1599
1617
|
}
|
|
1600
1618
|
|
|
1601
1619
|
get refetchEvents() {
|
|
1602
|
-
return this.$$.ctx[
|
|
1620
|
+
return this.$$.ctx[22];
|
|
1603
1621
|
}
|
|
1604
1622
|
|
|
1605
1623
|
get getEvents() {
|
|
1606
|
-
return this.$$.ctx[
|
|
1624
|
+
return this.$$.ctx[23];
|
|
1607
1625
|
}
|
|
1608
1626
|
|
|
1609
1627
|
get getEventById() {
|
|
1610
|
-
return this.$$.ctx[
|
|
1628
|
+
return this.$$.ctx[24];
|
|
1611
1629
|
}
|
|
1612
1630
|
|
|
1613
1631
|
get addEvent() {
|
|
1614
|
-
return this.$$.ctx[
|
|
1632
|
+
return this.$$.ctx[25];
|
|
1615
1633
|
}
|
|
1616
1634
|
|
|
1617
1635
|
get updateEvent() {
|
|
1618
|
-
return this.$$.ctx[
|
|
1636
|
+
return this.$$.ctx[26];
|
|
1619
1637
|
}
|
|
1620
1638
|
|
|
1621
1639
|
get removeEventById() {
|
|
1622
|
-
return this.$$.ctx[
|
|
1640
|
+
return this.$$.ctx[27];
|
|
1623
1641
|
}
|
|
1624
1642
|
|
|
1625
1643
|
get getView() {
|
|
1626
|
-
return this.$$.ctx[
|
|
1644
|
+
return this.$$.ctx[28];
|
|
1627
1645
|
}
|
|
1628
1646
|
|
|
1629
1647
|
get unselect() {
|
|
1630
|
-
return this.$$.ctx[
|
|
1648
|
+
return this.$$.ctx[29];
|
|
1631
1649
|
}
|
|
1632
1650
|
|
|
1633
1651
|
get dateFromPoint() {
|
|
1634
|
-
return this.$$.ctx[
|
|
1652
|
+
return this.$$.ctx[30];
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
get destroy() {
|
|
1656
|
+
return this.$$.ctx[31];
|
|
1635
1657
|
}
|
|
1636
1658
|
}
|
|
1637
1659
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@event-calendar/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"title": "Event Calendar Core package",
|
|
5
5
|
"description": "Full-sized drag & drop event calendar with resource view",
|
|
6
6
|
"keywords": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@event-calendar/common": "~0.
|
|
40
|
+
"@event-calendar/common": "~0.17.1",
|
|
41
41
|
"svelte": "^3.55.1"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/Calendar.svelte
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import '../index.css';
|
|
3
|
-
import {setContext} from 'svelte';
|
|
3
|
+
import {setContext, beforeUpdate} from 'svelte';
|
|
4
|
+
import {destroy_component, get_current_component} from 'svelte/internal';
|
|
4
5
|
import {get} from 'svelte/store';
|
|
5
6
|
import {diff} from './storage/options';
|
|
6
7
|
import State from './storage/state';
|
|
@@ -12,16 +13,19 @@
|
|
|
12
13
|
toLocalDate,
|
|
13
14
|
ignore,
|
|
14
15
|
hasFn,
|
|
15
|
-
runFn
|
|
16
|
+
runFn,
|
|
17
|
+
flushDebounce
|
|
16
18
|
} from '@event-calendar/common';
|
|
17
19
|
|
|
18
20
|
export let plugins = [];
|
|
19
21
|
export let options = {};
|
|
20
22
|
|
|
23
|
+
let component = get_current_component();
|
|
24
|
+
|
|
21
25
|
let state = new State(plugins, options);
|
|
22
26
|
setContext('state', state);
|
|
23
27
|
|
|
24
|
-
let {_viewComponent, _viewClass, _ignoreClick, _interaction, _iClass, _events,
|
|
28
|
+
let {_viewComponent, _viewClass, _ignoreClick, _interaction, _iClass, _events, _queue,
|
|
25
29
|
events, eventSources, height, theme} = state;
|
|
26
30
|
|
|
27
31
|
// Reactively update options that did change
|
|
@@ -50,11 +54,11 @@
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
export function getEvents() {
|
|
53
|
-
return
|
|
57
|
+
return $_events.map(toEventWithLocalDates);
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
export function getEventById(id) {
|
|
57
|
-
for (let event of
|
|
61
|
+
for (let event of $_events) {
|
|
58
62
|
if (event.id == id) {
|
|
59
63
|
return toEventWithLocalDates(event);
|
|
60
64
|
}
|
|
@@ -106,6 +110,10 @@
|
|
|
106
110
|
return null;
|
|
107
111
|
}
|
|
108
112
|
|
|
113
|
+
export function destroy() {
|
|
114
|
+
destroy_component(component, true);
|
|
115
|
+
}
|
|
116
|
+
|
|
109
117
|
function updateEvents(func) {
|
|
110
118
|
if ($eventSources.length) {
|
|
111
119
|
$_events = func($_events);
|
|
@@ -120,6 +128,10 @@
|
|
|
120
128
|
$_ignoreClick = false;
|
|
121
129
|
}
|
|
122
130
|
}
|
|
131
|
+
|
|
132
|
+
beforeUpdate(() => {
|
|
133
|
+
flushDebounce($_queue);
|
|
134
|
+
});
|
|
123
135
|
</script>
|
|
124
136
|
|
|
125
137
|
<div
|
package/src/index.scss
CHANGED
|
@@ -226,8 +226,7 @@
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
.ec-month .ec-uniform & {
|
|
229
|
-
|
|
230
|
-
overflow: hidden;
|
|
229
|
+
overflow: hidden; // remove scrolling due to hidden events
|
|
231
230
|
}
|
|
232
231
|
|
|
233
232
|
.ec-list & {
|
|
@@ -253,8 +252,8 @@
|
|
|
253
252
|
}
|
|
254
253
|
|
|
255
254
|
.ec-month .ec-uniform & {
|
|
256
|
-
flex: 1 1 0
|
|
257
|
-
min-height:
|
|
255
|
+
flex: 1 1 0%; // % is required to work properly for both auto and fixed calendar height
|
|
256
|
+
min-height: 0;
|
|
258
257
|
}
|
|
259
258
|
}
|
|
260
259
|
|
|
@@ -274,6 +273,10 @@
|
|
|
274
273
|
position: relative;
|
|
275
274
|
}
|
|
276
275
|
|
|
276
|
+
.ec-month .ec-uniform & {
|
|
277
|
+
min-height: 0;
|
|
278
|
+
}
|
|
279
|
+
|
|
277
280
|
.ec-month &:first-child {
|
|
278
281
|
border-left: none;
|
|
279
282
|
}
|
package/src/storage/state.js
CHANGED
|
@@ -28,6 +28,7 @@ export default class {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// Private stores
|
|
31
|
+
this._queue = writable(new Map()); // debounce queue
|
|
31
32
|
this._currentRange = currentRange(this);
|
|
32
33
|
this._activeRange = activeRange(this);
|
|
33
34
|
this._fetchedRange = writable({start: undefined, end: undefined});
|
|
@@ -83,6 +84,7 @@ export default class {
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
});
|
|
87
|
+
// Process options
|
|
86
88
|
for (let key of Object.keys(opts)) {
|
|
87
89
|
if (this.hasOwnProperty(key) && key[0] !== '_') {
|
|
88
90
|
let {set, _set, ...rest} = this[key];
|
package/src/storage/stores.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {derived, writable, readable} from 'svelte/store';
|
|
2
|
-
import {is_function, noop
|
|
2
|
+
import {is_function, noop} from 'svelte/internal';
|
|
3
3
|
import {
|
|
4
4
|
DAY_IN_SECONDS,
|
|
5
5
|
cloneDate,
|
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
nextClosestDay,
|
|
12
12
|
prevClosestDay,
|
|
13
13
|
setMidnight,
|
|
14
|
-
toLocalDate
|
|
14
|
+
toLocalDate,
|
|
15
|
+
debounce
|
|
15
16
|
} from '@event-calendar/common';
|
|
16
17
|
import {derived2} from '@event-calendar/common';
|
|
17
18
|
import {createEvents} from '@event-calendar/common';
|
|
@@ -41,19 +42,19 @@ export function activeRange(state) {
|
|
|
41
42
|
}
|
|
42
43
|
);
|
|
43
44
|
|
|
44
|
-
let
|
|
45
|
-
derived([_activeRange, state.datesSet],
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
let debounceHandle = {};
|
|
46
|
+
derived([_activeRange, state.datesSet], values => {
|
|
47
|
+
let [, $datesSet] = values;
|
|
48
|
+
if ($datesSet) {
|
|
49
|
+
debounce(() => {
|
|
50
|
+
let [$_activeRange, $datesSet] = values;
|
|
50
51
|
$datesSet({
|
|
51
52
|
start: toLocalDate($_activeRange.start),
|
|
52
53
|
end: toLocalDate($_activeRange.end),
|
|
53
54
|
startStr: toISOString($_activeRange.start),
|
|
54
55
|
endStr: toISOString($_activeRange.end)
|
|
55
56
|
});
|
|
56
|
-
});
|
|
57
|
+
}, debounceHandle, state._queue);
|
|
57
58
|
}
|
|
58
59
|
}).subscribe(noop);
|
|
59
60
|
|
|
@@ -123,9 +124,11 @@ export function events(state) {
|
|
|
123
124
|
let _events = writable([]);
|
|
124
125
|
let abortController;
|
|
125
126
|
let fetching = 0;
|
|
127
|
+
let debounceHandle = {};
|
|
126
128
|
derived(
|
|
127
129
|
[state.events, state.eventSources, state._activeRange, state._fetchedRange, state.lazyFetching, state.loading],
|
|
128
|
-
(
|
|
130
|
+
(values, set) => debounce(() => {
|
|
131
|
+
let [$events, $eventSources, $_activeRange, $_fetchedRange, $lazyFetching, $loading] = values;
|
|
129
132
|
if (!$eventSources.length) {
|
|
130
133
|
set($events);
|
|
131
134
|
return;
|
|
@@ -198,7 +201,7 @@ export function events(state) {
|
|
|
198
201
|
$_fetchedRange.start = $_activeRange.start;
|
|
199
202
|
$_fetchedRange.end = $_activeRange.end;
|
|
200
203
|
}
|
|
201
|
-
},
|
|
204
|
+
}, debounceHandle, state._queue),
|
|
202
205
|
[]
|
|
203
206
|
).subscribe(_events.set);
|
|
204
207
|
|