@event-calendar/core 0.16.0 → 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 +12 -6
- package/index.css +8 -2
- package/index.js +69 -48
- package/package.json +2 -2
- package/src/Calendar.svelte +17 -5
- package/src/index.scss +10 -2
- package/src/storage/state.js +2 -0
- package/src/storage/stores.js +13 -11
package/README.md
CHANGED
|
@@ -116,7 +116,8 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
|
|
|
116
116
|
- [refetchEvents](#refetchevents)
|
|
117
117
|
</td><td>
|
|
118
118
|
|
|
119
|
-
- [dateFromPoint](#datefrompoint)
|
|
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>
|
|
@@ -1990,17 +1991,22 @@ Refetches events from all sources.
|
|
|
1990
1991
|
### dateFromPoint( x, y )
|
|
1991
1992
|
- Return value `Date` or `null`
|
|
1992
1993
|
|
|
1993
|
-
Returns the date and time
|
|
1994
|
+
Returns the date and time as if the [dateClick](#dateclick) event had fired for that point.
|
|
1994
1995
|
|
|
1995
|
-
Using this method, you can
|
|
1996
|
+
Using this method, you can, for example, find out on which day a click occurred inside a multi-day event. To do this, inside [eventClick](#eventclick), pass the `jsEvent.clientX` and `jsEvent.clientY` coordinates to `dateFromPoint` and get the desired date.
|
|
1996
1997
|
|
|
1997
1998
|
<details>
|
|
1998
1999
|
<summary>Note</summary>
|
|
1999
2000
|
|
|
2000
|
-
> In the `'listDay'`, `'listWeek'`, `'listMonth'` and `'listYear'` views, the events are rendered outside
|
|
2001
|
+
> In the `'listDay'`, `'listWeek'`, `'listMonth'` and `'listYear'` views, the events are rendered outside the day container, so the method will return `null` for the coordinates that are inside the events.
|
|
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
|
@@ -198,6 +198,9 @@
|
|
|
198
198
|
flex-direction: column;
|
|
199
199
|
height: 100%;
|
|
200
200
|
}
|
|
201
|
+
.ec-month .ec-uniform .ec-content {
|
|
202
|
+
overflow: hidden;
|
|
203
|
+
}
|
|
201
204
|
.ec-list .ec-content {
|
|
202
205
|
flex-direction: column;
|
|
203
206
|
}
|
|
@@ -217,8 +220,8 @@
|
|
|
217
220
|
flex: 1 0 auto;
|
|
218
221
|
}
|
|
219
222
|
.ec-month .ec-uniform .ec-days {
|
|
220
|
-
flex: 1 1 0
|
|
221
|
-
min-height:
|
|
223
|
+
flex: 1 1 0%;
|
|
224
|
+
min-height: 0;
|
|
222
225
|
}
|
|
223
226
|
|
|
224
227
|
.ec-day {
|
|
@@ -234,6 +237,9 @@
|
|
|
234
237
|
min-height: 5em;
|
|
235
238
|
position: relative;
|
|
236
239
|
}
|
|
240
|
+
.ec-month .ec-uniform .ec-day {
|
|
241
|
+
min-height: 0;
|
|
242
|
+
}
|
|
237
243
|
.ec-month .ec-day:first-child {
|
|
238
244
|
border-left: none;
|
|
239
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,10 @@ 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
|
-
(values, set) =>
|
|
267
|
+
(values, set) => debounce(() => {
|
|
267
268
|
let [$events, $eventSources, $_activeRange, $_fetchedRange, $lazyFetching, $loading] = values;
|
|
268
269
|
if (!$eventSources.length) {
|
|
269
270
|
set($events);
|
|
@@ -337,7 +338,7 @@ function events(state) {
|
|
|
337
338
|
$_fetchedRange.start = $_activeRange.start;
|
|
338
339
|
$_fetchedRange.end = $_activeRange.end;
|
|
339
340
|
}
|
|
340
|
-
}),
|
|
341
|
+
}, debounceHandle, state._queue),
|
|
341
342
|
[]
|
|
342
343
|
).subscribe(_events.set);
|
|
343
344
|
|
|
@@ -372,6 +373,7 @@ class State {
|
|
|
372
373
|
}
|
|
373
374
|
|
|
374
375
|
// Private stores
|
|
376
|
+
this._queue = writable(new Map()); // debounce queue
|
|
375
377
|
this._currentRange = currentRange(this);
|
|
376
378
|
this._activeRange = activeRange(this);
|
|
377
379
|
this._fetchedRange = writable({start: undefined, end: undefined});
|
|
@@ -427,6 +429,7 @@ class State {
|
|
|
427
429
|
}
|
|
428
430
|
}
|
|
429
431
|
});
|
|
432
|
+
// Process options
|
|
430
433
|
for (let key of Object.keys(opts)) {
|
|
431
434
|
if (this.hasOwnProperty(key) && key[0] !== '_') {
|
|
432
435
|
let {set, _set, ...rest} = this[key];
|
|
@@ -1299,7 +1302,7 @@ function create_fragment(ctx) {
|
|
|
1299
1302
|
current = true;
|
|
1300
1303
|
|
|
1301
1304
|
if (!mounted) {
|
|
1302
|
-
dispose = listen(window, "click", /*handleClick*/ ctx[
|
|
1305
|
+
dispose = listen(window, "click", /*handleClick*/ ctx[17], true);
|
|
1303
1306
|
mounted = true;
|
|
1304
1307
|
}
|
|
1305
1308
|
},
|
|
@@ -1385,6 +1388,7 @@ function create_fragment(ctx) {
|
|
|
1385
1388
|
}
|
|
1386
1389
|
|
|
1387
1390
|
function instance($$self, $$props, $$invalidate) {
|
|
1391
|
+
let $_queue;
|
|
1388
1392
|
let $_ignoreClick;
|
|
1389
1393
|
let $events;
|
|
1390
1394
|
let $_events;
|
|
@@ -1397,17 +1401,19 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1397
1401
|
let $_viewComponent;
|
|
1398
1402
|
let { plugins = [] } = $$props;
|
|
1399
1403
|
let { options = {} } = $$props;
|
|
1404
|
+
let component = get_current_component();
|
|
1400
1405
|
let state = new State(plugins, options);
|
|
1401
1406
|
setContext('state', state);
|
|
1402
|
-
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;
|
|
1403
1408
|
component_subscribe($$self, _viewComponent, value => $$invalidate(5, $_viewComponent = value));
|
|
1404
1409
|
component_subscribe($$self, _viewClass, value => $$invalidate(2, $_viewClass = value));
|
|
1405
|
-
component_subscribe($$self, _ignoreClick, value => $$invalidate(
|
|
1410
|
+
component_subscribe($$self, _ignoreClick, value => $$invalidate(33, $_ignoreClick = value));
|
|
1406
1411
|
component_subscribe($$self, _interaction, value => $$invalidate(0, $_interaction = value));
|
|
1407
1412
|
component_subscribe($$self, _iClass, value => $$invalidate(3, $_iClass = value));
|
|
1408
|
-
component_subscribe($$self, _events, value => $$invalidate(
|
|
1409
|
-
component_subscribe($$self,
|
|
1410
|
-
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));
|
|
1411
1417
|
component_subscribe($$self, height, value => $$invalidate(4, $height = value));
|
|
1412
1418
|
component_subscribe($$self, theme, value => $$invalidate(1, $theme = value));
|
|
1413
1419
|
|
|
@@ -1437,11 +1443,11 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1437
1443
|
}
|
|
1438
1444
|
|
|
1439
1445
|
function getEvents() {
|
|
1440
|
-
return
|
|
1446
|
+
return $_events.map(toEventWithLocalDates);
|
|
1441
1447
|
}
|
|
1442
1448
|
|
|
1443
1449
|
function getEventById(id) {
|
|
1444
|
-
for (let event of
|
|
1450
|
+
for (let event of $_events) {
|
|
1445
1451
|
if (event.id == id) {
|
|
1446
1452
|
return toEventWithLocalDates(event);
|
|
1447
1453
|
}
|
|
@@ -1498,6 +1504,10 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1498
1504
|
return null;
|
|
1499
1505
|
}
|
|
1500
1506
|
|
|
1507
|
+
function destroy() {
|
|
1508
|
+
destroy_component(component, true);
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1501
1511
|
function updateEvents(func) {
|
|
1502
1512
|
if ($eventSources.length) {
|
|
1503
1513
|
set_store_value(_events, $_events = func($_events), $_events);
|
|
@@ -1513,13 +1523,17 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1513
1523
|
}
|
|
1514
1524
|
}
|
|
1515
1525
|
|
|
1526
|
+
beforeUpdate(() => {
|
|
1527
|
+
flushDebounce($_queue);
|
|
1528
|
+
});
|
|
1529
|
+
|
|
1516
1530
|
$$self.$$set = $$props => {
|
|
1517
|
-
if ('plugins' in $$props) $$invalidate(
|
|
1518
|
-
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);
|
|
1519
1533
|
};
|
|
1520
1534
|
|
|
1521
1535
|
$$self.$$.update = () => {
|
|
1522
|
-
if ($$self.$$.dirty[0] & /*options*/
|
|
1536
|
+
if ($$self.$$.dirty[0] & /*options*/ 524288) {
|
|
1523
1537
|
// Reactively update options that did change
|
|
1524
1538
|
for (let [name, value] of diff(options)) {
|
|
1525
1539
|
setOption(name, value);
|
|
@@ -1540,6 +1554,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1540
1554
|
_interaction,
|
|
1541
1555
|
_iClass,
|
|
1542
1556
|
_events,
|
|
1557
|
+
_queue,
|
|
1543
1558
|
events,
|
|
1544
1559
|
eventSources,
|
|
1545
1560
|
height,
|
|
@@ -1557,7 +1572,8 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1557
1572
|
removeEventById,
|
|
1558
1573
|
getView,
|
|
1559
1574
|
unselect,
|
|
1560
|
-
dateFromPoint
|
|
1575
|
+
dateFromPoint,
|
|
1576
|
+
destroy
|
|
1561
1577
|
];
|
|
1562
1578
|
}
|
|
1563
1579
|
|
|
@@ -1572,19 +1588,20 @@ class Calendar extends SvelteComponent {
|
|
|
1572
1588
|
create_fragment,
|
|
1573
1589
|
safe_not_equal,
|
|
1574
1590
|
{
|
|
1575
|
-
plugins:
|
|
1576
|
-
options:
|
|
1577
|
-
setOption:
|
|
1578
|
-
getOption:
|
|
1579
|
-
refetchEvents:
|
|
1580
|
-
getEvents:
|
|
1581
|
-
getEventById:
|
|
1582
|
-
addEvent:
|
|
1583
|
-
updateEvent:
|
|
1584
|
-
removeEventById:
|
|
1585
|
-
getView:
|
|
1586
|
-
unselect:
|
|
1587
|
-
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
|
|
1588
1605
|
},
|
|
1589
1606
|
null,
|
|
1590
1607
|
[-1, -1]
|
|
@@ -1592,47 +1609,51 @@ class Calendar extends SvelteComponent {
|
|
|
1592
1609
|
}
|
|
1593
1610
|
|
|
1594
1611
|
get setOption() {
|
|
1595
|
-
return this.$$.ctx[
|
|
1612
|
+
return this.$$.ctx[20];
|
|
1596
1613
|
}
|
|
1597
1614
|
|
|
1598
1615
|
get getOption() {
|
|
1599
|
-
return this.$$.ctx[
|
|
1616
|
+
return this.$$.ctx[21];
|
|
1600
1617
|
}
|
|
1601
1618
|
|
|
1602
1619
|
get refetchEvents() {
|
|
1603
|
-
return this.$$.ctx[
|
|
1620
|
+
return this.$$.ctx[22];
|
|
1604
1621
|
}
|
|
1605
1622
|
|
|
1606
1623
|
get getEvents() {
|
|
1607
|
-
return this.$$.ctx[
|
|
1624
|
+
return this.$$.ctx[23];
|
|
1608
1625
|
}
|
|
1609
1626
|
|
|
1610
1627
|
get getEventById() {
|
|
1611
|
-
return this.$$.ctx[
|
|
1628
|
+
return this.$$.ctx[24];
|
|
1612
1629
|
}
|
|
1613
1630
|
|
|
1614
1631
|
get addEvent() {
|
|
1615
|
-
return this.$$.ctx[
|
|
1632
|
+
return this.$$.ctx[25];
|
|
1616
1633
|
}
|
|
1617
1634
|
|
|
1618
1635
|
get updateEvent() {
|
|
1619
|
-
return this.$$.ctx[
|
|
1636
|
+
return this.$$.ctx[26];
|
|
1620
1637
|
}
|
|
1621
1638
|
|
|
1622
1639
|
get removeEventById() {
|
|
1623
|
-
return this.$$.ctx[
|
|
1640
|
+
return this.$$.ctx[27];
|
|
1624
1641
|
}
|
|
1625
1642
|
|
|
1626
1643
|
get getView() {
|
|
1627
|
-
return this.$$.ctx[
|
|
1644
|
+
return this.$$.ctx[28];
|
|
1628
1645
|
}
|
|
1629
1646
|
|
|
1630
1647
|
get unselect() {
|
|
1631
|
-
return this.$$.ctx[
|
|
1648
|
+
return this.$$.ctx[29];
|
|
1632
1649
|
}
|
|
1633
1650
|
|
|
1634
1651
|
get dateFromPoint() {
|
|
1635
|
-
return this.$$.ctx[
|
|
1652
|
+
return this.$$.ctx[30];
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
get destroy() {
|
|
1656
|
+
return this.$$.ctx[31];
|
|
1636
1657
|
}
|
|
1637
1658
|
}
|
|
1638
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
|
@@ -225,6 +225,10 @@
|
|
|
225
225
|
height: 100%;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
.ec-month .ec-uniform & {
|
|
229
|
+
overflow: hidden; // remove scrolling due to hidden events
|
|
230
|
+
}
|
|
231
|
+
|
|
228
232
|
.ec-list & {
|
|
229
233
|
flex-direction: column;
|
|
230
234
|
}
|
|
@@ -248,8 +252,8 @@
|
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
.ec-month .ec-uniform & {
|
|
251
|
-
flex: 1 1 0
|
|
252
|
-
min-height:
|
|
255
|
+
flex: 1 1 0%; // % is required to work properly for both auto and fixed calendar height
|
|
256
|
+
min-height: 0;
|
|
253
257
|
}
|
|
254
258
|
}
|
|
255
259
|
|
|
@@ -269,6 +273,10 @@
|
|
|
269
273
|
position: relative;
|
|
270
274
|
}
|
|
271
275
|
|
|
276
|
+
.ec-month .ec-uniform & {
|
|
277
|
+
min-height: 0;
|
|
278
|
+
}
|
|
279
|
+
|
|
272
280
|
.ec-month &:first-child {
|
|
273
281
|
border-left: none;
|
|
274
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,10 @@ 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
|
-
(values, set) =>
|
|
130
|
+
(values, set) => debounce(() => {
|
|
129
131
|
let [$events, $eventSources, $_activeRange, $_fetchedRange, $lazyFetching, $loading] = values;
|
|
130
132
|
if (!$eventSources.length) {
|
|
131
133
|
set($events);
|
|
@@ -199,7 +201,7 @@ export function events(state) {
|
|
|
199
201
|
$_fetchedRange.start = $_activeRange.start;
|
|
200
202
|
$_fetchedRange.end = $_activeRange.end;
|
|
201
203
|
}
|
|
202
|
-
}),
|
|
204
|
+
}, debounceHandle, state._queue),
|
|
203
205
|
[]
|
|
204
206
|
).subscribe(_events.set);
|
|
205
207
|
|