@sunsama/event-calendar 0.2.3 → 0.2.5

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.
Files changed (44) hide show
  1. package/lib/commonjs/hooks/use-events.js +79 -0
  2. package/lib/commonjs/hooks/use-events.js.map +1 -0
  3. package/lib/commonjs/hooks/use-is-editing.js +6 -3
  4. package/lib/commonjs/hooks/use-is-editing.js.map +1 -1
  5. package/lib/commonjs/index.js +65 -35
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/module/hooks/use-events.js +72 -0
  8. package/lib/module/hooks/use-events.js.map +1 -0
  9. package/lib/module/hooks/use-is-editing.js +5 -2
  10. package/lib/module/hooks/use-is-editing.js.map +1 -1
  11. package/lib/module/index.js +65 -35
  12. package/lib/module/index.js.map +1 -1
  13. package/lib/typescript/commonjs/hooks/use-events.d.ts +31 -0
  14. package/lib/typescript/commonjs/hooks/use-events.d.ts.map +1 -0
  15. package/lib/typescript/commonjs/hooks/use-is-editing.d.ts.map +1 -1
  16. package/lib/typescript/commonjs/index.d.ts +4 -1
  17. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  18. package/lib/typescript/module/hooks/use-events.d.ts +31 -0
  19. package/lib/typescript/module/hooks/use-events.d.ts.map +1 -0
  20. package/lib/typescript/module/hooks/use-is-editing.d.ts.map +1 -1
  21. package/lib/typescript/module/index.d.ts +4 -1
  22. package/lib/typescript/module/index.d.ts.map +1 -1
  23. package/package.json +1 -1
  24. package/src/hooks/use-events.tsx +112 -0
  25. package/src/hooks/use-is-editing.tsx +9 -2
  26. package/src/index.tsx +92 -44
  27. package/lib/commonjs/hooks/use-cloned-events.js +0 -25
  28. package/lib/commonjs/hooks/use-cloned-events.js.map +0 -1
  29. package/lib/commonjs/hooks/use-events-layout.js +0 -34
  30. package/lib/commonjs/hooks/use-events-layout.js.map +0 -1
  31. package/lib/module/hooks/use-cloned-events.js +0 -21
  32. package/lib/module/hooks/use-cloned-events.js.map +0 -1
  33. package/lib/module/hooks/use-events-layout.js +0 -29
  34. package/lib/module/hooks/use-events-layout.js.map +0 -1
  35. package/lib/typescript/commonjs/hooks/use-cloned-events.d.ts +0 -11
  36. package/lib/typescript/commonjs/hooks/use-cloned-events.d.ts.map +0 -1
  37. package/lib/typescript/commonjs/hooks/use-events-layout.d.ts +0 -13
  38. package/lib/typescript/commonjs/hooks/use-events-layout.d.ts.map +0 -1
  39. package/lib/typescript/module/hooks/use-cloned-events.d.ts +0 -11
  40. package/lib/typescript/module/hooks/use-cloned-events.d.ts.map +0 -1
  41. package/lib/typescript/module/hooks/use-events-layout.d.ts +0 -13
  42. package/lib/typescript/module/hooks/use-events-layout.d.ts.map +0 -1
  43. package/src/hooks/use-cloned-events.ts +0 -26
  44. package/src/hooks/use-events-layout.ts +0 -55
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-cloned-events.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-cloned-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAuB,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,eAAO,IAAI,kBAAkB,EAAE,QAAQ,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;AAEzE;;;;GAIG;AACH,QAAA,MAAM,eAAe,WACX,aAAa,EAAE,6BACI,OAAO,oBAUnC,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,13 +0,0 @@
1
- import { CalendarEvent, CalendarViewIntervalType, FullCalendarEventLayout } from "../types";
2
- export type UpdateEvent = {
3
- events: CalendarEvent[];
4
- userCalendarId: string;
5
- timezone: string;
6
- startCalendarDate: string;
7
- endCalendarDate: string;
8
- startDayOfWeekOffset?: number;
9
- calendarViewInterval?: CalendarViewIntervalType;
10
- };
11
- declare const useEventsLayout: (props: UpdateEvent) => FullCalendarEventLayout;
12
- export default useEventsLayout;
13
- //# sourceMappingURL=use-events-layout.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-events-layout.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-events-layout.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAUlB,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,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,CAAC;AAkBF,QAAA,MAAM,eAAe,UAAW,WAAW,4BAQ1C,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,26 +0,0 @@
1
- import { Dispatch, SetStateAction, useEffect, useState } from "react";
2
- import { cloneDeep } from "lodash";
3
- import { CalendarEvent } from "../types";
4
-
5
- export let updateClonedEvents: Dispatch<SetStateAction<CalendarEvent[]>>;
6
-
7
- /**
8
- * Returns a cloned version of the events array if the updateLocalStateAfterEdit is set to true.
9
- * We do this to make local state updates faster and more responsive. If the updateLocalStateAfterEdit is set to false,
10
- * we return the original events array and don't clone it.
11
- */
12
- const useClonedEvents = (
13
- events: CalendarEvent[],
14
- updateLocalStateAfterEdit: boolean
15
- ) => {
16
- const [clonedEvents, setClonedEvents] = useState(events);
17
-
18
- useEffect(() => {
19
- setClonedEvents(updateLocalStateAfterEdit ? cloneDeep(events) : events);
20
- updateClonedEvents = setClonedEvents;
21
- }, [events, updateLocalStateAfterEdit]);
22
-
23
- return clonedEvents;
24
- };
25
-
26
- export default useClonedEvents;
@@ -1,55 +0,0 @@
1
- import { create } from "zustand";
2
- import { immer } from "zustand/middleware/immer";
3
- import generateEventLayouts from "../utils/generate-event-layouts";
4
- import { useEffect } from "react";
5
- import {
6
- CalendarEvent,
7
- CalendarViewIntervalType,
8
- FullCalendarEventLayout,
9
- } from "../types";
10
-
11
- type State = {
12
- events: FullCalendarEventLayout;
13
- };
14
-
15
- type Actions = {
16
- updateEvents: (props: UpdateEvent) => void;
17
- };
18
-
19
- export type UpdateEvent = {
20
- events: CalendarEvent[];
21
- userCalendarId: string;
22
- timezone: string;
23
- startCalendarDate: string;
24
- endCalendarDate: string;
25
- startDayOfWeekOffset?: number;
26
- calendarViewInterval?: CalendarViewIntervalType;
27
- };
28
-
29
- const useEventsLayoutStore = create<State & Actions>()(
30
- immer((set) => ({
31
- events: {
32
- allDayEventsLayout: [],
33
- partDayEventsLayout: [],
34
- },
35
- updateEvents: (props: UpdateEvent) =>
36
- set((state) => {
37
- state.events = generateEventLayouts(props)[props.startCalendarDate] || {
38
- partDayEventsLayout: [],
39
- allDayEventsLayout: [],
40
- };
41
- }),
42
- }))
43
- );
44
-
45
- const useEventsLayout = (props: UpdateEvent) => {
46
- const { events: layoutEvents } = useEventsLayoutStore();
47
-
48
- useEffect(() => {
49
- useEventsLayoutStore.getState().updateEvents(props);
50
- }, [props]);
51
-
52
- return layoutEvents;
53
- };
54
-
55
- export default useEventsLayout;