@event-calendar/core 0.16.1 → 0.17.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 +8 -2
- 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
|
@@ -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.0/event-calendar.min.css">
|
|
196
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.17.0/event-calendar.min.js"></script>
|
|
196
197
|
```
|
|
197
198
|
|
|
198
199
|
<details>
|
|
@@ -2001,6 +2002,11 @@ Using this method, you can, for example, find out on which day a click occurred
|
|
|
2001
2002
|
|
|
2002
2003
|
</details>
|
|
2003
2004
|
|
|
2005
|
+
### destroy()
|
|
2006
|
+
- Return value `undefined`
|
|
2007
|
+
|
|
2008
|
+
Destroys the calendar, removing all DOM elements, event handlers, and internal data.
|
|
2009
|
+
|
|
2004
2010
|
### getView()
|
|
2005
2011
|
- Return value `View`
|
|
2006
2012
|
|
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.0",
|
|
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.0",
|
|
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
|
|