@event-calendar/core 5.2.2 → 5.2.3

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
@@ -247,8 +247,8 @@ This bundle contains a version of the calendar that includes all plugins and is
247
247
 
248
248
  The first step is to include the following lines of code in the `<head>` section of your page:
249
249
  ```html
250
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.2/dist/event-calendar.min.css">
251
- <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.2/dist/event-calendar.min.js"></script>
250
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.3/dist/event-calendar.min.css">
251
+ <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.3/dist/event-calendar.min.js"></script>
252
252
  ```
253
253
 
254
254
  <details>
package/dist/index.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * EventCalendar v5.2.2
2
+ * EventCalendar v5.2.3
3
3
  * https://github.com/vkurko/calendar
4
4
  */
5
5
  .ec {
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * EventCalendar v5.2.2
2
+ * EventCalendar v5.2.3
3
3
  * https://github.com/vkurko/calendar
4
4
  */
5
5
  import { untrack, getAbortSignal, tick, getContext, setContext, onMount, mount, unmount } from "svelte";
@@ -219,18 +219,22 @@ function copyTime(toDate, fromDate) {
219
219
  function toSeconds(duration) {
220
220
  return duration.seconds;
221
221
  }
222
- function nextDate(date, duration) {
222
+ function nextDate(date, duration, hiddenDays) {
223
223
  addDuration(date, duration);
224
+ _skipHiddenDays(date, hiddenDays, addDay);
224
225
  return date;
225
226
  }
226
227
  function prevDate(date, duration, hiddenDays) {
227
228
  subtractDuration(date, duration);
229
+ _skipHiddenDays(date, hiddenDays, subtractDay);
230
+ return date;
231
+ }
232
+ function _skipHiddenDays(date, hiddenDays, dateFn) {
228
233
  if (hiddenDays.length && hiddenDays.length < 7) {
229
234
  while (hiddenDays.includes(date.getUTCDay())) {
230
- subtractDay(date);
235
+ dateFn(date);
231
236
  }
232
237
  }
233
- return date;
234
238
  }
235
239
  function getWeekNumber(date, firstDay) {
236
240
  date = cloneDate(date);
@@ -1175,9 +1179,12 @@ function viewDates(mainState) {
1175
1179
  addDay(date);
1176
1180
  }
1177
1181
  if (!dates.length && hiddenDays.length && hiddenDays.length < 7) {
1178
- while (hiddenDays.includes(options.date.getUTCDay())) {
1179
- mainState.setOption("date", addDay(cloneDate(options.date)));
1182
+ while (hiddenDays.includes(date.getUTCDay())) {
1183
+ addDay(date);
1180
1184
  }
1185
+ tick().then(() => {
1186
+ mainState.setOption("date", date);
1187
+ });
1181
1188
  }
1182
1189
  });
1183
1190
  return dates;
@@ -1462,7 +1469,7 @@ function Buttons($$anchor, $$props) {
1462
1469
  mainState.setOption("date", prevDate(cloneDate($.get(date)), $.get(duration), $.get(hiddenDays)));
1463
1470
  }
1464
1471
  function next() {
1465
- mainState.setOption("date", nextDate(cloneDate($.get(date)), $.get(duration)));
1472
+ mainState.setOption("date", nextDate(cloneDate($.get(date)), $.get(duration), $.get(hiddenDays)));
1466
1473
  }
1467
1474
  function setToday() {
1468
1475
  mainState.setOption("date", cloneDate($.get(today)));
@@ -1776,7 +1783,7 @@ function Calendar($$anchor, $$props) {
1776
1783
  return null;
1777
1784
  }
1778
1785
  function next() {
1779
- mainState.setOption("date", nextDate(cloneDate($.get(date)), $.get(duration)));
1786
+ mainState.setOption("date", nextDate(cloneDate($.get(date)), $.get(duration), $.get(hiddenDays)));
1780
1787
  return this;
1781
1788
  }
1782
1789
  function prev() {
@@ -5112,7 +5119,7 @@ function prepareChunks(chunks) {
5112
5119
  }
5113
5120
  }
5114
5121
  function repositionEvent(chunk, height2, monthView2) {
5115
- let top = 0;
5122
+ let top = 1;
5116
5123
  let bottom = top + height2;
5117
5124
  let dayChunks = chunk.day;
5118
5125
  dayChunks.sort((a, b) => (a.top ?? Number.POSITIVE_INFINITY) - (b.top ?? Number.POSITIVE_INFINITY));
@@ -5382,7 +5389,7 @@ function Event($$anchor, $$props) {
5382
5389
  let $$d = $.derived(() => getContext("state")), slotDuration = $.derived(() => $.get($$d).options.slotDuration), slotWidth = $.derived(() => $.get($$d).options.slotWidth);
5383
5390
  let $$d_1 = $.derived(() => getContext("view-state")), monthView2 = $.derived(() => $.get($$d_1).monthView);
5384
5391
  let el = $.state(void 0);
5385
- let margin = $.state(0);
5392
+ let margin = $.state(1);
5386
5393
  let event = $.derived(() => $$props.chunk.event);
5387
5394
  let styles = $.derived(() => (style) => {
5388
5395
  style["grid-column"] = `${$$props.chunk.gridColumn} / span ${$$props.chunk.dates.length}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-calendar/core",
3
- "version": "5.2.2",
3
+ "version": "5.2.3",
4
4
  "title": "Event Calendar Core package",
5
5
  "description": "Full-sized drag & drop event calendar with resource & timeline views",
6
6
  "keywords": [
@@ -56,7 +56,7 @@
56
56
  }
57
57
 
58
58
  function next() {
59
- mainState.setOption('date', nextDate(cloneDate(date), duration));
59
+ mainState.setOption('date', nextDate(cloneDate(date), duration, hiddenDays));
60
60
  }
61
61
 
62
62
  function setToday() {
@@ -117,7 +117,7 @@
117
117
  }
118
118
 
119
119
  export function next() {
120
- mainState.setOption('date', nextDate(cloneDate(date), duration));
120
+ mainState.setOption('date', nextDate(cloneDate(date), duration, hiddenDays));
121
121
  return this;
122
122
  }
123
123
 
package/src/lib/date.js CHANGED
@@ -135,8 +135,10 @@ export function toSeconds(duration) {
135
135
  /**
136
136
  * Move the date forward (when pressing the next button)
137
137
  */
138
- export function nextDate(date, duration) {
138
+ export function nextDate(date, duration, hiddenDays) {
139
139
  addDuration(date, duration);
140
+ _skipHiddenDays(date, hiddenDays, addDay);
141
+
140
142
  return date;
141
143
  }
142
144
 
@@ -145,12 +147,17 @@ export function nextDate(date, duration) {
145
147
  */
146
148
  export function prevDate(date, duration, hiddenDays) {
147
149
  subtractDuration(date, duration);
150
+ _skipHiddenDays(date, hiddenDays, subtractDay);
151
+
152
+ return date;
153
+ }
154
+
155
+ function _skipHiddenDays(date, hiddenDays, dateFn) {
148
156
  if (hiddenDays.length && hiddenDays.length < 7) {
149
157
  while (hiddenDays.includes(date.getUTCDay())) {
150
- subtractDay(date);
158
+ dateFn(date);
151
159
  }
152
160
  }
153
- return date;
154
161
  }
155
162
 
156
163
  /**
@@ -10,7 +10,7 @@
10
10
  let {monthView} = $derived(getContext('view-state'));
11
11
 
12
12
  let el = $state();
13
- let margin = $state(0);
13
+ let margin = $state(1);
14
14
  let event = $derived(chunk.event);
15
15
  // Style
16
16
  let styles = $derived(style => {
@@ -68,7 +68,7 @@ export function prepareChunks(chunks) {
68
68
  }
69
69
 
70
70
  export function repositionEvent(chunk, height, monthView) {
71
- let top = 0;
71
+ let top = 1;
72
72
  let bottom = top + height;
73
73
  let dayChunks = chunk.day;
74
74
  dayChunks.sort((a, b) => (a.top ?? Number.POSITIVE_INFINITY) - (b.top ?? Number.POSITIVE_INFINITY));
@@ -1,4 +1,4 @@
1
- import {untrack} from 'svelte';
1
+ import {tick, untrack} from 'svelte';
2
2
  import {
3
3
  addDay, addDuration, cloneDate, createView, isFunction, prevClosestDay, subtractDay,
4
4
  toEventWithLocalDates, toViewWithLocalDates
@@ -101,9 +101,12 @@ export function viewDates(mainState) {
101
101
  }
102
102
  if (!dates.length && hiddenDays.length && hiddenDays.length < 7) {
103
103
  // Try to move the date
104
- while (hiddenDays.includes(options.date.getUTCDay())) {
105
- mainState.setOption('date', addDay(cloneDate(options.date)));
104
+ while (hiddenDays.includes(date.getUTCDay())) {
105
+ addDay(date);
106
106
  }
107
+ tick().then(() => {
108
+ mainState.setOption('date', date);
109
+ });
107
110
  }
108
111
  });
109
112