@sunsama/event-calendar 0.2.6 → 0.2.8
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/lib/commonjs/components/all-day-events.js +3 -13
- package/lib/commonjs/components/all-day-events.js.map +1 -1
- package/lib/commonjs/components/event-container.js.map +1 -1
- package/lib/commonjs/components/timed-event-container.js.map +1 -1
- package/lib/commonjs/hooks/use-events.js +4 -4
- package/lib/commonjs/hooks/use-events.js.map +1 -1
- package/lib/commonjs/hooks/use-is-editing.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/compute-positioning.js.map +1 -1
- package/lib/commonjs/utils/double-tap-reset-zoom-gesture.js.map +1 -1
- package/lib/commonjs/utils/generate-event-layouts.js.map +1 -1
- package/lib/commonjs/utils/globals.js.map +1 -1
- package/lib/commonjs/utils/pan-edit-event-gesture.js.map +1 -1
- package/lib/module/components/all-day-events.js +3 -13
- package/lib/module/components/all-day-events.js.map +1 -1
- package/lib/module/components/event-container.js.map +1 -1
- package/lib/module/components/timed-event-container.js.map +1 -1
- package/lib/module/hooks/use-events.js +4 -4
- package/lib/module/hooks/use-events.js.map +1 -1
- package/lib/module/hooks/use-is-editing.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/compute-positioning.js.map +1 -1
- package/lib/module/utils/double-tap-reset-zoom-gesture.js.map +1 -1
- package/lib/module/utils/generate-event-layouts.js.map +1 -1
- package/lib/module/utils/globals.js.map +1 -1
- package/lib/module/utils/pan-edit-event-gesture.js.map +1 -1
- package/lib/typescript/commonjs/components/all-day-events.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/event-container.d.ts +4 -4
- package/lib/typescript/commonjs/components/event-container.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/timed-event-container.d.ts +4 -4
- package/lib/typescript/commonjs/components/timed-event-container.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-events.d.ts +12 -12
- package/lib/typescript/commonjs/hooks/use-events.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-is-editing.d.ts +6 -6
- package/lib/typescript/commonjs/hooks/use-is-editing.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +11 -11
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +15 -15
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/compute-positioning.d.ts +4 -4
- package/lib/typescript/commonjs/utils/compute-positioning.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/double-tap-reset-zoom-gesture.d.ts +2 -2
- package/lib/typescript/commonjs/utils/double-tap-reset-zoom-gesture.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/generate-event-layouts.d.ts +4 -4
- package/lib/typescript/commonjs/utils/generate-event-layouts.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/globals.d.ts +1 -1
- package/lib/typescript/commonjs/utils/globals.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/pan-edit-event-gesture.d.ts +2 -2
- package/lib/typescript/commonjs/utils/pan-edit-event-gesture.d.ts.map +1 -1
- package/lib/typescript/module/components/all-day-events.d.ts.map +1 -1
- package/lib/typescript/module/components/event-container.d.ts +4 -4
- package/lib/typescript/module/components/event-container.d.ts.map +1 -1
- package/lib/typescript/module/components/timed-event-container.d.ts +4 -4
- package/lib/typescript/module/components/timed-event-container.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-events.d.ts +12 -12
- package/lib/typescript/module/hooks/use-events.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-is-editing.d.ts +6 -6
- package/lib/typescript/module/hooks/use-is-editing.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +11 -11
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +15 -15
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/utils/compute-positioning.d.ts +4 -4
- package/lib/typescript/module/utils/compute-positioning.d.ts.map +1 -1
- package/lib/typescript/module/utils/double-tap-reset-zoom-gesture.d.ts +2 -2
- package/lib/typescript/module/utils/double-tap-reset-zoom-gesture.d.ts.map +1 -1
- package/lib/typescript/module/utils/generate-event-layouts.d.ts +4 -4
- package/lib/typescript/module/utils/generate-event-layouts.d.ts.map +1 -1
- package/lib/typescript/module/utils/globals.d.ts +1 -1
- package/lib/typescript/module/utils/globals.d.ts.map +1 -1
- package/lib/typescript/module/utils/pan-edit-event-gesture.d.ts +2 -2
- package/lib/typescript/module/utils/pan-edit-event-gesture.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/components/all-day-events.tsx +5 -15
- package/src/components/event-container.tsx +12 -6
- package/src/components/timed-event-container.tsx +10 -6
- package/src/hooks/use-events.tsx +20 -21
- package/src/hooks/use-is-editing.tsx +17 -10
- package/src/index.tsx +23 -23
- package/src/types.ts +15 -15
- package/src/utils/__tests___/compute-positioning.test.ts +1 -1
- package/src/utils/compute-positioning.ts +5 -5
- package/src/utils/double-tap-reset-zoom-gesture.ts +3 -3
- package/src/utils/generate-event-layouts.ts +17 -17
- package/src/utils/globals.ts +1 -1
- package/src/utils/pan-edit-event-gesture.ts +3 -3
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import type { CalendarEvent, Config, onCreateEvent, ThemeStyle } from "./types";
|
|
2
2
|
export * from "./types";
|
|
3
|
-
type EventCalenderProps = {
|
|
3
|
+
type EventCalenderProps<T extends CalendarEvent> = {
|
|
4
4
|
canCreateEvents?: boolean;
|
|
5
|
-
canEditEvent?: Config["canEditEvent"];
|
|
5
|
+
canEditEvent?: Config<T>["canEditEvent"];
|
|
6
6
|
dayDate: string;
|
|
7
|
-
events:
|
|
7
|
+
events: T[];
|
|
8
8
|
fiveMinuteInterval?: boolean;
|
|
9
9
|
initialZoomLevel?: number;
|
|
10
10
|
maxAllDayEvents?: number;
|
|
11
11
|
onCreateEvent?: onCreateEvent;
|
|
12
|
-
onEventEdit?: Config["onEventEdit"];
|
|
13
|
-
onPressEvent?: Config["onPressEvent"];
|
|
14
|
-
renderDragBars?: Config["renderDragBars"];
|
|
15
|
-
renderEvent: Config["renderEvent"];
|
|
16
|
-
renderNewEventContainer?: Config["renderNewEventContainer"];
|
|
12
|
+
onEventEdit?: Config<T>["onEventEdit"];
|
|
13
|
+
onPressEvent?: Config<T>["onPressEvent"];
|
|
14
|
+
renderDragBars?: Config<T>["renderDragBars"];
|
|
15
|
+
renderEvent: Config<T>["renderEvent"];
|
|
16
|
+
renderNewEventContainer?: Config<T>["renderNewEventContainer"];
|
|
17
17
|
showTimeIndicator?: boolean;
|
|
18
18
|
theme?: ThemeStyle;
|
|
19
19
|
timeFormat?: string;
|
|
20
20
|
timezone?: string;
|
|
21
21
|
updateLocalStateAfterEdit?: boolean;
|
|
22
22
|
userCalendarId?: string;
|
|
23
|
-
extraTimedComponents?: Config["extraTimedComponents"];
|
|
24
|
-
onZoomChange?: Config["onZoomChange"];
|
|
23
|
+
extraTimedComponents?: Config<T>["extraTimedComponents"];
|
|
24
|
+
onZoomChange?: Config<T>["onZoomChange"];
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
27
|
* Wraps `EventCalendarContent` inside `ClonedEventsProvider` to manage cloned events independently.
|
|
28
28
|
*/
|
|
29
|
-
declare const EventCalendar: ({ timeFormat, dayDate, events, initialZoomLevel, timezone, userCalendarId, maxAllDayEvents, updateLocalStateAfterEdit, canCreateEvents, canEditEvent, ...props }: EventCalenderProps) => import("react").JSX.Element;
|
|
29
|
+
declare const EventCalendar: <T extends CalendarEvent>({ timeFormat, dayDate, events, initialZoomLevel, timezone, userCalendarId, maxAllDayEvents, updateLocalStateAfterEdit, canCreateEvents, canEditEvent, ...props }: EventCalenderProps<T>) => import("react").JSX.Element;
|
|
30
30
|
export default EventCalendar;
|
|
31
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/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AAM,CAAC;IAClB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;CAC1C,CAAC;AAmGF;;GAEG;AACH,QAAA,MAAM,aAAa,GAAI,CAAC,SAAS,aAAa,oKAY3C,kBAAkB,CAAC,CAAC,CAAC,gCAgCvB,CAAC;AA0BF,eAAe,aAAa,CAAC"}
|
|
@@ -10,23 +10,23 @@ export type CalendarEvent = {
|
|
|
10
10
|
end: string;
|
|
11
11
|
isAllDay?: boolean;
|
|
12
12
|
};
|
|
13
|
-
export type AllDayEventLayoutType = {
|
|
14
|
-
event:
|
|
13
|
+
export type AllDayEventLayoutType<T extends CalendarEvent> = {
|
|
14
|
+
event: T;
|
|
15
15
|
rowIndex?: number;
|
|
16
16
|
visibleWidthDays?: number;
|
|
17
17
|
extend: EventExtend;
|
|
18
18
|
isPrimaryRendered?: boolean;
|
|
19
19
|
};
|
|
20
|
-
export type PartDayEventLayoutType = {
|
|
21
|
-
event:
|
|
20
|
+
export type PartDayEventLayoutType<T extends CalendarEvent> = {
|
|
21
|
+
event: T;
|
|
22
22
|
collisions?: {
|
|
23
23
|
total: number;
|
|
24
24
|
order: number;
|
|
25
25
|
};
|
|
26
26
|
position: EventPosition;
|
|
27
27
|
};
|
|
28
|
-
export interface CollisionObject {
|
|
29
|
-
event:
|
|
28
|
+
export interface CollisionObject<T extends CalendarEvent> {
|
|
29
|
+
event: T;
|
|
30
30
|
collisions?: {
|
|
31
31
|
total: number;
|
|
32
32
|
order: number;
|
|
@@ -38,9 +38,9 @@ export type EventPosition = {
|
|
|
38
38
|
width: string;
|
|
39
39
|
marginLeft: string;
|
|
40
40
|
};
|
|
41
|
-
export type FullCalendarEventLayout = {
|
|
42
|
-
allDayEventsLayout: AllDayEventLayoutType[];
|
|
43
|
-
partDayEventsLayout: PartDayEventLayoutType[];
|
|
41
|
+
export type FullCalendarEventLayout<T extends CalendarEvent> = {
|
|
42
|
+
allDayEventsLayout: AllDayEventLayoutType<T>[];
|
|
43
|
+
partDayEventsLayout: PartDayEventLayoutType<T>[];
|
|
44
44
|
};
|
|
45
45
|
export type ThemeStyle = {
|
|
46
46
|
container?: ViewStyle;
|
|
@@ -64,34 +64,34 @@ export type OnCreateEventProps = {
|
|
|
64
64
|
isAllDay?: boolean;
|
|
65
65
|
};
|
|
66
66
|
export type onCreateEvent = (arg: OnCreateEventProps) => void;
|
|
67
|
-
export type Config = {
|
|
67
|
+
export type Config<T extends CalendarEvent> = {
|
|
68
68
|
timezone: string;
|
|
69
69
|
timeFormat: string;
|
|
70
70
|
dayDate: Moment;
|
|
71
71
|
theme?: ThemeStyle;
|
|
72
72
|
zoomLevel: SharedValue<number>;
|
|
73
|
-
layout: FullCalendarEventLayout
|
|
73
|
+
layout: FullCalendarEventLayout<T>;
|
|
74
74
|
createY: SharedValue<number>;
|
|
75
75
|
maximumHour: SharedValue<number>;
|
|
76
76
|
onCreateEvent?: onCreateEvent;
|
|
77
77
|
initialZoomLevel: number;
|
|
78
|
-
renderEvent: (event:
|
|
78
|
+
renderEvent: (event: T, extended: EventExtend, eventHeight?: SharedValue<number>, updatedTimes?: {
|
|
79
79
|
updatedStart: DerivedValue<number>;
|
|
80
80
|
updatedEnd: DerivedValue<number>;
|
|
81
81
|
}) => ReactNode;
|
|
82
82
|
onEventEdit?: (params: {
|
|
83
|
-
event:
|
|
83
|
+
event: T;
|
|
84
84
|
status: EditStatus;
|
|
85
85
|
updatedTimes?: {
|
|
86
86
|
updatedStart: string;
|
|
87
87
|
updatedEnd: string;
|
|
88
88
|
};
|
|
89
89
|
}) => void;
|
|
90
|
-
onPressEvent?: (event:
|
|
90
|
+
onPressEvent?: (event: T) => void;
|
|
91
91
|
showTimeIndicator?: boolean;
|
|
92
92
|
maxAllDayEvents: number;
|
|
93
93
|
canCreateEvents: boolean;
|
|
94
|
-
canEditEvent: boolean | ((event:
|
|
94
|
+
canEditEvent: boolean | ((event: T) => boolean);
|
|
95
95
|
renderNewEventContainer?: (hour: number, minute: number) => ReactNode;
|
|
96
96
|
fiveMinuteInterval?: boolean;
|
|
97
97
|
renderDragBars?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,M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P,UAAU,GACV,MAAM,GACN,MAAM,GACN,MAAM,CAAC;AAEX;;;GAGG;AACH,oBAAY,WAAW;IAErB,IAAI,IAAA;IACJ,IAAI,IAAA;IACJ,MAAM,IAAA;IACN,IAAI,IAAA;CACL;AAED,oBAAY,UAAU;IACpB,KAAK,IAAA;IACL,MAAM,IAAA;CACP"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Moment } from "moment-timezone";
|
|
2
|
-
import { CollisionObject, EventPosition } from "../types";
|
|
3
|
-
type ComputePositioning = {
|
|
4
|
-
collisionObject: CollisionObject
|
|
2
|
+
import { type CalendarEvent, CollisionObject, EventPosition } from "../types";
|
|
3
|
+
type ComputePositioning<T extends CalendarEvent> = {
|
|
4
|
+
collisionObject: CollisionObject<T>;
|
|
5
5
|
startOfDayMoment: Moment;
|
|
6
6
|
timezone: string;
|
|
7
7
|
};
|
|
8
|
-
declare const computePositioning: ({ collisionObject, startOfDayMoment, timezone, }: ComputePositioning) => EventPosition;
|
|
8
|
+
declare const computePositioning: <T extends CalendarEvent>({ collisionObject, startOfDayMoment, timezone, }: ComputePositioning<T>) => EventPosition;
|
|
9
9
|
export default computePositioning;
|
|
10
10
|
//# sourceMappingURL=compute-positioning.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute-positioning.d.ts","sourceRoot":"","sources":["../../../../src/utils/compute-positioning.ts"],"names":[],"mappings":"AAAA,OAAe,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"compute-positioning.d.ts","sourceRoot":"","sources":["../../../../src/utils/compute-positioning.ts"],"names":[],"mappings":"AAAA,OAAe,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9E,KAAK,kBAAkB,CAAC,CAAC,SAAS,aAAa,IAAI;IAEjD,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,kBAAkB,GAAI,CAAC,SAAS,aAAa,oDAIhD,kBAAkB,CAAC,CAAC,CAAC,KAAG,aA2B1B,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SharedValue } from "react-native-reanimated";
|
|
2
|
-
import { Config } from "../types";
|
|
3
|
-
declare const doubleTapGesture: (zoomLevel: SharedValue<number>, initialZoomLevel: number, onZoomChange?: Config["onZoomChange"]) => import("react-native-gesture-handler/lib/typescript/handlers/gestures/tapGesture").TapGesture;
|
|
2
|
+
import { type CalendarEvent, Config } from "../types";
|
|
3
|
+
declare const doubleTapGesture: <T extends CalendarEvent>(zoomLevel: SharedValue<number>, initialZoomLevel: number, onZoomChange?: Config<T>["onZoomChange"]) => import("react-native-gesture-handler/lib/typescript/handlers/gestures/tapGesture").TapGesture;
|
|
4
4
|
export default doubleTapGesture;
|
|
5
5
|
//# sourceMappingURL=double-tap-reset-zoom-gesture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"double-tap-reset-zoom-gesture.d.ts","sourceRoot":"","sources":["../../../../src/utils/double-tap-reset-zoom-gesture.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"double-tap-reset-zoom-gesture.d.ts","sourceRoot":"","sources":["../../../../src/utils/double-tap-reset-zoom-gesture.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEtD,QAAA,MAAM,gBAAgB,GAAI,CAAC,SAAS,aAAa,aACpC,WAAW,CAAC,MAAM,CAAC,oBACZ,MAAM,iBACT,MAAM,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,kGAapC,CAAC;AAEP,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CalendarEvent, CalendarViewIntervalType, FullCalendarEventLayout } from "../types";
|
|
2
|
-
interface GenerateEventLayouts {
|
|
3
|
-
events:
|
|
2
|
+
interface GenerateEventLayouts<T extends CalendarEvent> {
|
|
3
|
+
events: T[];
|
|
4
4
|
userCalendarId: string;
|
|
5
5
|
timezone: string;
|
|
6
6
|
startCalendarDate: string;
|
|
@@ -8,8 +8,8 @@ interface GenerateEventLayouts {
|
|
|
8
8
|
startDayOfWeekOffset?: number;
|
|
9
9
|
calendarViewInterval?: CalendarViewIntervalType;
|
|
10
10
|
}
|
|
11
|
-
export declare const generateEventLayouts: ({ events, startCalendarDate, endCalendarDate, userCalendarId, calendarViewInterval, startDayOfWeekOffset, timezone, }: GenerateEventLayouts) => {
|
|
12
|
-
[day: string]: FullCalendarEventLayout
|
|
11
|
+
export declare const generateEventLayouts: <T extends CalendarEvent>({ events, startCalendarDate, endCalendarDate, userCalendarId, calendarViewInterval, startDayOfWeekOffset, timezone, }: GenerateEventLayouts<T>) => {
|
|
12
|
+
[day: string]: FullCalendarEventLayout<T>;
|
|
13
13
|
};
|
|
14
14
|
export default generateEventLayouts;
|
|
15
15
|
//# sourceMappingURL=generate-event-layouts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-event-layouts.d.ts","sourceRoot":"","sources":["../../../../src/utils/generate-event-layouts.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,aAAa,EACb,wBAAwB,EAGxB,uBAAuB,EAExB,MAAM,UAAU,CAAC;AAElB,UAAU,oBAAoB;
|
|
1
|
+
{"version":3,"file":"generate-event-layouts.d.ts","sourceRoot":"","sources":["../../../../src/utils/generate-event-layouts.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,aAAa,EACb,wBAAwB,EAGxB,uBAAuB,EAExB,MAAM,UAAU,CAAC;AAElB,UAAU,oBAAoB,CAAC,CAAC,SAAS,aAAa;IACpD,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oBAAoB,CAAC,EAAE,wBAAwB,CAAC;CACjD;AAED,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,aAAa,yHAQzD,oBAAoB,CAAC,CAAC,CAAC;;CA8JzB,CAAC;AAgHF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config } from "../types";
|
|
2
|
-
export declare const ConfigProvider: import("react").Context<Config
|
|
2
|
+
export declare const ConfigProvider: import("react").Context<Config<any>>;
|
|
3
3
|
export declare const DEFAULT_MINUTE_HEIGHT = 0.8;
|
|
4
4
|
export declare const TOP_MARGIN_PIXEL_OFFSET = 5;
|
|
5
5
|
//# sourceMappingURL=globals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../../../src/utils/globals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../../../src/utils/globals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,cAAc,sCAAiD,CAAC;AAE7E,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,eAAO,MAAM,uBAAuB,IAAI,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SharedValue } from "react-native-reanimated";
|
|
2
2
|
import { RefObject } from "react";
|
|
3
|
-
import { PartDayEventLayoutType } from "../types";
|
|
4
|
-
declare const gesturePan: (startY: SharedValue<number>, top: SharedValue<number>, currentY: SharedValue<number>, zoomLevel: SharedValue<number>, maximumHour: SharedValue<number>, height: SharedValue<number>, refNewEvent: RefObject<any>, fiveMinuteInterval?: boolean, isEditing?: null | PartDayEventLayoutType
|
|
3
|
+
import { type CalendarEvent, PartDayEventLayoutType } from "../types";
|
|
4
|
+
declare const gesturePan: <T extends CalendarEvent>(startY: SharedValue<number>, top: SharedValue<number>, currentY: SharedValue<number>, zoomLevel: SharedValue<number>, maximumHour: SharedValue<number>, height: SharedValue<number>, refNewEvent: RefObject<any>, fiveMinuteInterval?: boolean, isEditing?: null | PartDayEventLayoutType<T>, startEditing?: () => void) => import("react-native-gesture-handler/lib/typescript/handlers/gestures/panGesture").PanGesture;
|
|
5
5
|
export default gesturePan;
|
|
6
6
|
//# sourceMappingURL=pan-edit-event-gesture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pan-edit-event-gesture.d.ts","sourceRoot":"","sources":["../../../../src/utils/pan-edit-event-gesture.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"pan-edit-event-gesture.d.ts","sourceRoot":"","sources":["../../../../src/utils/pan-edit-event-gesture.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,KAAK,aAAa,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEtE,QAAA,MAAM,UAAU,GAAI,CAAC,SAAS,aAAa,UACjC,WAAW,CAAC,MAAM,CAAC,OACtB,WAAW,CAAC,MAAM,CAAC,YACd,WAAW,CAAC,MAAM,CAAC,aAClB,WAAW,CAAC,MAAM,CAAC,eACjB,WAAW,CAAC,MAAM,CAAC,UACxB,WAAW,CAAC,MAAM,CAAC,eACd,SAAS,CAAC,GAAG,CAAC,uBACN,OAAO,cAChB,IAAI,GAAG,sBAAsB,CAAC,CAAC,CAAC,iBAC7B,MAAM,IAAI,kGA8CrB,CAAC;AAEP,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sunsama/event-calendar",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Event calendar.",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -68,8 +68,7 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"immer": "^10.1.1",
|
|
70
70
|
"lodash": "^4.17.21",
|
|
71
|
-
"moment-timezone": "^0.5.47"
|
|
72
|
-
"zustand": "^5.0.3"
|
|
71
|
+
"moment-timezone": "^0.5.47"
|
|
73
72
|
},
|
|
74
73
|
"devDependencies": {
|
|
75
74
|
"@commitlint/config-conventional": "^19.7.1",
|
|
@@ -9,6 +9,7 @@ import Animated, {
|
|
|
9
9
|
useSharedValue,
|
|
10
10
|
withTiming,
|
|
11
11
|
} from "react-native-reanimated";
|
|
12
|
+
import type { AllDayEventLayoutType } from "src/types";
|
|
12
13
|
|
|
13
14
|
const AllDayEvents = memo(
|
|
14
15
|
() => {
|
|
@@ -42,7 +43,6 @@ const AllDayEvents = memo(
|
|
|
42
43
|
const restEventAmount =
|
|
43
44
|
layout.allDayEventsLayout.length - allDayEvents.length;
|
|
44
45
|
|
|
45
|
-
// Called whenever the content inside changes layout
|
|
46
46
|
const onContentLayout = useCallback(
|
|
47
47
|
(e: LayoutChangeEvent) => {
|
|
48
48
|
const { height } = e.nativeEvent.layout;
|
|
@@ -53,16 +53,15 @@ const AllDayEvents = memo(
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// Animate from the old height to the new height
|
|
57
56
|
measuredHeight.value = withTiming(height, { duration: 250 });
|
|
58
57
|
},
|
|
59
58
|
[measuredHeight, originalHeight]
|
|
60
59
|
);
|
|
61
60
|
|
|
62
|
-
// Apply the animated height to the wrapping container
|
|
63
61
|
const animatedStyle = useAnimatedStyle(() => {
|
|
64
62
|
return {
|
|
65
|
-
|
|
63
|
+
overflow: "hidden",
|
|
64
|
+
minHeight: 1,
|
|
66
65
|
height: measuredHeight.value,
|
|
67
66
|
};
|
|
68
67
|
});
|
|
@@ -70,18 +69,9 @@ const AllDayEvents = memo(
|
|
|
70
69
|
return (
|
|
71
70
|
<View style={[styles.container, theme?.allDayContainer]}>
|
|
72
71
|
<View style={[styles.eventContainer, theme?.allDayEventContainer]}>
|
|
73
|
-
<Animated.View
|
|
74
|
-
style={[
|
|
75
|
-
animatedStyle,
|
|
76
|
-
{
|
|
77
|
-
overflow: "hidden", // so children get clipped during animation
|
|
78
|
-
backgroundColor: "lightgrey",
|
|
79
|
-
minHeight: 1,
|
|
80
|
-
},
|
|
81
|
-
]}
|
|
82
|
-
>
|
|
72
|
+
<Animated.View style={animatedStyle}>
|
|
83
73
|
<View onLayout={onContentLayout}>
|
|
84
|
-
{allDayEvents.map((allDayLayout) => (
|
|
74
|
+
{allDayEvents.map((allDayLayout: AllDayEventLayoutType<any>) => (
|
|
85
75
|
<EventContainer
|
|
86
76
|
key={allDayLayout.event.id}
|
|
87
77
|
layout={allDayLayout}
|
|
@@ -2,13 +2,19 @@ import { ConfigProvider } from "../utils/globals";
|
|
|
2
2
|
import { useCallback, useContext, useMemo } from "react";
|
|
3
3
|
import { Pressable } from "react-native-gesture-handler";
|
|
4
4
|
import { View } from "react-native";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
AllDayEventLayoutType,
|
|
7
|
+
type CalendarEvent,
|
|
8
|
+
EventExtend,
|
|
9
|
+
} from "../types";
|
|
6
10
|
|
|
7
|
-
type EventContainerProps = {
|
|
8
|
-
layout: AllDayEventLayoutType
|
|
11
|
+
type EventContainerProps<T extends CalendarEvent> = {
|
|
12
|
+
layout: AllDayEventLayoutType<T>;
|
|
9
13
|
};
|
|
10
14
|
|
|
11
|
-
const EventContainer =
|
|
15
|
+
const EventContainer = <T extends CalendarEvent>({
|
|
16
|
+
layout,
|
|
17
|
+
}: EventContainerProps<T>) => {
|
|
12
18
|
const { onPressEvent, renderEvent, initialZoomLevel } =
|
|
13
19
|
useContext(ConfigProvider);
|
|
14
20
|
|
|
@@ -16,8 +22,8 @@ const EventContainer = ({ layout }: EventContainerProps) => {
|
|
|
16
22
|
() =>
|
|
17
23
|
renderEvent(
|
|
18
24
|
layout.event,
|
|
19
|
-
(layout as AllDayEventLayoutType).extend
|
|
20
|
-
? (layout as AllDayEventLayoutType).extend
|
|
25
|
+
(layout as AllDayEventLayoutType<T>).extend
|
|
26
|
+
? (layout as AllDayEventLayoutType<T>).extend
|
|
21
27
|
: EventExtend.None
|
|
22
28
|
),
|
|
23
29
|
[layout, renderEvent]
|
|
@@ -11,17 +11,21 @@ import { StyleSheet, View } from "react-native";
|
|
|
11
11
|
import { useIsEditing } from "../hooks/use-is-editing";
|
|
12
12
|
import gesturePan from "../utils/pan-edit-event-gesture";
|
|
13
13
|
import doubleTapGesture from "../utils/double-tap-reset-zoom-gesture";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
import {
|
|
15
|
+
type CalendarEvent,
|
|
16
|
+
EventExtend,
|
|
17
|
+
PartDayEventLayoutType,
|
|
18
|
+
} from "../types";
|
|
19
|
+
|
|
20
|
+
type TimedEventContainerProps<T extends CalendarEvent> = {
|
|
21
|
+
layout: PartDayEventLayoutType<T>;
|
|
18
22
|
refNewEvent: RefObject<any>;
|
|
19
23
|
};
|
|
20
24
|
|
|
21
|
-
const TimedEventContainer = ({
|
|
25
|
+
const TimedEventContainer = <T extends CalendarEvent>({
|
|
22
26
|
layout,
|
|
23
27
|
refNewEvent,
|
|
24
|
-
}: TimedEventContainerProps) => {
|
|
28
|
+
}: TimedEventContainerProps<T>) => {
|
|
25
29
|
const { currentY, setIsEditing, isEditing } = useIsEditing();
|
|
26
30
|
const {
|
|
27
31
|
onPressEvent,
|
package/src/hooks/use-events.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createContext,
|
|
3
3
|
type Dispatch,
|
|
4
|
+
ReactNode,
|
|
4
5
|
type SetStateAction,
|
|
5
6
|
useCallback,
|
|
6
7
|
useContext,
|
|
@@ -15,8 +16,8 @@ import {
|
|
|
15
16
|
FullCalendarEventLayout,
|
|
16
17
|
} from "../types";
|
|
17
18
|
|
|
18
|
-
export type UpdateEvent = {
|
|
19
|
-
events:
|
|
19
|
+
export type UpdateEvent<T extends CalendarEvent> = {
|
|
20
|
+
events: T[];
|
|
20
21
|
userCalendarId: string;
|
|
21
22
|
timezone: string;
|
|
22
23
|
startCalendarDate: string;
|
|
@@ -25,66 +26,64 @@ export type UpdateEvent = {
|
|
|
25
26
|
calendarViewInterval?: CalendarViewIntervalType;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
type EventsContextType = {
|
|
29
|
-
clonedEvents:
|
|
30
|
-
updateClonedEvents: Dispatch<SetStateAction<
|
|
31
|
-
eventsLayout: FullCalendarEventLayout
|
|
32
|
-
updateEventsLayout: (props: UpdateEvent) => void;
|
|
29
|
+
type EventsContextType<T extends CalendarEvent> = {
|
|
30
|
+
clonedEvents: T[];
|
|
31
|
+
updateClonedEvents: Dispatch<SetStateAction<T[]>>;
|
|
32
|
+
eventsLayout: FullCalendarEventLayout<T>;
|
|
33
|
+
updateEventsLayout: (props: UpdateEvent<T>) => void;
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
// Context to store both cloned events & event layouts
|
|
36
|
-
const EventsContext = createContext<EventsContextType | null>(null);
|
|
37
|
+
const EventsContext = createContext<EventsContextType<any> | null>(null);
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Provider that manages both cloned events & event layouts independently.
|
|
40
41
|
*/
|
|
41
|
-
export const EventsProvider = ({
|
|
42
|
+
export const EventsProvider = <T extends CalendarEvent>({
|
|
42
43
|
children,
|
|
43
44
|
initialProps,
|
|
44
45
|
updateLocalStateAfterEdit = true,
|
|
45
46
|
}: {
|
|
46
|
-
children:
|
|
47
|
-
initialProps: UpdateEvent
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
initialProps: UpdateEvent<T>;
|
|
48
49
|
updateLocalStateAfterEdit?: boolean;
|
|
49
50
|
}) => {
|
|
50
51
|
// Cloned Events State
|
|
51
|
-
const [clonedEvents, setClonedEvents] = useState<
|
|
52
|
-
initialProps.events
|
|
53
|
-
);
|
|
52
|
+
const [clonedEvents, setClonedEvents] = useState<T[]>(initialProps.events);
|
|
54
53
|
|
|
55
54
|
// Event Layouts State
|
|
56
|
-
const [eventsLayout, setEventsLayout] = useState<FullCalendarEventLayout
|
|
55
|
+
const [eventsLayout, setEventsLayout] = useState<FullCalendarEventLayout<T>>({
|
|
57
56
|
allDayEventsLayout: [],
|
|
58
57
|
partDayEventsLayout: [],
|
|
59
58
|
});
|
|
60
59
|
|
|
61
60
|
// Function to update cloned events
|
|
62
61
|
const updateClonedEvents = useCallback(
|
|
63
|
-
(events:
|
|
62
|
+
(events: T[]) => {
|
|
64
63
|
setClonedEvents(updateLocalStateAfterEdit ? cloneDeep(events) : events);
|
|
65
64
|
},
|
|
66
65
|
[updateLocalStateAfterEdit]
|
|
67
66
|
);
|
|
68
67
|
|
|
69
68
|
// Function to update event layouts
|
|
70
|
-
const updateEventsLayout = (props: UpdateEvent) => {
|
|
69
|
+
const updateEventsLayout = useCallback((props: UpdateEvent<T>) => {
|
|
71
70
|
setEventsLayout(
|
|
72
|
-
generateEventLayouts(props)[props.startCalendarDate] || {
|
|
71
|
+
generateEventLayouts<T>(props)[props.startCalendarDate] || {
|
|
73
72
|
partDayEventsLayout: [],
|
|
74
73
|
allDayEventsLayout: [],
|
|
75
74
|
}
|
|
76
75
|
);
|
|
77
|
-
};
|
|
76
|
+
}, []);
|
|
78
77
|
|
|
79
78
|
// Update both states when initialProps change
|
|
80
79
|
useEffect(() => {
|
|
81
80
|
updateClonedEvents(initialProps.events);
|
|
82
81
|
updateEventsLayout(initialProps);
|
|
83
|
-
}, [initialProps, updateClonedEvents]);
|
|
82
|
+
}, [initialProps, updateClonedEvents, updateEventsLayout]);
|
|
84
83
|
|
|
85
84
|
useEffect(() => {
|
|
86
85
|
updateEventsLayout({ ...initialProps, events: clonedEvents });
|
|
87
|
-
}, [initialProps, clonedEvents]);
|
|
86
|
+
}, [initialProps, clonedEvents, updateEventsLayout]);
|
|
88
87
|
|
|
89
88
|
return (
|
|
90
89
|
<EventsContext.Provider
|
|
@@ -8,14 +8,18 @@ import React, {
|
|
|
8
8
|
import { SharedValue, useSharedValue } from "react-native-reanimated";
|
|
9
9
|
import { ConfigProvider } from "../utils/globals";
|
|
10
10
|
import { isFunction } from "lodash";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
type CalendarEvent,
|
|
13
|
+
EditStatus,
|
|
14
|
+
PartDayEventLayoutType,
|
|
15
|
+
} from "../types";
|
|
12
16
|
import { useEvents } from "./use-events";
|
|
13
17
|
|
|
14
|
-
interface IsEditingType {
|
|
15
|
-
isEditing: null | PartDayEventLayoutType
|
|
18
|
+
interface IsEditingType<T extends CalendarEvent> {
|
|
19
|
+
isEditing: null | PartDayEventLayoutType<T>;
|
|
16
20
|
currentY: SharedValue<number>;
|
|
17
21
|
setIsEditing: (
|
|
18
|
-
newValue: PartDayEventLayoutType | null,
|
|
22
|
+
newValue: PartDayEventLayoutType<T> | null,
|
|
19
23
|
updatedTimes?: {
|
|
20
24
|
updatedStart: string;
|
|
21
25
|
updatedEnd: string;
|
|
@@ -23,7 +27,7 @@ interface IsEditingType {
|
|
|
23
27
|
) => void;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
const IsEditing = createContext<IsEditingType | undefined>(undefined);
|
|
30
|
+
const IsEditing = createContext<IsEditingType<any> | undefined>(undefined);
|
|
27
31
|
|
|
28
32
|
export const useIsEditing = () => {
|
|
29
33
|
const context = useContext(IsEditing);
|
|
@@ -35,18 +39,21 @@ export const useIsEditing = () => {
|
|
|
35
39
|
};
|
|
36
40
|
|
|
37
41
|
// Provider component
|
|
38
|
-
export const IsEditingProvider =
|
|
42
|
+
export const IsEditingProvider = <T extends CalendarEvent>({
|
|
43
|
+
children,
|
|
44
|
+
}: {
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}) => {
|
|
39
47
|
const { canEditEvent, onEventEdit, updateLocalStateAfterEdit } =
|
|
40
48
|
useContext(ConfigProvider);
|
|
41
49
|
const { updateClonedEvents } = useEvents();
|
|
42
|
-
const [isEditing, baseSetIsEditing] =
|
|
43
|
-
null
|
|
44
|
-
);
|
|
50
|
+
const [isEditing, baseSetIsEditing] =
|
|
51
|
+
useState<null | PartDayEventLayoutType<T>>(null);
|
|
45
52
|
const currentY = useSharedValue(0);
|
|
46
53
|
|
|
47
54
|
const setIsEditing = useCallback(
|
|
48
55
|
(
|
|
49
|
-
newValue: PartDayEventLayoutType | null,
|
|
56
|
+
newValue: PartDayEventLayoutType<T> | null,
|
|
50
57
|
updatedTimes?: {
|
|
51
58
|
updatedStart: string;
|
|
52
59
|
updatedEnd: string;
|