@super-calendar/solid 2.16.0 → 2.17.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 +46 -2
- package/dist/client/index.d.ts +40 -3
- package/dist/client/index.js +538 -101
- package/dist/server/index.d.ts +40 -3
- package/dist/server/index.js +854 -338
- package/package.json +2 -2
- package/src/Calendar.tsx +73 -2
- package/src/MonthView.tsx +435 -86
- package/src/MultiWeekView.tsx +49 -0
- package/src/index.ts +7 -0
- package/src/touch.ts +70 -0
package/dist/client/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthGrid as buildMonthGrid$1, buildMonthWeeks, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, defaultCalendarLabels, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getViewDays, getViewDays as getViewDays$1, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isDateSelectable as isDateSelectable$1, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, layoutMonthWeek as layoutMonthWeek$1, lightColors, loadEventSource, loadEventSource as loadEventSource$1, monthCreateRange, monthDropBounds, movedClockSpan, nextDateRange, nextDateRange as nextDateRange$1, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, titleNumberOfLines, toICalendar, toZonedTime, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core/vanilla";
|
|
1
|
+
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthGrid as buildMonthGrid$1, buildMonthWeeks, buildMultiWeekGrid, buildMultiWeekGrid as buildMultiWeekGrid$1, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, defaultCalendarLabels, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getViewDays, getViewDays as getViewDays$1, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isDateSelectable as isDateSelectable$1, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, layoutMonthWeek as layoutMonthWeek$1, lightColors, loadEventSource, loadEventSource as loadEventSource$1, monthCreateRange, monthDropBounds, movedClockSpan, nextDateRange, nextDateRange as nextDateRange$1, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, titleNumberOfLines, toICalendar, toZonedTime, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core/vanilla";
|
|
2
2
|
import { For, Show, createEffect, createMemo, createSignal, createUniqueId, merge, onCleanup, onSettled, untrack } from "solid-js";
|
|
3
3
|
import { Dynamic, className, createComponent, delegateEvents, effect, getNextElement, getNextMarker, insert, memo, mergeProps, readShallow, ref, runHydrationEvents, scope, setAttribute, setStyleProperty, spread, style, template } from "@solidjs/web";
|
|
4
|
-
import { addDays, addMonths, addYears, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, isSameDay, isSameMonth, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
4
|
+
import { addDays, addMonths, addWeeks, addYears, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, isSameDay, isSameMonth, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
5
5
|
// src/createEventSource.ts
|
|
6
6
|
/** Load a reactive URL or async function, with optional polling and owned cleanup. */
|
|
7
7
|
function createEventSource(source, options = () => ({})) {
|
|
@@ -538,6 +538,99 @@ function Agenda(incoming) {
|
|
|
538
538
|
});
|
|
539
539
|
return _el$9;
|
|
540
540
|
}
|
|
541
|
+
// src/touch.ts
|
|
542
|
+
function waitForHold(grab, delay, threshold, onHold, onTap, onCancel) {
|
|
543
|
+
const detach = () => {
|
|
544
|
+
clearTimeout(timer);
|
|
545
|
+
document.removeEventListener("pointermove", move);
|
|
546
|
+
document.removeEventListener("pointerup", up);
|
|
547
|
+
document.removeEventListener("pointercancel", cancelPointer);
|
|
548
|
+
document.removeEventListener("pointerdown", anotherPointer);
|
|
549
|
+
};
|
|
550
|
+
const cancel = () => {
|
|
551
|
+
detach();
|
|
552
|
+
onCancel();
|
|
553
|
+
};
|
|
554
|
+
const move = (event) => {
|
|
555
|
+
if (event.pointerId === grab.pointerId && Math.hypot(event.clientX - grab.clientX, event.clientY - grab.clientY) > threshold) cancel();
|
|
556
|
+
};
|
|
557
|
+
const up = (event) => {
|
|
558
|
+
if (event.pointerId === grab.pointerId) {
|
|
559
|
+
detach();
|
|
560
|
+
onTap();
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
const cancelPointer = (event) => {
|
|
564
|
+
if (event.pointerId === grab.pointerId) cancel();
|
|
565
|
+
};
|
|
566
|
+
const anotherPointer = (event) => {
|
|
567
|
+
if (event.pointerId !== grab.pointerId) cancel();
|
|
568
|
+
};
|
|
569
|
+
const timer = setTimeout(() => {
|
|
570
|
+
detach();
|
|
571
|
+
onHold();
|
|
572
|
+
}, delay);
|
|
573
|
+
document.addEventListener("pointermove", move);
|
|
574
|
+
document.addEventListener("pointerup", up);
|
|
575
|
+
document.addEventListener("pointercancel", cancelPointer);
|
|
576
|
+
document.addEventListener("pointerdown", anotherPointer);
|
|
577
|
+
return cancel;
|
|
578
|
+
}
|
|
579
|
+
/** A quick swipe scrolls; a held pointer owns a date-row drag until release. */
|
|
580
|
+
function holdDateDrag(grab, start, move, cancel, release) {
|
|
581
|
+
const doc = grab.box.ownerDocument;
|
|
582
|
+
let active = false;
|
|
583
|
+
let finished = false;
|
|
584
|
+
let cancelWait;
|
|
585
|
+
const detach = () => {
|
|
586
|
+
doc.removeEventListener("pointermove", onMove);
|
|
587
|
+
doc.removeEventListener("pointerup", onUp);
|
|
588
|
+
doc.removeEventListener("pointercancel", onCancel);
|
|
589
|
+
doc.removeEventListener("pointerdown", onAnotherPointer);
|
|
590
|
+
doc.removeEventListener("touchmove", onTouchMove);
|
|
591
|
+
doc.removeEventListener("contextmenu", onContextMenu);
|
|
592
|
+
};
|
|
593
|
+
const stop = () => {
|
|
594
|
+
if (finished) return;
|
|
595
|
+
finished = true;
|
|
596
|
+
detach();
|
|
597
|
+
cancelWait?.();
|
|
598
|
+
cancel();
|
|
599
|
+
release();
|
|
600
|
+
};
|
|
601
|
+
const onMove = (event) => {
|
|
602
|
+
if (active && event.pointerId === grab.pointerId) move(event.clientX, event.clientY);
|
|
603
|
+
};
|
|
604
|
+
const onUp = (event) => {
|
|
605
|
+
if (event.pointerId !== grab.pointerId) return;
|
|
606
|
+
finished = true;
|
|
607
|
+
detach();
|
|
608
|
+
release();
|
|
609
|
+
};
|
|
610
|
+
const onCancel = (event) => {
|
|
611
|
+
if (event.pointerId === grab.pointerId) stop();
|
|
612
|
+
};
|
|
613
|
+
const onAnotherPointer = (event) => {
|
|
614
|
+
if (event.pointerId !== grab.pointerId) stop();
|
|
615
|
+
};
|
|
616
|
+
const onTouchMove = (event) => {
|
|
617
|
+
if (active && event.cancelable) event.preventDefault();
|
|
618
|
+
};
|
|
619
|
+
const onContextMenu = (event) => {
|
|
620
|
+
event.preventDefault();
|
|
621
|
+
};
|
|
622
|
+
doc.addEventListener("pointermove", onMove);
|
|
623
|
+
doc.addEventListener("pointerup", onUp);
|
|
624
|
+
doc.addEventListener("pointercancel", onCancel);
|
|
625
|
+
doc.addEventListener("pointerdown", onAnotherPointer);
|
|
626
|
+
doc.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
627
|
+
doc.addEventListener("contextmenu", onContextMenu);
|
|
628
|
+
cancelWait = waitForHold(grab, 400, 8, () => {
|
|
629
|
+
active = true;
|
|
630
|
+
start();
|
|
631
|
+
}, release, stop);
|
|
632
|
+
return stop;
|
|
633
|
+
}
|
|
541
634
|
// src/MonthView.tsx
|
|
542
635
|
var _tmpl$$7 = /*#__PURE__*/ template(`<div><!$><!/><!$><!/><div>`);
|
|
543
636
|
var _tmpl$2$6 = /*#__PURE__*/ template(`<div>`);
|
|
@@ -563,6 +656,7 @@ const CELL_PAD = 4;
|
|
|
563
656
|
const DRAGGED_CHIP_OPACITY = .4;
|
|
564
657
|
/** Props passed to a custom month event chip renderer. */
|
|
565
658
|
/** A component that renders a single month-grid event chip. */
|
|
659
|
+
const isOutsidePeriod = (day) => day.isCurrentMonth === false;
|
|
566
660
|
/** Props for {@link MonthView}. */
|
|
567
661
|
function dayCellDefault(day, theme, highlightWeekends) {
|
|
568
662
|
return {
|
|
@@ -723,7 +817,7 @@ function chipDefault(theme, chipHeight) {
|
|
|
723
817
|
}
|
|
724
818
|
};
|
|
725
819
|
}
|
|
726
|
-
function moreButtonDefault(theme, chipHeight) {
|
|
820
|
+
function moreButtonDefault(theme, chipHeight, multiWeek = false) {
|
|
727
821
|
return {
|
|
728
822
|
base: {
|
|
729
823
|
position: "relative",
|
|
@@ -734,7 +828,12 @@ function moreButtonDefault(theme, chipHeight) {
|
|
|
734
828
|
textAlign: "left",
|
|
735
829
|
height: chipHeight,
|
|
736
830
|
lineHeight: `${chipHeight}px`,
|
|
737
|
-
fontFamily: "inherit"
|
|
831
|
+
fontFamily: "inherit",
|
|
832
|
+
...multiWeek ? {
|
|
833
|
+
whiteSpace: "nowrap",
|
|
834
|
+
overflow: "hidden",
|
|
835
|
+
textOverflow: "ellipsis"
|
|
836
|
+
} : {}
|
|
738
837
|
},
|
|
739
838
|
themed: {
|
|
740
839
|
padding: "0 6px",
|
|
@@ -758,6 +857,15 @@ function collectRowEvents(week, eventsByDay) {
|
|
|
758
857
|
return out;
|
|
759
858
|
}
|
|
760
859
|
/**
|
|
860
|
+
* Which rows a {@link DateRows} grid shows. Internal to the package: the public
|
|
861
|
+
* views adapt their own props to it.
|
|
862
|
+
*/
|
|
863
|
+
function rangeTitle(start, endExclusive, locale) {
|
|
864
|
+
const options = locale ? { locale } : void 0;
|
|
865
|
+
return `${format(start, "PP", options)} – ${format(addDays(endExclusive, -1), "PP", options)}`;
|
|
866
|
+
}
|
|
867
|
+
/** Props for the private {@link DateRows} grid shared by the public row views. */
|
|
868
|
+
/**
|
|
761
869
|
* A single static month grid, rendered with plain DOM elements.
|
|
762
870
|
*
|
|
763
871
|
* @example
|
|
@@ -765,7 +873,22 @@ function collectRowEvents(week, eventsByDay) {
|
|
|
765
873
|
* <MonthView date={new Date()} events={events} onPressDay={(d) => setDate(d)} />
|
|
766
874
|
* ```
|
|
767
875
|
*/
|
|
768
|
-
function MonthView(
|
|
876
|
+
function MonthView(props) {
|
|
877
|
+
return createComponent(DateRows, mergeProps(props, { source: {
|
|
878
|
+
kind: "month",
|
|
879
|
+
get date() {
|
|
880
|
+
return props.date;
|
|
881
|
+
},
|
|
882
|
+
get showAdjacentMonths() {
|
|
883
|
+
return props.showAdjacentMonths ?? true;
|
|
884
|
+
}
|
|
885
|
+
} }));
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* The day-row grid behind the public row views: week rows of day cells with
|
|
889
|
+
* spanning event bars, overflow, selection, drag, and keyboard handling.
|
|
890
|
+
*/
|
|
891
|
+
function DateRows(incoming) {
|
|
769
892
|
const props = withDefaults({
|
|
770
893
|
weekStartsOn: 0,
|
|
771
894
|
weekdayFormat: "short",
|
|
@@ -773,7 +896,6 @@ function MonthView(incoming) {
|
|
|
773
896
|
chipHeight: CHIP_HEIGHT,
|
|
774
897
|
chipGap: CHIP_GAP,
|
|
775
898
|
moreLabel: "{moreCount} More",
|
|
776
|
-
showAdjacentMonths: true,
|
|
777
899
|
highlightWeekends: true,
|
|
778
900
|
fillCellOnSelection: false,
|
|
779
901
|
showTitle: true,
|
|
@@ -785,7 +907,11 @@ function MonthView(incoming) {
|
|
|
785
907
|
const theme = createMemo(() => mergeSolidTheme(props.theme));
|
|
786
908
|
const labels = createMemo(() => resolveCalendarLabels(props.labels));
|
|
787
909
|
const slot = createSlots(props);
|
|
788
|
-
const
|
|
910
|
+
const multiWeek = createMemo(() => props.source.kind === "multiweek");
|
|
911
|
+
const showAdjacentMonths = createMemo(() => props.source.kind === "month" ? props.source.showAdjacentMonths : true);
|
|
912
|
+
const numberOfWeeks = createMemo(() => props.source.kind === "multiweek" ? props.source.numberOfWeeks : void 0);
|
|
913
|
+
const viewMode = createMemo(() => multiWeek() ? "multiweek" : "month");
|
|
914
|
+
const eventsMode = createMemo(() => props.events !== void 0 || multiWeek());
|
|
789
915
|
const dayRoving = createMemo(() => !eventsMode() || props.keyboardDayNavigation);
|
|
790
916
|
const eventsByDay = createMemo(() => {
|
|
791
917
|
if (props.eventsByDay) return props.eventsByDay;
|
|
@@ -823,42 +949,98 @@ function MonthView(incoming) {
|
|
|
823
949
|
document.removeEventListener("keydown", onKey);
|
|
824
950
|
};
|
|
825
951
|
}));
|
|
826
|
-
const eventRowHeight = createMemo(() => 32 + props.maxVisibleEventCount * (props.chipHeight + props.chipGap));
|
|
827
|
-
const _grid = createMemo(() =>
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
952
|
+
const eventRowHeight = createMemo(() => 32 + (multiWeek() ? Math.max(1, props.maxVisibleEventCount) : props.maxVisibleEventCount) * (props.chipHeight + props.chipGap));
|
|
953
|
+
const _grid = createMemo(() => {
|
|
954
|
+
const options = {
|
|
955
|
+
weekStartsOn: props.weekStartsOn,
|
|
956
|
+
hiddenDays: props.hiddenDays,
|
|
957
|
+
weekdayFormat: props.weekdayFormat,
|
|
958
|
+
selectedRange: props.selectedRange,
|
|
959
|
+
selectedDates: props.selectedDates,
|
|
960
|
+
minDate: props.minDate,
|
|
961
|
+
maxDate: props.maxDate,
|
|
962
|
+
isDateDisabled: props.isDateDisabled,
|
|
963
|
+
locale: props.locale
|
|
964
|
+
};
|
|
965
|
+
const weeks = numberOfWeeks();
|
|
966
|
+
if (weeks === void 0) return {
|
|
967
|
+
...buildMonthGrid$1(props.source.date, options),
|
|
968
|
+
title: format(props.source.date, "MMMM yyyy", props.locale ? { locale: props.locale } : void 0),
|
|
969
|
+
period: null
|
|
970
|
+
};
|
|
971
|
+
const grid = buildMultiWeekGrid$1(props.source.date, {
|
|
972
|
+
...options,
|
|
973
|
+
numberOfWeeks: weeks
|
|
974
|
+
});
|
|
975
|
+
return {
|
|
976
|
+
weeks: grid.weeks,
|
|
977
|
+
weekdays: grid.weekdays,
|
|
978
|
+
title: rangeTitle(grid.visibleRange.start, grid.visibleRange.endExclusive, props.locale),
|
|
979
|
+
period: grid.period
|
|
980
|
+
};
|
|
981
|
+
});
|
|
838
982
|
const weekLayouts = createMemo(() => eventsMode() ? _grid().weeks.map((week) => layoutMonthWeek$1(week.days.map((d) => d.date), collectRowEvents(week, eventsByDay()))) : []);
|
|
983
|
+
const focusableDays = createMemo(() => _grid().period ? _grid().weeks.flatMap((week) => week.days).filter((day) => !day.isDisabled).map((day) => startOfDay(day.date)).sort((a, b) => a.getTime() - b.getTime()) : null);
|
|
984
|
+
const focusableKeys = createMemo(() => {
|
|
985
|
+
const days = focusableDays();
|
|
986
|
+
return days ? new Set(days.map((d) => format(d, "yyyy-MM-dd"))) : null;
|
|
987
|
+
});
|
|
839
988
|
const initialFocus = createMemo(() => {
|
|
840
|
-
const
|
|
989
|
+
const days = focusableDays();
|
|
990
|
+
const keys = focusableKeys();
|
|
991
|
+
if (days && keys) {
|
|
992
|
+
const rendered = (d) => !!d && keys.has(format(d, "yyyy-MM-dd"));
|
|
993
|
+
const rangeStart = props.selectedRange?.start;
|
|
994
|
+
if (rendered(rangeStart)) return startOfDay(rangeStart);
|
|
995
|
+
const picked = props.selectedDates?.find(rendered);
|
|
996
|
+
if (picked) return startOfDay(picked);
|
|
997
|
+
const today = /* @__PURE__ */ new Date();
|
|
998
|
+
if (rendered(today)) return startOfDay(today);
|
|
999
|
+
return days[0] ?? null;
|
|
1000
|
+
}
|
|
1001
|
+
const inMonth = (d) => !!d && isSameMonth(d, props.source.date);
|
|
841
1002
|
if (inMonth(props.selectedRange?.start)) return startOfDay(props.selectedRange.start);
|
|
842
1003
|
const picked = props.selectedDates?.find(inMonth);
|
|
843
1004
|
if (picked) return startOfDay(picked);
|
|
844
1005
|
const today = /* @__PURE__ */ new Date();
|
|
845
|
-
return isSameMonth(today, props.date) ? startOfDay(today) : startOfMonth(props.date);
|
|
1006
|
+
return isSameMonth(today, props.source.date) ? startOfDay(today) : startOfMonth(props.source.date);
|
|
846
1007
|
});
|
|
847
1008
|
const [focusedDate, setFocusedDate] = createSignal(untrack(() => initialFocus()));
|
|
848
1009
|
const initialFocusRef = { current: untrack(() => initialFocus()) };
|
|
849
1010
|
createEffect(() => initialFocus(), (value) => {
|
|
850
1011
|
initialFocusRef.current = value;
|
|
851
1012
|
});
|
|
852
|
-
const
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
1013
|
+
const windowKey = createMemo(() => {
|
|
1014
|
+
const period = _grid().period;
|
|
1015
|
+
return period ? `${format(period.start, "yyyy-MM-dd")}+${numberOfWeeks()}:${_grid().weekdays.map((day) => day.date.getDay()).join(",")}` : format(props.source.date, "yyyy-MM");
|
|
1016
|
+
});
|
|
1017
|
+
let focusedWindow = untrack(windowKey);
|
|
1018
|
+
createEffect(windowKey, (key) => untrack(() => {
|
|
1019
|
+
if (key === focusedWindow) return;
|
|
1020
|
+
focusedWindow = key;
|
|
857
1021
|
setFocusedDate(initialFocusRef.current);
|
|
858
1022
|
}));
|
|
859
1023
|
const [hoveredKey, setHoveredKey] = createSignal(null);
|
|
860
1024
|
const gridRef = { current: null };
|
|
861
|
-
const
|
|
1025
|
+
const lastDayFocus = { current: null };
|
|
1026
|
+
const focusKey = createMemo(() => {
|
|
1027
|
+
const focused = focusedDate();
|
|
1028
|
+
const stored = focused ? format(focused, "yyyy-MM-dd") : null;
|
|
1029
|
+
const keys = focusableKeys();
|
|
1030
|
+
if (!keys || stored !== null && keys.has(stored)) return stored;
|
|
1031
|
+
const initial = initialFocus();
|
|
1032
|
+
return initial && format(initial, "yyyy-MM-dd");
|
|
1033
|
+
});
|
|
1034
|
+
createEffect(() => ({
|
|
1035
|
+
enabled: multiWeek(),
|
|
1036
|
+
key: focusKey()
|
|
1037
|
+
}), ({ enabled, key }) => {
|
|
1038
|
+
if (!enabled) return;
|
|
1039
|
+
const active = gridRef.current?.ownerDocument.activeElement;
|
|
1040
|
+
if (!(active === gridRef.current?.ownerDocument.body && lastDayFocus.current !== null && !lastDayFocus.current.isConnected) && (!active?.hasAttribute("data-day") || !gridRef.current?.contains(active))) return;
|
|
1041
|
+
if (active?.getAttribute("data-day") === key && active?.getAttribute("aria-disabled") !== "true") return;
|
|
1042
|
+
(key ? gridRef.current?.querySelector(`[data-day="${key}"]`) : gridRef.current)?.focus();
|
|
1043
|
+
});
|
|
862
1044
|
const [drag, setDrag] = createSignal(null);
|
|
863
1045
|
const dragRef = { current: null };
|
|
864
1046
|
const applyDrag = (value) => {
|
|
@@ -886,7 +1068,8 @@ function MonthView(incoming) {
|
|
|
886
1068
|
kind: "create",
|
|
887
1069
|
pointerId,
|
|
888
1070
|
anchor: t,
|
|
889
|
-
hover: t
|
|
1071
|
+
hover: t,
|
|
1072
|
+
windowKey: windowKey()
|
|
890
1073
|
});
|
|
891
1074
|
};
|
|
892
1075
|
const beginMove = (event, day, pointerId) => {
|
|
@@ -897,7 +1080,8 @@ function MonthView(incoming) {
|
|
|
897
1080
|
pointerId,
|
|
898
1081
|
event,
|
|
899
1082
|
from: t,
|
|
900
|
-
to: t
|
|
1083
|
+
to: t,
|
|
1084
|
+
windowKey: windowKey()
|
|
901
1085
|
});
|
|
902
1086
|
props.onDragStart?.(event);
|
|
903
1087
|
};
|
|
@@ -919,6 +1103,62 @@ function MonthView(incoming) {
|
|
|
919
1103
|
props.onSelectDrag?.(new Date(lo), new Date(hi));
|
|
920
1104
|
}
|
|
921
1105
|
};
|
|
1106
|
+
let heldTouch = null;
|
|
1107
|
+
let heldOrigin = null;
|
|
1108
|
+
const dayLookup = createMemo(() => new Map(_grid().weeks.flatMap((week) => week.days).map((day) => [day.id, day])));
|
|
1109
|
+
const pressRow = (event, day, moving) => {
|
|
1110
|
+
if (event.button !== 0 || heldTouch || !beginPress(event)) return;
|
|
1111
|
+
const start = () => {
|
|
1112
|
+
if (moving) beginMove(moving, day, event.pointerId);
|
|
1113
|
+
else beginCreate(day, event.pointerId);
|
|
1114
|
+
};
|
|
1115
|
+
if (!multiWeek() || !event.pointerType || event.pointerType === "mouse") {
|
|
1116
|
+
start();
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
heldOrigin = {
|
|
1120
|
+
day,
|
|
1121
|
+
event: moving
|
|
1122
|
+
};
|
|
1123
|
+
heldTouch = holdDateDrag({
|
|
1124
|
+
box: event.currentTarget,
|
|
1125
|
+
pointerId: event.pointerId,
|
|
1126
|
+
pointerType: event.pointerType,
|
|
1127
|
+
clientX: event.clientX,
|
|
1128
|
+
clientY: event.clientY
|
|
1129
|
+
}, start, (x, y) => {
|
|
1130
|
+
const element = gridRef.current?.ownerDocument.elementFromPoint(x, y)?.closest("[data-day]");
|
|
1131
|
+
if (!element || !gridRef.current?.contains(element)) return;
|
|
1132
|
+
const day = dayLookup().get(element.dataset.day ?? "");
|
|
1133
|
+
if (day && !day.isDisabled) extendDrag(day.date, event.pointerId);
|
|
1134
|
+
}, () => {
|
|
1135
|
+
applyDrag(null);
|
|
1136
|
+
movedRef.current = false;
|
|
1137
|
+
}, () => {
|
|
1138
|
+
heldTouch = null;
|
|
1139
|
+
heldOrigin = null;
|
|
1140
|
+
});
|
|
1141
|
+
};
|
|
1142
|
+
createEffect(() => windowKey(), () => () => {
|
|
1143
|
+
heldTouch?.();
|
|
1144
|
+
});
|
|
1145
|
+
createEffect(() => ({
|
|
1146
|
+
days: dayLookup(),
|
|
1147
|
+
events: props.events,
|
|
1148
|
+
canCreate: !!(props.onCreateEvent || props.onSelectDrag),
|
|
1149
|
+
canMove: !!props.onDragEvent,
|
|
1150
|
+
eventStartEditable: props.eventStartEditable
|
|
1151
|
+
}), (state) => {
|
|
1152
|
+
const origin = heldOrigin;
|
|
1153
|
+
if (!origin) return;
|
|
1154
|
+
const current = dragRef.current;
|
|
1155
|
+
const destination = current ? new Date(current.kind === "create" ? current.hover : current.to) : origin.day;
|
|
1156
|
+
const enabled = (day) => {
|
|
1157
|
+
const cell = state.days.get(format(day, "yyyy-MM-dd"));
|
|
1158
|
+
return cell != null && !cell.isDisabled;
|
|
1159
|
+
};
|
|
1160
|
+
if (!enabled(origin.day) || !enabled(destination) || (origin.event ? !state.canMove || !state.events?.includes(origin.event) || origin.event.disabled || origin.event.draggable === false || !(origin.event.startEditable ?? state.eventStartEditable) : !state.canCreate)) heldTouch?.();
|
|
1161
|
+
});
|
|
922
1162
|
const isDragging = createMemo(() => drag() !== null);
|
|
923
1163
|
const dragWired = createMemo(() => props.onCreateEvent != null || props.onSelectDrag != null || props.onDragEvent != null);
|
|
924
1164
|
createEffect(() => [
|
|
@@ -935,6 +1175,7 @@ function MonthView(incoming) {
|
|
|
935
1175
|
applyDrag(null);
|
|
936
1176
|
if (!movedRef.current) return;
|
|
937
1177
|
suppressClickRef.current = true;
|
|
1178
|
+
if (multiWeek() && current.windowKey !== windowKey()) return;
|
|
938
1179
|
if (current.kind === "create") {
|
|
939
1180
|
const range = monthCreateRange(new Date(current.anchor), new Date(current.hover));
|
|
940
1181
|
props.onCreateEvent?.(range.start, range.end);
|
|
@@ -958,17 +1199,59 @@ function MonthView(incoming) {
|
|
|
958
1199
|
window.removeEventListener("pointercancel", cancel);
|
|
959
1200
|
};
|
|
960
1201
|
}));
|
|
1202
|
+
let transientWindow = untrack(windowKey);
|
|
1203
|
+
createEffect(windowKey, (key) => untrack(() => {
|
|
1204
|
+
if (key === transientWindow) return;
|
|
1205
|
+
transientWindow = key;
|
|
1206
|
+
if (!multiWeek()) return;
|
|
1207
|
+
applyDrag(null);
|
|
1208
|
+
setMoreOpenFor(null);
|
|
1209
|
+
}));
|
|
1210
|
+
const nextMultiWeekFocus = (key) => {
|
|
1211
|
+
const days = focusableDays();
|
|
1212
|
+
const keys = focusableKeys();
|
|
1213
|
+
const period = _grid().period;
|
|
1214
|
+
if (!days || !keys || !period) return null;
|
|
1215
|
+
const index = days.findIndex((d) => format(d, "yyyy-MM-dd") === focusKey());
|
|
1216
|
+
if (index === -1) return null;
|
|
1217
|
+
if (key === "ArrowLeft") return days[index - 1] ?? null;
|
|
1218
|
+
if (key === "ArrowRight") return days[index + 1] ?? null;
|
|
1219
|
+
if (key === "Home") return days[0];
|
|
1220
|
+
if (key === "End") return days[days.length - 1];
|
|
1221
|
+
const step = key === "ArrowUp" ? -7 : 7;
|
|
1222
|
+
for (let cursor = addDays(days[index], step); cursor >= period.start && cursor < period.endExclusive; cursor = addDays(cursor, step)) if (keys.has(format(cursor, "yyyy-MM-dd"))) return cursor;
|
|
1223
|
+
return null;
|
|
1224
|
+
};
|
|
961
1225
|
const onKeyDown = (e) => {
|
|
1226
|
+
if (multiWeek()) {
|
|
1227
|
+
if (![
|
|
1228
|
+
"ArrowLeft",
|
|
1229
|
+
"ArrowRight",
|
|
1230
|
+
"ArrowUp",
|
|
1231
|
+
"ArrowDown",
|
|
1232
|
+
"Home",
|
|
1233
|
+
"End"
|
|
1234
|
+
].includes(e.key)) return;
|
|
1235
|
+
e.preventDefault();
|
|
1236
|
+
const target = nextMultiWeekFocus(e.key);
|
|
1237
|
+
if (!target) return;
|
|
1238
|
+
setFocusedDate(target);
|
|
1239
|
+
const targetKey = format(target, "yyyy-MM-dd");
|
|
1240
|
+
gridRef.current?.querySelector(`[data-day="${targetKey}"]`)?.focus();
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
const focused = focusedDate();
|
|
1244
|
+
if (!focused) return;
|
|
962
1245
|
let next = null;
|
|
963
|
-
if (e.key === "ArrowLeft") next = addDays(
|
|
964
|
-
else if (e.key === "ArrowRight") next = addDays(
|
|
965
|
-
else if (e.key === "ArrowUp") next = addDays(
|
|
966
|
-
else if (e.key === "ArrowDown") next = addDays(
|
|
967
|
-
else if (e.key === "Home") next = startOfMonth(props.date);
|
|
968
|
-
else if (e.key === "End") next = endOfMonth(props.date);
|
|
1246
|
+
if (e.key === "ArrowLeft") next = addDays(focused, -1);
|
|
1247
|
+
else if (e.key === "ArrowRight") next = addDays(focused, 1);
|
|
1248
|
+
else if (e.key === "ArrowUp") next = addDays(focused, -7);
|
|
1249
|
+
else if (e.key === "ArrowDown") next = addDays(focused, 7);
|
|
1250
|
+
else if (e.key === "Home") next = startOfMonth(props.source.date);
|
|
1251
|
+
else if (e.key === "End") next = endOfMonth(props.source.date);
|
|
969
1252
|
else return;
|
|
970
1253
|
e.preventDefault();
|
|
971
|
-
if (!isSameMonth(next, props.date)) return;
|
|
1254
|
+
if (!isSameMonth(next, props.source.date)) return;
|
|
972
1255
|
setFocusedDate(next);
|
|
973
1256
|
const key = format(next, "yyyy-MM-dd");
|
|
974
1257
|
gridRef.current?.querySelector(`[data-day="${key}"]`)?.focus();
|
|
@@ -983,7 +1266,7 @@ function MonthView(incoming) {
|
|
|
983
1266
|
fontWeight: 700,
|
|
984
1267
|
padding: "10px 14px 6px"
|
|
985
1268
|
} }), true);
|
|
986
|
-
insert(_el$7, scope(() =>
|
|
1269
|
+
insert(_el$7, scope(() => _grid().title));
|
|
987
1270
|
runHydrationEvents();
|
|
988
1271
|
return _el$7;
|
|
989
1272
|
})() : null;
|
|
@@ -995,7 +1278,7 @@ function MonthView(incoming) {
|
|
|
995
1278
|
spread(_el$8, () => slot("weekdays", {
|
|
996
1279
|
base: {
|
|
997
1280
|
display: "grid",
|
|
998
|
-
gridTemplateColumns:
|
|
1281
|
+
gridTemplateColumns: `repeat(${_grid().weekdays.length}, minmax(0, 1fr))`
|
|
999
1282
|
},
|
|
1000
1283
|
themed: {
|
|
1001
1284
|
borderBottom: `1px solid ${theme().gridLine}`,
|
|
@@ -1026,13 +1309,20 @@ function MonthView(incoming) {
|
|
|
1026
1309
|
})()), _el$6, _co$2);
|
|
1027
1310
|
spread(_el$2, [{
|
|
1028
1311
|
"role": "grid",
|
|
1312
|
+
get tabindex() {
|
|
1313
|
+
return multiWeek() ? -1 : void 0;
|
|
1314
|
+
},
|
|
1029
1315
|
get "aria-label"() {
|
|
1030
|
-
return
|
|
1316
|
+
return _grid().title;
|
|
1031
1317
|
},
|
|
1032
1318
|
get onKeyDown() {
|
|
1033
1319
|
return dayRoving() ? onKeyDown : void 0;
|
|
1034
1320
|
}
|
|
1035
|
-
}, () => slot("grid"
|
|
1321
|
+
}, () => slot("grid", multiWeek() ? { base: {
|
|
1322
|
+
flex: "1 1 auto",
|
|
1323
|
+
minHeight: 0,
|
|
1324
|
+
overflowY: "auto"
|
|
1325
|
+
} } : void 0)], true);
|
|
1036
1326
|
ref(() => (el) => gridRef.current = el, _el$2);
|
|
1037
1327
|
insert(_el$2, scope(() => createComponent(For, {
|
|
1038
1328
|
get each() {
|
|
@@ -1047,9 +1337,9 @@ function MonthView(incoming) {
|
|
|
1047
1337
|
const columns = createMemo(() => {
|
|
1048
1338
|
let first = 0;
|
|
1049
1339
|
let last = cols() - 1;
|
|
1050
|
-
if (eventsMode() && !
|
|
1051
|
-
const start = week().days.findIndex((d) => d
|
|
1052
|
-
const end = [...week().days].reverse().findIndex((d) => d
|
|
1340
|
+
if (eventsMode() && !showAdjacentMonths()) {
|
|
1341
|
+
const start = week().days.findIndex((d) => !isOutsidePeriod(d));
|
|
1342
|
+
const end = [...week().days].reverse().findIndex((d) => !isOutsidePeriod(d));
|
|
1053
1343
|
if (start !== -1) {
|
|
1054
1344
|
first = start;
|
|
1055
1345
|
last = cols() - 1 - end;
|
|
@@ -1077,7 +1367,7 @@ function MonthView(incoming) {
|
|
|
1077
1367
|
var _el$0 = getNextElement(_tmpl$2$6);
|
|
1078
1368
|
spread(_el$0, [{ "role": "row" }, () => slot("week", { base: {
|
|
1079
1369
|
display: "grid",
|
|
1080
|
-
gridTemplateColumns:
|
|
1370
|
+
gridTemplateColumns: `repeat(${cols()}, minmax(0, 1fr))`
|
|
1081
1371
|
} })], true);
|
|
1082
1372
|
insert(_el$0, scope(() => createComponent(For, {
|
|
1083
1373
|
get each() {
|
|
@@ -1085,7 +1375,7 @@ function MonthView(incoming) {
|
|
|
1085
1375
|
},
|
|
1086
1376
|
keyed: false,
|
|
1087
1377
|
children: (day, dayCol) => {
|
|
1088
|
-
const hidden = createMemo(() => !
|
|
1378
|
+
const hidden = createMemo(() => !showAdjacentMonths() && isOutsidePeriod(day()));
|
|
1089
1379
|
const cellHeight = createMemo(() => eventsMode() ? eventRowHeight() : theme().cellHeight);
|
|
1090
1380
|
return memo(() => {
|
|
1091
1381
|
if (hidden()) {
|
|
@@ -1116,7 +1406,7 @@ function MonthView(incoming) {
|
|
|
1116
1406
|
"data-selected": day().isSelected,
|
|
1117
1407
|
"data-range": day().isInRange,
|
|
1118
1408
|
"data-weekend": day().isWeekend,
|
|
1119
|
-
"data-outside":
|
|
1409
|
+
"data-outside": isOutsidePeriod(day()),
|
|
1120
1410
|
"data-disabled": day().isDisabled,
|
|
1121
1411
|
"data-creating": inCreate(),
|
|
1122
1412
|
"data-drop": isDropTarget()
|
|
@@ -1134,7 +1424,18 @@ function MonthView(incoming) {
|
|
|
1134
1424
|
return day().id;
|
|
1135
1425
|
},
|
|
1136
1426
|
"onFocusIn": (event) => {
|
|
1137
|
-
if (event.target === event.currentTarget)
|
|
1427
|
+
if (event.target === event.currentTarget) {
|
|
1428
|
+
lastDayFocus.current = event.currentTarget;
|
|
1429
|
+
setFocusedDate(day().date);
|
|
1430
|
+
}
|
|
1431
|
+
},
|
|
1432
|
+
"onFocusOut": (event) => {
|
|
1433
|
+
if (event.target !== event.currentTarget) return;
|
|
1434
|
+
const previous = event.currentTarget;
|
|
1435
|
+
if (event.relatedTarget) lastDayFocus.current = null;
|
|
1436
|
+
else queueMicrotask(() => {
|
|
1437
|
+
if (lastDayFocus.current === previous && previous.isConnected) lastDayFocus.current = null;
|
|
1438
|
+
});
|
|
1138
1439
|
}
|
|
1139
1440
|
},
|
|
1140
1441
|
dayData,
|
|
@@ -1160,14 +1461,14 @@ function MonthView(incoming) {
|
|
|
1160
1461
|
get style() {
|
|
1161
1462
|
return css(dragWired() ? {
|
|
1162
1463
|
...dayCellProps().style,
|
|
1163
|
-
touchAction: "none",
|
|
1464
|
+
touchAction: multiWeek() ? "pan-y" : "none",
|
|
1164
1465
|
userSelect: "none"
|
|
1165
1466
|
} : dayCellProps().style);
|
|
1166
1467
|
},
|
|
1167
1468
|
get onPointerDown() {
|
|
1168
1469
|
return dragWired() && !day().isDisabled ? (e) => {
|
|
1169
|
-
|
|
1170
|
-
|
|
1470
|
+
const date = day().date;
|
|
1471
|
+
pressRow(e, date);
|
|
1171
1472
|
} : void 0;
|
|
1172
1473
|
},
|
|
1173
1474
|
get onPointerEnter() {
|
|
@@ -1225,9 +1526,10 @@ function MonthView(incoming) {
|
|
|
1225
1526
|
"type": "button",
|
|
1226
1527
|
get onPointerDown() {
|
|
1227
1528
|
return canMove(b().seg.event) ? (e) => {
|
|
1228
|
-
if (e.button !== 0 || !beginPress(e)) return;
|
|
1229
1529
|
e.stopPropagation();
|
|
1230
|
-
|
|
1530
|
+
const event = b().seg.event;
|
|
1531
|
+
const date = day().date;
|
|
1532
|
+
pressRow(e, date, event);
|
|
1231
1533
|
} : void 0;
|
|
1232
1534
|
},
|
|
1233
1535
|
"onClick": (e) => {
|
|
@@ -1243,7 +1545,7 @@ function MonthView(incoming) {
|
|
|
1243
1545
|
},
|
|
1244
1546
|
get "aria-label"() {
|
|
1245
1547
|
return props.eventAccessibilityLabel ? props.eventAccessibilityLabel(b().seg.event, {
|
|
1246
|
-
mode:
|
|
1548
|
+
mode: viewMode(),
|
|
1247
1549
|
isAllDay: isAllDayEvent$1(b().seg.event),
|
|
1248
1550
|
ampm: false
|
|
1249
1551
|
}) : `${b().seg.event.title}, ${dayLabel()}`;
|
|
@@ -1259,7 +1561,7 @@ function MonthView(incoming) {
|
|
|
1259
1561
|
pointerEvents: isDragging() ? "none" : "auto",
|
|
1260
1562
|
opacity: isDragged() ? DRAGGED_CHIP_OPACITY : void 0,
|
|
1261
1563
|
cursor: canMove(b().seg.event) ? "grab" : void 0,
|
|
1262
|
-
touchAction: dragWired() ? "none" : void 0,
|
|
1564
|
+
touchAction: dragWired() ? multiWeek() ? "pan-y" : "none" : void 0,
|
|
1263
1565
|
zIndex: 2
|
|
1264
1566
|
});
|
|
1265
1567
|
}
|
|
@@ -1271,6 +1573,9 @@ function MonthView(incoming) {
|
|
|
1271
1573
|
get component() {
|
|
1272
1574
|
return Chip();
|
|
1273
1575
|
},
|
|
1576
|
+
get mode() {
|
|
1577
|
+
return viewMode();
|
|
1578
|
+
},
|
|
1274
1579
|
get event() {
|
|
1275
1580
|
return b().seg.event;
|
|
1276
1581
|
},
|
|
@@ -1330,7 +1635,7 @@ function MonthView(incoming) {
|
|
|
1330
1635
|
}
|
|
1331
1636
|
}
|
|
1332
1637
|
},
|
|
1333
|
-
() => slot("more", moreButtonDefault(theme(), props.chipHeight)),
|
|
1638
|
+
() => slot("more", moreButtonDefault(theme(), props.chipHeight, multiWeek())),
|
|
1334
1639
|
{
|
|
1335
1640
|
get "aria-label"() {
|
|
1336
1641
|
return `${labels().moreEvents(hiddenEvents().length)}, ${dayLabel()}`;
|
|
@@ -1409,6 +1714,9 @@ function MonthView(incoming) {
|
|
|
1409
1714
|
get component() {
|
|
1410
1715
|
return Chip();
|
|
1411
1716
|
},
|
|
1717
|
+
get mode() {
|
|
1718
|
+
return viewMode();
|
|
1719
|
+
},
|
|
1412
1720
|
get event() {
|
|
1413
1721
|
return event();
|
|
1414
1722
|
},
|
|
@@ -1460,7 +1768,10 @@ function MonthView(incoming) {
|
|
|
1460
1768
|
return day().id;
|
|
1461
1769
|
},
|
|
1462
1770
|
"onFocusIn": (event) => {
|
|
1463
|
-
if (event.target === event.currentTarget)
|
|
1771
|
+
if (event.target === event.currentTarget) {
|
|
1772
|
+
lastDayFocus.current = event.currentTarget;
|
|
1773
|
+
setFocusedDate(day().date);
|
|
1774
|
+
}
|
|
1464
1775
|
}
|
|
1465
1776
|
},
|
|
1466
1777
|
dayData,
|
|
@@ -1523,6 +1834,11 @@ function MonthView(incoming) {
|
|
|
1523
1834
|
t: readShallow(css({
|
|
1524
1835
|
fontFamily: theme().fontFamily,
|
|
1525
1836
|
color: theme().text,
|
|
1837
|
+
...multiWeek() ? {
|
|
1838
|
+
display: "flex",
|
|
1839
|
+
flexDirection: "column",
|
|
1840
|
+
minHeight: 0
|
|
1841
|
+
} : null,
|
|
1526
1842
|
...props.style
|
|
1527
1843
|
}))
|
|
1528
1844
|
}), ({ e, t }, _p$) => {
|
|
@@ -1533,6 +1849,37 @@ function MonthView(incoming) {
|
|
|
1533
1849
|
return _el$;
|
|
1534
1850
|
}
|
|
1535
1851
|
delegateEvents(["click"]);
|
|
1852
|
+
// src/MultiWeekView.tsx
|
|
1853
|
+
/** Props for {@link MultiWeekView}. */
|
|
1854
|
+
/**
|
|
1855
|
+
* Consecutive full weeks as stacked seven-day rows, with event chips and no hour
|
|
1856
|
+
* slots. It has the month grid's event bars, overflow, selection, and drag
|
|
1857
|
+
* interactions, and the month slots, `renderEvent`, and theme style it. Every
|
|
1858
|
+
* row is kept at full height; when the view is given less room, the rows scroll
|
|
1859
|
+
* under the title and weekday header.
|
|
1860
|
+
*
|
|
1861
|
+
* Standalone, it shows `events` as given; expand recurring events first with
|
|
1862
|
+
* `expandRecurringEvents`, or use `Calendar` with `mode="multiweek"`.
|
|
1863
|
+
*
|
|
1864
|
+
* @example
|
|
1865
|
+
* ```tsx
|
|
1866
|
+
* <MultiWeekView date={new Date()} numberOfWeeks={3} events={events} />
|
|
1867
|
+
* ```
|
|
1868
|
+
*/
|
|
1869
|
+
function MultiWeekView(props) {
|
|
1870
|
+
return createComponent(DateRows, mergeProps(props, {
|
|
1871
|
+
get chipHeight() {
|
|
1872
|
+
return props.chipHeight ?? 24;
|
|
1873
|
+
},
|
|
1874
|
+
get source() {
|
|
1875
|
+
return {
|
|
1876
|
+
kind: "multiweek",
|
|
1877
|
+
date: props.date,
|
|
1878
|
+
numberOfWeeks: props.numberOfWeeks ?? 2
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1881
|
+
}));
|
|
1882
|
+
}
|
|
1536
1883
|
// src/EventActions.tsx
|
|
1537
1884
|
var _tmpl$$6 = /*#__PURE__*/ template(`<div><button></button><!$><!/>`);
|
|
1538
1885
|
var _tmpl$2$5 = /*#__PURE__*/ template(`<div>`);
|
|
@@ -1979,44 +2326,6 @@ function createDateRange(options = () => ({})) {
|
|
|
1979
2326
|
function createMonthGrid(month, options = () => ({})) {
|
|
1980
2327
|
return createMemo(() => buildMonthGrid$1(month(), options()));
|
|
1981
2328
|
}
|
|
1982
|
-
// src/touch.ts
|
|
1983
|
-
function waitForHold(grab, delay, threshold, onHold, onTap, onCancel) {
|
|
1984
|
-
const detach = () => {
|
|
1985
|
-
clearTimeout(timer);
|
|
1986
|
-
document.removeEventListener("pointermove", move);
|
|
1987
|
-
document.removeEventListener("pointerup", up);
|
|
1988
|
-
document.removeEventListener("pointercancel", cancelPointer);
|
|
1989
|
-
document.removeEventListener("pointerdown", anotherPointer);
|
|
1990
|
-
};
|
|
1991
|
-
const cancel = () => {
|
|
1992
|
-
detach();
|
|
1993
|
-
onCancel();
|
|
1994
|
-
};
|
|
1995
|
-
const move = (event) => {
|
|
1996
|
-
if (event.pointerId === grab.pointerId && Math.hypot(event.clientX - grab.clientX, event.clientY - grab.clientY) > threshold) cancel();
|
|
1997
|
-
};
|
|
1998
|
-
const up = (event) => {
|
|
1999
|
-
if (event.pointerId === grab.pointerId) {
|
|
2000
|
-
detach();
|
|
2001
|
-
onTap();
|
|
2002
|
-
}
|
|
2003
|
-
};
|
|
2004
|
-
const cancelPointer = (event) => {
|
|
2005
|
-
if (event.pointerId === grab.pointerId) cancel();
|
|
2006
|
-
};
|
|
2007
|
-
const anotherPointer = (event) => {
|
|
2008
|
-
if (event.pointerId !== grab.pointerId) cancel();
|
|
2009
|
-
};
|
|
2010
|
-
const timer = setTimeout(() => {
|
|
2011
|
-
detach();
|
|
2012
|
-
onHold();
|
|
2013
|
-
}, delay);
|
|
2014
|
-
document.addEventListener("pointermove", move);
|
|
2015
|
-
document.addEventListener("pointerup", up);
|
|
2016
|
-
document.addEventListener("pointercancel", cancelPointer);
|
|
2017
|
-
document.addEventListener("pointerdown", anotherPointer);
|
|
2018
|
-
return cancel;
|
|
2019
|
-
}
|
|
2020
2329
|
// src/TimeGrid.tsx
|
|
2021
2330
|
var _tmpl$$5 = /*#__PURE__*/ template(`<div><div></div><!$><!/>`);
|
|
2022
2331
|
var _tmpl$2$4 = /*#__PURE__*/ template(`<div>`);
|
|
@@ -4288,14 +4597,22 @@ var _tmpl$$3 = /*#__PURE__*/ template(`<div>`);
|
|
|
4288
4597
|
*/
|
|
4289
4598
|
/** Props for {@link Calendar}. */
|
|
4290
4599
|
const EMPTY_EVENTS = [];
|
|
4291
|
-
function expansionRange(mode, date, weekStartsOn, numberOfDays) {
|
|
4600
|
+
function expansionRange(mode, date, weekStartsOn, numberOfDays, numberOfWeeks) {
|
|
4601
|
+
if (mode === "multiweek") {
|
|
4602
|
+
const { period } = buildMultiWeekGrid$1(date, {
|
|
4603
|
+
weekStartsOn,
|
|
4604
|
+
numberOfWeeks
|
|
4605
|
+
});
|
|
4606
|
+
return [period.start, endOfDay(addDays(period.endExclusive, -1))];
|
|
4607
|
+
}
|
|
4292
4608
|
if (mode === "month") return [startOfWeek(startOfMonth(date), { weekStartsOn }), endOfWeek(endOfMonth(date), { weekStartsOn })];
|
|
4293
4609
|
if (mode === "year") return [startOfWeek(startOfYear(date), { weekStartsOn }), endOfWeek(endOfYear(date), { weekStartsOn })];
|
|
4294
4610
|
if (mode === "schedule") return [startOfDay(date), endOfDay(addMonths(date, 3))];
|
|
4295
4611
|
const days = getViewDays$1(mode, date, weekStartsOn, numberOfDays ?? 1);
|
|
4296
4612
|
return [startOfDay(days[0]), endOfDay(days[days.length - 1])];
|
|
4297
4613
|
}
|
|
4298
|
-
function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
4614
|
+
function pageStep(mode, date, direction, weekStartsOn, numberOfDays, numberOfWeeks) {
|
|
4615
|
+
if (mode === "multiweek") return addWeeks(date, direction * numberOfWeeks);
|
|
4299
4616
|
if (mode === "year") return addYears(date, direction);
|
|
4300
4617
|
if (mode === "month") return addMonths(date, direction);
|
|
4301
4618
|
if (mode === "schedule") return addDays(date, direction * 7);
|
|
@@ -4315,7 +4632,8 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
4315
4632
|
function Calendar(incoming) {
|
|
4316
4633
|
const props = withDefaults({
|
|
4317
4634
|
mode: "week",
|
|
4318
|
-
weekStartsOn: 0
|
|
4635
|
+
weekStartsOn: 0,
|
|
4636
|
+
numberOfWeeks: 2
|
|
4319
4637
|
}, incoming);
|
|
4320
4638
|
const timeGridRef = { current: null };
|
|
4321
4639
|
onSettled(() => {
|
|
@@ -4324,7 +4642,7 @@ function Calendar(incoming) {
|
|
|
4324
4642
|
const displayEvents = createMemo(() => {
|
|
4325
4643
|
let out = props.events ?? EMPTY_EVENTS;
|
|
4326
4644
|
if (out.some((e) => e.recurrence)) {
|
|
4327
|
-
let [start, end] = expansionRange(props.mode, props.date, props.weekStartsOn, props.numberOfDays);
|
|
4645
|
+
let [start, end] = expansionRange(props.mode, props.date, props.weekStartsOn, props.numberOfDays, props.numberOfWeeks);
|
|
4328
4646
|
if (props.timeZone) {
|
|
4329
4647
|
start = addDays(start, -1);
|
|
4330
4648
|
end = addDays(end, 1);
|
|
@@ -4336,8 +4654,8 @@ function Calendar(incoming) {
|
|
|
4336
4654
|
});
|
|
4337
4655
|
const handlePageKeys = (e) => {
|
|
4338
4656
|
if (!props.onChangeDate) return;
|
|
4339
|
-
if (e.key === "PageDown") props.onChangeDate(pageStep(props.mode, props.date, 1, props.weekStartsOn, props.numberOfDays));
|
|
4340
|
-
else if (e.key === "PageUp") props.onChangeDate(pageStep(props.mode, props.date, -1, props.weekStartsOn, props.numberOfDays));
|
|
4657
|
+
if (e.key === "PageDown") props.onChangeDate(pageStep(props.mode, props.date, 1, props.weekStartsOn, props.numberOfDays, props.numberOfWeeks));
|
|
4658
|
+
else if (e.key === "PageUp") props.onChangeDate(pageStep(props.mode, props.date, -1, props.weekStartsOn, props.numberOfDays, props.numberOfWeeks));
|
|
4341
4659
|
else return;
|
|
4342
4660
|
e.preventDefault();
|
|
4343
4661
|
};
|
|
@@ -4569,6 +4887,125 @@ function Calendar(incoming) {
|
|
|
4569
4887
|
return props.eventAccessibilityLabel;
|
|
4570
4888
|
}
|
|
4571
4889
|
});
|
|
4890
|
+
else if (mode === "multiweek") return createComponent(MultiWeekView, {
|
|
4891
|
+
get date() {
|
|
4892
|
+
return props.date;
|
|
4893
|
+
},
|
|
4894
|
+
get numberOfWeeks() {
|
|
4895
|
+
return props.numberOfWeeks;
|
|
4896
|
+
},
|
|
4897
|
+
get events() {
|
|
4898
|
+
return displayEvents();
|
|
4899
|
+
},
|
|
4900
|
+
get weekStartsOn() {
|
|
4901
|
+
return props.weekStartsOn;
|
|
4902
|
+
},
|
|
4903
|
+
get hiddenDays() {
|
|
4904
|
+
return props.hiddenDays;
|
|
4905
|
+
},
|
|
4906
|
+
get weekdayFormat() {
|
|
4907
|
+
return props.weekdayFormat;
|
|
4908
|
+
},
|
|
4909
|
+
get highlightWeekends() {
|
|
4910
|
+
return props.highlightWeekends;
|
|
4911
|
+
},
|
|
4912
|
+
get locale() {
|
|
4913
|
+
return props.locale;
|
|
4914
|
+
},
|
|
4915
|
+
get labels() {
|
|
4916
|
+
return props.labels;
|
|
4917
|
+
},
|
|
4918
|
+
get theme() {
|
|
4919
|
+
return props.theme;
|
|
4920
|
+
},
|
|
4921
|
+
get className() {
|
|
4922
|
+
return props.className;
|
|
4923
|
+
},
|
|
4924
|
+
get style() {
|
|
4925
|
+
return {
|
|
4926
|
+
height: props.height,
|
|
4927
|
+
...props.style
|
|
4928
|
+
};
|
|
4929
|
+
},
|
|
4930
|
+
get classNames() {
|
|
4931
|
+
return props.classNames;
|
|
4932
|
+
},
|
|
4933
|
+
get styles() {
|
|
4934
|
+
return props.styles;
|
|
4935
|
+
},
|
|
4936
|
+
get maxVisibleEventCount() {
|
|
4937
|
+
return props.maxVisibleEventCount;
|
|
4938
|
+
},
|
|
4939
|
+
get chipHeight() {
|
|
4940
|
+
return props.chipHeight;
|
|
4941
|
+
},
|
|
4942
|
+
get chipGap() {
|
|
4943
|
+
return props.chipGap;
|
|
4944
|
+
},
|
|
4945
|
+
get moreLabel() {
|
|
4946
|
+
return props.moreLabel;
|
|
4947
|
+
},
|
|
4948
|
+
get showTitle() {
|
|
4949
|
+
return props.showTitle;
|
|
4950
|
+
},
|
|
4951
|
+
get fillCellOnSelection() {
|
|
4952
|
+
return props.fillCellOnSelection;
|
|
4953
|
+
},
|
|
4954
|
+
get selectedRange() {
|
|
4955
|
+
return props.selectedRange;
|
|
4956
|
+
},
|
|
4957
|
+
get selectedDates() {
|
|
4958
|
+
return props.selectedDates;
|
|
4959
|
+
},
|
|
4960
|
+
get minDate() {
|
|
4961
|
+
return props.minDate;
|
|
4962
|
+
},
|
|
4963
|
+
get maxDate() {
|
|
4964
|
+
return props.maxDate;
|
|
4965
|
+
},
|
|
4966
|
+
get isDateDisabled() {
|
|
4967
|
+
return props.isDateDisabled;
|
|
4968
|
+
},
|
|
4969
|
+
get keyboardDayNavigation() {
|
|
4970
|
+
return props.keyboardDayNavigation;
|
|
4971
|
+
},
|
|
4972
|
+
get onPressDay() {
|
|
4973
|
+
return props.onPressDay;
|
|
4974
|
+
},
|
|
4975
|
+
get onPressCell() {
|
|
4976
|
+
return props.onPressCell;
|
|
4977
|
+
},
|
|
4978
|
+
get onCreateEvent() {
|
|
4979
|
+
return props.onCreateEvent;
|
|
4980
|
+
},
|
|
4981
|
+
get onSelectDrag() {
|
|
4982
|
+
return props.onSelectDrag;
|
|
4983
|
+
},
|
|
4984
|
+
get onDragEvent() {
|
|
4985
|
+
return props.onDragEvent;
|
|
4986
|
+
},
|
|
4987
|
+
get onDragStart() {
|
|
4988
|
+
return props.onDragStart;
|
|
4989
|
+
},
|
|
4990
|
+
get eventStartEditable() {
|
|
4991
|
+
return props.eventStartEditable;
|
|
4992
|
+
},
|
|
4993
|
+
get eventOverlap() {
|
|
4994
|
+
return props.eventOverlap;
|
|
4995
|
+
},
|
|
4996
|
+
get onPressEvent() {
|
|
4997
|
+
return props.onPressEvent;
|
|
4998
|
+
},
|
|
4999
|
+
get onPressMore() {
|
|
5000
|
+
return props.onPressMore;
|
|
5001
|
+
},
|
|
5002
|
+
get renderEvent() {
|
|
5003
|
+
return props.renderMonthEvent;
|
|
5004
|
+
},
|
|
5005
|
+
get eventAccessibilityLabel() {
|
|
5006
|
+
return props.eventAccessibilityLabel;
|
|
5007
|
+
}
|
|
5008
|
+
});
|
|
4572
5009
|
else return createComponent(TimeGrid, {
|
|
4573
5010
|
ref: (el) => timeGridRef.current = el,
|
|
4574
5011
|
get date() {
|
|
@@ -6611,4 +7048,4 @@ function ResourceTimeline(incoming) {
|
|
|
6611
7048
|
})];
|
|
6612
7049
|
}
|
|
6613
7050
|
delegateEvents(["pointerdown"]);
|
|
6614
|
-
export { Agenda, Calendar, DatePicker, DateRangePicker, MonthList, MonthView, ResourceTimeline, TimeGrid, YearView, backgroundBandsForDay, buildMonthGrid, createDateRange, createEventSource, createMonthGrid, createNow, darkSolidTheme, daySelectionState, defaultCalendarLabels, defaultSolidTheme, expandRecurringEvents, getViewDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, layoutMonthWeek, loadEventSource, mergeSolidTheme, nextDateRange, parseICalendar, toICalendar, weekdayFormatToken };
|
|
7051
|
+
export { Agenda, Calendar, DatePicker, DateRangePicker, MonthList, MonthView, MultiWeekView, ResourceTimeline, TimeGrid, YearView, backgroundBandsForDay, buildMonthGrid, buildMultiWeekGrid, createDateRange, createEventSource, createMonthGrid, createNow, darkSolidTheme, daySelectionState, defaultCalendarLabels, defaultSolidTheme, expandRecurringEvents, getViewDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, layoutMonthWeek, loadEventSource, mergeSolidTheme, nextDateRange, parseICalendar, toICalendar, weekdayFormatToken };
|