@event-calendar/core 5.1.4 → 5.2.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
@@ -246,8 +246,8 @@ This bundle contains a version of the calendar that includes all plugins and is
246
246
 
247
247
  The first step is to include the following lines of code in the `<head>` section of your page:
248
248
  ```html
249
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1.4/dist/event-calendar.min.css">
250
- <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1.4/dist/event-calendar.min.js"></script>
249
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.0/dist/event-calendar.min.css">
250
+ <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.0/dist/event-calendar.min.js"></script>
251
251
  ```
252
252
 
253
253
  <details>
@@ -337,9 +337,16 @@ When hidden with `false`, all-day events will not be displayed in `timeGrid`/`re
337
337
 
338
338
  ### buttonText
339
339
  - Type `object` or `function`
340
- - Default `{close: 'Close', dayGridMonth: 'month', listDay: 'list', listMonth: 'list', listWeek: 'list', listYear: 'list', resourceTimeGridDay: 'resources', resourceTimeGridWeek: 'resources', resourceTimelineDay: 'timeline', resourceTimelineMonth: 'timeline', resourceTimelineWeek: 'timeline', timeGridDay: 'day', timeGridWeek: 'week', today: 'today'}`
340
+ <ul>
341
+ <li>
342
+ <details>
343
+ <summary>Default</summary>
344
+
345
+ `{close: 'Close', dayGridMonth: 'month', listDay: 'list', listMonth: 'list', listWeek: 'list', listYear: 'list', resourceTimeGridDay: 'resources', resourceTimeGridWeek: 'resources', resourceTimelineDay: 'timeline', resourceTimelineMonth: 'timeline', resourceTimelineWeek: 'timeline', timeGridDay: 'day', timeGridWeek: 'week', today: 'today'}`
341
346
  > Views override the default value as follows:
347
+ > - dayGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
342
348
  > - dayGridMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
349
+ > - dayGridWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
343
350
  > - listDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
344
351
  > - listMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
345
352
  > - listWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
@@ -352,6 +359,10 @@ When hidden with `false`, all-day events will not be displayed in `timeGrid`/`re
352
359
  > - timeGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
353
360
  > - timeGridWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
354
361
 
362
+ </details>
363
+ </li>
364
+ </ul>
365
+
355
366
  Text that is displayed in buttons of the header toolbar.
356
367
 
357
368
  This value can be either a plain object with all necessary properties, or a callback function that receives default button text object and should return a new one:
