@super-calendar/native 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/src/index.tsx CHANGED
@@ -23,6 +23,7 @@
23
23
  export { Calendar, type CalendarProps, type CalendarSlot } from "./components/Calendar";
24
24
  export { Agenda, type AgendaProps, type AgendaSlot } from "./components/Agenda";
25
25
  export { MonthView, type MonthViewProps, type MonthViewSlot } from "./components/MonthView";
26
+ export { MultiWeekView, type MultiWeekViewProps } from "./components/MultiWeekView";
26
27
  export { YearView, type YearViewProps, type YearViewSlot } from "./components/YearView";
27
28
  export { type ResolvedSlot, type SlotDefault, type SlotStyleProps } from "./utils/slots";
28
29
  export { MonthPager, type MonthPagerProps } from "./components/MonthPager";
@@ -89,6 +90,7 @@ export {
89
90
  } from "@super-calendar/core";
90
91
  export {
91
92
  buildMonthGrid,
93
+ buildMultiWeekGrid,
92
94
  layoutMonthWeek,
93
95
  type MonthEventSegment,
94
96
  type MonthGrid,
@@ -96,6 +98,11 @@ export {
96
98
  type MonthGridWeek,
97
99
  type MonthGridWeekday,
98
100
  type MonthWeekEvents,
101
+ type MultiWeekGrid,
102
+ type MultiWeekGridDay,
103
+ type MultiWeekGridInterval,
104
+ type MultiWeekGridOptions,
105
+ type MultiWeekGridWeek,
99
106
  type UseMonthGridOptions,
100
107
  useMonthGrid,
101
108
  weekdayFormatToken,
@@ -0,0 +1,63 @@
1
+ /** Keep quick swipes scrollable, then let a held pointer own the date-row drag. */
2
+ export function holdWebDateDrag(
3
+ node: HTMLElement,
4
+ pointer: { pointerId: number; clientX: number; clientY: number },
5
+ start: () => void,
6
+ move: (x: number, y: number) => void,
7
+ cancel: () => void,
8
+ release: () => void,
9
+ ): () => void {
10
+ const doc = node.ownerDocument;
11
+ let active = false;
12
+ let finished = false;
13
+ const detach = () => {
14
+ clearTimeout(timer);
15
+ doc.removeEventListener("pointermove", onMove);
16
+ doc.removeEventListener("pointerup", onUp);
17
+ doc.removeEventListener("pointercancel", onCancel);
18
+ doc.removeEventListener("pointerdown", onAnotherPointer);
19
+ doc.removeEventListener("touchmove", onTouchMove);
20
+ doc.removeEventListener("contextmenu", onContextMenu);
21
+ };
22
+ const stop = () => {
23
+ if (finished) return;
24
+ finished = true;
25
+ detach();
26
+ cancel();
27
+ release();
28
+ };
29
+ const onMove = (event: PointerEvent) => {
30
+ if (event.pointerId !== pointer.pointerId) return;
31
+ if (active) move(event.clientX, event.clientY);
32
+ else if (Math.hypot(event.clientX - pointer.clientX, event.clientY - pointer.clientY) > 8)
33
+ stop();
34
+ };
35
+ const onUp = (event: PointerEvent) => {
36
+ if (event.pointerId !== pointer.pointerId) return;
37
+ finished = true;
38
+ detach();
39
+ release();
40
+ // The view's window pointerup listener commits an active drag.
41
+ };
42
+ const onCancel = (event: PointerEvent) => {
43
+ if (event.pointerId === pointer.pointerId) stop();
44
+ };
45
+ const onAnotherPointer = (event: PointerEvent) => {
46
+ if (event.pointerId !== pointer.pointerId) stop();
47
+ };
48
+ const onTouchMove = (event: TouchEvent) => {
49
+ if (active && event.cancelable) event.preventDefault();
50
+ };
51
+ const onContextMenu = (event: Event) => event.preventDefault();
52
+ const timer = setTimeout(() => {
53
+ active = true;
54
+ start();
55
+ }, 400);
56
+ doc.addEventListener("pointermove", onMove);
57
+ doc.addEventListener("pointerup", onUp);
58
+ doc.addEventListener("pointercancel", onCancel);
59
+ doc.addEventListener("pointerdown", onAnotherPointer);
60
+ doc.addEventListener("touchmove", onTouchMove, { passive: false });
61
+ doc.addEventListener("contextmenu", onContextMenu);
62
+ return stop;
63
+ }