@event-calendar/core 0.15.2 → 0.16.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 CHANGED
@@ -116,9 +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
120
  - [getView](#getview)
120
- </td><td>
121
-
122
121
  - [unselect](#unselect-1)
123
122
  </td></tr>
124
123
  </table>
@@ -192,8 +191,8 @@ import '@event-calendar/core/index.css';
192
191
  ### Pre-built browser ready bundle
193
192
  Include the following lines of code in the `<head>` section of your page:
194
193
  ```html
195
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.15.2/event-calendar.min.css">
196
- <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.15.2/event-calendar.min.js"></script>
194
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.16.0/event-calendar.min.css">
195
+ <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@0.16.0/event-calendar.min.js"></script>
197
196
  ```
198
197
 
199
198
  <details>
@@ -1988,6 +1987,20 @@ Updates a single event with the matching `event`.`id`.
1988
1987
 
1989
1988
  Refetches events from all sources.
1990
1989
 
1990
+ ### dateFromPoint( x, y )
1991
+ - Return value `Date` or `null`
1992
+
1993
+ Returns the date and time that would be determined if a click was made on the specified coordinates within the application's [viewport](https://developer.mozilla.org/en-US/docs/Glossary/Viewport).
1994
+
1995
+ Using this method, you can get the date and time for any point inside the calendar, as if it was clicked. For example, you want to know, when you click on a multi-day event, which day the click happened on. To do this, inside [eventClick](#eventclick), pass the `jsEvent.clientX` and `jsEvent.clientY` coordinates to `dateFromPoint` and get the date that corresponds to the place in the calendar where the click was.
1996
+
1997
+ <details>
1998
+ <summary>Note</summary>
1999
+
2000
+ > In the `'listDay'`, `'listWeek'`, `'listMonth'` and `'listYear'` views, the events are rendered outside of the day container, so the method will return `null` for the coordinates that are inside the events.
2001
+
2002
+ </details>
2003
+
1991
2004
  ### getView()
1992
2005
  - Return value `View`
1993
2006
 
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { is_function, tick, noop, identity, 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 } from 'svelte/internal';
2
2
  import { getContext, setContext } 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, ignore } from '@event-calendar/common';
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';
5
5
 
6
6
  function createOptions(plugins) {
7
7
  let options = {
@@ -1402,12 +1402,12 @@ function instance($$self, $$props, $$invalidate) {
1402
1402
  let { _viewComponent, _viewClass, _ignoreClick, _interaction, _iClass, _events, events, eventSources, height, theme } = state;
1403
1403
  component_subscribe($$self, _viewComponent, value => $$invalidate(5, $_viewComponent = value));
1404
1404
  component_subscribe($$self, _viewClass, value => $$invalidate(2, $_viewClass = value));
1405
- component_subscribe($$self, _ignoreClick, value => $$invalidate(29, $_ignoreClick = value));
1405
+ component_subscribe($$self, _ignoreClick, value => $$invalidate(30, $_ignoreClick = value));
1406
1406
  component_subscribe($$self, _interaction, value => $$invalidate(0, $_interaction = value));
1407
1407
  component_subscribe($$self, _iClass, value => $$invalidate(3, $_iClass = value));
1408
- component_subscribe($$self, _events, value => $$invalidate(31, $_events = value));
1409
- component_subscribe($$self, events, value => $$invalidate(30, $events = value));
1410
- component_subscribe($$self, eventSources, value => $$invalidate(32, $eventSources = value));
1408
+ component_subscribe($$self, _events, value => $$invalidate(32, $_events = value));
1409
+ component_subscribe($$self, events, value => $$invalidate(31, $events = value));
1410
+ component_subscribe($$self, eventSources, value => $$invalidate(33, $eventSources = value));
1411
1411
  component_subscribe($$self, height, value => $$invalidate(4, $height = value));
1412
1412
  component_subscribe($$self, theme, value => $$invalidate(1, $theme = value));
1413
1413
 
@@ -1487,6 +1487,17 @@ function instance($$self, $$props, $$invalidate) {
1487
1487
  return this;
1488
1488
  }
1489
1489
 
1490
+ function dateFromPoint(x, y) {
1491
+ for (let el of document.elementsFromPoint(x, y)) {
1492
+ if (hasFn(el)) {
1493
+ let date = runFn(el, y);
1494
+ return date ? toLocalDate(date) : null;
1495
+ }
1496
+ }
1497
+
1498
+ return null;
1499
+ }
1500
+
1490
1501
  function updateEvents(func) {
1491
1502
  if ($eventSources.length) {
1492
1503
  set_store_value(_events, $_events = func($_events), $_events);
@@ -1545,7 +1556,8 @@ function instance($$self, $$props, $$invalidate) {
1545
1556
  updateEvent,
1546
1557
  removeEventById,
1547
1558
  getView,
1548
- unselect
1559
+ unselect,
1560
+ dateFromPoint
1549
1561
  ];
1550
1562
  }
1551
1563
 
@@ -1571,7 +1583,8 @@ class Calendar extends SvelteComponent {
1571
1583
  updateEvent: 25,
1572
1584
  removeEventById: 26,
1573
1585
  getView: 27,
1574
- unselect: 28
1586
+ unselect: 28,
1587
+ dateFromPoint: 29
1575
1588
  },
1576
1589
  null,
1577
1590
  [-1, -1]
@@ -1617,6 +1630,10 @@ class Calendar extends SvelteComponent {
1617
1630
  get unselect() {
1618
1631
  return this.$$.ctx[28];
1619
1632
  }
1633
+
1634
+ get dateFromPoint() {
1635
+ return this.$$.ctx[29];
1636
+ }
1620
1637
  }
1621
1638
 
1622
1639
  export { Calendar as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-calendar/core",
3
- "version": "0.15.2",
3
+ "version": "0.16.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.15.2",
40
+ "@event-calendar/common": "~0.16.0",
41
41
  "svelte": "^3.55.1"
42
42
  }
43
43
  }
@@ -5,7 +5,15 @@
5
5
  import {diff} from './storage/options';
6
6
  import State from './storage/state';
7
7
  import Toolbar from './Toolbar.svelte';
8
- import {assign, toEventWithLocalDates, toViewWithLocalDates, toLocalDate, ignore} from '@event-calendar/common';
8
+ import {
9
+ assign,
10
+ toEventWithLocalDates,
11
+ toViewWithLocalDates,
12
+ toLocalDate,
13
+ ignore,
14
+ hasFn,
15
+ runFn
16
+ } from '@event-calendar/common';
9
17
 
10
18
  export let plugins = [];
11
19
  export let options = {};
@@ -88,6 +96,16 @@
88
96
  return this;
89
97
  }
90
98
 
99
+ export function dateFromPoint(x, y) {
100
+ for (let el of document.elementsFromPoint(x, y)) {
101
+ if (hasFn(el)) {
102
+ let date = runFn(el, y);
103
+ return date ? toLocalDate(date) : null;
104
+ }
105
+ }
106
+ return null;
107
+ }
108
+
91
109
  function updateEvents(func) {
92
110
  if ($eventSources.length) {
93
111
  $_events = func($_events);