@@ -465,7 +476,7 @@ function (customButtons) {
465
476
 
466
477
  Date that is currently displayed on the calendar.
467
478
 
468
- This value can be either a JavaScript Date object, or an ISO8601 date string like `'2022-12-31'`.
479
+ This value can be either a JavaScript Date object, or an ISO8601 date string like `'2026-12-31'`.
469
480
 
470
481
  ### dateClick
471
482
  - Type `function`
@@ -599,7 +610,7 @@ The current [View](#view-object) object
599
610
  - Type `object` or `function`
600
611
  - Default `{day: 'numeric'}`
601
612
 
602
- Defines the text that is displayed inside the day cell in the `dayGrid` view.
613
+ Defines the text that is displayed inside the day cell in the `dayGridMonth` view.
603
614
 
604
615
  This value can be either an object with options for the native JavaScript [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat) object, or a callback function that returns a [Content](#content) with the formatted string:
605
616
 
@@ -647,6 +658,7 @@ function (date) {
647
658
  - Type `object` or `function`
648
659
  - Default `{weekday: 'short', month: 'numeric', day: 'numeric'}`
649
660
  > Views override the default value as follows:
661
+ > - dayGridDay `{weekday: 'long'}`
650
662
  > - dayGridMonth `{weekday: 'short'}`
651
663
  > - resourceTimelineMonth `{weekday: 'short', day: 'numeric'}`
652
664
  > - timeGridDay `{weekday: 'long'}`
@@ -697,7 +709,9 @@ function (date) {
697
709
  - Type `boolean`
698
710
  - Default `true`
699
711
  > Views override the default value as follows:
712
+ > - dayGridDay `false`
700
713
  > - dayGridMonth `false`
714
+ > - dayGridWeek `false`
701
715
  > - resourceTimelineDay `false`
702
716
  > - resourceTimelineMonth `false`
703
717
  > - resourceTimelineWeek `false`
@@ -724,6 +738,7 @@ Determines whether the calendar should automatically scroll during the event dra
724
738
  - Type `string`, `integer` or `object`
725
739
  - Default `{weeks: 1}`
726
740
  > Views override the default value as follows:
741
+ > - dayGridDay `{days: 1}`
727
742
  > - dayGridMonth `{months: 1}`
728
743
  > - listDay `{days: 1}`
729
744
  > - listMonth `{months: 1}`
@@ -1799,7 +1814,7 @@ Exclude certain days-of-the-week from being displayed, where Sunday is `0`, Mond
1799
1814
 
1800
1815
  Array of dates that need to be highlighted in the calendar.
1801
1816
 
1802
- Each date can be either an ISO8601 date string like `'2022-12-31'`, or a JavaScript Date object.
1817
+ Each date can be either an ISO8601 date string like `'2026-12-31'`, or a JavaScript Date object.
1803
1818
 
1804
1819
  ### lazyFetching
1805
1820
  - Type `boolean`
@@ -2297,7 +2312,9 @@ If not specified, then equal to [slotDuration](#slotduration).
2297
2312
 
2298
2313
  `'{allDay: 'ec-all-day', active: 'ec-active', bgEvent: 'ec-bg-event', bgEvents: 'ec-bg-events', body: 'ec-body', button: 'ec-button', buttonGroup: 'ec-button-group', calendar: 'ec', colHead: 'ec-col-head', day: 'ec-day', dayHead: 'ec-day-head', disabled: 'ec-disabled', event: 'ec-event', eventBody: 'ec-event-body', eventTime: 'ec-event-time', eventTitle: 'ec-event-title', events: 'ec-events', grid: 'ec-grid', header: 'ec-header', hidden: 'ec-hidden', highlight: 'ec-highlight', icon: 'ec-icon', main: 'ec-main', noIeb: 'ec-no-ieb', noBeb: 'ec-no-beb', today: 'ec-today', title: 'ec-title', toolbar: 'ec-toolbar', view: 'ec-list ec-week-view', weekdays: ['ec-sun', ec-mon', ec-tue', ec-wed', ec-thu', ec-fri', ec-sat'], draggable: 'ec-draggable', ghost: 'ec-ghost', preview: 'ec-preview', pointer: 'ec-pointer', resizer: 'ec-resizer', start: 'ec-start', dragging: 'ec-dragging', resizingY: 'ec-resizing-y', resizingX: 'ec-resizing-x', selecting: 'ec-selecting', uniform: 'ec-uniform', dayFoot: 'ec-day-foot', otherMonth: 'ec-other-month', popup: 'ec-popup', weekNumber: 'ec-week-number', daySide: 'ec-day-side', eventTag: 'ec-event-tag', noEvents: 'ec-no-events', nowIndicator: 'ec-now-indicator', sidebar: 'ec-sidebar', slot: 'ec-slot', colGroup: 'ec-col-group', expander: 'ec-expander', rowHead: 'ec-row-head', slots: 'ec-slots}'`
2299
2314
  > Views override the default value as follows:
2315
+ > - dayGridDay `theme => ({...theme, view: 'ec-day-grid ec-day-view'})`
2300
2316
  > - dayGridMonth `theme => ({...theme, view: 'ec-day-grid ec-month-view'})`
2317
+ > - dayGridWeek `theme => ({...theme, view: 'ec-day-grid ec-week-view'})`
2301
2318
  > - listDay `theme => ({...theme, view: 'ec-list ec-day-view'})`
2302
2319
  > - listMonth `theme => ({...theme, view: 'ec-list ec-month-view'})`
2303
2320
  > - listWeek `theme => ({...theme, view: 'ec-list ec-week-view'})`
@@ -2438,7 +2455,7 @@ The range should be an object with the following properties:
2438
2455
  </td>
2439
2456
  <td>
2440
2457
 
2441
- `string` or `Date` This should be either an ISO8601 date string like `'2025-12-31'`, or a JavaScript Date object holding the range start date
2458
+ `string` or `Date` This should be either an ISO8601 date string like `'2026-12-31'`, or a JavaScript Date object holding the range start date
2442
2459
  </td>
2443
2460
  </tr>
2444
2461
  <tr>
@@ -2448,7 +2465,7 @@ The range should be an object with the following properties:
2448
2465
  </td>
2449
2466
  <td>
2450
2467
 
2451
- `string` or `Date` This should be either an ISO8601 date string like `'2025-12-31'`, or a JavaScript Date object holding the range end date
2468
+ `string` or `Date` This should be either an ISO8601 date string like `'2026-12-31'`, or a JavaScript Date object holding the range end date
2452
2469
  </td>
2453
2470
  </tr>
2454
2471
  </table>
@@ -2457,9 +2474,25 @@ It is not necessary to specify both properties. The range may have only `start`
2457
2474
 
2458
2475
  ### view
2459
2476
  - Type `string`
2460
- - Default `'resourceTimeGridWeek'`
2461
-
2462
- The view that is displayed in the calendar. Can be `'dayGridMonth'`, `'listDay'`, `'listWeek'`, `'listMonth'`, `'listYear'`, `'resourceTimeGridDay'`, `'resourceTimeGridWeek'`, `'resourceTimelineDay'`, `'resourceTimelineWeek'`, `'resourceTimelineMonth'`, `'timeGridDay'` or `'timeGridWeek'`.
2477
+ - Default `'timeGridWeek'`
2478
+
2479
+ The view that is displayed in the calendar.
2480
+
2481
+ The following values are available:
2482
+ - `'dayGridDay'`
2483
+ - `'dayGridWeek'`
2484
+ - `'dayGridMonth'`
2485
+ - `'listDay'`
2486
+ - `'listWeek'`
2487
+ - `'listMonth'`
2488
+ - `'listYear'`
2489
+ - `'resourceTimeGridDay'`
2490
+ - `'resourceTimeGridWeek'`
2491
+ - `'resourceTimelineDay'`
2492
+ - `'resourceTimelineWeek'`
2493
+ - `'resourceTimelineMonth'`
2494
+ - `'timeGridDay'`
2495
+ - `'timeGridWeek'`
2463
2496
 
2464
2497
  ### viewDidMount
2465
2498
  - Type `function`
@@ -2878,7 +2911,7 @@ Here are all admissible fields for the event’s input object:
2878
2911
  </td>
2879
2912
  <td>
2880
2913
 
2881
- `string` or `Date` This should be either an ISO8601 datetime string like `'2022-12-31 09:00:00'`, or a JavaScript Date object holding the event’s start time
2914
+ `string` or `Date` This should be either an ISO8601 datetime string like `'2026-12-31 09:00:00'`, or a JavaScript Date object holding the event’s start time
2882
2915
  </td>
2883
2916
  </tr>
2884
2917
  <tr>
@@ -2888,7 +2921,7 @@ Here are all admissible fields for the event’s input object:
2888
2921
  </td>
2889
2922
  <td>
2890
2923
 
2891
- `string` or `Date` This should be either an ISO8601 datetime string like `'2022-12-31 13:00:00'`, or a JavaScript Date object holding the event’s end time
2924
+ `string` or `Date` This should be either an ISO8601 datetime string like `'2026-12-31 13:00:00'`, or a JavaScript Date object holding the event’s end time
2892
2925
  </td>
2893
2926
  </tr>
2894
2927
  <tr>
package/dist/index.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * EventCalendar v5.1.4
2
+ * EventCalendar v5.2.0
3
3
  * https://github.com/vkurko/calendar
4
4
  */
5
5
  .ec {
@@ -152,7 +152,10 @@
152
152
  display: flex;
153
153
  flex-direction: row-reverse;
154
154
  justify-content: space-between;
155
- padding: .375rem;
155
+
156
+ .ec-day-grid.ec-month-view & {
157
+ padding: .375rem;
158
+ }
156
159
 
157
160
  .ec-day.ec-other-month & time {
158
161
  opacity: .3;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * EventCalendar v5.1.4
2
+ * EventCalendar v5.2.0
3
3
  * https://github.com/vkurko/calendar
4
4
  */
5
5
  import { untrack, getAbortSignal, tick, getContext, setContext, onMount, mount, unmount } from "svelte";
@@ -473,14 +473,27 @@ function ghostEvent(display) {
473
473
  function pointerEvent(display) {
474
474
  return display === "pointer";
475
475
  }
476
+ const ids = /* @__PURE__ */ new WeakMap();
477
+ let idCounter = 1;
476
478
  function createEventChunk(event, start, end) {
477
- let chunk = {
478
- start: event.start > start ? event.start : start,
479
- end: event.end < end ? event.end : end,
480
- event
479
+ start = event.start > start ? event.start : start;
480
+ end = event.end < end ? event.end : end;
481
+ return {
482
+ start,
483
+ end,
484
+ event,
485
+ get id() {
486
+ let id = ids.get(event);
487
+ if (!id) {
488
+ id = idCounter++;
489
+ ids.set(event, id);
490
+ }
491
+ delete this.id;
492
+ this.id = `${id}-${start.getTime()}`;
493
+ return this.id;
494
+ },
495
+ zeroDuration: datesEqual(start, end)
481
496
  };
482
- chunk.zeroDuration = datesEqual(chunk.start, chunk.end);
483
- return chunk;
484
497
  }
485
498
  function createAllDayChunks(event, days) {
486
499
  let dates = [];
@@ -526,7 +539,7 @@ function prepareAllDayChunks(chunks) {
526
539
  prevChunks[key] = chunk;
527
540
  }
528
541
  }
529
- function repositionEvent$1(chunk, height2, top = 0) {
542
+ function repositionEvent$1(chunk, height2, top = 1) {
530
543
  if (chunk.prev) {
531
544
  top = chunk.prev.bottom + 1;
532
545
  }
@@ -1148,8 +1161,8 @@ function viewDates(mainState) {
1148
1161
  let { hiddenDays } = options;
1149
1162
  let dates = [];
1150
1163
  untrack(() => {
1151
- let date = setMidnight(cloneDate(activeRange2.start));
1152
- let end = setMidnight(cloneDate(activeRange2.end));
1164
+ let date = cloneDate(activeRange2.start);
1165
+ let end = cloneDate(activeRange2.end);
1153
1166
  while (date < end) {
1154
1167
  if (!hiddenDays.includes(date.getUTCDay())) {
1155
1168
  dates.push(cloneDate(date));
@@ -1167,10 +1180,10 @@ function viewDates(mainState) {
1167
1180
  }
1168
1181
  function viewTitle(mainState) {
1169
1182
  return () => {
1170
- let { activeRange: activeRange2, intlTitle, features, options: { date } } = mainState;
1183
+ let { currentRange: currentRange2, intlTitle } = mainState;
1171
1184
  let title;
1172
1185
  untrack(() => {
1173
- title = features.includes("day-grid") ? intlTitle.formatRange(date, date) : intlTitle.formatRange(activeRange2.start, subtractDay(cloneDate(activeRange2.end)));
1186
+ title = intlTitle.formatRange(currentRange2.start, subtractDay(cloneDate(currentRange2.end)));
1174
1187
  });
1175
1188
  return title;
1176
1189
  };
@@ -1391,7 +1404,7 @@ class State {
1391
1404
  }
1392
1405
  }
1393
1406
  var root_2$4 = $.from_html(`<h2></h2>`);
1394
- var root_4 = $.from_html(`<button><i></i></button>`);
1407
+ var root_4$1 = $.from_html(`<button><i></i></button>`);
1395
1408
  var root_6$1 = $.from_html(`<button><i></i></button>`);
1396
1409
  var root_8 = $.from_html(`<button> </button>`);
1397
1410
  var root_10 = $.from_html(`<button></button>`);
@@ -1466,7 +1479,7 @@ function Buttons($$anchor, $$props) {
1466
1479
  var node_2 = $.first_child(fragment_2);
1467
1480
  {
1468
1481
  var consequent_1 = ($$anchor4) => {
1469
- var button_1 = root_4();
1482
+ var button_1 = root_4$1();
1470
1483
  button_1.__click = prev;
1471
1484
  var i = $.child(button_1);
1472
1485
  $.reset(button_1);
@@ -1825,9 +1838,9 @@ function Calendar($$anchor, $$props) {
1825
1838
  }
1826
1839
  function colsCount(mainState) {
1827
1840
  return () => {
1828
- let { options: { hiddenDays } } = mainState;
1841
+ let { viewDates: viewDates2, options: { duration, hiddenDays } } = mainState;
1829
1842
  let count;
1830
- untrack(() => count = 7 - hiddenDays.length);
1843
+ untrack(() => count = duration.months || duration.inWeeks ? 7 - hiddenDays.length : viewDates2.length);
1831
1844
  return count;
1832
1845
  };
1833
1846
  }
@@ -2248,16 +2261,17 @@ function InteractableEvent($$anchor, $$props) {
2248
2261
  }
2249
2262
  $.pop();
2250
2263
  }
2251
- var root_2$3 = $.from_html(`<span></span>`);
2252
- var root_3 = $.from_html(`<a role="button" tabindex="0" aria-haspopup="dialog"></a>`);
2253
- var root_1$8 = $.from_html(`<div><time></time> <!></div> <div><!></div>`, 1);
2264
+ var root_2$3 = $.from_html(`<time></time>`);
2265
+ var root_3 = $.from_html(`<span></span>`);
2266
+ var root_4 = $.from_html(`<a role="button" tabindex="0" aria-haspopup="dialog"></a>`);
2267
+ var root_1$8 = $.from_html(`<div><!> <!></div> <div><!></div>`, 1);
2254
2268
  function Day$3($$anchor, $$props) {
2255
2269
  $.push($$props, true);
2256
2270
  const $firstDay = () => $.store_get($.get(firstDay), "$firstDay", $$stores);
2257
2271
  const [$$stores, $$cleanup] = $.setup_stores();
2258
2272
  let mainState = getContext("state");
2259
2273
  let viewState = getContext("view-state");
2260
- let date = $.derived(() => mainState.options.date), firstDay = $.derived(() => mainState.options.firstDay), moreLinkContent = $.derived(() => mainState.options.moreLinkContent), theme = $.derived(() => mainState.options.theme), weekNumbers = $.derived(() => mainState.options.weekNumbers), weekNumberContent = $.derived(() => mainState.options.weekNumberContent);
2274
+ let features = $.derived(() => mainState.features), date = $.derived(() => mainState.options.date), firstDay = $.derived(() => mainState.options.firstDay), moreLinkContent = $.derived(() => mainState.options.moreLinkContent), theme = $.derived(() => mainState.options.theme), weekNumbers = $.derived(() => mainState.options.weekNumbers), weekNumberContent = $.derived(() => mainState.options.weekNumberContent);
2261
2275
  let hiddenChunks = $.derived(() => viewState.hiddenChunks), intlDayCell = $.derived(() => viewState.intlDayCell);
2262
2276
  let dayStart = $.derived(() => $$props.day.dayStart), disabled = $.derived(() => $$props.day.disabled), highlight = $.derived(() => $$props.day.highlight);
2263
2277
  let otherMonth = $.derived(() => $.get(dayStart).getUTCMonth() !== $.get(date).getUTCMonth());
@@ -2314,26 +2328,36 @@ function Day$3($$anchor, $$props) {
2314
2328
  children: ($$anchor2, $$slotProps) => {
2315
2329
  var fragment_1 = root_1$8();
2316
2330
  var div = $.first_child(fragment_1);
2317
- var time = $.child(div);
2318
- $.attach(time, () => contentFrom($.get(intlDayCell).format($.get(dayStart))));
2319
- var node = $.sibling(time, 2);
2331
+ var node = $.child(div);
2320
2332
  {
2321
2333
  var consequent = ($$anchor3) => {
2322
- var span = root_2$3();
2334
+ var time = root_2$3();
2335
+ $.attach(time, () => contentFrom($.get(intlDayCell).format($.get(dayStart))));
2336
+ $.template_effect(($0) => $.set_attribute(time, "datetime", $0), [() => toISOString($.get(dayStart), 10)]);
2337
+ $.append($$anchor3, time);
2338
+ };
2339
+ $.if(node, ($$render) => {
2340
+ if ($.get(features).includes("dayNumber")) $$render(consequent);
2341
+ });
2342
+ }
2343
+ var node_1 = $.sibling(node, 2);
2344
+ {
2345
+ var consequent_1 = ($$anchor3) => {
2346
+ var span = root_3();
2323
2347
  $.attach(span, () => contentFrom($.get(weekNumber)));
2324
2348
  $.template_effect(() => $.set_class(span, 1, $.get(theme).weekNumber));
2325
2349
  $.append($$anchor3, span);
2326
2350
  };
2327
- $.if(node, ($$render) => {
2328
- if ($.get(showWeekNumber)) $$render(consequent);
2351
+ $.if(node_1, ($$render) => {
2352
+ if ($.get(showWeekNumber)) $$render(consequent_1);
2329
2353
  });
2330
2354
  }
2331
2355
  $.reset(div);
2332
2356
  var div_1 = $.sibling(div, 2);
2333
- var node_1 = $.child(div_1);
2357
+ var node_2 = $.child(div_1);
2334
2358
  {
2335
- var consequent_1 = ($$anchor3) => {
2336
- var a = root_3();
2359
+ var consequent_2 = ($$anchor3) => {
2360
+ var a = root_4();
2337
2361
  var event_handler = $.derived(() => stopPropagation(showMore));
2338
2362
  a.__click = function(...$$args) {
2339
2363
  $.get(event_handler)?.apply(this, $$args);
@@ -2349,19 +2373,15 @@ function Day$3($$anchor, $$props) {
2349
2373
  $.attach(a, () => contentFrom($.get(moreLink)));
2350
2374
  $.append($$anchor3, a);
2351
2375
  };
2352
- $.if(node_1, ($$render) => {
2353
- if ($.get(dayHiddenChunks)) $$render(consequent_1);
2376
+ $.if(node_2, ($$render) => {
2377
+ if ($.get(dayHiddenChunks)) $$render(consequent_2);
2354
2378
  });
2355
2379
  }
2356
2380
  $.reset(div_1);
2357
- $.template_effect(
2358
- ($0) => {
2359
- $.set_class(div, 1, $.get(theme).dayHead);
2360
- $.set_attribute(time, "datetime", $0);
2361
- $.set_class(div_1, 1, $.get(theme).dayFoot);
2362
- },
2363
- [() => toISOString($.get(dayStart), 10)]
2364
- );
2381
+ $.template_effect(() => {
2382
+ $.set_class(div, 1, $.get(theme).dayHead);
2383
+ $.set_class(div_1, 1, $.get(theme).dayFoot);
2384
+ });
2365
2385
  $.append($$anchor2, fragment_1);
2366
2386
  },
2367
2387
  $$slots: { default: true }
@@ -2376,14 +2396,14 @@ function Event$3($$anchor, $$props) {
2376
2396
  let $$d = $.derived(() => getContext("state")), dayMaxEvents = $.derived(() => $.get($$d).options.dayMaxEvents);
2377
2397
  let $$d_1 = $.derived(() => getContext("view-state")), colsCount2 = $.derived(() => $.get($$d_1).colsCount), gridEl = $.derived(() => $.get($$d_1).gridEl), hiddenChunks = $.derived(() => $.get($$d_1).hiddenChunks), popupDay = $.derived(() => $.get($$d_1).popupDay);
2378
2398
  let el = $.state(void 0);
2379
- let margin = $.state(0);
2399
+ let margin = $.state(1);
2380
2400
  let hidden = $.state(false);
2381
2401
  let event = $.derived(() => $$props.chunk.event);
2382
2402
  let display = $.derived(() => $$props.chunk.event.display);
2383
2403
  let dayEl = $.derived(() => $.get(gridEl).children.item(($$props.chunk.gridRow - 1) * $.get(colsCount2) + $$props.chunk.gridColumn - 1));
2384
2404
  $.user_effect(() => {
2385
2405
  if (!inPopup()) {
2386
- $.set(margin, height($.get(dayEl).firstElementChild), true);
2406
+ $.set(margin, height($.get(dayEl).firstElementChild) || 1, true);
2387
2407
  }
2388
2408
  });
2389
2409
  let styles = $.derived(() => (style) => {
@@ -2405,7 +2425,7 @@ function Event$3($$anchor, $$props) {
2405
2425
  return style;
2406
2426
  });
2407
2427
  function reposition() {
2408
- $.set(margin, repositionEvent$1($$props.chunk, height($.get(el)), height($.get(dayEl).firstElementChild)), true);
2428
+ $.set(margin, repositionEvent$1($$props.chunk, height($.get(el)), height($.get(dayEl).firstElementChild) || 1), true);
2409
2429
  }
2410
2430
  function hide() {
2411
2431
  if ($.get(dayMaxEvents) === true) {
@@ -2597,14 +2617,16 @@ function View$3($$anchor, $$props) {
2597
2617
  let grid2 = $.derived(() => viewState.grid), chunks = $.derived(() => viewState.chunks), bgChunks = $.derived(() => viewState.bgChunks), iChunks = $.derived(() => viewState.iChunks), hiddenChunks = $.derived(() => viewState.hiddenChunks), popupDay = $.derived(() => viewState.popupDay);
2598
2618
  let refs = [];
2599
2619
  function reposition() {
2600
- $.get(hiddenChunks).clear();
2601
2620
  runReposition(refs, $.get(chunks));
2621
+ $.get(hiddenChunks).clear();
2622
+ tick().then(hide);
2602
2623
  }
2603
- $.user_effect(reposition);
2604
- $.user_effect(() => {
2605
- $.get(chunks);
2624
+ function hide() {
2625
+ $.get(hiddenChunks).size;
2606
2626
  refs.forEach((ref) => ref.hide());
2607
- });
2627
+ }
2628
+ $.user_effect(reposition);
2629
+ $.user_effect(hide);
2608
2630
  var section = root$7();
2609
2631
  let styles;
2610
2632
  var header = $.child(section);
@@ -2661,7 +2683,7 @@ function View$3($$anchor, $$props) {
2661
2683
  $.bind_this(div_3, ($$value) => viewState.gridEl = $$value, () => viewState?.gridEl);
2662
2684
  var div_4 = $.sibling(div_3, 2);
2663
2685
  var node_1 = $.child(div_4);
2664
- $.each(node_1, 17, () => $.get(chunks), $.index, ($$anchor2, chunk, i) => {
2686
+ $.each(node_1, 19, () => $.get(chunks), (chunk) => chunk.id, ($$anchor2, chunk, i) => {
2665
2687
  $.bind_this(
2666
2688
  Event$3($$anchor2, {
2667
2689
  get chunk() {
@@ -2670,11 +2692,11 @@ function View$3($$anchor, $$props) {
2670
2692
  }),
2671
2693
  ($$value, i2) => refs[i2] = $$value,
2672
2694
  (i2) => refs?.[i2],
2673
- () => [i]
2695
+ () => [$.get(i)]
2674
2696
  );
2675
2697
  });
2676
2698
  var node_2 = $.sibling(node_1, 2);
2677
- $.each(node_2, 17, () => $.get(bgChunks), $.index, ($$anchor2, chunk) => {
2699
+ $.each(node_2, 17, () => $.get(bgChunks), (chunk) => chunk.id, ($$anchor2, chunk) => {
2678
2700
  Event$3($$anchor2, {
2679
2701
  get chunk() {
2680
2702
  return $.get(chunk);
@@ -2734,7 +2756,9 @@ const index$5 = {
2734
2756
  view: "dayGridMonth"
2735
2757
  });
2736
2758
  assign(options.buttonText, {
2759
+ dayGridDay: "day",
2737
2760
  dayGridMonth: "month",
2761
+ dayGridWeek: "week",
2738
2762
  close: "Close"
2739
2763
  });
2740
2764
  assign(options.theme, {
@@ -2745,9 +2769,23 @@ const index$5 = {
2745
2769
  weekNumber: "ec-week-number"
2746
2770
  });
2747
2771
  assign(options.views, {
2772
+ dayGridDay: {
2773
+ buttonText: btnTextDay,
2774
+ component: () => View$3,
2775
+ dayHeaderFormat: { weekday: "long" },
2776
+ displayEventEnd: false,
2777
+ duration: { days: 1 },
2778
+ theme: themeView("ec-day-grid ec-day-view")
2779
+ },
2780
+ dayGridWeek: {
2781
+ buttonText: btnTextWeek,
2782
+ component: () => View$3,
2783
+ displayEventEnd: false,
2784
+ theme: themeView("ec-day-grid ec-week-view")
2785
+ },
2748
2786
  dayGridMonth: {
2749
2787
  buttonText: btnTextMonth,
2750
- component: initViewComponent$4,
2788
+ component: initMonthViewComponent$1,
2751
2789
  dayHeaderFormat: { weekday: "short" },
2752
2790
  dayHeaderAriaLabelFormat: { weekday: "long" },
2753
2791
  displayEventEnd: false,
@@ -2758,8 +2796,8 @@ const index$5 = {
2758
2796
  });
2759
2797
  }
2760
2798
  };
2761
- function initViewComponent$4(mainState) {
2762
- mainState.features = ["day-grid"];
2799
+ function initMonthViewComponent$1(mainState) {
2800
+ mainState.features = ["dayNumber"];
2763
2801
  mainState.extensions.activeRange = (start, end) => {
2764
2802
  let { options: { firstDay } } = mainState;
2765
2803
  return {
@@ -3637,7 +3675,7 @@ function Day$2($$anchor, $$props) {
3637
3675
  $.attach(time_1, () => contentFrom($.get(intlListDaySide).format($$props.date)));
3638
3676
  $.reset(h4);
3639
3677
  var node_1 = $.sibling(h4, 2);
3640
- $.each(node_1, 17, () => $.get(chunks), (chunk) => chunk.event, ($$anchor4, chunk) => {
3678
+ $.each(node_1, 17, () => $.get(chunks), (chunk) => chunk.id, ($$anchor4, chunk) => {
3641
3679
  Event$2($$anchor4, {
3642
3680
  get chunk() {
3643
3681
  return $.get(chunk);
@@ -4562,7 +4600,7 @@ function View$1($$anchor, $$props) {
4562
4600
  $.reset(div_2);
4563
4601
  var div_3 = $.sibling(div_2, 2);
4564
4602
  var node_5 = $.child(div_3);
4565
- $.each(node_5, 17, () => $.get(allDayChunks), $.index, ($$anchor3, chunk, i) => {
4603
+ $.each(node_5, 19, () => $.get(allDayChunks), (chunk) => chunk.id, ($$anchor3, chunk, i) => {
4566
4604
  $.bind_this(
4567
4605
  AllDayEvent($$anchor3, {
4568
4606
  get chunk() {
@@ -4571,11 +4609,11 @@ function View$1($$anchor, $$props) {
4571
4609
  }),
4572
4610
  ($$value, i2) => refs[i2] = $$value,
4573
4611
  (i2) => refs?.[i2],
4574
- () => [i]
4612
+ () => [$.get(i)]
4575
4613
  );
4576
4614
  });
4577
4615
  var node_6 = $.sibling(node_5, 2);
4578
- $.each(node_6, 17, () => $.get(allDayBgChunks), $.index, ($$anchor3, chunk) => {
4616
+ $.each(node_6, 17, () => $.get(allDayBgChunks), (chunk) => chunk.id, ($$anchor3, chunk) => {
4579
4617
  AllDayEvent($$anchor3, {
4580
4618
  get chunk() {
4581
4619
  return $.get(chunk);
@@ -4644,7 +4682,7 @@ function View$1($$anchor, $$props) {
4644
4682
  $.reset(div_6);
4645
4683
  var div_7 = $.sibling(div_6, 2);
4646
4684
  var node_9 = $.child(div_7);
4647
- $.each(node_9, 17, () => $.get(chunks), $.index, ($$anchor2, chunk) => {
4685
+ $.each(node_9, 17, () => $.get(chunks), (chunk) => chunk.id, ($$anchor2, chunk) => {
4648
4686
  Event$1($$anchor2, {
4649
4687
  get chunk() {
4650
4688
  return $.get(chunk);
@@ -4652,7 +4690,7 @@ function View$1($$anchor, $$props) {
4652
4690
  });
4653
4691
  });
4654
4692
  var node_10 = $.sibling(node_9, 2);
4655
- $.each(node_10, 17, () => $.get(bgChunks), $.index, ($$anchor2, chunk) => {
4693
+ $.each(node_10, 17, () => $.get(bgChunks), (chunk) => chunk.id, ($$anchor2, chunk) => {
4656
4694
  Event$1($$anchor2, {
4657
4695
  get chunk() {
4658
4696
  return $.get(chunk);
@@ -5685,7 +5723,7 @@ function View($$anchor, $$props) {
5685
5723
  $.reset(div_4);
5686
5724
  var div_5 = $.sibling(div_4, 2);
5687
5725
  var node_7 = $.child(div_5);
5688
- $.each(node_7, 17, () => $.get(chunks), $.index, ($$anchor2, chunk, i) => {
5726
+ $.each(node_7, 19, () => $.get(chunks), (chunk) => chunk.id, ($$anchor2, chunk, i) => {
5689
5727
  $.bind_this(
5690
5728
  Event($$anchor2, {
5691
5729
  get chunk() {
@@ -5694,11 +5732,11 @@ function View($$anchor, $$props) {
5694
5732
  }),
5695
5733
  ($$value, i2) => refs[i2] = $$value,
5696
5734
  (i2) => refs?.[i2],
5697
- () => [i]
5735
+ () => [$.get(i)]
5698
5736
  );
5699
5737
  });
5700
5738
  var node_8 = $.sibling(node_7, 2);
5701
- $.each(node_8, 17, () => $.get(bgChunks), $.index, ($$anchor2, chunk) => {
5739
+ $.each(node_8, 17, () => $.get(bgChunks), (chunk) => chunk.id, ($$anchor2, chunk) => {
5702
5740
  Event($$anchor2, {
5703
5741
  get chunk() {
5704
5742
  return $.get(chunk);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-calendar/core",
3
- "version": "5.1.4",
3
+ "version": "5.2.0",
4
4
  "title": "Event Calendar Core package",
5
5
  "description": "Full-sized drag & drop event calendar with resource & timeline views",
6
6
  "keywords": [
package/src/lib/chunks.js CHANGED
@@ -2,12 +2,17 @@ import {datesEqual} from './date.js';
2
2
  import {eventIntersects} from './events.js';
3
3
  import {assign} from './utils.js';
4
4
 
5
+ // Storage of unique event identifiers for generating chunk ids
6
+ const ids = new WeakMap();
7
+ let idCounter = 1;
8
+
5
9
  /**
6
10
  * @returns {{
11
+ * id: String, // this can be used as key in Svelte keyed each block
7
12
  * start: Date,
8
13
  * end: Date,
9
14
  * event: Object,
10
- * zeroDuration?: boolean,
15
+ * zeroDuration: boolean,
11
16
  * gridColumn?: Number,
12
17
  * gridRow?: Number,
13
18
  * group?: Object,
@@ -25,14 +30,25 @@ import {assign} from './utils.js';
25
30
  * }}
26
31
  */
27
32
  export function createEventChunk(event, start, end) {
28
- let chunk = {
29
- start: event.start > start ? event.start : start,
30
- end: event.end < end ? event.end : end,
31
- event
32
- };
33
- chunk.zeroDuration = datesEqual(chunk.start, chunk.end);
33
+ start = event.start > start ? event.start : start;
34
+ end = event.end < end ? event.end : end;
34
35
 
35
- return chunk;
36
+ return {
37
+ start,
38
+ end,
39
+ event,
40
+ get id() {
41
+ let id = ids.get(event);
42
+ if (!id) {
43
+ id = idCounter++;
44
+ ids.set(event, id);
45
+ }
46
+ delete this.id;
47
+ this.id = `${id}-${start.getTime()}`;
48
+ return this.id;
49
+ },
50
+ zeroDuration: datesEqual(start, end)
51
+ };
36
52
  }
37
53
 
38
54
  /**
@@ -92,7 +108,7 @@ export function prepareAllDayChunks(chunks) {
92
108
  }
93
109
  }
94
110
 
95
- export function repositionEvent(chunk, height, top = 0) {
111
+ export function repositionEvent(chunk, height, top = 1) {
96
112
  if (chunk.prev) {
97
113
  top = chunk.prev.bottom + 1;
98
114
  }
@@ -10,7 +10,7 @@
10
10
  let mainState = getContext('state');
11
11
  let viewState = getContext('view-state');
12
12
 
13
- let {options: {date, firstDay, moreLinkContent, theme, weekNumbers, weekNumberContent}} = $derived(mainState);
13
+ let {features, options: {date, firstDay, moreLinkContent, theme, weekNumbers, weekNumberContent}} = $derived(mainState);
14
14
  let {hiddenChunks, intlDayCell} = $derived(viewState);
15
15
 
16
16
  let {dayStart, disabled, highlight} = $derived(day);
@@ -59,10 +59,12 @@
59
59
 
60
60
  <BaseDay date={dayStart} allDay {classes} {disabled} {highlight} {noIeb} {noBeb}>
61
61
  <div class="{theme.dayHead}">
62
- <time
63
- datetime="{toISOString(dayStart, 10)}"
64
- {@attach contentFrom(intlDayCell.format(dayStart))}
65
- ></time>
62
+ {#if features.includes('dayNumber')}
63
+ <time
64
+ datetime="{toISOString(dayStart, 10)}"
65
+ {@attach contentFrom(intlDayCell.format(dayStart))}
66
+ ></time>
67
+ {/if}
66
68
  {#if showWeekNumber}
67
69
  <span
68
70
  class="{theme.weekNumber}"
@@ -9,7 +9,7 @@
9
9
  let {colsCount, gridEl, hiddenChunks, popupDay} = $derived(getContext('view-state'));
10
10
 
11
11
  let el = $state();
12
- let margin = $state(0);
12
+ let margin = $state(1);
13
13
  let hidden = $state(false);
14
14
 
15
15
  let event = $derived(chunk.event);
@@ -18,7 +18,7 @@
18
18
 
19
19
  $effect(() => {
20
20
  if (!inPopup) {
21
- margin = height(dayEl.firstElementChild);
21
+ margin = height(dayEl.firstElementChild) || 1;
22
22
  }
23
23
  });
24
24
 
@@ -44,7 +44,7 @@
44
44
  });
45
45
 
46
46
  export function reposition() {
47
- margin = repositionEvent(chunk, height(el), height(dayEl.firstElementChild));
47
+ margin = repositionEvent(chunk, height(el), height(dayEl.firstElementChild) || 1);
48
48
  }
49
49
 
50
50
  export function hide() {
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import {getContext, setContext} from 'svelte';
2
+ import {getContext, setContext, tick} from 'svelte';
3
3
  import {contentFrom, resizeObserver, runReposition} from '#lib';
4
4
  import ViewState from './state.svelte.js';
5
5
  import Day from './Day.svelte';
@@ -16,14 +16,16 @@
16
16
  // Events reposition
17
17
  let refs = [];
18
18
  function reposition() {
19
- hiddenChunks.clear();
20
19
  runReposition(refs, chunks);
20
+ hiddenChunks.clear();
21
+ tick().then(hide);
21
22
  }
22
- $effect(reposition);
23
- $effect(() => {
24
- chunks;
23
+ function hide() {
24
+ hiddenChunks.size;
25
25
  refs.forEach(ref => ref.hide());
26
- });
26
+ }
27
+ $effect(reposition);
28
+ $effect(hide);
27
29
  </script>
28
30
 
29
31
  <section
@@ -59,11 +61,11 @@
59
61
  {/each}
60
62
  </div>
61
63
  <div class="{theme.events}">
62
- {#each chunks as chunk, i}
64
+ {#each chunks as chunk, i (chunk.id)}
63
65
  <!-- svelte-ignore binding_property_non_reactive -->
64
66
  <Event bind:this={refs[i]} {chunk}/>
65
67
  {/each}
66
- {#each bgChunks as chunk}
68
+ {#each bgChunks as chunk (chunk.id)}
67
69
  <Event {chunk}/>
68
70
  {/each}
69
71
  {#each iChunks as chunk}
@@ -4,11 +4,11 @@ import {addDay, bgEvent, cloneDate, createAllDayChunks, datesEqual, outsideRange
4
4
  export function colsCount(mainState) {
5
5
  return () => {
6
6
  // Dependencies
7
- let {options: {hiddenDays}} = mainState;
7
+ let {viewDates, options: {duration, hiddenDays}} = mainState;
8
8
 
9
9
  let count;
10
10
 
11
- untrack(() => count = 7 - hiddenDays.length);
11
+ untrack(() => count = duration.months || duration.inWeeks ? 7 - hiddenDays.length : viewDates.length);
12
12
 
13
13
  return count;
14
14
  };
@@ -1,4 +1,4 @@
1
- import {assign, btnTextMonth, nextClosestDay, prevClosestDay, themeView} from '#lib';
1
+ import {assign, btnTextDay, btnTextMonth, btnTextWeek, nextClosestDay, prevClosestDay, themeView} from '#lib';
2
2
  import View from './View.svelte';
3
3
 
4
4
  export default {
@@ -14,7 +14,9 @@ export default {
14
14
  view: 'dayGridMonth'
15
15
  });
16
16
  assign(options.buttonText, {
17
+ dayGridDay: 'day',
17
18
  dayGridMonth: 'month',
19
+ dayGridWeek: 'week',
18
20
  close: 'Close'
19
21
  });
20
22
  assign(options.theme, {
@@ -25,9 +27,23 @@ export default {
25
27
  weekNumber: 'ec-week-number'
26
28
  });
27
29
  assign(options.views, {
30
+ dayGridDay: {
31
+ buttonText: btnTextDay,
32
+ component: () => View,
33
+ dayHeaderFormat: {weekday: 'long'},
34
+ displayEventEnd: false,
35
+ duration: {days: 1},
36
+ theme: themeView('ec-day-grid ec-day-view')
37
+ },
38
+ dayGridWeek: {
39
+ buttonText: btnTextWeek,
40
+ component: () => View,
41
+ displayEventEnd: false,
42
+ theme: themeView('ec-day-grid ec-week-view')
43
+ },
28
44
  dayGridMonth: {
29
45
  buttonText: btnTextMonth,
30
- component: initViewComponent,
46
+ component: initMonthViewComponent,
31
47
  dayHeaderFormat: {weekday: 'short'},
32
48
  dayHeaderAriaLabelFormat: {weekday: 'long'},
33
49
  displayEventEnd: false,
@@ -39,8 +55,8 @@ export default {
39
55
  }
40
56
  }
41
57
 
42
- function initViewComponent(mainState) {
43
- mainState.features = ['day-grid'];
58
+ function initMonthViewComponent(mainState) {
59
+ mainState.features = ['dayNumber'];
44
60
  mainState.extensions.activeRange = (start, end) => {
45
61
  // Dependencies
46
62
  let {options: {firstDay}} = mainState;
@@ -38,7 +38,7 @@
38
38
  <time {datetime} {@attach contentFrom(intlListDay.format(date))}></time>
39
39
  <time class="{theme.daySide}" {datetime} {@attach contentFrom(intlListDaySide.format(date))}></time>
40
40
  </h4>
41
- {#each chunks as chunk (chunk.event)}
41
+ {#each chunks as chunk (chunk.id)}
42
42
  <Event {chunk}/>
43
43
  {/each}
44
44
  </BaseDay>
@@ -124,11 +124,11 @@
124
124
  {/each}
125
125
  </div>
126
126
  <div class="{theme.events}">
127
- {#each chunks as chunk, i}
127
+ {#each chunks as chunk, i (chunk.id)}
128
128
  <!-- svelte-ignore binding_property_non_reactive -->
129
129
  <Event bind:this={refs[i]} {chunk}/>
130
130
  {/each}
131
- {#each bgChunks as chunk}
131
+ {#each bgChunks as chunk (chunk.id)}
132
132
  <Event {chunk}/>
133
133
  {/each}
134
134
  {#each iChunks as chunk}
@@ -84,11 +84,11 @@
84
84
  {/each}
85
85
  </div>
86
86
  <div class="{theme.events}">
87
- {#each allDayChunks as chunk, i}
87
+ {#each allDayChunks as chunk, i (chunk.id)}
88
88
  <!-- svelte-ignore binding_property_non_reactive -->
89
89
  <AllDayEvent bind:this={refs[i]} {chunk}/>
90
90
  {/each}
91
- {#each allDayBgChunks as chunk}
91
+ {#each allDayBgChunks as chunk (chunk.id)}
92
92
  <AllDayEvent {chunk}/>
93
93
  {/each}
94
94
  {#each allDayIChunks as chunk}
@@ -121,10 +121,10 @@
121
121
  {/each}
122
122
  </div>
123
123
  <div class="{theme.events}">
124
- {#each chunks as chunk}
124
+ {#each chunks as chunk (chunk.id)}
125
125
  <Event {chunk}/>
126
126
  {/each}
127
- {#each bgChunks as chunk}
127
+ {#each bgChunks as chunk (chunk.id)}
128
128
  <Event {chunk}/>
129
129
  {/each}
130
130
  {#each iChunks as chunk}
@@ -1,6 +1,6 @@
1
1
  import {untrack} from 'svelte';
2
2
  import {
3
- addDay, addDuration, cloneDate, createView, isFunction, prevClosestDay, setMidnight, subtractDay,
3
+ addDay, addDuration, cloneDate, createView, isFunction, prevClosestDay, subtractDay,
4
4
  toEventWithLocalDates, toViewWithLocalDates
5
5
  } from '#lib';
6
6
 
@@ -91,8 +91,8 @@ export function viewDates(mainState) {
91
91
  let dates = [];
92
92
 
93
93
  untrack(() => {
94
- let date = setMidnight(cloneDate(activeRange.start));
95
- let end = setMidnight(cloneDate(activeRange.end));
94
+ let date = cloneDate(activeRange.start);
95
+ let end = cloneDate(activeRange.end);
96
96
  while (date < end) {
97
97
  if (!hiddenDays.includes(date.getUTCDay())) {
98
98
  dates.push(cloneDate(date));
@@ -114,14 +114,12 @@ export function viewDates(mainState) {
114
114
  export function viewTitle(mainState) {
115
115
  return () => {
116
116
  // Dependencies
117
- let {activeRange, intlTitle, features, options: {date}} = mainState;
117
+ let {currentRange, intlTitle} = mainState;
118
118
 
119
119
  let title;
120
120
 
121
121
  untrack(() => {
122
- title = features.includes('day-grid')
123
- ? intlTitle.formatRange(date, date)
124
- : intlTitle.formatRange(activeRange.start, subtractDay(cloneDate(activeRange.end)));
122
+ title = intlTitle.formatRange(currentRange.start, subtractDay(cloneDate(currentRange.end)));
125
123
  });
126
124
 
127
125
  return title;
@@ -81,7 +81,10 @@
81
81
  display: flex;
82
82
  flex-direction: row-reverse;
83
83
  justify-content: space-between;
84
- padding: .375rem;
84
+
85
+ .ec-day-grid.ec-month-view & {
86
+ padding: .375rem;
87
+ }
85
88
 
86
89
  .ec-day.ec-other-month & time {
87
90
  opacity: .3;