@event-calendar/core 5.1.4 → 5.2.1
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 +46 -13
- package/dist/index.css +5 -2
- package/dist/index.js +115 -69
- package/package.json +1 -1
- package/src/lib/chunks.js +28 -10
- package/src/plugins/day-grid/Day.svelte +7 -5
- package/src/plugins/day-grid/Event.svelte +3 -3
- package/src/plugins/day-grid/View.svelte +10 -8
- package/src/plugins/day-grid/derived.js +3 -3
- package/src/plugins/day-grid/index.js +20 -4
- package/src/plugins/resource-timeline/View.svelte +2 -2
- package/src/plugins/resource-timeline/derived.js +2 -2
- package/src/plugins/resource-timeline/lib.js +5 -2
- package/src/plugins/time-grid/View.svelte +4 -4
- package/src/plugins/time-grid/derived.js +2 -2
- package/src/plugins/time-grid/lib.js +6 -2
- package/src/storage/derived.js +5 -7
- package/src/styles/days.css +4 -1
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
|
|
250
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1
|
|
249
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.1/dist/event-calendar.min.css">
|
|
250
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.2.1/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
|
-
|
|
340
|
+
<ul>
|
|
341
|
+
<li>
|
|
342
|
+
<details>
|
|
343
|
+
<summary>Default</summary>
|
|
344
|
+
|
|
345
|
+
`{close: 'Close', dayGridDay: 'day', dayGridMonth: 'month', dayGridWeek: 'week', 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 `'
|
|
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 `
|
|
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 `'
|
|
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 `'
|
|
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 `'
|
|
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 `'
|
|
2461
|
-
|
|
2462
|
-
The view that is displayed in the calendar.
|
|
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 `'
|
|
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 `'
|
|
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
|
|
2
|
+
* EventCalendar v5.2.1
|
|
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
|
-
|
|
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
|
|
2
|
+
* EventCalendar v5.2.1
|
|
3
3
|
* https://github.com/vkurko/calendar
|
|
4
4
|
*/
|
|
5
5
|
import { untrack, getAbortSignal, tick, getContext, setContext, onMount, mount, unmount } from "svelte";
|
|
@@ -474,15 +474,16 @@ function pointerEvent(display) {
|
|
|
474
474
|
return display === "pointer";
|
|
475
475
|
}
|
|
476
476
|
function createEventChunk(event, start, end) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
477
|
+
start = event.start > start ? event.start : start;
|
|
478
|
+
end = event.end < end ? event.end : end;
|
|
479
|
+
return {
|
|
480
|
+
start,
|
|
481
|
+
end,
|
|
482
|
+
event,
|
|
483
|
+
zeroDuration: datesEqual(start, end)
|
|
481
484
|
};
|
|
482
|
-
chunk.zeroDuration = datesEqual(chunk.start, chunk.end);
|
|
483
|
-
return chunk;
|
|
484
485
|
}
|
|
485
|
-
function createAllDayChunks(event, days) {
|
|
486
|
+
function createAllDayChunks(event, days, withId = true) {
|
|
486
487
|
let dates = [];
|
|
487
488
|
let lastEnd;
|
|
488
489
|
let gridColumn;
|
|
@@ -500,6 +501,9 @@ function createAllDayChunks(event, days) {
|
|
|
500
501
|
if (dates.length) {
|
|
501
502
|
let chunk = createEventChunk(event, dates[0], lastEnd);
|
|
502
503
|
assign(chunk, { gridColumn, gridRow, dates });
|
|
504
|
+
if (withId) {
|
|
505
|
+
assignChunkId(chunk);
|
|
506
|
+
}
|
|
503
507
|
return [chunk];
|
|
504
508
|
}
|
|
505
509
|
return [];
|
|
@@ -526,7 +530,7 @@ function prepareAllDayChunks(chunks) {
|
|
|
526
530
|
prevChunks[key] = chunk;
|
|
527
531
|
}
|
|
528
532
|
}
|
|
529
|
-
function repositionEvent$1(chunk, height2, top =
|
|
533
|
+
function repositionEvent$1(chunk, height2, top = 1) {
|
|
530
534
|
if (chunk.prev) {
|
|
531
535
|
top = chunk.prev.bottom + 1;
|
|
532
536
|
}
|
|
@@ -548,6 +552,17 @@ function repositionEvent$1(chunk, height2, top = 0) {
|
|
|
548
552
|
assign(chunk, { top, bottom });
|
|
549
553
|
return top;
|
|
550
554
|
}
|
|
555
|
+
const ids = /* @__PURE__ */ new WeakMap();
|
|
556
|
+
let idCounter = 1;
|
|
557
|
+
function assignChunkId(chunk) {
|
|
558
|
+
let { event, gridColumn, gridRow } = chunk;
|
|
559
|
+
let id = ids.get(event);
|
|
560
|
+
if (!id) {
|
|
561
|
+
id = idCounter++;
|
|
562
|
+
ids.set(event, id);
|
|
563
|
+
}
|
|
564
|
+
chunk.id = `${id}-${gridColumn}-${gridRow}`;
|
|
565
|
+
}
|
|
551
566
|
function intl(mainState, option) {
|
|
552
567
|
return () => {
|
|
553
568
|
let { options: { locale } } = mainState;
|
|
@@ -1148,8 +1163,8 @@ function viewDates(mainState) {
|
|
|
1148
1163
|
let { hiddenDays } = options;
|
|
1149
1164
|
let dates = [];
|
|
1150
1165
|
untrack(() => {
|
|
1151
|
-
let date =
|
|
1152
|
-
let end =
|
|
1166
|
+
let date = cloneDate(activeRange2.start);
|
|
1167
|
+
let end = cloneDate(activeRange2.end);
|
|
1153
1168
|
while (date < end) {
|
|
1154
1169
|
if (!hiddenDays.includes(date.getUTCDay())) {
|
|
1155
1170
|
dates.push(cloneDate(date));
|
|
@@ -1167,10 +1182,10 @@ function viewDates(mainState) {
|
|
|
1167
1182
|
}
|
|
1168
1183
|
function viewTitle(mainState) {
|
|
1169
1184
|
return () => {
|
|
1170
|
-
let {
|
|
1185
|
+
let { currentRange: currentRange2, intlTitle } = mainState;
|
|
1171
1186
|
let title;
|
|
1172
1187
|
untrack(() => {
|
|
1173
|
-
title =
|
|
1188
|
+
title = intlTitle.formatRange(currentRange2.start, subtractDay(cloneDate(currentRange2.end)));
|
|
1174
1189
|
});
|
|
1175
1190
|
return title;
|
|
1176
1191
|
};
|
|
@@ -1391,7 +1406,7 @@ class State {
|
|
|
1391
1406
|
}
|
|
1392
1407
|
}
|
|
1393
1408
|
var root_2$4 = $.from_html(`<h2></h2>`);
|
|
1394
|
-
var root_4 = $.from_html(`<button><i></i></button>`);
|
|
1409
|
+
var root_4$1 = $.from_html(`<button><i></i></button>`);
|
|
1395
1410
|
var root_6$1 = $.from_html(`<button><i></i></button>`);
|
|
1396
1411
|
var root_8 = $.from_html(`<button> </button>`);
|
|
1397
1412
|
var root_10 = $.from_html(`<button></button>`);
|
|
@@ -1466,7 +1481,7 @@ function Buttons($$anchor, $$props) {
|
|
|
1466
1481
|
var node_2 = $.first_child(fragment_2);
|
|
1467
1482
|
{
|
|
1468
1483
|
var consequent_1 = ($$anchor4) => {
|
|
1469
|
-
var button_1 = root_4();
|
|
1484
|
+
var button_1 = root_4$1();
|
|
1470
1485
|
button_1.__click = prev;
|
|
1471
1486
|
var i = $.child(button_1);
|
|
1472
1487
|
$.reset(button_1);
|
|
@@ -1825,9 +1840,9 @@ function Calendar($$anchor, $$props) {
|
|
|
1825
1840
|
}
|
|
1826
1841
|
function colsCount(mainState) {
|
|
1827
1842
|
return () => {
|
|
1828
|
-
let { options: { hiddenDays } } = mainState;
|
|
1843
|
+
let { viewDates: viewDates2, options: { duration, hiddenDays } } = mainState;
|
|
1829
1844
|
let count;
|
|
1830
|
-
untrack(() => count = 7 - hiddenDays.length);
|
|
1845
|
+
untrack(() => count = duration.months || duration.inWeeks ? 7 - hiddenDays.length : viewDates2.length);
|
|
1831
1846
|
return count;
|
|
1832
1847
|
};
|
|
1833
1848
|
}
|
|
@@ -1896,7 +1911,7 @@ function iEventChunks$2(mainState, viewState) {
|
|
|
1896
1911
|
}
|
|
1897
1912
|
untrack(() => {
|
|
1898
1913
|
for (let days of grid2) {
|
|
1899
|
-
iChunks = iChunks.concat(createAllDayChunks(event, days));
|
|
1914
|
+
iChunks = iChunks.concat(createAllDayChunks(event, days, false));
|
|
1900
1915
|
}
|
|
1901
1916
|
});
|
|
1902
1917
|
}
|
|
@@ -2248,16 +2263,17 @@ function InteractableEvent($$anchor, $$props) {
|
|
|
2248
2263
|
}
|
|
2249
2264
|
$.pop();
|
|
2250
2265
|
}
|
|
2251
|
-
var root_2$3 = $.from_html(`<
|
|
2252
|
-
var root_3 = $.from_html(`<
|
|
2253
|
-
var
|
|
2266
|
+
var root_2$3 = $.from_html(`<time></time>`);
|
|
2267
|
+
var root_3 = $.from_html(`<span></span>`);
|
|
2268
|
+
var root_4 = $.from_html(`<a role="button" tabindex="0" aria-haspopup="dialog"></a>`);
|
|
2269
|
+
var root_1$8 = $.from_html(`<div><!> <!></div> <div><!></div>`, 1);
|
|
2254
2270
|
function Day$3($$anchor, $$props) {
|
|
2255
2271
|
$.push($$props, true);
|
|
2256
2272
|
const $firstDay = () => $.store_get($.get(firstDay), "$firstDay", $$stores);
|
|
2257
2273
|
const [$$stores, $$cleanup] = $.setup_stores();
|
|
2258
2274
|
let mainState = getContext("state");
|
|
2259
2275
|
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);
|
|
2276
|
+
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
2277
|
let hiddenChunks = $.derived(() => viewState.hiddenChunks), intlDayCell = $.derived(() => viewState.intlDayCell);
|
|
2262
2278
|
let dayStart = $.derived(() => $$props.day.dayStart), disabled = $.derived(() => $$props.day.disabled), highlight = $.derived(() => $$props.day.highlight);
|
|
2263
2279
|
let otherMonth = $.derived(() => $.get(dayStart).getUTCMonth() !== $.get(date).getUTCMonth());
|
|
@@ -2314,26 +2330,36 @@ function Day$3($$anchor, $$props) {
|
|
|
2314
2330
|
children: ($$anchor2, $$slotProps) => {
|
|
2315
2331
|
var fragment_1 = root_1$8();
|
|
2316
2332
|
var div = $.first_child(fragment_1);
|
|
2317
|
-
var
|
|
2318
|
-
$.attach(time, () => contentFrom($.get(intlDayCell).format($.get(dayStart))));
|
|
2319
|
-
var node = $.sibling(time, 2);
|
|
2333
|
+
var node = $.child(div);
|
|
2320
2334
|
{
|
|
2321
2335
|
var consequent = ($$anchor3) => {
|
|
2322
|
-
var
|
|
2336
|
+
var time = root_2$3();
|
|
2337
|
+
$.attach(time, () => contentFrom($.get(intlDayCell).format($.get(dayStart))));
|
|
2338
|
+
$.template_effect(($0) => $.set_attribute(time, "datetime", $0), [() => toISOString($.get(dayStart), 10)]);
|
|
2339
|
+
$.append($$anchor3, time);
|
|
2340
|
+
};
|
|
2341
|
+
$.if(node, ($$render) => {
|
|
2342
|
+
if ($.get(features).includes("dayNumber")) $$render(consequent);
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2345
|
+
var node_1 = $.sibling(node, 2);
|
|
2346
|
+
{
|
|
2347
|
+
var consequent_1 = ($$anchor3) => {
|
|
2348
|
+
var span = root_3();
|
|
2323
2349
|
$.attach(span, () => contentFrom($.get(weekNumber)));
|
|
2324
2350
|
$.template_effect(() => $.set_class(span, 1, $.get(theme).weekNumber));
|
|
2325
2351
|
$.append($$anchor3, span);
|
|
2326
2352
|
};
|
|
2327
|
-
$.if(
|
|
2328
|
-
if ($.get(showWeekNumber)) $$render(
|
|
2353
|
+
$.if(node_1, ($$render) => {
|
|
2354
|
+
if ($.get(showWeekNumber)) $$render(consequent_1);
|
|
2329
2355
|
});
|
|
2330
2356
|
}
|
|
2331
2357
|
$.reset(div);
|
|
2332
2358
|
var div_1 = $.sibling(div, 2);
|
|
2333
|
-
var
|
|
2359
|
+
var node_2 = $.child(div_1);
|
|
2334
2360
|
{
|
|
2335
|
-
var
|
|
2336
|
-
var a =
|
|
2361
|
+
var consequent_2 = ($$anchor3) => {
|
|
2362
|
+
var a = root_4();
|
|
2337
2363
|
var event_handler = $.derived(() => stopPropagation(showMore));
|
|
2338
2364
|
a.__click = function(...$$args) {
|
|
2339
2365
|
$.get(event_handler)?.apply(this, $$args);
|
|
@@ -2349,19 +2375,15 @@ function Day$3($$anchor, $$props) {
|
|
|
2349
2375
|
$.attach(a, () => contentFrom($.get(moreLink)));
|
|
2350
2376
|
$.append($$anchor3, a);
|
|
2351
2377
|
};
|
|
2352
|
-
$.if(
|
|
2353
|
-
if ($.get(dayHiddenChunks)) $$render(
|
|
2378
|
+
$.if(node_2, ($$render) => {
|
|
2379
|
+
if ($.get(dayHiddenChunks)) $$render(consequent_2);
|
|
2354
2380
|
});
|
|
2355
2381
|
}
|
|
2356
2382
|
$.reset(div_1);
|
|
2357
|
-
$.template_effect(
|
|
2358
|
-
(
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
$.set_class(div_1, 1, $.get(theme).dayFoot);
|
|
2362
|
-
},
|
|
2363
|
-
[() => toISOString($.get(dayStart), 10)]
|
|
2364
|
-
);
|
|
2383
|
+
$.template_effect(() => {
|
|
2384
|
+
$.set_class(div, 1, $.get(theme).dayHead);
|
|
2385
|
+
$.set_class(div_1, 1, $.get(theme).dayFoot);
|
|
2386
|
+
});
|
|
2365
2387
|
$.append($$anchor2, fragment_1);
|
|
2366
2388
|
},
|
|
2367
2389
|
$$slots: { default: true }
|
|
@@ -2376,14 +2398,14 @@ function Event$3($$anchor, $$props) {
|
|
|
2376
2398
|
let $$d = $.derived(() => getContext("state")), dayMaxEvents = $.derived(() => $.get($$d).options.dayMaxEvents);
|
|
2377
2399
|
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
2400
|
let el = $.state(void 0);
|
|
2379
|
-
let margin = $.state(
|
|
2401
|
+
let margin = $.state(1);
|
|
2380
2402
|
let hidden = $.state(false);
|
|
2381
2403
|
let event = $.derived(() => $$props.chunk.event);
|
|
2382
2404
|
let display = $.derived(() => $$props.chunk.event.display);
|
|
2383
2405
|
let dayEl = $.derived(() => $.get(gridEl).children.item(($$props.chunk.gridRow - 1) * $.get(colsCount2) + $$props.chunk.gridColumn - 1));
|
|
2384
2406
|
$.user_effect(() => {
|
|
2385
2407
|
if (!inPopup()) {
|
|
2386
|
-
$.set(margin, height($.get(dayEl).firstElementChild), true);
|
|
2408
|
+
$.set(margin, height($.get(dayEl).firstElementChild) || 1, true);
|
|
2387
2409
|
}
|
|
2388
2410
|
});
|
|
2389
2411
|
let styles = $.derived(() => (style) => {
|
|
@@ -2405,7 +2427,7 @@ function Event$3($$anchor, $$props) {
|
|
|
2405
2427
|
return style;
|
|
2406
2428
|
});
|
|
2407
2429
|
function reposition() {
|
|
2408
|
-
$.set(margin, repositionEvent$1($$props.chunk, height($.get(el)), height($.get(dayEl).firstElementChild)), true);
|
|
2430
|
+
$.set(margin, repositionEvent$1($$props.chunk, height($.get(el)), height($.get(dayEl).firstElementChild) || 1), true);
|
|
2409
2431
|
}
|
|
2410
2432
|
function hide() {
|
|
2411
2433
|
if ($.get(dayMaxEvents) === true) {
|
|
@@ -2597,14 +2619,16 @@ function View$3($$anchor, $$props) {
|
|
|
2597
2619
|
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
2620
|
let refs = [];
|
|
2599
2621
|
function reposition() {
|
|
2600
|
-
$.get(hiddenChunks).clear();
|
|
2601
2622
|
runReposition(refs, $.get(chunks));
|
|
2623
|
+
$.get(hiddenChunks).clear();
|
|
2624
|
+
tick().then(hide);
|
|
2602
2625
|
}
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
$.get(chunks);
|
|
2626
|
+
function hide() {
|
|
2627
|
+
$.get(hiddenChunks).size;
|
|
2606
2628
|
refs.forEach((ref) => ref.hide());
|
|
2607
|
-
}
|
|
2629
|
+
}
|
|
2630
|
+
$.user_effect(reposition);
|
|
2631
|
+
$.user_effect(hide);
|
|
2608
2632
|
var section = root$7();
|
|
2609
2633
|
let styles;
|
|
2610
2634
|
var header = $.child(section);
|
|
@@ -2661,7 +2685,7 @@ function View$3($$anchor, $$props) {
|
|
|
2661
2685
|
$.bind_this(div_3, ($$value) => viewState.gridEl = $$value, () => viewState?.gridEl);
|
|
2662
2686
|
var div_4 = $.sibling(div_3, 2);
|
|
2663
2687
|
var node_1 = $.child(div_4);
|
|
2664
|
-
$.each(node_1,
|
|
2688
|
+
$.each(node_1, 19, () => $.get(chunks), (chunk) => chunk.id, ($$anchor2, chunk, i) => {
|
|
2665
2689
|
$.bind_this(
|
|
2666
2690
|
Event$3($$anchor2, {
|
|
2667
2691
|
get chunk() {
|
|
@@ -2670,11 +2694,11 @@ function View$3($$anchor, $$props) {
|
|
|
2670
2694
|
}),
|
|
2671
2695
|
($$value, i2) => refs[i2] = $$value,
|
|
2672
2696
|
(i2) => refs?.[i2],
|
|
2673
|
-
() => [i]
|
|
2697
|
+
() => [$.get(i)]
|
|
2674
2698
|
);
|
|
2675
2699
|
});
|
|
2676
2700
|
var node_2 = $.sibling(node_1, 2);
|
|
2677
|
-
$.each(node_2, 17, () => $.get(bgChunks),
|
|
2701
|
+
$.each(node_2, 17, () => $.get(bgChunks), (chunk) => chunk.id, ($$anchor2, chunk) => {
|
|
2678
2702
|
Event$3($$anchor2, {
|
|
2679
2703
|
get chunk() {
|
|
2680
2704
|
return $.get(chunk);
|
|
@@ -2734,7 +2758,9 @@ const index$5 = {
|
|
|
2734
2758
|
view: "dayGridMonth"
|
|
2735
2759
|
});
|
|
2736
2760
|
assign(options.buttonText, {
|
|
2761
|
+
dayGridDay: "day",
|
|
2737
2762
|
dayGridMonth: "month",
|
|
2763
|
+
dayGridWeek: "week",
|
|
2738
2764
|
close: "Close"
|
|
2739
2765
|
});
|
|
2740
2766
|
assign(options.theme, {
|
|
@@ -2745,9 +2771,23 @@ const index$5 = {
|
|
|
2745
2771
|
weekNumber: "ec-week-number"
|
|
2746
2772
|
});
|
|
2747
2773
|
assign(options.views, {
|
|
2774
|
+
dayGridDay: {
|
|
2775
|
+
buttonText: btnTextDay,
|
|
2776
|
+
component: () => View$3,
|
|
2777
|
+
dayHeaderFormat: { weekday: "long" },
|
|
2778
|
+
displayEventEnd: false,
|
|
2779
|
+
duration: { days: 1 },
|
|
2780
|
+
theme: themeView("ec-day-grid ec-day-view")
|
|
2781
|
+
},
|
|
2782
|
+
dayGridWeek: {
|
|
2783
|
+
buttonText: btnTextWeek,
|
|
2784
|
+
component: () => View$3,
|
|
2785
|
+
displayEventEnd: false,
|
|
2786
|
+
theme: themeView("ec-day-grid ec-week-view")
|
|
2787
|
+
},
|
|
2748
2788
|
dayGridMonth: {
|
|
2749
2789
|
buttonText: btnTextMonth,
|
|
2750
|
-
component:
|
|
2790
|
+
component: initMonthViewComponent$1,
|
|
2751
2791
|
dayHeaderFormat: { weekday: "short" },
|
|
2752
2792
|
dayHeaderAriaLabelFormat: { weekday: "long" },
|
|
2753
2793
|
displayEventEnd: false,
|
|
@@ -2758,8 +2798,8 @@ const index$5 = {
|
|
|
2758
2798
|
});
|
|
2759
2799
|
}
|
|
2760
2800
|
};
|
|
2761
|
-
function
|
|
2762
|
-
mainState.features = ["
|
|
2801
|
+
function initMonthViewComponent$1(mainState) {
|
|
2802
|
+
mainState.features = ["dayNumber"];
|
|
2763
2803
|
mainState.extensions.activeRange = (start, end) => {
|
|
2764
2804
|
let { options: { firstDay } } = mainState;
|
|
2765
2805
|
return {
|
|
@@ -3778,7 +3818,7 @@ function initViewComponent$3(mainState) {
|
|
|
3778
3818
|
mainState.features = ["list"];
|
|
3779
3819
|
return View$2;
|
|
3780
3820
|
}
|
|
3781
|
-
function createChunks$1(event, days) {
|
|
3821
|
+
function createChunks$1(event, days, withId = true) {
|
|
3782
3822
|
let chunks = [];
|
|
3783
3823
|
for (let { gridColumn, gridRow, resource, start, end, disabled } of days) {
|
|
3784
3824
|
if (!disabled && eventIntersects(event, start, end, resource)) {
|
|
@@ -3790,6 +3830,9 @@ function createChunks$1(event, days) {
|
|
|
3790
3830
|
height: (chunk.end - chunk.start) / 1e3,
|
|
3791
3831
|
maxHeight: (end - chunk.start) / 1e3
|
|
3792
3832
|
});
|
|
3833
|
+
if (withId) {
|
|
3834
|
+
assignChunkId(chunk);
|
|
3835
|
+
}
|
|
3793
3836
|
chunks.push(chunk);
|
|
3794
3837
|
}
|
|
3795
3838
|
}
|
|
@@ -3981,9 +4024,9 @@ function iEventChunks$1(mainState, viewState) {
|
|
|
3981
4024
|
untrack(() => {
|
|
3982
4025
|
for (let days of grid2) {
|
|
3983
4026
|
if (event.allDay) {
|
|
3984
|
-
allDayIChunks = allDayIChunks.concat(createAllDayChunks(event, days));
|
|
4027
|
+
allDayIChunks = allDayIChunks.concat(createAllDayChunks(event, days, false));
|
|
3985
4028
|
} else {
|
|
3986
|
-
iChunks = iChunks.concat(createChunks$1(event, days));
|
|
4029
|
+
iChunks = iChunks.concat(createChunks$1(event, days, false));
|
|
3987
4030
|
}
|
|
3988
4031
|
}
|
|
3989
4032
|
});
|
|
@@ -4562,7 +4605,7 @@ function View$1($$anchor, $$props) {
|
|
|
4562
4605
|
$.reset(div_2);
|
|
4563
4606
|
var div_3 = $.sibling(div_2, 2);
|
|
4564
4607
|
var node_5 = $.child(div_3);
|
|
4565
|
-
$.each(node_5,
|
|
4608
|
+
$.each(node_5, 19, () => $.get(allDayChunks), (chunk) => chunk.id, ($$anchor3, chunk, i) => {
|
|
4566
4609
|
$.bind_this(
|
|
4567
4610
|
AllDayEvent($$anchor3, {
|
|
4568
4611
|
get chunk() {
|
|
@@ -4571,11 +4614,11 @@ function View$1($$anchor, $$props) {
|
|
|
4571
4614
|
}),
|
|
4572
4615
|
($$value, i2) => refs[i2] = $$value,
|
|
4573
4616
|
(i2) => refs?.[i2],
|
|
4574
|
-
() => [i]
|
|
4617
|
+
() => [$.get(i)]
|
|
4575
4618
|
);
|
|
4576
4619
|
});
|
|
4577
4620
|
var node_6 = $.sibling(node_5, 2);
|
|
4578
|
-
$.each(node_6, 17, () => $.get(allDayBgChunks),
|
|
4621
|
+
$.each(node_6, 17, () => $.get(allDayBgChunks), (chunk) => chunk.id, ($$anchor3, chunk) => {
|
|
4579
4622
|
AllDayEvent($$anchor3, {
|
|
4580
4623
|
get chunk() {
|
|
4581
4624
|
return $.get(chunk);
|
|
@@ -4644,7 +4687,7 @@ function View$1($$anchor, $$props) {
|
|
|
4644
4687
|
$.reset(div_6);
|
|
4645
4688
|
var div_7 = $.sibling(div_6, 2);
|
|
4646
4689
|
var node_9 = $.child(div_7);
|
|
4647
|
-
$.each(node_9, 17, () => $.get(chunks),
|
|
4690
|
+
$.each(node_9, 17, () => $.get(chunks), (chunk) => chunk.id, ($$anchor2, chunk) => {
|
|
4648
4691
|
Event$1($$anchor2, {
|
|
4649
4692
|
get chunk() {
|
|
4650
4693
|
return $.get(chunk);
|
|
@@ -4652,7 +4695,7 @@ function View$1($$anchor, $$props) {
|
|
|
4652
4695
|
});
|
|
4653
4696
|
});
|
|
4654
4697
|
var node_10 = $.sibling(node_9, 2);
|
|
4655
|
-
$.each(node_10, 17, () => $.get(bgChunks),
|
|
4698
|
+
$.each(node_10, 17, () => $.get(bgChunks), (chunk) => chunk.id, ($$anchor2, chunk) => {
|
|
4656
4699
|
Event$1($$anchor2, {
|
|
4657
4700
|
get chunk() {
|
|
4658
4701
|
return $.get(chunk);
|
|
@@ -5003,7 +5046,7 @@ function initViewComponent$2(mainState) {
|
|
|
5003
5046
|
setExtensions(mainState);
|
|
5004
5047
|
return View_1;
|
|
5005
5048
|
}
|
|
5006
|
-
function createChunks(event, days, monthView2) {
|
|
5049
|
+
function createChunks(event, days, monthView2, withId = true) {
|
|
5007
5050
|
let dates = [];
|
|
5008
5051
|
let firstStart;
|
|
5009
5052
|
let lastEnd;
|
|
@@ -5041,6 +5084,9 @@ function createChunks(event, days, monthView2) {
|
|
|
5041
5084
|
if (dates.length) {
|
|
5042
5085
|
let chunk = createEventChunk(event, firstStart, lastEnd);
|
|
5043
5086
|
assign(chunk, { gridColumn, gridRow, dates, left, width });
|
|
5087
|
+
if (withId) {
|
|
5088
|
+
assignChunkId(chunk);
|
|
5089
|
+
}
|
|
5044
5090
|
return [chunk];
|
|
5045
5091
|
}
|
|
5046
5092
|
return [];
|
|
@@ -5140,7 +5186,7 @@ function eventChunks(mainState, viewState) {
|
|
|
5140
5186
|
function iEventChunks(mainState, viewState) {
|
|
5141
5187
|
return () => {
|
|
5142
5188
|
let { iEvents } = mainState;
|
|
5143
|
-
let { grid: grid2 } = viewState;
|
|
5189
|
+
let { grid: grid2, monthView: monthView2 } = viewState;
|
|
5144
5190
|
let iChunks = [];
|
|
5145
5191
|
for (let [, event] of iEvents) {
|
|
5146
5192
|
if (!event) {
|
|
@@ -5148,7 +5194,7 @@ function iEventChunks(mainState, viewState) {
|
|
|
5148
5194
|
}
|
|
5149
5195
|
untrack(() => {
|
|
5150
5196
|
for (let days of grid2) {
|
|
5151
|
-
iChunks = iChunks.concat(createChunks(event, days));
|
|
5197
|
+
iChunks = iChunks.concat(createChunks(event, days, monthView2, false));
|
|
5152
5198
|
}
|
|
5153
5199
|
});
|
|
5154
5200
|
}
|
|
@@ -5685,7 +5731,7 @@ function View($$anchor, $$props) {
|
|
|
5685
5731
|
$.reset(div_4);
|
|
5686
5732
|
var div_5 = $.sibling(div_4, 2);
|
|
5687
5733
|
var node_7 = $.child(div_5);
|
|
5688
|
-
$.each(node_7,
|
|
5734
|
+
$.each(node_7, 19, () => $.get(chunks), (chunk) => chunk.id, ($$anchor2, chunk, i) => {
|
|
5689
5735
|
$.bind_this(
|
|
5690
5736
|
Event($$anchor2, {
|
|
5691
5737
|
get chunk() {
|
|
@@ -5694,11 +5740,11 @@ function View($$anchor, $$props) {
|
|
|
5694
5740
|
}),
|
|
5695
5741
|
($$value, i2) => refs[i2] = $$value,
|
|
5696
5742
|
(i2) => refs?.[i2],
|
|
5697
|
-
() => [i]
|
|
5743
|
+
() => [$.get(i)]
|
|
5698
5744
|
);
|
|
5699
5745
|
});
|
|
5700
5746
|
var node_8 = $.sibling(node_7, 2);
|
|
5701
|
-
$.each(node_8, 17, () => $.get(bgChunks),
|
|
5747
|
+
$.each(node_8, 17, () => $.get(bgChunks), (chunk) => chunk.id, ($$anchor2, chunk) => {
|
|
5702
5748
|
Event($$anchor2, {
|
|
5703
5749
|
get chunk() {
|
|
5704
5750
|
return $.get(chunk);
|
package/package.json
CHANGED
package/src/lib/chunks.js
CHANGED
|
@@ -4,10 +4,11 @@ import {assign} from './utils.js';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @returns {{
|
|
7
|
+
* id?: String, // this can be used as key in Svelte keyed each block
|
|
7
8
|
* start: Date,
|
|
8
9
|
* end: Date,
|
|
9
10
|
* event: Object,
|
|
10
|
-
* zeroDuration
|
|
11
|
+
* zeroDuration: boolean,
|
|
11
12
|
* gridColumn?: Number,
|
|
12
13
|
* gridRow?: Number,
|
|
13
14
|
* group?: Object,
|
|
@@ -25,20 +26,20 @@ import {assign} from './utils.js';
|
|
|
25
26
|
* }}
|
|
26
27
|
*/
|
|
27
28
|
export function createEventChunk(event, start, end) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
start = event.start > start ? event.start : start;
|
|
30
|
+
end = event.end < end ? event.end : end;
|
|
31
|
+
return {
|
|
32
|
+
start,
|
|
33
|
+
end,
|
|
34
|
+
event,
|
|
35
|
+
zeroDuration: datesEqual(start, end)
|
|
32
36
|
};
|
|
33
|
-
chunk.zeroDuration = datesEqual(chunk.start, chunk.end);
|
|
34
|
-
|
|
35
|
-
return chunk;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Create event chunk for month view and all-day slot in week view
|
|
40
41
|
*/
|
|
41
|
-
export function createAllDayChunks(event, days) {
|
|
42
|
+
export function createAllDayChunks(event, days, withId = true) {
|
|
42
43
|
let dates = [];
|
|
43
44
|
let lastEnd;
|
|
44
45
|
let gridColumn;
|
|
@@ -57,6 +58,9 @@ export function createAllDayChunks(event, days) {
|
|
|
57
58
|
let chunk = createEventChunk(event, dates[0], lastEnd);
|
|
58
59
|
// Chunk layout
|
|
59
60
|
assign(chunk, {gridColumn, gridRow, dates});
|
|
61
|
+
if (withId) {
|
|
62
|
+
assignChunkId(chunk);
|
|
63
|
+
}
|
|
60
64
|
|
|
61
65
|
return [chunk];
|
|
62
66
|
}
|
|
@@ -92,7 +96,7 @@ export function prepareAllDayChunks(chunks) {
|
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
export function repositionEvent(chunk, height, top =
|
|
99
|
+
export function repositionEvent(chunk, height, top = 1) {
|
|
96
100
|
if (chunk.prev) {
|
|
97
101
|
top = chunk.prev.bottom + 1;
|
|
98
102
|
}
|
|
@@ -115,3 +119,17 @@ export function repositionEvent(chunk, height, top = 0) {
|
|
|
115
119
|
|
|
116
120
|
return top;
|
|
117
121
|
}
|
|
122
|
+
|
|
123
|
+
// Storage of unique event identifiers for generating chunk ids
|
|
124
|
+
const ids = new WeakMap();
|
|
125
|
+
let idCounter = 1;
|
|
126
|
+
|
|
127
|
+
export function assignChunkId(chunk) {
|
|
128
|
+
let {event, gridColumn, gridRow} = chunk;
|
|
129
|
+
let id = ids.get(event);
|
|
130
|
+
if (!id) {
|
|
131
|
+
id = idCounter++;
|
|
132
|
+
ids.set(event, id);
|
|
133
|
+
}
|
|
134
|
+
chunk.id = `${id}-${gridColumn}-${gridRow}`;
|
|
135
|
+
}
|
|
@@ -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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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(
|
|
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
|
-
|
|
23
|
-
|
|
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
|
};
|
|
@@ -92,7 +92,7 @@ export function iEventChunks(mainState, viewState) {
|
|
|
92
92
|
}
|
|
93
93
|
untrack(() => {
|
|
94
94
|
for (let days of grid) {
|
|
95
|
-
iChunks = iChunks.concat(createAllDayChunks(event, days));
|
|
95
|
+
iChunks = iChunks.concat(createAllDayChunks(event, days, false));
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
}
|
|
@@ -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:
|
|
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
|
|
43
|
-
mainState.features = ['
|
|
58
|
+
function initMonthViewComponent(mainState) {
|
|
59
|
+
mainState.features = ['dayNumber'];
|
|
44
60
|
mainState.extensions.activeRange = (start, end) => {
|
|
45
61
|
// Dependencies
|
|
46
62
|
let {options: {firstDay}} = mainState;
|
|
@@ -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}
|
|
@@ -74,7 +74,7 @@ export function iEventChunks(mainState, viewState) {
|
|
|
74
74
|
return () => {
|
|
75
75
|
// Dependencies
|
|
76
76
|
let {iEvents} = mainState;
|
|
77
|
-
let {grid} = viewState;
|
|
77
|
+
let {grid, monthView} = viewState;
|
|
78
78
|
|
|
79
79
|
let iChunks = [];
|
|
80
80
|
|
|
@@ -84,7 +84,7 @@ export function iEventChunks(mainState, viewState) {
|
|
|
84
84
|
}
|
|
85
85
|
untrack(() => {
|
|
86
86
|
for (let days of grid) {
|
|
87
|
-
iChunks = iChunks.concat(createChunks(event, days));
|
|
87
|
+
iChunks = iChunks.concat(createChunks(event, days, monthView, false));
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {assign, createDuration, createEventChunk, eventIntersects, max, min} from '#lib';
|
|
1
|
+
import {assign, assignChunkId, createDuration, createEventChunk, eventIntersects, max, min} from '#lib';
|
|
2
2
|
|
|
3
|
-
export function createChunks(event, days, monthView) {
|
|
3
|
+
export function createChunks(event, days, monthView, withId = true) {
|
|
4
4
|
let dates = [];
|
|
5
5
|
let firstStart;
|
|
6
6
|
let lastEnd;
|
|
@@ -39,6 +39,9 @@ export function createChunks(event, days, monthView) {
|
|
|
39
39
|
let chunk = createEventChunk(event, firstStart, lastEnd);
|
|
40
40
|
// Chunk layout
|
|
41
41
|
assign(chunk, {gridColumn, gridRow, dates, left, width});
|
|
42
|
+
if (withId) {
|
|
43
|
+
assignChunkId(chunk);
|
|
44
|
+
}
|
|
42
45
|
|
|
43
46
|
return [chunk];
|
|
44
47
|
}
|
|
@@ -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}
|
|
@@ -87,9 +87,9 @@ export function iEventChunks(mainState, viewState) {
|
|
|
87
87
|
untrack(() => {
|
|
88
88
|
for (let days of grid) {
|
|
89
89
|
if (event.allDay) {
|
|
90
|
-
allDayIChunks = allDayIChunks.concat(createAllDayChunks(event, days));
|
|
90
|
+
allDayIChunks = allDayIChunks.concat(createAllDayChunks(event, days, false));
|
|
91
91
|
} else {
|
|
92
|
-
iChunks = iChunks.concat(createChunks(event, days));
|
|
92
|
+
iChunks = iChunks.concat(createChunks(event, days, false));
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
addDuration, assign, cloneDate, createEventChunk, DAY_IN_SECONDS, eventIntersects, isFunction,
|
|
2
|
+
addDuration, assign, assignChunkId, cloneDate, createEventChunk, DAY_IN_SECONDS, eventIntersects, isFunction,
|
|
3
|
+
subtractDay
|
|
3
4
|
} from '#lib';
|
|
4
5
|
|
|
5
|
-
export function createChunks(event, days) {
|
|
6
|
+
export function createChunks(event, days, withId = true) {
|
|
6
7
|
let chunks = [];
|
|
7
8
|
for (let {gridColumn, gridRow, resource, start, end, disabled} of days) {
|
|
8
9
|
if (!disabled && eventIntersects(event, start, end, resource)) {
|
|
@@ -15,6 +16,9 @@ export function createChunks(event, days) {
|
|
|
15
16
|
height: (chunk.end - chunk.start) / 1000,
|
|
16
17
|
maxHeight: (end - chunk.start) / 1000
|
|
17
18
|
});
|
|
19
|
+
if (withId) {
|
|
20
|
+
assignChunkId(chunk);
|
|
21
|
+
}
|
|
18
22
|
chunks.push(chunk);
|
|
19
23
|
}
|
|
20
24
|
}
|
package/src/storage/derived.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {untrack} from 'svelte';
|
|
2
2
|
import {
|
|
3
|
-
addDay, addDuration, cloneDate, createView, isFunction, prevClosestDay,
|
|
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 =
|
|
95
|
-
let 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 {
|
|
117
|
+
let {currentRange, intlTitle} = mainState;
|
|
118
118
|
|
|
119
119
|
let title;
|
|
120
120
|
|
|
121
121
|
untrack(() => {
|
|
122
|
-
title =
|
|
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;
|
package/src/styles/days.css
CHANGED