@event-calendar/core 5.5.0 → 5.6.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 +119 -19
- package/dist/index.css +1 -1
- package/dist/index.js +108 -97
- package/package.json +2 -2
- package/src/Buttons.svelte +4 -4
- package/src/Calendar.svelte +3 -3
- package/src/lib/components/BaseDay.svelte +15 -4
- package/src/lib/utils.js +4 -0
- package/src/plugins/day-grid/Day.svelte +27 -27
- package/src/plugins/list/Day.svelte +10 -8
- package/src/plugins/list/index.js +4 -4
- package/src/plugins/resource-time-grid/index.js +2 -2
- package/src/plugins/resource-timeline/derived.js +8 -6
- package/src/plugins/resource-timeline/index.js +7 -7
- package/src/plugins/time-grid/options.js +3 -3
- package/src/storage/options.js +4 -1
- package/src/storage/state.svelte.js +2 -2
package/README.md
CHANGED
|
@@ -48,8 +48,10 @@ Inspired by [FullCalendar](https://fullcalendar.io/), it implements similar opti
|
|
|
48
48
|
- [customScrollbars](#customscrollbars)
|
|
49
49
|
- [date](#date)
|
|
50
50
|
- [dateClick](#dateclick)
|
|
51
|
+
- [dateIncrement](#dateincrement)
|
|
51
52
|
- [datesAboveResources](#datesaboveresources)
|
|
52
53
|
- [datesSet](#datesset)
|
|
54
|
+
- [dayCellContent](#daycellcontent)
|
|
53
55
|
- [dayCellFormat](#daycellformat)
|
|
54
56
|
- [dayHeaderAriaLabelFormat](#dayheaderarialabelformat)
|
|
55
57
|
- [dayHeaderFormat](#dayheaderformat)
|
|
@@ -72,9 +74,9 @@ Inspired by [FullCalendar](https://fullcalendar.io/), it implements similar opti
|
|
|
72
74
|
- [eventDragStart](#eventdragstart)
|
|
73
75
|
- [eventDragStop](#eventdragstop)
|
|
74
76
|
- [eventDrop](#eventdrop)
|
|
75
|
-
- [eventDurationEditable](#eventdurationeditable)
|
|
76
77
|
</td><td>
|
|
77
78
|
|
|
79
|
+
- [eventDurationEditable](#eventdurationeditable)
|
|
78
80
|
- [eventFilter](#eventfilter)
|
|
79
81
|
- [eventLongPressDelay](#eventlongpressdelay)
|
|
80
82
|
- [eventMouseEnter](#eventmouseenter)
|
|
@@ -103,13 +105,14 @@ Inspired by [FullCalendar](https://fullcalendar.io/), it implements similar opti
|
|
|
103
105
|
- [loading](#loading)
|
|
104
106
|
- [locale](#locale)
|
|
105
107
|
- [longPressDelay](#longpressdelay)
|
|
108
|
+
- [monthHeaderFormat](#monthheaderformat)
|
|
106
109
|
- [moreLinkContent](#morelinkcontent)
|
|
107
110
|
- [noEventsClick](#noeventsclick)
|
|
108
111
|
- [noEventsContent](#noeventscontent)
|
|
109
112
|
- [nowIndicator](#nowindicator)
|
|
110
|
-
- [pointer](#pointer)
|
|
111
113
|
</td><td>
|
|
112
114
|
|
|
115
|
+
- [pointer](#pointer)
|
|
113
116
|
- [refetchResourcesOnNavigate](#refetchresourcesonnavigate)
|
|
114
117
|
- [resizeConstraint](#resizeconstraint)
|
|
115
118
|
- [resourceExpand](#resourceexpand)
|
|
@@ -257,8 +260,8 @@ This bundle contains a version of the calendar that includes all plugins and is
|
|
|
257
260
|
|
|
258
261
|
The first step is to include the following lines of code in the `<head>` section of your page:
|
|
259
262
|
```html
|
|
260
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.
|
|
261
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.
|
|
263
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.6.0/dist/event-calendar.min.css">
|
|
264
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.6.0/dist/event-calendar.min.js"></script>
|
|
262
265
|
```
|
|
263
266
|
|
|
264
267
|
<details>
|
|
@@ -353,7 +356,7 @@ When hidden with `false`, all-day events will not be displayed in `timeGrid`/`re
|
|
|
353
356
|
<details>
|
|
354
357
|
<summary>Default</summary>
|
|
355
358
|
|
|
356
|
-
`{collapse: 'Collapse', close: 'Close', dayGridDay: 'day', dayGridMonth: 'month', dayGridWeek: 'week', expand: 'Expand', listDay: '
|
|
359
|
+
`{collapse: 'Collapse', close: 'Close', dayGridDay: 'day', dayGridMonth: 'month', dayGridWeek: 'week', expand: 'Expand', listDay: 'day', listMonth: 'month', listWeek: 'week', listYear: 'year', resourceTimeGridDay: 'day', resourceTimeGridWeek: 'week', resourceTimelineDay: 'day', resourceTimelineMonth: 'month', resourceTimelineWeek: 'week', resourceTimelineYear: 'year', timeGridDay: 'day', timeGridWeek: 'week', today: 'today'}`
|
|
357
360
|
> Views override the default value as follows:
|
|
358
361
|
> - dayGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
|
|
359
362
|
> - dayGridMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
|
|
@@ -367,6 +370,7 @@ When hidden with `false`, all-day events will not be displayed in `timeGrid`/`re
|
|
|
367
370
|
> - resourceTimelineDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
|
|
368
371
|
> - resourceTimelineMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
|
|
369
372
|
> - resourceTimelineWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
|
|
373
|
+
> - resourceTimelineYear `text => ({...text, next: 'Next year', prev: 'Previous year'})`
|
|
370
374
|
> - timeGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
|
|
371
375
|
> - timeGridWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
|
|
372
376
|
|
|
@@ -568,6 +572,16 @@ If the current view is a resource view, the [Resource](#resource-object) object
|
|
|
568
572
|
</tr>
|
|
569
573
|
</table>
|
|
570
574
|
|
|
575
|
+
### dateIncrement
|
|
576
|
+
- Type `string`, `integer` or `object`
|
|
577
|
+
- Default `undefined`
|
|
578
|
+
|
|
579
|
+
Defines the interval by which the displayed view is shifted when pressing the prev/next buttons or when the [prev()](#prev)/[next()](#next) methods are called.
|
|
580
|
+
|
|
581
|
+
This should be a value that can be parsed into a [Duration](#duration-object) object.
|
|
582
|
+
|
|
583
|
+
If not specified, then equal to [duration](#duration).
|
|
584
|
+
|
|
571
585
|
### datesAboveResources
|
|
572
586
|
- Type `boolean`
|
|
573
587
|
- Default `false`
|
|
@@ -625,6 +639,60 @@ The current [View](#view-object) object
|
|
|
625
639
|
</tr>
|
|
626
640
|
</table>
|
|
627
641
|
|
|
642
|
+
### dayCellContent
|
|
643
|
+
- Type `Content` or `function`
|
|
644
|
+
- Default `undefined`
|
|
645
|
+
|
|
646
|
+
Defines the content that is rendered inside the day cell.
|
|
647
|
+
|
|
648
|
+
This value can be either a [Content](#content) or a function that returns content:
|
|
649
|
+
|
|
650
|
+
```js
|
|
651
|
+
function (arg) {
|
|
652
|
+
// return Content
|
|
653
|
+
}
|
|
654
|
+
```
|
|
655
|
+
`arg` is an object with the following properties:
|
|
656
|
+
<table>
|
|
657
|
+
<tr>
|
|
658
|
+
<td>
|
|
659
|
+
|
|
660
|
+
`allDay`
|
|
661
|
+
</td>
|
|
662
|
+
<td>
|
|
663
|
+
|
|
664
|
+
`true` or `false`. Determines if the cell is within `all-day` slot. Month and list views are also considered as all-day slots
|
|
665
|
+
</td>
|
|
666
|
+
</tr>
|
|
667
|
+
<tr>
|
|
668
|
+
<td>
|
|
669
|
+
|
|
670
|
+
`date`
|
|
671
|
+
</td>
|
|
672
|
+
<td>JavaScript Date object corresponding to the day</td>
|
|
673
|
+
</tr>
|
|
674
|
+
<tr>
|
|
675
|
+
<td>
|
|
676
|
+
|
|
677
|
+
`isToday`
|
|
678
|
+
</td>
|
|
679
|
+
<td>
|
|
680
|
+
|
|
681
|
+
`true` or `false`. Determines if the cell is for today
|
|
682
|
+
</td>
|
|
683
|
+
</tr>
|
|
684
|
+
<tr>
|
|
685
|
+
<td>
|
|
686
|
+
|
|
687
|
+
`resource`
|
|
688
|
+
</td>
|
|
689
|
+
<td>
|
|
690
|
+
|
|
691
|
+
If the current view is a resource view, the [Resource](#resource-object) object that owns this cell
|
|
692
|
+
</td>
|
|
693
|
+
</tr>
|
|
694
|
+
</table>
|
|
695
|
+
|
|
628
696
|
### dayCellFormat
|
|
629
697
|
- Type `object` or `function`
|
|
630
698
|
- Default `{day: 'numeric'}`
|
|
@@ -680,6 +748,7 @@ function (date) {
|
|
|
680
748
|
> - dayGridDay `{weekday: 'long'}`
|
|
681
749
|
> - dayGridMonth `{weekday: 'short'}`
|
|
682
750
|
> - resourceTimelineMonth `{weekday: 'short', day: 'numeric'}`
|
|
751
|
+
> - resourceTimelineYear `{weekday: 'short', day: 'numeric'}`
|
|
683
752
|
> - timeGridDay `{weekday: 'long'}`
|
|
684
753
|
|
|
685
754
|
Defines the text that is displayed on the calendar’s column headings.
|
|
@@ -734,6 +803,7 @@ function (date) {
|
|
|
734
803
|
> - resourceTimelineDay `false`
|
|
735
804
|
> - resourceTimelineMonth `false`
|
|
736
805
|
> - resourceTimelineWeek `false`
|
|
806
|
+
> - resourceTimelineYear `false`
|
|
737
807
|
|
|
738
808
|
Determines whether to display an event’s end time.
|
|
739
809
|
|
|
@@ -765,6 +835,7 @@ Determines whether the calendar should automatically scroll during the event dra
|
|
|
765
835
|
> - resourceTimeGridDay `{days: 1}`
|
|
766
836
|
> - resourceTimelineDay `{days: 1}`
|
|
767
837
|
> - resourceTimelineMonth `{months: 1}`
|
|
838
|
+
> - resourceTimelineYear `{years: 1}`
|
|
768
839
|
> - timeGridDay `{days: 1}`
|
|
769
840
|
|
|
770
841
|
Sets the duration of a view.
|
|
@@ -1954,6 +2025,29 @@ For touch devices, the amount of time (in milliseconds) the user must hold down
|
|
|
1954
2025
|
|
|
1955
2026
|
For a more granular configuration, see [eventLongPressDelay](#eventlongpressdelay) and [selectLongPressDelay](#selectlongpressdelay).
|
|
1956
2027
|
|
|
2028
|
+
### monthHeaderFormat
|
|
2029
|
+
- Type `object` or `function`
|
|
2030
|
+
- Default `{month: 'long'}`
|
|
2031
|
+
|
|
2032
|
+
Defines the text that is displayed in month headings in `resourceTimelineYear` view.
|
|
2033
|
+
|
|
2034
|
+
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:
|
|
2035
|
+
|
|
2036
|
+
```js
|
|
2037
|
+
function (date) {
|
|
2038
|
+
// return Content with the formatted date string
|
|
2039
|
+
}
|
|
2040
|
+
```
|
|
2041
|
+
<table>
|
|
2042
|
+
<tr>
|
|
2043
|
+
<td>
|
|
2044
|
+
|
|
2045
|
+
`date`
|
|
2046
|
+
</td>
|
|
2047
|
+
<td>JavaScript Date object that needs to be formatted</td>
|
|
2048
|
+
</tr>
|
|
2049
|
+
</table>
|
|
2050
|
+
|
|
1957
2051
|
### moreLinkContent
|
|
1958
2052
|
- Type `Content` or `function`
|
|
1959
2053
|
- Default `undefined`
|
|
@@ -2412,6 +2506,7 @@ Defines how many pixels the user’s mouse must move before the selection begins
|
|
|
2412
2506
|
- Default `'00:30:00'`
|
|
2413
2507
|
> Views override the default value as follows:
|
|
2414
2508
|
> - resourceTimelineMonth `{days: 1}`
|
|
2509
|
+
> - resourceTimelineYear `{days: 1}`
|
|
2415
2510
|
|
|
2416
2511
|
Defines the frequency for displaying time slots.
|
|
2417
2512
|
|
|
@@ -2519,6 +2614,7 @@ If not specified, then equal to [slotDuration](#slotduration).
|
|
|
2519
2614
|
> - resourceTimelineDay `theme => ({...theme, view: 'ec-resource ec-timeline ec-day-view'})`
|
|
2520
2615
|
> - resourceTimelineMonth `theme => ({...theme, view: 'ec-resource ec-timeline ec-month-view'})`
|
|
2521
2616
|
> - resourceTimelineWeek `theme => ({...theme, view: 'ec-resource ec-timeline ec-week-view'})`
|
|
2617
|
+
> - resourceTimelineYear `theme => ({...theme, view: 'ec-resource ec-timeline ec-year-view'})`
|
|
2522
2618
|
> - timeGridDay `theme => ({...theme, view: 'ec-time-grid ec-day-view'})`
|
|
2523
2619
|
> - timeGridWeek `theme => ({...theme, view: 'ec-time-grid ec-week-view'})`
|
|
2524
2620
|
</details>
|
|
@@ -2549,6 +2645,9 @@ function (theme) {
|
|
|
2549
2645
|
- Default `{year: 'numeric', month: 'short', day: 'numeric'}`
|
|
2550
2646
|
> Views override the default value as follows:
|
|
2551
2647
|
> - dayGridMonth `{year: 'numeric', month: 'long'}`
|
|
2648
|
+
> - listDay `{year: 'numeric', month: 'long', day: 'numeric'}`
|
|
2649
|
+
> - listMonth `{year: 'numeric', month: 'long'}`
|
|
2650
|
+
> - listYear `{year: 'numeric'}`
|
|
2552
2651
|
> - timeGridDay `{year: 'numeric', month: 'long', day: 'numeric'}`
|
|
2553
2652
|
|
|
2554
2653
|
Defines the text that is displayed in the header toolbar’s title.
|
|
@@ -2686,6 +2785,7 @@ The following values are available:
|
|
|
2686
2785
|
- `'resourceTimelineDay'`
|
|
2687
2786
|
- `'resourceTimelineWeek'`
|
|
2688
2787
|
- `'resourceTimelineMonth'`
|
|
2788
|
+
- `'resourceTimelineYear'`
|
|
2689
2789
|
- `'timeGridDay'`
|
|
2690
2790
|
- `'timeGridWeek'`
|
|
2691
2791
|
|
|
@@ -2765,7 +2865,7 @@ function (arg) {
|
|
|
2765
2865
|
- Type `boolean`
|
|
2766
2866
|
- Default `false`
|
|
2767
2867
|
|
|
2768
|
-
Determines whether week numbers should be displayed in
|
|
2868
|
+
Determines whether week numbers should be displayed in `dayGrid`/`resourceTimeline` views.
|
|
2769
2869
|
|
|
2770
2870
|
The numbering of weeks depends on the value of [firstDay](#firstday). When `firstDay` is `0`, the [Western](https://en.wikipedia.org/wiki/Week#Other_week_numbering_systems) system is used. Any other value uses the [ISO](https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system) system.
|
|
2771
2871
|
|
|
@@ -2775,20 +2875,20 @@ Methods allow you to manipulate EventCalendar after initialization. They are acc
|
|
|
2775
2875
|
In Svelte, methods are available from a component instance:
|
|
2776
2876
|
```html
|
|
2777
2877
|
<script>
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
let ec = $state();
|
|
2781
|
-
let options = $state({
|
|
2782
|
-
view: 'timeGridWeek',
|
|
2783
|
-
eventSources: [{events: function() {
|
|
2784
|
-
console.log('fetching...');
|
|
2785
|
-
return [];
|
|
2786
|
-
}}]
|
|
2787
|
-
});
|
|
2878
|
+
import {Calendar, TimeGrid} from '@event-calendar/core';
|
|
2788
2879
|
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2880
|
+
let ec = $state();
|
|
2881
|
+
let options = $state({
|
|
2882
|
+
view: 'timeGridWeek',
|
|
2883
|
+
eventSources: [{events: function() {
|
|
2884
|
+
console.log('fetching...');
|
|
2885
|
+
return [];
|
|
2886
|
+
}}]
|
|
2887
|
+
});
|
|
2888
|
+
|
|
2889
|
+
function invokeMethod() {
|
|
2890
|
+
ec.refetchEvents();
|
|
2891
|
+
}
|
|
2792
2892
|
</script>
|
|
2793
2893
|
|
|
2794
2894
|
<button onclick={invokeMethod}>Refetch events</button>
|
package/dist/index.css
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* EventCalendar v5.
|
|
2
|
+
* EventCalendar v5.6.0
|
|
3
3
|
* https://github.com/vkurko/calendar
|
|
4
4
|
*/
|
|
5
5
|
import { getAbortSignal, getContext, mount, onMount, setContext, tick, unmount, untrack } from "svelte";
|
|
@@ -115,6 +115,9 @@ var identity = (x) => x;
|
|
|
115
115
|
function isRtl() {
|
|
116
116
|
return window.getComputedStyle(document.documentElement).direction === "rtl";
|
|
117
117
|
}
|
|
118
|
+
function undefinedOr(fn) {
|
|
119
|
+
return (input) => input === void 0 ? void 0 : fn(input);
|
|
120
|
+
}
|
|
118
121
|
//#endregion
|
|
119
122
|
//#region packages/core/src/lib/date.js
|
|
120
123
|
var DAY_IN_SECONDS = 86400;
|
|
@@ -796,7 +799,9 @@ function createOptions(plugins) {
|
|
|
796
799
|
customButtons: {},
|
|
797
800
|
customScrollbars: false,
|
|
798
801
|
date: /* @__PURE__ */ new Date(),
|
|
802
|
+
dateIncrement: void 0,
|
|
799
803
|
datesSet: void 0,
|
|
804
|
+
dayCellContent: void 0,
|
|
800
805
|
dayHeaderFormat: {
|
|
801
806
|
weekday: "short",
|
|
802
807
|
month: "numeric",
|
|
@@ -897,6 +902,7 @@ function createOptions(plugins) {
|
|
|
897
902
|
function createParsers(plugins) {
|
|
898
903
|
let parsers = {
|
|
899
904
|
date: (input) => setMidnight(createDate(input)),
|
|
905
|
+
dateIncrement: undefinedOr(createDuration),
|
|
900
906
|
duration: createDuration,
|
|
901
907
|
events: createEvents,
|
|
902
908
|
eventSources: createEventSources,
|
|
@@ -1410,7 +1416,7 @@ var State = class {
|
|
|
1410
1416
|
this.#filteredEvents = $.derived(filteredEvents(this));
|
|
1411
1417
|
this.#mainEl = $.state();
|
|
1412
1418
|
this.#now = $.state($.proxy(createDate()));
|
|
1413
|
-
this.#resources = $.state(arrayProxy(this.options.resources));
|
|
1419
|
+
this.#resources = $.state(arrayProxy(isArray(this.options.resources) ? this.options.resources : []));
|
|
1414
1420
|
this.#today = $.state($.proxy(setMidnight(cloneDate(this.now))));
|
|
1415
1421
|
this.#intlEventTime = $.derived(intlRange(this, "eventTimeFormat"));
|
|
1416
1422
|
this.#intlDayHeader = $.derived(intl(this, "dayHeaderFormat"));
|
|
@@ -1444,14 +1450,14 @@ var State = class {
|
|
|
1444
1450
|
//#region packages/core/src/Buttons.svelte
|
|
1445
1451
|
var root_2$5 = $.from_html(`<h2></h2>`);
|
|
1446
1452
|
var root_3$2 = $.from_html(`<button><i></i></button>`);
|
|
1447
|
-
var root_4$
|
|
1453
|
+
var root_4$1 = $.from_html(`<button><i></i></button>`);
|
|
1448
1454
|
var root_5 = $.from_html(`<button> </button>`);
|
|
1449
1455
|
var root_6$1 = $.from_html(`<button></button>`);
|
|
1450
1456
|
var root_7$1 = $.from_html(`<button> </button>`);
|
|
1451
1457
|
function Buttons($$anchor, $$props) {
|
|
1452
1458
|
$.push($$props, true);
|
|
1453
1459
|
let mainState = getContext("state");
|
|
1454
|
-
let currentRange = $.derived(() => mainState.currentRange), today = $.derived(() => mainState.today), viewTitle = $.derived(() => mainState.viewTitle), viewDates = $.derived(() => mainState.viewDates), buttonText = $.derived(() => mainState.options.buttonText), customButtons = $.derived(() => mainState.options.customButtons), date = $.derived(() => mainState.options.date), duration = $.derived(() => mainState.options.duration), hiddenDays = $.derived(() => mainState.options.hiddenDays), theme = $.derived(() => mainState.options.theme), validRange = $.derived(() => mainState.options.validRange), view = $.derived(() => mainState.options.view);
|
|
1460
|
+
let currentRange = $.derived(() => mainState.currentRange), today = $.derived(() => mainState.today), viewTitle = $.derived(() => mainState.viewTitle), viewDates = $.derived(() => mainState.viewDates), buttonText = $.derived(() => mainState.options.buttonText), customButtons = $.derived(() => mainState.options.customButtons), date = $.derived(() => mainState.options.date), dateIncrement = $.derived(() => mainState.options.dateIncrement), duration = $.derived(() => mainState.options.duration), hiddenDays = $.derived(() => mainState.options.hiddenDays), theme = $.derived(() => mainState.options.theme), validRange = $.derived(() => mainState.options.validRange), view = $.derived(() => mainState.options.view);
|
|
1455
1461
|
let prevDisabled = $.state(false);
|
|
1456
1462
|
let nextDisabled = $.state(false);
|
|
1457
1463
|
let todayDisabled = $.state(false);
|
|
@@ -1487,10 +1493,10 @@ function Buttons($$anchor, $$props) {
|
|
|
1487
1493
|
return result;
|
|
1488
1494
|
}
|
|
1489
1495
|
function prev() {
|
|
1490
|
-
mainState.setOption("date", prevDate(cloneDate($.get(date)), $.get(duration), $.get(hiddenDays)));
|
|
1496
|
+
mainState.setOption("date", prevDate(cloneDate($.get(date)), $.get(dateIncrement) ?? $.get(duration), $.get(hiddenDays)));
|
|
1491
1497
|
}
|
|
1492
1498
|
function next() {
|
|
1493
|
-
mainState.setOption("date", nextDate(cloneDate($.get(date)), $.get(duration), $.get(hiddenDays)));
|
|
1499
|
+
mainState.setOption("date", nextDate(cloneDate($.get(date)), $.get(dateIncrement) ?? $.get(duration), $.get(hiddenDays)));
|
|
1494
1500
|
}
|
|
1495
1501
|
function setToday() {
|
|
1496
1502
|
mainState.setOption("date", cloneDate($.get(today)));
|
|
@@ -1521,7 +1527,7 @@ function Buttons($$anchor, $$props) {
|
|
|
1521
1527
|
$.append($$anchor, button_1);
|
|
1522
1528
|
};
|
|
1523
1529
|
var consequent_2 = ($$anchor) => {
|
|
1524
|
-
var button_2 = root_4$
|
|
1530
|
+
var button_2 = root_4$1();
|
|
1525
1531
|
var i_1 = $.child(button_2);
|
|
1526
1532
|
$.reset(button_2);
|
|
1527
1533
|
$.template_effect(() => {
|
|
@@ -1648,7 +1654,7 @@ function Calendar($$anchor, $$props) {
|
|
|
1648
1654
|
let plugins = $.prop($$props, "plugins", 19, () => []), options = $.prop($$props, "options", 19, () => ({}));
|
|
1649
1655
|
let mainState = new State(plugins(), options());
|
|
1650
1656
|
setContext("state", mainState);
|
|
1651
|
-
let auxComponents = $.derived(() => mainState.auxComponents), features = $.derived(() => mainState.features), events = $.derived(() => mainState.events), interaction = $.derived(() => mainState.interaction), iClass = $.derived(() => mainState.iClass), view = $.derived(() => mainState.view), View = $.derived(() => mainState.viewComponent), date = $.derived(() => mainState.options.date), duration = $.derived(() => mainState.options.duration), height = $.derived(() => mainState.options.height), hiddenDays = $.derived(() => mainState.options.hiddenDays), customScrollbars = $.derived(() => mainState.options.customScrollbars), theme = $.derived(() => mainState.options.theme);
|
|
1657
|
+
let auxComponents = $.derived(() => mainState.auxComponents), features = $.derived(() => mainState.features), events = $.derived(() => mainState.events), interaction = $.derived(() => mainState.interaction), iClass = $.derived(() => mainState.iClass), view = $.derived(() => mainState.view), View = $.derived(() => mainState.viewComponent), date = $.derived(() => mainState.options.date), dateIncrement = $.derived(() => mainState.options.dateIncrement), duration = $.derived(() => mainState.options.duration), height = $.derived(() => mainState.options.height), hiddenDays = $.derived(() => mainState.options.hiddenDays), customScrollbars = $.derived(() => mainState.options.customScrollbars), theme = $.derived(() => mainState.options.theme);
|
|
1652
1658
|
let prevOptions = { ...options() };
|
|
1653
1659
|
$.user_pre_effect(() => {
|
|
1654
1660
|
for (let [name, value] of diff(options(), prevOptions)) untrack(() => {
|
|
@@ -1718,11 +1724,11 @@ function Calendar($$anchor, $$props) {
|
|
|
1718
1724
|
return null;
|
|
1719
1725
|
}
|
|
1720
1726
|
function next() {
|
|
1721
|
-
mainState.setOption("date", nextDate(cloneDate($.get(date)), $.get(duration), $.get(hiddenDays)));
|
|
1727
|
+
mainState.setOption("date", nextDate(cloneDate($.get(date)), $.get(dateIncrement) ?? $.get(duration), $.get(hiddenDays)));
|
|
1722
1728
|
return this;
|
|
1723
1729
|
}
|
|
1724
1730
|
function prev() {
|
|
1725
|
-
mainState.setOption("date", prevDate(cloneDate($.get(date)), $.get(duration), $.get(hiddenDays)));
|
|
1731
|
+
mainState.setOption("date", prevDate(cloneDate($.get(date)), $.get(dateIncrement) ?? $.get(duration), $.get(hiddenDays)));
|
|
1726
1732
|
return this;
|
|
1727
1733
|
}
|
|
1728
1734
|
var $$exports = {
|
|
@@ -1931,9 +1937,15 @@ var root$9 = $.from_html(`<div><!></div>`);
|
|
|
1931
1937
|
function BaseDay($$anchor, $$props) {
|
|
1932
1938
|
$.push($$props, true);
|
|
1933
1939
|
let el = $.prop($$props, "el", 15), allDay = $.prop($$props, "allDay", 3, false), resource = $.prop($$props, "resource", 3, void 0), dateFromPoint = $.prop($$props, "dateFromPoint", 3, () => $$props.date), classes = $.prop($$props, "classes", 3, identity), disabled = $.prop($$props, "disabled", 3, false), highlight = $.prop($$props, "highlight", 3, false), role = $.prop($$props, "role", 3, "cell"), noIeb = $.prop($$props, "noIeb", 3, false), noBeb = $.prop($$props, "noBeb", 3, false);
|
|
1934
|
-
let $$d = $.derived(() => getContext("state")), today = $.derived(() => $.get($$d).today), action = $.derived(() => $.get($$d).interaction.action), theme = $.derived(() => $.get($$d).options.theme);
|
|
1940
|
+
let $$d = $.derived(() => getContext("state")), today = $.derived(() => $.get($$d).today), action = $.derived(() => $.get($$d).interaction.action), dayCellContent = $.derived(() => $.get($$d).options.dayCellContent), theme = $.derived(() => $.get($$d).options.theme);
|
|
1935
1941
|
let $$d_1 = $.derived(() => getContext("view-state")), snap = $.derived(() => $.get($$d_1).snap);
|
|
1936
1942
|
let isToday = $.derived(() => datesEqual($$props.date, $.get(today)));
|
|
1943
|
+
let dayContent = $.derived(() => isFunction($.get(dayCellContent)) ? $.get(dayCellContent)({
|
|
1944
|
+
allDay: allDay(),
|
|
1945
|
+
date: toLocalDate($$props.date),
|
|
1946
|
+
isToday: $.get(isToday),
|
|
1947
|
+
resource: resource()
|
|
1948
|
+
}) : $.get(dayCellContent));
|
|
1937
1949
|
let classNames = $.derived(() => classes()([
|
|
1938
1950
|
$.get(theme).day,
|
|
1939
1951
|
$.get(theme).weekdays?.[$$props.date.getUTCDay()],
|
|
@@ -1957,9 +1969,10 @@ function BaseDay($$anchor, $$props) {
|
|
|
1957
1969
|
let onpointerdown = $.derived(() => !disabled() && $.get(action) ? (jsEvent) => $.get(action).select(jsEvent, $.get(snap)) : void 0);
|
|
1958
1970
|
var div = root$9();
|
|
1959
1971
|
var node = $.child(div);
|
|
1960
|
-
$.snippet(node, () => $$props.
|
|
1972
|
+
$.snippet(node, () => $$props.content ?? $.noop, () => $.get(dayContent));
|
|
1961
1973
|
$.reset(div);
|
|
1962
1974
|
$.bind_this(div, ($$value) => el($$value), () => el());
|
|
1975
|
+
$.attach(div, () => $$props.content ? null : contentFrom($.get(dayContent)));
|
|
1963
1976
|
$.template_effect(() => {
|
|
1964
1977
|
$.set_class(div, 1, $.clsx($.get(classNames)));
|
|
1965
1978
|
$.set_attribute(div, "role", role());
|
|
@@ -2193,15 +2206,15 @@ function InteractableEvent($$anchor, $$props) {
|
|
|
2193
2206
|
}
|
|
2194
2207
|
//#endregion
|
|
2195
2208
|
//#region packages/core/src/plugins/day-grid/Day.svelte
|
|
2196
|
-
var root_2$4 = $.from_html(`<
|
|
2197
|
-
var root_3 = $.from_html(`<
|
|
2198
|
-
var
|
|
2199
|
-
var root_1$10 = $.from_html(`<div><!> <!></div> <div><!></div>`, 1);
|
|
2209
|
+
var root_2$4 = $.from_html(`<span></span>`);
|
|
2210
|
+
var root_3 = $.from_html(`<a role="button" tabindex="0" aria-haspopup="dialog"></a>`);
|
|
2211
|
+
var root_1$10 = $.from_html(`<div><time></time> <!></div> <div><!></div>`, 1);
|
|
2200
2212
|
function Day$3($$anchor, $$props) {
|
|
2201
2213
|
$.push($$props, true);
|
|
2202
2214
|
let mainState = getContext("state");
|
|
2203
2215
|
let viewState = getContext("view-state");
|
|
2204
|
-
|
|
2216
|
+
$.derived(() => mainState.features);
|
|
2217
|
+
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);
|
|
2205
2218
|
let hiddenChunks = $.derived(() => viewState.hiddenChunks), intlDayCell = $.derived(() => viewState.intlDayCell);
|
|
2206
2219
|
let dayStart = $.derived(() => $$props.day.dayStart), disabled = $.derived(() => $$props.day.disabled), highlight = $.derived(() => $$props.day.highlight);
|
|
2207
2220
|
let otherMonth = $.derived(() => $.get(dayStart).getUTCMonth() !== $.get(date).getUTCMonth());
|
|
@@ -2224,55 +2237,27 @@ function Day$3($$anchor, $$props) {
|
|
|
2224
2237
|
function showMore() {
|
|
2225
2238
|
viewState.popupDay = $$props.day;
|
|
2226
2239
|
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
return $.get(dayStart);
|
|
2230
|
-
},
|
|
2231
|
-
allDay: true,
|
|
2232
|
-
get classes() {
|
|
2233
|
-
return $.get(classes);
|
|
2234
|
-
},
|
|
2235
|
-
get disabled() {
|
|
2236
|
-
return $.get(disabled);
|
|
2237
|
-
},
|
|
2238
|
-
get highlight() {
|
|
2239
|
-
return $.get(highlight);
|
|
2240
|
-
},
|
|
2241
|
-
get noIeb() {
|
|
2242
|
-
return $$props.noIeb;
|
|
2243
|
-
},
|
|
2244
|
-
get noBeb() {
|
|
2245
|
-
return $$props.noBeb;
|
|
2246
|
-
},
|
|
2247
|
-
children: ($$anchor, $$slotProps) => {
|
|
2240
|
+
{
|
|
2241
|
+
const content = ($$anchor, dayContent = $.noop) => {
|
|
2248
2242
|
var fragment_1 = root_1$10();
|
|
2249
2243
|
var div = $.first_child(fragment_1);
|
|
2250
|
-
var
|
|
2244
|
+
var time = $.child(div);
|
|
2245
|
+
$.attach(time, () => contentFrom(dayContent() ?? $.get(intlDayCell).format($.get(dayStart))));
|
|
2246
|
+
var node = $.sibling(time, 2);
|
|
2251
2247
|
var consequent = ($$anchor) => {
|
|
2252
|
-
var
|
|
2253
|
-
$.attach(time, () => contentFrom($.get(intlDayCell).format($.get(dayStart))));
|
|
2254
|
-
$.template_effect(($0) => $.set_attribute(time, "datetime", $0), [() => toISOString($.get(dayStart), 10)]);
|
|
2255
|
-
$.append($$anchor, time);
|
|
2256
|
-
};
|
|
2257
|
-
var d = $.derived(() => $.get(features).includes("dayNumber"));
|
|
2258
|
-
$.if(node, ($$render) => {
|
|
2259
|
-
if ($.get(d)) $$render(consequent);
|
|
2260
|
-
});
|
|
2261
|
-
var node_1 = $.sibling(node, 2);
|
|
2262
|
-
var consequent_1 = ($$anchor) => {
|
|
2263
|
-
var span = root_3();
|
|
2248
|
+
var span = root_2$4();
|
|
2264
2249
|
$.attach(span, () => contentFrom($.get(weekNumber)));
|
|
2265
2250
|
$.template_effect(() => $.set_class(span, 1, $.get(theme).weekNumber));
|
|
2266
2251
|
$.append($$anchor, span);
|
|
2267
2252
|
};
|
|
2268
|
-
$.if(
|
|
2269
|
-
if ($.get(showWeekNumber)) $$render(
|
|
2253
|
+
$.if(node, ($$render) => {
|
|
2254
|
+
if ($.get(showWeekNumber)) $$render(consequent);
|
|
2270
2255
|
});
|
|
2271
2256
|
$.reset(div);
|
|
2272
2257
|
var div_1 = $.sibling(div, 2);
|
|
2273
|
-
var
|
|
2274
|
-
var
|
|
2275
|
-
var a =
|
|
2258
|
+
var node_1 = $.child(div_1);
|
|
2259
|
+
var consequent_1 = ($$anchor) => {
|
|
2260
|
+
var a = root_3();
|
|
2276
2261
|
var event_handler = $.derived(() => stopPropagation(showMore));
|
|
2277
2262
|
var event_handler_1 = $.derived(() => keyEnter(showMore));
|
|
2278
2263
|
var event_handler_2 = $.derived(stopPropagation);
|
|
@@ -2288,18 +2273,41 @@ function Day$3($$anchor, $$props) {
|
|
|
2288
2273
|
});
|
|
2289
2274
|
$.append($$anchor, a);
|
|
2290
2275
|
};
|
|
2291
|
-
$.if(
|
|
2292
|
-
if ($.get(dayHiddenChunks)) $$render(
|
|
2276
|
+
$.if(node_1, ($$render) => {
|
|
2277
|
+
if ($.get(dayHiddenChunks)) $$render(consequent_1);
|
|
2293
2278
|
});
|
|
2294
2279
|
$.reset(div_1);
|
|
2295
|
-
$.template_effect(() => {
|
|
2280
|
+
$.template_effect(($0) => {
|
|
2296
2281
|
$.set_class(div, 1, $.get(theme).dayHead);
|
|
2282
|
+
$.set_attribute(time, "datetime", $0);
|
|
2297
2283
|
$.set_class(div_1, 1, $.get(theme).dayFoot);
|
|
2298
|
-
});
|
|
2284
|
+
}, [() => toISOString($.get(dayStart), 10)]);
|
|
2299
2285
|
$.append($$anchor, fragment_1);
|
|
2300
|
-
}
|
|
2301
|
-
$$
|
|
2302
|
-
|
|
2286
|
+
};
|
|
2287
|
+
BaseDay($$anchor, {
|
|
2288
|
+
get date() {
|
|
2289
|
+
return $.get(dayStart);
|
|
2290
|
+
},
|
|
2291
|
+
allDay: true,
|
|
2292
|
+
get classes() {
|
|
2293
|
+
return $.get(classes);
|
|
2294
|
+
},
|
|
2295
|
+
get disabled() {
|
|
2296
|
+
return $.get(disabled);
|
|
2297
|
+
},
|
|
2298
|
+
get highlight() {
|
|
2299
|
+
return $.get(highlight);
|
|
2300
|
+
},
|
|
2301
|
+
get noIeb() {
|
|
2302
|
+
return $$props.noIeb;
|
|
2303
|
+
},
|
|
2304
|
+
get noBeb() {
|
|
2305
|
+
return $$props.noBeb;
|
|
2306
|
+
},
|
|
2307
|
+
content,
|
|
2308
|
+
$$slots: { content: true }
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2303
2311
|
$.pop();
|
|
2304
2312
|
}
|
|
2305
2313
|
$.delegate([
|
|
@@ -3476,23 +3484,12 @@ function Day$2($$anchor, $$props) {
|
|
|
3476
3484
|
var fragment = $.comment();
|
|
3477
3485
|
var node = $.first_child(fragment);
|
|
3478
3486
|
var consequent = ($$anchor) => {
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
return $$props.date;
|
|
3482
|
-
},
|
|
3483
|
-
allDay: true,
|
|
3484
|
-
role: "listitem",
|
|
3485
|
-
get disabled() {
|
|
3486
|
-
return $.get(disabled);
|
|
3487
|
-
},
|
|
3488
|
-
get highlight() {
|
|
3489
|
-
return $.get(highlight);
|
|
3490
|
-
},
|
|
3491
|
-
children: ($$anchor, $$slotProps) => {
|
|
3487
|
+
{
|
|
3488
|
+
const content = ($$anchor, dayContent = $.noop) => {
|
|
3492
3489
|
var fragment_2 = root_2$1();
|
|
3493
3490
|
var h4 = $.first_child(fragment_2);
|
|
3494
3491
|
var time = $.child(h4);
|
|
3495
|
-
$.attach(time, () => contentFrom($.get(intlListDay).format($$props.date)));
|
|
3492
|
+
$.attach(time, () => contentFrom(dayContent() ?? $.get(intlListDay).format($$props.date)));
|
|
3496
3493
|
var time_1 = $.sibling(time, 2);
|
|
3497
3494
|
$.attach(time_1, () => contentFrom($.get(intlListDaySide).format($$props.date)));
|
|
3498
3495
|
$.reset(h4);
|
|
@@ -3509,9 +3506,23 @@ function Day$2($$anchor, $$props) {
|
|
|
3509
3506
|
$.set_attribute(time_1, "datetime", $.get(datetime));
|
|
3510
3507
|
});
|
|
3511
3508
|
$.append($$anchor, fragment_2);
|
|
3512
|
-
}
|
|
3513
|
-
$$
|
|
3514
|
-
|
|
3509
|
+
};
|
|
3510
|
+
BaseDay($$anchor, {
|
|
3511
|
+
get date() {
|
|
3512
|
+
return $$props.date;
|
|
3513
|
+
},
|
|
3514
|
+
allDay: true,
|
|
3515
|
+
role: "listitem",
|
|
3516
|
+
get disabled() {
|
|
3517
|
+
return $.get(disabled);
|
|
3518
|
+
},
|
|
3519
|
+
get highlight() {
|
|
3520
|
+
return $.get(highlight);
|
|
3521
|
+
},
|
|
3522
|
+
content,
|
|
3523
|
+
$$slots: { content: true }
|
|
3524
|
+
});
|
|
3525
|
+
}
|
|
3515
3526
|
};
|
|
3516
3527
|
$.if(node, ($$render) => {
|
|
3517
3528
|
if ($.get(chunks).length) $$render(consequent);
|
|
@@ -3592,10 +3603,10 @@ var list_default = { createOptions(options) {
|
|
|
3592
3603
|
view: "listWeek"
|
|
3593
3604
|
});
|
|
3594
3605
|
assign(options.buttonText, {
|
|
3595
|
-
listDay: "
|
|
3596
|
-
listWeek: "
|
|
3597
|
-
listMonth: "
|
|
3598
|
-
listYear: "
|
|
3606
|
+
listDay: "day",
|
|
3607
|
+
listWeek: "week",
|
|
3608
|
+
listMonth: "month",
|
|
3609
|
+
listYear: "year"
|
|
3599
3610
|
});
|
|
3600
3611
|
assign(options.theme, {
|
|
3601
3612
|
daySide: "ec-day-side",
|
|
@@ -3755,10 +3766,10 @@ function createTRRParsers(parsers) {
|
|
|
3755
3766
|
if (!("scrollTime" in parsers)) assign(parsers, {
|
|
3756
3767
|
scrollTime: createDuration,
|
|
3757
3768
|
slotDuration: createDuration,
|
|
3758
|
-
slotLabelInterval: (
|
|
3769
|
+
slotLabelInterval: undefinedOr(createDuration),
|
|
3759
3770
|
slotMaxTime: createDuration,
|
|
3760
3771
|
slotMinTime: createDuration,
|
|
3761
|
-
snapDuration: (
|
|
3772
|
+
snapDuration: undefinedOr(createDuration)
|
|
3762
3773
|
});
|
|
3763
3774
|
}
|
|
3764
3775
|
//#endregion
|
|
@@ -4796,8 +4807,8 @@ var resource_time_grid_default = {
|
|
|
4796
4807
|
view: "resourceTimeGridWeek"
|
|
4797
4808
|
});
|
|
4798
4809
|
assign(options.buttonText, {
|
|
4799
|
-
resourceTimeGridDay: "
|
|
4800
|
-
resourceTimeGridWeek: "
|
|
4810
|
+
resourceTimeGridDay: "day",
|
|
4811
|
+
resourceTimeGridWeek: "week"
|
|
4801
4812
|
});
|
|
4802
4813
|
assign(options.theme, { colGroup: "ec-col-group" });
|
|
4803
4814
|
assign(options.views, {
|
|
@@ -4948,7 +4959,7 @@ function grid(mainState, viewState) {
|
|
|
4948
4959
|
}
|
|
4949
4960
|
function extraHeads(mainState, viewState) {
|
|
4950
4961
|
return () => {
|
|
4951
|
-
let { options: { firstDay, weekNumbers } } = mainState;
|
|
4962
|
+
let { features, options: { firstDay, weekNumbers } } = mainState;
|
|
4952
4963
|
let { grid } = viewState;
|
|
4953
4964
|
let months = [];
|
|
4954
4965
|
let weeks = [];
|
|
@@ -4956,7 +4967,7 @@ function extraHeads(mainState, viewState) {
|
|
|
4956
4967
|
let month;
|
|
4957
4968
|
let week;
|
|
4958
4969
|
if (!empty(grid)) for (let { dayStart, gridColumn } of grid[0]) {
|
|
4959
|
-
if (month && month.date.getUTCMonth() === dayStart.getUTCMonth()) ++month.span;
|
|
4970
|
+
if (features.includes("month")) if (month && month.date.getUTCMonth() === dayStart.getUTCMonth()) ++month.span;
|
|
4960
4971
|
else {
|
|
4961
4972
|
month = {
|
|
4962
4973
|
date: dayStart,
|
|
@@ -5677,10 +5688,10 @@ var resource_timeline_default = {
|
|
|
5677
5688
|
assign(options.buttonText, {
|
|
5678
5689
|
expand: "Expand",
|
|
5679
5690
|
collapse: "Collapse",
|
|
5680
|
-
resourceTimelineDay: "
|
|
5681
|
-
resourceTimelineWeek: "
|
|
5682
|
-
resourceTimelineMonth: "
|
|
5683
|
-
resourceTimelineYear: "
|
|
5691
|
+
resourceTimelineDay: "day",
|
|
5692
|
+
resourceTimelineWeek: "week",
|
|
5693
|
+
resourceTimelineMonth: "month",
|
|
5694
|
+
resourceTimelineYear: "year"
|
|
5684
5695
|
});
|
|
5685
5696
|
assign(options.icons, {
|
|
5686
5697
|
collapse: { html: "−" },
|
|
@@ -5752,10 +5763,10 @@ function initViewComponent$1(mainState) {
|
|
|
5752
5763
|
return _initViewComponent(mainState);
|
|
5753
5764
|
}
|
|
5754
5765
|
function initMonthViewComponent(mainState) {
|
|
5755
|
-
return _initViewComponent(mainState);
|
|
5766
|
+
return _initViewComponent(mainState, ["month"]);
|
|
5756
5767
|
}
|
|
5757
|
-
function _initViewComponent(mainState) {
|
|
5758
|
-
mainState.features = ["timeline"];
|
|
5768
|
+
function _initViewComponent(mainState, extraFeatures = []) {
|
|
5769
|
+
mainState.features = ["timeline", ...extraFeatures];
|
|
5759
5770
|
mainState.extensions.viewResources = (resources) => resources.filter((resource) => !getPayload(resource).hidden);
|
|
5760
5771
|
return View;
|
|
5761
5772
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@event-calendar/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"title": "Event Calendar Core package",
|
|
5
5
|
"description": "Full-sized drag & drop event calendar with resource & timeline views",
|
|
6
6
|
"keywords": [
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"#components": "./src/lib/components/index.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"svelte": "^5.
|
|
35
|
+
"svelte": "^5.55.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/Buttons.svelte
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
let {buttons} = $props();
|
|
6
6
|
|
|
7
7
|
let mainState = getContext('state');
|
|
8
|
-
let {currentRange, today, viewTitle, viewDates, options: {buttonText, customButtons, date,
|
|
9
|
-
theme, validRange, view}} = $derived(mainState);
|
|
8
|
+
let {currentRange, today, viewTitle, viewDates, options: {buttonText, customButtons, date, dateIncrement, duration,
|
|
9
|
+
hiddenDays, theme, validRange, view}} = $derived(mainState);
|
|
10
10
|
|
|
11
11
|
let prevDisabled = $state(false);
|
|
12
12
|
let nextDisabled = $state(false);
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function prev() {
|
|
55
|
-
mainState.setOption('date', prevDate(cloneDate(date), duration, hiddenDays));
|
|
55
|
+
mainState.setOption('date', prevDate(cloneDate(date), dateIncrement ?? duration, hiddenDays));
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function next() {
|
|
59
|
-
mainState.setOption('date', nextDate(cloneDate(date), duration, hiddenDays));
|
|
59
|
+
mainState.setOption('date', nextDate(cloneDate(date), dateIncrement ?? duration, hiddenDays));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function setToday() {
|
package/src/Calendar.svelte
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
let {
|
|
19
19
|
auxComponents, features, events, interaction, iClass, view, viewComponent: View,
|
|
20
|
-
options: {date, duration, height, hiddenDays, customScrollbars, theme}
|
|
20
|
+
options: {date, dateIncrement, duration, height, hiddenDays, customScrollbars, theme}
|
|
21
21
|
} = $derived(mainState);
|
|
22
22
|
|
|
23
23
|
// Reactively update options that did change
|
|
@@ -113,12 +113,12 @@
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
export function next() {
|
|
116
|
-
mainState.setOption('date', nextDate(cloneDate(date), duration, hiddenDays));
|
|
116
|
+
mainState.setOption('date', nextDate(cloneDate(date), dateIncrement ?? duration, hiddenDays));
|
|
117
117
|
return this;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
export function prev() {
|
|
121
|
-
mainState.setOption('date', prevDate(cloneDate(date), duration, hiddenDays));
|
|
121
|
+
mainState.setOption('date', prevDate(cloneDate(date), dateIncrement ?? duration, hiddenDays));
|
|
122
122
|
return this;
|
|
123
123
|
}
|
|
124
124
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {getContext, onMount} from 'svelte';
|
|
3
|
-
import {datesEqual, identity, setPayload} from '#lib';
|
|
3
|
+
import {contentFrom, datesEqual, identity, isFunction, setPayload, toLocalDate} from '#lib';
|
|
4
4
|
|
|
5
5
|
let {
|
|
6
6
|
el = $bindable(),
|
|
@@ -14,13 +14,23 @@
|
|
|
14
14
|
role = 'cell',
|
|
15
15
|
noIeb = false,
|
|
16
16
|
noBeb = false,
|
|
17
|
-
|
|
17
|
+
content
|
|
18
18
|
} = $props();
|
|
19
19
|
|
|
20
|
-
let {today, interaction: {action}, options: {theme}} = $derived(getContext('state'));
|
|
20
|
+
let {today, interaction: {action}, options: {dayCellContent, theme}} = $derived(getContext('state'));
|
|
21
21
|
let {snap} = $derived(getContext('view-state')); // timeGrid has snap, others don't
|
|
22
22
|
|
|
23
23
|
let isToday = $derived(datesEqual(date, today));
|
|
24
|
+
let dayContent = $derived(
|
|
25
|
+
isFunction(dayCellContent)
|
|
26
|
+
? dayCellContent({
|
|
27
|
+
allDay,
|
|
28
|
+
date: toLocalDate(date),
|
|
29
|
+
isToday,
|
|
30
|
+
resource
|
|
31
|
+
})
|
|
32
|
+
: dayCellContent
|
|
33
|
+
);
|
|
24
34
|
|
|
25
35
|
// Class
|
|
26
36
|
let classNames = $derived(classes([
|
|
@@ -54,4 +64,5 @@
|
|
|
54
64
|
class={classNames}
|
|
55
65
|
{role}
|
|
56
66
|
{onpointerdown}
|
|
57
|
-
|
|
67
|
+
{@attach content ? null : contentFrom(dayContent)}
|
|
68
|
+
>{@render content?.(dayContent)}</div>
|
package/src/lib/utils.js
CHANGED
|
@@ -48,35 +48,35 @@
|
|
|
48
48
|
</script>
|
|
49
49
|
|
|
50
50
|
<BaseDay date={dayStart} allDay {classes} {disabled} {highlight} {noIeb} {noBeb}>
|
|
51
|
-
|
|
52
|
-
{
|
|
51
|
+
{#snippet content(dayContent)}
|
|
52
|
+
<div class="{theme.dayHead}">
|
|
53
53
|
<time
|
|
54
54
|
datetime="{toISOString(dayStart, 10)}"
|
|
55
|
-
{@attach contentFrom(intlDayCell.format(dayStart))}
|
|
55
|
+
{@attach contentFrom(dayContent ?? intlDayCell.format(dayStart))}
|
|
56
56
|
></time>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
</div>
|
|
57
|
+
{#if showWeekNumber}
|
|
58
|
+
<span
|
|
59
|
+
class="{theme.weekNumber}"
|
|
60
|
+
{@attach contentFrom(weekNumber)}
|
|
61
|
+
></span>
|
|
62
|
+
{/if}
|
|
63
|
+
</div>
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
65
|
+
<div class="{theme.dayFoot}">
|
|
66
|
+
{#if dayHiddenChunks}
|
|
67
|
+
<!-- svelte-ignore a11y_missing_attribute -->
|
|
68
|
+
<!-- svelte-ignore a11y_missing_content -->
|
|
69
|
+
<!-- svelte-ignore a11y_consider_explicit_label -->
|
|
70
|
+
<a
|
|
71
|
+
role="button"
|
|
72
|
+
tabindex="0"
|
|
73
|
+
aria-haspopup="dialog"
|
|
74
|
+
onclick={stopPropagation(showMore)}
|
|
75
|
+
onkeydown={keyEnter(showMore)}
|
|
76
|
+
onpointerdown={stopPropagation()}
|
|
77
|
+
{@attach contentFrom(moreLink)}
|
|
78
|
+
></a>
|
|
79
|
+
{/if}
|
|
80
|
+
</div>
|
|
81
|
+
{/snippet}
|
|
82
82
|
</BaseDay>
|
|
@@ -33,13 +33,15 @@
|
|
|
33
33
|
|
|
34
34
|
{#if chunks.length}
|
|
35
35
|
<BaseDay {date} allDay role="listitem" {disabled} {highlight}>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
{#snippet content(dayContent)}
|
|
37
|
+
<!-- svelte-ignore a11y_missing_content -->
|
|
38
|
+
<h4 class="{theme.dayHead}">
|
|
39
|
+
<time {datetime} {@attach contentFrom(dayContent ?? intlListDay.format(date))}></time>
|
|
40
|
+
<time class="{theme.daySide}" {datetime} {@attach contentFrom(intlListDaySide.format(date))}></time>
|
|
41
|
+
</h4>
|
|
42
|
+
{#each chunks as chunk (chunk.event)}
|
|
43
|
+
<Event {chunk}/>
|
|
44
|
+
{/each}
|
|
45
|
+
{/snippet}
|
|
44
46
|
</BaseDay>
|
|
45
47
|
{/if}
|
|
@@ -12,10 +12,10 @@ export default {
|
|
|
12
12
|
view: 'listWeek'
|
|
13
13
|
});
|
|
14
14
|
assign(options.buttonText, {
|
|
15
|
-
listDay: '
|
|
16
|
-
listWeek: '
|
|
17
|
-
listMonth: '
|
|
18
|
-
listYear: '
|
|
15
|
+
listDay: 'day',
|
|
16
|
+
listWeek: 'week',
|
|
17
|
+
listMonth: 'month',
|
|
18
|
+
listYear: 'year'
|
|
19
19
|
});
|
|
20
20
|
assign(options.theme, {
|
|
21
21
|
daySide: 'ec-day-side',
|
|
@@ -15,8 +15,8 @@ export default {
|
|
|
15
15
|
view: 'resourceTimeGridWeek'
|
|
16
16
|
});
|
|
17
17
|
assign(options.buttonText, {
|
|
18
|
-
resourceTimeGridDay: '
|
|
19
|
-
resourceTimeGridWeek: '
|
|
18
|
+
resourceTimeGridDay: 'day',
|
|
19
|
+
resourceTimeGridWeek: 'week'
|
|
20
20
|
});
|
|
21
21
|
assign(options.theme, {
|
|
22
22
|
colGroup: 'ec-col-group'
|
|
@@ -45,7 +45,7 @@ export function grid(mainState, viewState) {
|
|
|
45
45
|
export function extraHeads(mainState, viewState) {
|
|
46
46
|
return () => {
|
|
47
47
|
// Dependencies
|
|
48
|
-
let {options: {firstDay, weekNumbers}} = mainState;
|
|
48
|
+
let {features, options: {firstDay, weekNumbers}} = mainState;
|
|
49
49
|
let {grid} = viewState;
|
|
50
50
|
|
|
51
51
|
let months = [];
|
|
@@ -56,11 +56,13 @@ export function extraHeads(mainState, viewState) {
|
|
|
56
56
|
let week;
|
|
57
57
|
if (!empty(grid)) {
|
|
58
58
|
for (let {dayStart, gridColumn} of grid[0]) {
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
if (features.includes('month')) {
|
|
60
|
+
if (month && month.date.getUTCMonth() === dayStart.getUTCMonth()) {
|
|
61
|
+
++month.span;
|
|
62
|
+
} else {
|
|
63
|
+
month = {date: dayStart, gridColumn, span: 1};
|
|
64
|
+
months.push(month);
|
|
65
|
+
}
|
|
64
66
|
}
|
|
65
67
|
if (weekNumbers) {
|
|
66
68
|
let number = getWeekNumber(dayStart, firstDay);
|
|
@@ -20,10 +20,10 @@ export default {
|
|
|
20
20
|
assign(options.buttonText, {
|
|
21
21
|
expand: 'Expand',
|
|
22
22
|
collapse: 'Collapse',
|
|
23
|
-
resourceTimelineDay: '
|
|
24
|
-
resourceTimelineWeek: '
|
|
25
|
-
resourceTimelineMonth: '
|
|
26
|
-
resourceTimelineYear: '
|
|
23
|
+
resourceTimelineDay: 'day',
|
|
24
|
+
resourceTimelineWeek: 'week',
|
|
25
|
+
resourceTimelineMonth: 'month',
|
|
26
|
+
resourceTimelineYear: 'year'
|
|
27
27
|
});
|
|
28
28
|
assign(options.icons, {
|
|
29
29
|
collapse: {html: '−'},
|
|
@@ -91,11 +91,11 @@ function initViewComponent(mainState) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
function initMonthViewComponent(mainState) {
|
|
94
|
-
return _initViewComponent(mainState);
|
|
94
|
+
return _initViewComponent(mainState, ['month']);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
function _initViewComponent(mainState) {
|
|
98
|
-
mainState.features = ['timeline'];
|
|
97
|
+
function _initViewComponent(mainState, extraFeatures = []) {
|
|
98
|
+
mainState.features = ['timeline', ...extraFeatures];
|
|
99
99
|
mainState.extensions.viewResources = resources => resources.filter(resource => !getPayload(resource).hidden);
|
|
100
100
|
return View;
|
|
101
101
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {assign, createDuration} from '#lib';
|
|
1
|
+
import {assign, createDuration, undefinedOr} from '#lib';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* TimeGrid + ResourceTimeGrid + ResourceTimeline
|
|
@@ -53,10 +53,10 @@ export function createTRRParsers(parsers) {
|
|
|
53
53
|
assign(parsers, {
|
|
54
54
|
scrollTime: createDuration,
|
|
55
55
|
slotDuration: createDuration,
|
|
56
|
-
slotLabelInterval:
|
|
56
|
+
slotLabelInterval: undefinedOr(createDuration),
|
|
57
57
|
slotMaxTime: createDuration,
|
|
58
58
|
slotMinTime: createDuration,
|
|
59
|
-
snapDuration:
|
|
59
|
+
snapDuration: undefinedOr(createDuration)
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
}
|
package/src/storage/options.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {untrack} from 'svelte';
|
|
2
2
|
import {
|
|
3
3
|
assign, createDate, createDateRange, createDuration, createEvents, createEventSources, createResources, hasOwn,
|
|
4
|
-
isArray, isFunction, isPlainObject, keys, setMidnight
|
|
4
|
+
isArray, isFunction, isPlainObject, keys, setMidnight, undefinedOr
|
|
5
5
|
} from '#lib';
|
|
6
6
|
import {objectProxy} from './proxy.svelte.js';
|
|
7
7
|
|
|
@@ -13,7 +13,9 @@ function createOptions(plugins) {
|
|
|
13
13
|
customButtons: {},
|
|
14
14
|
customScrollbars: false, // ec option
|
|
15
15
|
date: new Date(),
|
|
16
|
+
dateIncrement: undefined,
|
|
16
17
|
datesSet: undefined,
|
|
18
|
+
dayCellContent: undefined,
|
|
17
19
|
dayHeaderFormat: {
|
|
18
20
|
weekday: 'short',
|
|
19
21
|
month: 'numeric',
|
|
@@ -114,6 +116,7 @@ function createOptions(plugins) {
|
|
|
114
116
|
function createParsers(plugins) {
|
|
115
117
|
let parsers = {
|
|
116
118
|
date: input => setMidnight(createDate(input)),
|
|
119
|
+
dateIncrement: undefinedOr(createDuration),
|
|
117
120
|
duration: createDuration,
|
|
118
121
|
events: createEvents,
|
|
119
122
|
eventSources: createEventSources,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {SvelteMap} from 'svelte/reactivity';
|
|
2
|
-
import {cloneDate, createDate, identity, intl, intlRange, setMidnight} from '#lib';
|
|
2
|
+
import {cloneDate, createDate, identity, intl, intlRange, isArray, setMidnight} from '#lib';
|
|
3
3
|
import {optionsState} from './options.js';
|
|
4
4
|
import {
|
|
5
5
|
createLoadingInvoker, loadEvents, loadResources, runDatesSet, runEventAllUpdated, runViewDidMount, setNowAndToday,
|
|
@@ -27,7 +27,7 @@ export default class State {
|
|
|
27
27
|
this.filteredEvents = $derived.by(filteredEvents(this));
|
|
28
28
|
this.mainEl = $state();
|
|
29
29
|
this.now = $state(createDate());
|
|
30
|
-
this.resources = $state.raw(arrayProxy(this.options.resources));
|
|
30
|
+
this.resources = $state.raw(arrayProxy(isArray(this.options.resources) ? this.options.resources : []));
|
|
31
31
|
this.today = $state(setMidnight(cloneDate(this.now)));
|
|
32
32
|
this.intlEventTime = $derived.by(intlRange(this, 'eventTimeFormat'));
|
|
33
33
|
this.intlDayHeader = $derived.by(intl(this, 'dayHeaderFormat'));
|