@event-calendar/core 1.3.0 → 1.4.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
@@ -193,8 +193,8 @@ import '@event-calendar/core/index.css';
193
193
  ### Pre-built browser ready bundle
194
194
  Include the following lines of code in the `<head>` section of your page:
195
195
  ```html
196
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@1.3.0/event-calendar.min.css">
197
- <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@1.3.0/event-calendar.min.js"></script>
196
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@1.4.0/event-calendar.min.css">
197
+ <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@1.4.0/event-calendar.min.js"></script>
198
198
  ```
199
199
 
200
200
  <details>
@@ -1319,7 +1319,9 @@ function(event) {
1319
1319
  </td>
1320
1320
  <td>
1321
1321
 
1322
- [Event](#event-object) object to be analyzed. The function must return `true` to have this event counted, or `false` to ignore it
1322
+ [Event](#event-object) object to be analyzed.
1323
+
1324
+ The function must return `true` to have this event counted, or `false` to ignore it
1323
1325
  </td>
1324
1326
  </tr>
1325
1327
  </table>
package/index.css CHANGED
@@ -151,9 +151,6 @@
151
151
  .ec-all-day .ec-day {
152
152
  padding-bottom: 4px;
153
153
  }
154
- .ec-all-day .ec-event-time {
155
- display: none;
156
- }
157
154
 
158
155
  /* Body */
159
156
  .ec-body {
package/index.js CHANGED
@@ -340,11 +340,18 @@ function getPayload(el) {
340
340
  return el[payloadProp];
341
341
  }
342
342
 
343
- function getElementWithPayload(x, y) {
344
- for (let el of document.elementsFromPoint(x, y)) {
343
+ function getElementWithPayload(x, y, root = document) {
344
+ for (let el of root.elementsFromPoint(x, y)) {
345
345
  if (hasPayload(el)) {
346
346
  return el;
347
347
  }
348
+ /** @see https://github.com/vkurko/calendar/issues/142 */
349
+ if (el.shadowRoot) {
350
+ let shadowEl = getElementWithPayload(x, y, el.shadowRoot);
351
+ if (shadowEl) {
352
+ return shadowEl;
353
+ }
354
+ }
348
355
  }
349
356
  return null;
350
357
  }
@@ -411,16 +418,8 @@ function createEventChunk(event, start, end) {
411
418
  }
412
419
 
413
420
  function sortEventChunks(chunks) {
414
- // Sort by start date
415
- chunks.sort((a, b) => {
416
- if (a.start < b.start) {
417
- return -1;
418
- }
419
- if (a.start > b.start) {
420
- return 1;
421
- }
422
- return 0;
423
- });
421
+ // Sort by start date (all-day events always on top)
422
+ chunks.sort((a, b) => a.start - b.start || b.event.allDay - a.event.allDay);
424
423
  }
425
424
 
426
425
  /**
@@ -487,7 +486,7 @@ function repositionEvent(chunk, longChunks, height) {
487
486
  chunk.bottom = chunk.top + height;
488
487
  let margin = 1;
489
488
  let key = chunk.date.getTime();
490
- if (longChunks[key]) {
489
+ if (longChunks[key]?.sorted || longChunks[key]?.chunks.every(chunk => 'top' in chunk)) {
491
490
  if (!longChunks[key].sorted) {
492
491
  longChunks[key].chunks.sort((a, b) => a.top - b.top);
493
492
  longChunks[key].sorted = true;
@@ -531,7 +530,7 @@ function createEventContent(chunk, displayEventEnd, eventContent, theme, _intlEv
531
530
  default:
532
531
  content = {
533
532
  domNodes: [
534
- createElement('div', theme.eventTime, null, timeText),
533
+ ...chunk.event.allDay ? [] : [createElement('div', theme.eventTime, null, timeText)],
535
534
  createElement('div', theme.eventTitle, chunk.event.titleHTML, chunk.event.title)
536
535
  ]
537
536
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-calendar/core",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "title": "Event Calendar Core package",
5
5
  "description": "Full-sized drag & drop event calendar with resource view",
6
6
  "keywords": [
package/src/index.scss CHANGED
@@ -172,10 +172,6 @@
172
172
  .ec-day {
173
173
  padding-bottom: 4px;
174
174
  }
175
-
176
- .ec-event-time {
177
- display: none;
178
- }
179
175
  }
180
176
 
181
177
  /* Body */
package/src/lib/dom.js CHANGED
@@ -43,11 +43,18 @@ export function getPayload(el) {
43
43
  return el[payloadProp];
44
44
  }
45
45
 
46
- export function getElementWithPayload(x, y) {
47
- for (let el of document.elementsFromPoint(x, y)) {
46
+ export function getElementWithPayload(x, y, root = document) {
47
+ for (let el of root.elementsFromPoint(x, y)) {
48
48
  if (hasPayload(el)) {
49
49
  return el;
50
50
  }
51
+ /** @see https://github.com/vkurko/calendar/issues/142 */
52
+ if (el.shadowRoot) {
53
+ let shadowEl = getElementWithPayload(x, y, el.shadowRoot);
54
+ if (shadowEl) {
55
+ return shadowEl;
56
+ }
57
+ }
51
58
  }
52
59
  return null;
53
60
  }
package/src/lib/events.js CHANGED
@@ -44,16 +44,8 @@ export function createEventChunk(event, start, end) {
44
44
  }
45
45
 
46
46
  export function sortEventChunks(chunks) {
47
- // Sort by start date
48
- chunks.sort((a, b) => {
49
- if (a.start < b.start) {
50
- return -1;
51
- }
52
- if (a.start > b.start) {
53
- return 1;
54
- }
55
- return 0;
56
- });
47
+ // Sort by start date (all-day events always on top)
48
+ chunks.sort((a, b) => a.start - b.start || b.event.allDay - a.event.allDay);
57
49
  }
58
50
 
59
51
  /**
@@ -120,7 +112,7 @@ export function repositionEvent(chunk, longChunks, height) {
120
112
  chunk.bottom = chunk.top + height;
121
113
  let margin = 1;
122
114
  let key = chunk.date.getTime();
123
- if (longChunks[key]) {
115
+ if (longChunks[key]?.sorted || longChunks[key]?.chunks.every(chunk => 'top' in chunk)) {
124
116
  if (!longChunks[key].sorted) {
125
117
  longChunks[key].chunks.sort((a, b) => a.top - b.top);
126
118
  longChunks[key].sorted = true;
@@ -164,7 +156,7 @@ export function createEventContent(chunk, displayEventEnd, eventContent, theme,
164
156
  default:
165
157
  content = {
166
158
  domNodes: [
167
- createElement('div', theme.eventTime, null, timeText),
159
+ ...chunk.event.allDay ? [] : [createElement('div', theme.eventTime, null, timeText)],
168
160
  createElement('div', theme.eventTitle, chunk.event.titleHTML, chunk.event.title)
169
161
  ]
170
162
  };