feat: add isMobile prop to calendar views and time grid interactions
This commit is contained in:
@@ -119,6 +119,7 @@ export function CalendarDayView({
|
|||||||
created: t("notifications.event_created"),
|
created: t("notifications.event_created"),
|
||||||
error: t("notifications.event_error"),
|
error: t("notifications.event_error"),
|
||||||
},
|
},
|
||||||
|
isMobile,
|
||||||
});
|
});
|
||||||
|
|
||||||
const formatHour = (h: number): string => {
|
const formatHour = (h: number): string => {
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ export function CalendarWeekView({
|
|||||||
created: t("notifications.event_created"),
|
created: t("notifications.event_created"),
|
||||||
error: t("notifications.event_error"),
|
error: t("notifications.event_error"),
|
||||||
},
|
},
|
||||||
|
isMobile,
|
||||||
});
|
});
|
||||||
|
|
||||||
const formatHour = (h: number): string => {
|
const formatHour = (h: number): string => {
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ interface UseTimeGridInteractionsOptions {
|
|||||||
created: string;
|
created: string;
|
||||||
error: string;
|
error: string;
|
||||||
};
|
};
|
||||||
|
isMobile?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useTimeGridInteractions({
|
export function useTimeGridInteractions({
|
||||||
@@ -47,6 +48,7 @@ export function useTimeGridInteractions({
|
|||||||
calendars,
|
calendars,
|
||||||
onCreateRange,
|
onCreateRange,
|
||||||
errorMessages,
|
errorMessages,
|
||||||
|
isMobile,
|
||||||
}: UseTimeGridInteractionsOptions) {
|
}: UseTimeGridInteractionsOptions) {
|
||||||
const snapToMinutes = useCallback((clientY: number, containerTop: number): number => {
|
const snapToMinutes = useCallback((clientY: number, containerTop: number): number => {
|
||||||
const raw = ((clientY - containerTop) / hourHeight) * 60;
|
const raw = ((clientY - containerTop) / hourHeight) * 60;
|
||||||
@@ -72,6 +74,7 @@ export function useTimeGridInteractions({
|
|||||||
dayKey: string,
|
dayKey: string,
|
||||||
dayDate: Date,
|
dayDate: Date,
|
||||||
) => {
|
) => {
|
||||||
|
if (isMobile) return;
|
||||||
if (e.button !== 0) return;
|
if (e.button !== 0) return;
|
||||||
if ((e.target as HTMLElement).closest("[data-calendar-event], [data-resize-handle]")) return;
|
if ((e.target as HTMLElement).closest("[data-calendar-event], [data-resize-handle]")) return;
|
||||||
|
|
||||||
@@ -82,7 +85,7 @@ export function useTimeGridInteractions({
|
|||||||
dayKey, dayDate, startMinutes: minutes,
|
dayKey, dayDate, startMinutes: minutes,
|
||||||
pointerId: e.pointerId, startY: e.clientY, captured: false,
|
pointerId: e.pointerId, startY: e.clientY, captured: false,
|
||||||
};
|
};
|
||||||
}, [snapToMinutes]);
|
}, [snapToMinutes, isMobile]);
|
||||||
|
|
||||||
const handleGridPointerMove = useCallback((e: PointerEvent<HTMLDivElement>) => {
|
const handleGridPointerMove = useCallback((e: PointerEvent<HTMLDivElement>) => {
|
||||||
if (!dragRef.current) return;
|
if (!dragRef.current) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user