@sunsama/event-calendar 0.2.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/LICENSE +20 -0
- package/README.md +105 -0
- package/lib/commonjs/components/all-day-events.js +117 -0
- package/lib/commonjs/components/all-day-events.js.map +1 -0
- package/lib/commonjs/components/background-hours-content.js +43 -0
- package/lib/commonjs/components/background-hours-content.js.map +1 -0
- package/lib/commonjs/components/background-hours-layout.js +57 -0
- package/lib/commonjs/components/background-hours-layout.js.map +1 -0
- package/lib/commonjs/components/drag-bar.js +84 -0
- package/lib/commonjs/components/drag-bar.js.map +1 -0
- package/lib/commonjs/components/edit-event-container.js +114 -0
- package/lib/commonjs/components/edit-event-container.js.map +1 -0
- package/lib/commonjs/components/event-container.js +37 -0
- package/lib/commonjs/components/event-container.js.map +1 -0
- package/lib/commonjs/components/new-event-container.js +73 -0
- package/lib/commonjs/components/new-event-container.js.map +1 -0
- package/lib/commonjs/components/time-indicator.js +64 -0
- package/lib/commonjs/components/time-indicator.js.map +1 -0
- package/lib/commonjs/components/timed-event-container.js +91 -0
- package/lib/commonjs/components/timed-event-container.js.map +1 -0
- package/lib/commonjs/components/timed-events.js +68 -0
- package/lib/commonjs/components/timed-events.js.map +1 -0
- package/lib/commonjs/components/zoom-provider.js +109 -0
- package/lib/commonjs/components/zoom-provider.js.map +1 -0
- package/lib/commonjs/enums.js +2 -0
- package/lib/commonjs/enums.js.map +1 -0
- package/lib/commonjs/hooks/use-cloned-events.js +25 -0
- package/lib/commonjs/hooks/use-cloned-events.js.map +1 -0
- package/lib/commonjs/hooks/use-events-layout.js +34 -0
- package/lib/commonjs/hooks/use-events-layout.js.map +1 -0
- package/lib/commonjs/hooks/use-is-editing.js +83 -0
- package/lib/commonjs/hooks/use-is-editing.js.map +1 -0
- package/lib/commonjs/index.js +129 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types.js +24 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils/calendar-layout.js +113 -0
- package/lib/commonjs/utils/calendar-layout.js.map +1 -0
- package/lib/commonjs/utils/compute-positioning.js +33 -0
- package/lib/commonjs/utils/compute-positioning.js.map +1 -0
- package/lib/commonjs/utils/date-utils.js +152 -0
- package/lib/commonjs/utils/date-utils.js.map +1 -0
- package/lib/commonjs/utils/double-tap-reset-zoom-gesture.js +19 -0
- package/lib/commonjs/utils/double-tap-reset-zoom-gesture.js.map +1 -0
- package/lib/commonjs/utils/generate-event-layouts.js +198 -0
- package/lib/commonjs/utils/generate-event-layouts.js.map +1 -0
- package/lib/commonjs/utils/globals.js +11 -0
- package/lib/commonjs/utils/globals.js.map +1 -0
- package/lib/commonjs/utils/pan-edit-event-gesture.js +41 -0
- package/lib/commonjs/utils/pan-edit-event-gesture.js.map +1 -0
- package/lib/module/components/all-day-events.js +110 -0
- package/lib/module/components/all-day-events.js.map +1 -0
- package/lib/module/components/background-hours-content.js +37 -0
- package/lib/module/components/background-hours-content.js.map +1 -0
- package/lib/module/components/background-hours-layout.js +51 -0
- package/lib/module/components/background-hours-layout.js.map +1 -0
- package/lib/module/components/drag-bar.js +78 -0
- package/lib/module/components/drag-bar.js.map +1 -0
- package/lib/module/components/edit-event-container.js +107 -0
- package/lib/module/components/edit-event-container.js.map +1 -0
- package/lib/module/components/event-container.js +33 -0
- package/lib/module/components/event-container.js.map +1 -0
- package/lib/module/components/new-event-container.js +67 -0
- package/lib/module/components/new-event-container.js.map +1 -0
- package/lib/module/components/time-indicator.js +57 -0
- package/lib/module/components/time-indicator.js.map +1 -0
- package/lib/module/components/timed-event-container.js +84 -0
- package/lib/module/components/timed-event-container.js.map +1 -0
- package/lib/module/components/timed-events.js +63 -0
- package/lib/module/components/timed-events.js.map +1 -0
- package/lib/module/components/zoom-provider.js +102 -0
- package/lib/module/components/zoom-provider.js.map +1 -0
- package/lib/module/enums.js +2 -0
- package/lib/module/enums.js.map +1 -0
- package/lib/module/hooks/use-cloned-events.js +21 -0
- package/lib/module/hooks/use-cloned-events.js.map +1 -0
- package/lib/module/hooks/use-events-layout.js +29 -0
- package/lib/module/hooks/use-events-layout.js.map +1 -0
- package/lib/module/hooks/use-is-editing.js +75 -0
- package/lib/module/hooks/use-is-editing.js.map +1 -0
- package/lib/module/index.js +124 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types.js +20 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/calendar-layout.js +108 -0
- package/lib/module/utils/calendar-layout.js.map +1 -0
- package/lib/module/utils/compute-positioning.js +28 -0
- package/lib/module/utils/compute-positioning.js.map +1 -0
- package/lib/module/utils/date-utils.js +139 -0
- package/lib/module/utils/date-utils.js.map +1 -0
- package/lib/module/utils/double-tap-reset-zoom-gesture.js +15 -0
- package/lib/module/utils/double-tap-reset-zoom-gesture.js.map +1 -0
- package/lib/module/utils/generate-event-layouts.js +192 -0
- package/lib/module/utils/generate-event-layouts.js.map +1 -0
- package/lib/module/utils/globals.js +7 -0
- package/lib/module/utils/globals.js.map +1 -0
- package/lib/module/utils/pan-edit-event-gesture.js +37 -0
- package/lib/module/utils/pan-edit-event-gesture.js.map +1 -0
- package/lib/typescript/commonjs/components/all-day-events.d.ts +3 -0
- package/lib/typescript/commonjs/components/all-day-events.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/background-hours-content.d.ts +7 -0
- package/lib/typescript/commonjs/components/background-hours-content.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/background-hours-layout.d.ts +7 -0
- package/lib/typescript/commonjs/components/background-hours-layout.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/drag-bar.d.ts +14 -0
- package/lib/typescript/commonjs/components/drag-bar.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/edit-event-container.d.ts +7 -0
- package/lib/typescript/commonjs/components/edit-event-container.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/event-container.d.ts +7 -0
- package/lib/typescript/commonjs/components/event-container.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/new-event-container.d.ts +3 -0
- package/lib/typescript/commonjs/components/new-event-container.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/time-indicator.d.ts +3 -0
- package/lib/typescript/commonjs/components/time-indicator.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/timed-event-container.d.ts +9 -0
- package/lib/typescript/commonjs/components/timed-event-container.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/timed-events.d.ts +7 -0
- package/lib/typescript/commonjs/components/timed-events.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/zoom-provider.d.ts +7 -0
- package/lib/typescript/commonjs/components/zoom-provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/enums.d.ts +2 -0
- package/lib/typescript/commonjs/enums.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/use-cloned-events.d.ts +11 -0
- package/lib/typescript/commonjs/hooks/use-cloned-events.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/use-events-layout.d.ts +13 -0
- package/lib/typescript/commonjs/hooks/use-events-layout.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/use-is-editing.d.ts +17 -0
- package/lib/typescript/commonjs/hooks/use-is-editing.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +27 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/types.d.ts +128 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/__tests___/compute-positioning.test.d.ts +2 -0
- package/lib/typescript/commonjs/utils/__tests___/compute-positioning.test.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/__tests___/date-utils.test.d.ts +2 -0
- package/lib/typescript/commonjs/utils/__tests___/date-utils.test.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/__tests___/generate-event-layout.test.d.ts +2 -0
- package/lib/typescript/commonjs/utils/__tests___/generate-event-layout.test.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/calendar-layout.d.ts +36 -0
- package/lib/typescript/commonjs/utils/calendar-layout.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/compute-positioning.d.ts +10 -0
- package/lib/typescript/commonjs/utils/compute-positioning.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/date-utils.d.ts +30 -0
- package/lib/typescript/commonjs/utils/date-utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/double-tap-reset-zoom-gesture.d.ts +5 -0
- package/lib/typescript/commonjs/utils/double-tap-reset-zoom-gesture.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/generate-event-layouts.d.ts +15 -0
- package/lib/typescript/commonjs/utils/generate-event-layouts.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/globals.d.ts +5 -0
- package/lib/typescript/commonjs/utils/globals.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/pan-edit-event-gesture.d.ts +6 -0
- package/lib/typescript/commonjs/utils/pan-edit-event-gesture.d.ts.map +1 -0
- package/lib/typescript/module/components/all-day-events.d.ts +3 -0
- package/lib/typescript/module/components/all-day-events.d.ts.map +1 -0
- package/lib/typescript/module/components/background-hours-content.d.ts +7 -0
- package/lib/typescript/module/components/background-hours-content.d.ts.map +1 -0
- package/lib/typescript/module/components/background-hours-layout.d.ts +7 -0
- package/lib/typescript/module/components/background-hours-layout.d.ts.map +1 -0
- package/lib/typescript/module/components/drag-bar.d.ts +14 -0
- package/lib/typescript/module/components/drag-bar.d.ts.map +1 -0
- package/lib/typescript/module/components/edit-event-container.d.ts +7 -0
- package/lib/typescript/module/components/edit-event-container.d.ts.map +1 -0
- package/lib/typescript/module/components/event-container.d.ts +7 -0
- package/lib/typescript/module/components/event-container.d.ts.map +1 -0
- package/lib/typescript/module/components/new-event-container.d.ts +3 -0
- package/lib/typescript/module/components/new-event-container.d.ts.map +1 -0
- package/lib/typescript/module/components/time-indicator.d.ts +3 -0
- package/lib/typescript/module/components/time-indicator.d.ts.map +1 -0
- package/lib/typescript/module/components/timed-event-container.d.ts +9 -0
- package/lib/typescript/module/components/timed-event-container.d.ts.map +1 -0
- package/lib/typescript/module/components/timed-events.d.ts +7 -0
- package/lib/typescript/module/components/timed-events.d.ts.map +1 -0
- package/lib/typescript/module/components/zoom-provider.d.ts +7 -0
- package/lib/typescript/module/components/zoom-provider.d.ts.map +1 -0
- package/lib/typescript/module/enums.d.ts +2 -0
- package/lib/typescript/module/enums.d.ts.map +1 -0
- package/lib/typescript/module/hooks/use-cloned-events.d.ts +11 -0
- package/lib/typescript/module/hooks/use-cloned-events.d.ts.map +1 -0
- package/lib/typescript/module/hooks/use-events-layout.d.ts +13 -0
- package/lib/typescript/module/hooks/use-events-layout.d.ts.map +1 -0
- package/lib/typescript/module/hooks/use-is-editing.d.ts +17 -0
- package/lib/typescript/module/hooks/use-is-editing.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +27 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/types.d.ts +128 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/utils/__tests___/compute-positioning.test.d.ts +2 -0
- package/lib/typescript/module/utils/__tests___/compute-positioning.test.d.ts.map +1 -0
- package/lib/typescript/module/utils/__tests___/date-utils.test.d.ts +2 -0
- package/lib/typescript/module/utils/__tests___/date-utils.test.d.ts.map +1 -0
- package/lib/typescript/module/utils/__tests___/generate-event-layout.test.d.ts +2 -0
- package/lib/typescript/module/utils/__tests___/generate-event-layout.test.d.ts.map +1 -0
- package/lib/typescript/module/utils/calendar-layout.d.ts +36 -0
- package/lib/typescript/module/utils/calendar-layout.d.ts.map +1 -0
- package/lib/typescript/module/utils/compute-positioning.d.ts +10 -0
- package/lib/typescript/module/utils/compute-positioning.d.ts.map +1 -0
- package/lib/typescript/module/utils/date-utils.d.ts +30 -0
- package/lib/typescript/module/utils/date-utils.d.ts.map +1 -0
- package/lib/typescript/module/utils/double-tap-reset-zoom-gesture.d.ts +5 -0
- package/lib/typescript/module/utils/double-tap-reset-zoom-gesture.d.ts.map +1 -0
- package/lib/typescript/module/utils/generate-event-layouts.d.ts +15 -0
- package/lib/typescript/module/utils/generate-event-layouts.d.ts.map +1 -0
- package/lib/typescript/module/utils/globals.d.ts +5 -0
- package/lib/typescript/module/utils/globals.d.ts.map +1 -0
- package/lib/typescript/module/utils/pan-edit-event-gesture.d.ts +6 -0
- package/lib/typescript/module/utils/pan-edit-event-gesture.d.ts.map +1 -0
- package/package.json +195 -0
- package/src/components/all-day-events.tsx +134 -0
- package/src/components/background-hours-content.tsx +51 -0
- package/src/components/background-hours-layout.tsx +61 -0
- package/src/components/drag-bar.tsx +120 -0
- package/src/components/edit-event-container.tsx +158 -0
- package/src/components/event-container.tsx +44 -0
- package/src/components/new-event-container.tsx +90 -0
- package/src/components/time-indicator.tsx +72 -0
- package/src/components/timed-event-container.tsx +124 -0
- package/src/components/timed-events.tsx +72 -0
- package/src/components/zoom-provider.tsx +146 -0
- package/src/enums.ts +0 -0
- package/src/hooks/use-cloned-events.ts +26 -0
- package/src/hooks/use-events-layout.ts +55 -0
- package/src/hooks/use-is-editing.tsx +109 -0
- package/src/index.tsx +165 -0
- package/src/types.ts +163 -0
- package/src/utils/__tests___/compute-positioning.test.ts +255 -0
- package/src/utils/__tests___/date-utils.test.ts +41 -0
- package/src/utils/__tests___/generate-event-layout.test.ts +277 -0
- package/src/utils/calendar-layout.ts +139 -0
- package/src/utils/compute-positioning.ts +44 -0
- package/src/utils/date-utils.ts +238 -0
- package/src/utils/double-tap-reset-zoom-gesture.ts +23 -0
- package/src/utils/generate-event-layouts.ts +314 -0
- package/src/utils/globals.ts +8 -0
- package/src/utils/pan-edit-event-gesture.ts +64 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useIsEditing = exports.IsEditingProvider = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
+
var _globals = require("src/utils/globals");
|
|
10
|
+
var _lodash = require("lodash");
|
|
11
|
+
var _useClonedEvents = require("src/hooks/use-cloned-events");
|
|
12
|
+
var _types = require("src/types");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
const IsEditing = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
17
|
+
const useIsEditing = () => {
|
|
18
|
+
const context = (0, _react.useContext)(IsEditing);
|
|
19
|
+
if (!context) {
|
|
20
|
+
throw new Error("useIsEditing must be used within a IsEditingProvider");
|
|
21
|
+
}
|
|
22
|
+
return context;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Provider component
|
|
26
|
+
exports.useIsEditing = useIsEditing;
|
|
27
|
+
const IsEditingProvider = ({
|
|
28
|
+
children
|
|
29
|
+
}) => {
|
|
30
|
+
const {
|
|
31
|
+
canEditEvent,
|
|
32
|
+
onEventEdit,
|
|
33
|
+
updateLocalStateAfterEdit
|
|
34
|
+
} = (0, _react.useContext)(_globals.ConfigProvider);
|
|
35
|
+
const [isEditing, baseSetIsEditing] = (0, _react.useState)(null);
|
|
36
|
+
const currentY = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
37
|
+
const setIsEditing = (0, _react.useCallback)((newValue, updatedTimes) => {
|
|
38
|
+
if (newValue) {
|
|
39
|
+
if (isEditing) {
|
|
40
|
+
// Refuse to start a new edit
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const canEditEventParsed = (0, _lodash.isFunction)(canEditEvent) ? canEditEvent(newValue.event) : canEditEvent;
|
|
44
|
+
if (!canEditEventParsed) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
onEventEdit?.({
|
|
48
|
+
event: newValue.event,
|
|
49
|
+
status: _types.EditStatus.Start
|
|
50
|
+
});
|
|
51
|
+
} else if (isEditing) {
|
|
52
|
+
if (updateLocalStateAfterEdit) {
|
|
53
|
+
(0, _useClonedEvents.updateClonedEvents)(events => {
|
|
54
|
+
if (!updatedTimes) {
|
|
55
|
+
// This means we removed the event
|
|
56
|
+
return events.filter(event => event.id !== isEditing.event.id);
|
|
57
|
+
}
|
|
58
|
+
return events.map(event => event.id === isEditing.event.id ? {
|
|
59
|
+
...event,
|
|
60
|
+
start: updatedTimes?.updatedStart,
|
|
61
|
+
end: updatedTimes?.updatedEnd
|
|
62
|
+
} : event);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
onEventEdit?.({
|
|
66
|
+
event: isEditing.event,
|
|
67
|
+
status: _types.EditStatus.Finish,
|
|
68
|
+
updatedTimes
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
baseSetIsEditing(newValue);
|
|
72
|
+
}, [canEditEvent, isEditing, onEventEdit, updateLocalStateAfterEdit]);
|
|
73
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(IsEditing.Provider, {
|
|
74
|
+
value: {
|
|
75
|
+
currentY,
|
|
76
|
+
isEditing,
|
|
77
|
+
setIsEditing
|
|
78
|
+
},
|
|
79
|
+
children: children
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
exports.IsEditingProvider = IsEditingProvider;
|
|
83
|
+
//# sourceMappingURL=use-is-editing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_globals","_lodash","_useClonedEvents","_types","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","IsEditing","createContext","undefined","useIsEditing","context","useContext","Error","exports","IsEditingProvider","children","canEditEvent","onEventEdit","updateLocalStateAfterEdit","ConfigProvider","isEditing","baseSetIsEditing","useState","currentY","useSharedValue","setIsEditing","useCallback","newValue","updatedTimes","canEditEventParsed","isFunction","event","status","EditStatus","Start","updateClonedEvents","events","filter","id","map","start","updatedStart","end","updatedEnd","Finish","jsx","Provider","value"],"sourceRoot":"../../../src","sources":["hooks/use-is-editing.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAA+D,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA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C;EAED,oBACE,IAAAjC,WAAA,CAAA4D,GAAA,EAACvC,SAAS,CAACwC,QAAQ;IAACC,KAAK,EAAE;MAAExB,QAAQ;MAAEH,SAAS;MAAEK;IAAa,CAAE;IAAAV,QAAA,EAC9DA;EAAQ,CACS,CAAC;AAEzB,CAAC;AAACF,OAAA,CAAAC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _allDayEvents = _interopRequireDefault(require("src/components/all-day-events"));
|
|
9
|
+
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
10
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
11
|
+
var _zoomProvider = _interopRequireDefault(require("src/components/zoom-provider"));
|
|
12
|
+
var _timedEvents = _interopRequireDefault(require("src/components/timed-events"));
|
|
13
|
+
var _useEventsLayout = _interopRequireDefault(require("src/hooks/use-events-layout"));
|
|
14
|
+
var _globals = require("src/utils/globals");
|
|
15
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
16
|
+
var _react = require("react");
|
|
17
|
+
var _useIsEditing = require("src/hooks/use-is-editing");
|
|
18
|
+
var _useClonedEvents = _interopRequireDefault(require("src/hooks/use-cloned-events"));
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
const EventCalendar = ({
|
|
22
|
+
events,
|
|
23
|
+
timeFormat = "HH:mm",
|
|
24
|
+
dayDate,
|
|
25
|
+
theme,
|
|
26
|
+
initialZoomLevel = _globals.DEFAULT_MINUTE_HEIGHT,
|
|
27
|
+
onCreateEvent,
|
|
28
|
+
timezone = "UTC",
|
|
29
|
+
renderEvent,
|
|
30
|
+
onPressEvent,
|
|
31
|
+
userCalendarId = "",
|
|
32
|
+
showTimeIndicator,
|
|
33
|
+
maxAllDayEvents = 2,
|
|
34
|
+
canCreateEvents = true,
|
|
35
|
+
renderNewEventContainer,
|
|
36
|
+
fiveMinuteInterval,
|
|
37
|
+
canEditEvent = true,
|
|
38
|
+
onEventEdit,
|
|
39
|
+
renderDragBars,
|
|
40
|
+
updateLocalStateAfterEdit = true,
|
|
41
|
+
extraTimedComponents,
|
|
42
|
+
onZoomChange
|
|
43
|
+
}) => {
|
|
44
|
+
const startCalendarDate = (0, _react.useMemo)(() => _momentTimezone.default.tz(dayDate, timezone).startOf("day"), [dayDate, timezone]);
|
|
45
|
+
const clonedEvents = (0, _useClonedEvents.default)(events, updateLocalStateAfterEdit);
|
|
46
|
+
const memoizedProps = (0, _react.useMemo)(() => ({
|
|
47
|
+
startCalendarDate: startCalendarDate.format("YYYY-MM-DD"),
|
|
48
|
+
calendarViewInterval: "1day",
|
|
49
|
+
endCalendarDate: startCalendarDate.format("YYYY-MM-DD"),
|
|
50
|
+
userCalendarId,
|
|
51
|
+
timezone,
|
|
52
|
+
startDayOfWeekOffset: 0,
|
|
53
|
+
events: clonedEvents
|
|
54
|
+
}), [startCalendarDate, userCalendarId, timezone, clonedEvents]);
|
|
55
|
+
const layout = (0, _useEventsLayout.default)(memoizedProps);
|
|
56
|
+
const zoomLevel = (0, _reactNativeReanimated.useSharedValue)(initialZoomLevel);
|
|
57
|
+
const createY = (0, _reactNativeReanimated.useSharedValue)(-1);
|
|
58
|
+
const maximumHour = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
59
|
+
const refNewEvent = (0, _react.useRef)(null);
|
|
60
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
61
|
+
style: [styles.container, theme?.container],
|
|
62
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_globals.ConfigProvider.Provider, {
|
|
63
|
+
value: {
|
|
64
|
+
dayDate: startCalendarDate,
|
|
65
|
+
timeFormat,
|
|
66
|
+
layout,
|
|
67
|
+
zoomLevel,
|
|
68
|
+
createY,
|
|
69
|
+
initialZoomLevel,
|
|
70
|
+
onCreateEvent,
|
|
71
|
+
timezone,
|
|
72
|
+
renderEvent,
|
|
73
|
+
onPressEvent,
|
|
74
|
+
showTimeIndicator,
|
|
75
|
+
maxAllDayEvents,
|
|
76
|
+
canCreateEvents,
|
|
77
|
+
renderNewEventContainer,
|
|
78
|
+
fiveMinuteInterval,
|
|
79
|
+
canEditEvent,
|
|
80
|
+
onEventEdit,
|
|
81
|
+
renderDragBars,
|
|
82
|
+
maximumHour,
|
|
83
|
+
updateLocalStateAfterEdit,
|
|
84
|
+
extraTimedComponents,
|
|
85
|
+
onZoomChange
|
|
86
|
+
},
|
|
87
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_allDayEvents.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.ScrollView, {
|
|
88
|
+
bounces: false,
|
|
89
|
+
keyboardShouldPersistTaps: "always",
|
|
90
|
+
style: [styles.scrollView, theme?.scrollView],
|
|
91
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_useIsEditing.IsEditingProvider, {
|
|
92
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_zoomProvider.default, {
|
|
93
|
+
ref: refNewEvent,
|
|
94
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
95
|
+
style: [styles.borderContainer, theme?.borderContainer]
|
|
96
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_timedEvents.default, {
|
|
97
|
+
refNewEvent: refNewEvent
|
|
98
|
+
})]
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
})]
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const styles = _reactNative.StyleSheet.create({
|
|
106
|
+
container: {
|
|
107
|
+
flex: 1,
|
|
108
|
+
marginTop: 8,
|
|
109
|
+
borderTopWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
110
|
+
borderTopColor: "#F0F0F0",
|
|
111
|
+
overflow: "hidden"
|
|
112
|
+
},
|
|
113
|
+
scrollView: {
|
|
114
|
+
paddingTop: 8,
|
|
115
|
+
backgroundColor: "white",
|
|
116
|
+
flex: 1
|
|
117
|
+
},
|
|
118
|
+
borderContainer: {
|
|
119
|
+
position: "absolute",
|
|
120
|
+
height: "200%",
|
|
121
|
+
left: 50,
|
|
122
|
+
top: -18,
|
|
123
|
+
width: 5,
|
|
124
|
+
borderLeftWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
125
|
+
borderColor: "black"
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
var _default = exports.default = EventCalendar;
|
|
129
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_allDayEvents","_interopRequireDefault","_reactNativeGestureHandler","_reactNativeReanimated","_zoomProvider","_timedEvents","_useEventsLayout","_globals","_momentTimezone","_react","_useIsEditing","_useClonedEvents","_jsxRuntime","e","__esModule","default","EventCalendar","events","timeFormat","dayDate","theme","initialZoomLevel","DEFAULT_MINUTE_HEIGHT","onCreateEvent","timezone","renderEvent","onPressEvent","userCalendarId","showTimeIndicator","maxAllDayEvents","canCreateEvents","renderNewEventContainer","fiveMinuteInterval","canEditEvent","onEventEdit","renderDragBars","updateLocalStateAfterEdit","extraTimedComponents","onZoomChange","startCalendarDate","useMemo","moment","tz","startOf","clonedEvents","useClonedEvents","memoizedProps","format","calendarViewInterval","endCalendarDate","startDayOfWeekOffset","layout","useEventsLayout","zoomLevel","useSharedValue","createY","maximumHour","refNewEvent","useRef","jsx","View","style","styles","container","children","jsxs","ConfigProvider","Provider","value","ScrollView","bounces","keyboardShouldPersistTaps","scrollView","IsEditingProvider","ref","borderContainer","StyleSheet","create","flex","marginTop","borderTopWidth","hairlineWidth","borderTopColor","overflow","paddingTop","backgroundColor","position","height","left","top","width","borderLeftWidth","borderColor","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,YAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,gBAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAEA,IAAAW,aAAA,GAAAX,OAAA;AACA,IAAAY,gBAAA,GAAAV,sBAAA,CAAAF,OAAA;AAA0D,IAAAa,WAAA,GAAAb,OAAA;AAAA,SAAAE,uBAAAY,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAgC1D,MAAMG,aAAa,GAAGA,CAAC;EACrBC,MAAM;EACNC,UAAU,GAAG,OAAO;EACpBC,OAAO;EACPC,KAAK;EACLC,gBAAgB,GAAGC,8BAAqB;EACxCC,aAAa;EACbC,QAAQ,GAAG,KAAK;EAChBC,WAAW;EACXC,YAAY;EACZC,cAAc,GAAG,EAAE;EACnBC,iBAAiB;EACjBC,eAAe,GAAG,CAAC;EACnBC,eAAe,GAAG,IAAI;EACtBC,uBAAuB;EACvBC,kBAAkB;EAClBC,YAAY,GAAG,IAAI;EACnBC,WAAW;EACXC,cAAc;EACdC,yBAAyB,GAAG,IAAI;EAChCC,oBAAoB;EACpBC;AACkB,CAAC,KAAK;EACxB,MAAMC,iBAAiB,GAAG,IAAAC,cAAO,EAC/B,MAAMC,uBAAM,CAACC,EAAE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;EACDX,UAAU,EAAE;IACVY,UAAU,EAAE,CAAC;IACbC,eAAe,EAAE,OAAO;IACxBP,IAAI,EAAE;EACR,CAAC;EACDH,eAAe,EAAE;IACfW,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,MAAM;IACdC,IAAI,EAAE,EAAE;IACRC,GAAG,EAAE,CAAC,EAAE;IACRC,KAAK,EAAE,CAAC;IACRC,eAAe,EAAEf,uBAAU,CAACK,aAAa;IACzCW,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA/E,OAAA,GAEYC,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EventExtend = exports.EditStatus = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Tells us if an event extends into the next day, the previous day, or both.
|
|
9
|
+
* Used for all day events.
|
|
10
|
+
*/
|
|
11
|
+
let EventExtend = exports.EventExtend = /*#__PURE__*/function (EventExtend) {
|
|
12
|
+
// Keep None as value 0
|
|
13
|
+
EventExtend[EventExtend["None"] = 0] = "None";
|
|
14
|
+
EventExtend[EventExtend["Past"] = 1] = "Past";
|
|
15
|
+
EventExtend[EventExtend["Future"] = 2] = "Future";
|
|
16
|
+
EventExtend[EventExtend["Both"] = 3] = "Both";
|
|
17
|
+
return EventExtend;
|
|
18
|
+
}({});
|
|
19
|
+
let EditStatus = exports.EditStatus = /*#__PURE__*/function (EditStatus) {
|
|
20
|
+
EditStatus[EditStatus["Start"] = 0] = "Start";
|
|
21
|
+
EditStatus[EditStatus["Finish"] = 1] = "Finish";
|
|
22
|
+
return EditStatus;
|
|
23
|
+
}({});
|
|
24
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EventExtend","exports","EditStatus"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;;;;;AAmJA;AACA;AACA;AACA;AAHA,IAIYA,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAXA,WAAW;EACrB;EADUA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAAA,IAQXE,UAAU,GAAAD,OAAA,CAAAC,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CalendarLayout = void 0;
|
|
7
|
+
var _lodash = require("lodash");
|
|
8
|
+
var _types = require("src/types");
|
|
9
|
+
class CalendarLayout {
|
|
10
|
+
// visibleX is an array of numbers representing the x indexes currently 'in view'
|
|
11
|
+
// enableWeekBreaks is a bool indicating if events are split at week boundary (monthview)
|
|
12
|
+
// startOfWeekXOffset is the offset to the start of the week from index 0
|
|
13
|
+
|
|
14
|
+
constructor({
|
|
15
|
+
visibleX,
|
|
16
|
+
enableWeekBreaks,
|
|
17
|
+
startOfWeekXOffset
|
|
18
|
+
}) {
|
|
19
|
+
this.array2d = [];
|
|
20
|
+
this.visibleX = new Set(visibleX);
|
|
21
|
+
this.enableWeekBreaks = enableWeekBreaks;
|
|
22
|
+
this.startOfWeekXOffset = startOfWeekXOffset;
|
|
23
|
+
}
|
|
24
|
+
getAt(x, y) {
|
|
25
|
+
return this.array2d[x] && this.array2d[x][y];
|
|
26
|
+
}
|
|
27
|
+
setAt(x, y, value) {
|
|
28
|
+
let column = this.array2d[x];
|
|
29
|
+
if (!column) {
|
|
30
|
+
column = [];
|
|
31
|
+
this.array2d[x] = column;
|
|
32
|
+
}
|
|
33
|
+
column[y] = value;
|
|
34
|
+
}
|
|
35
|
+
// assign value to the line of cells from (x, y) to (x + w, y)
|
|
36
|
+
setRange(x, y, duration, value) {
|
|
37
|
+
for (let increment = 0; increment < duration; ++increment) {
|
|
38
|
+
this.setAt(x + increment, y, {
|
|
39
|
+
value,
|
|
40
|
+
meta: {
|
|
41
|
+
x
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// does the event starting time at x with duration w fit at position y?
|
|
47
|
+
fit(x, y, duration) {
|
|
48
|
+
for (let increment = 0; increment < duration; ++increment) {
|
|
49
|
+
if (this.getAt(x + increment, y)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
// find the row where the event starting at time x with duration w fits
|
|
56
|
+
findFit(x, duration) {
|
|
57
|
+
let rowIndex = 0;
|
|
58
|
+
while (!this.fit(x, rowIndex, duration)) {
|
|
59
|
+
++rowIndex;
|
|
60
|
+
}
|
|
61
|
+
return rowIndex;
|
|
62
|
+
}
|
|
63
|
+
// inserts an event record into the matrix
|
|
64
|
+
findFitAndInsert(eventStartIndex, eventDurationDays, event) {
|
|
65
|
+
const rowIndex = this.findFit(eventStartIndex, eventDurationDays);
|
|
66
|
+
this.setRange(eventStartIndex, rowIndex, eventDurationDays, event);
|
|
67
|
+
}
|
|
68
|
+
// find the height of the 2d array
|
|
69
|
+
height() {
|
|
70
|
+
return this.array2d.length > 0 ? (0, _lodash.max)(this.array2d.map(col => col && col.length || 0)) : 0;
|
|
71
|
+
}
|
|
72
|
+
// get the event and associated view data for the given cell
|
|
73
|
+
getViewAt(x, y) {
|
|
74
|
+
const record = this.getAt(x, y);
|
|
75
|
+
if (!record) {
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
const {
|
|
79
|
+
value: event,
|
|
80
|
+
meta: {
|
|
81
|
+
x: rootX
|
|
82
|
+
}
|
|
83
|
+
} = record;
|
|
84
|
+
const previousRecord = this.visibleX.has(x - 1) ? this.getAt(x - 1, y) : null;
|
|
85
|
+
if (event) {
|
|
86
|
+
const isPrimaryRendered = x === rootX || !previousRecord || previousRecord.value !== event || this.enableWeekBreaks && Math.floor((x + this.startOfWeekXOffset) / 7) !== Math.floor((x + this.startOfWeekXOffset - 1) / 7);
|
|
87
|
+
// count the contiguous visible days for this event
|
|
88
|
+
let visibleWidthDays = 1;
|
|
89
|
+
while (this.visibleX.has(x + visibleWidthDays) && (!this.enableWeekBreaks || Math.floor((x + this.startOfWeekXOffset + visibleWidthDays) / 7) === Math.floor((x + this.startOfWeekXOffset + visibleWidthDays - 1) / 7)) && this.getAt(x + visibleWidthDays, y) && this.getAt(x + visibleWidthDays, y).value === event) {
|
|
90
|
+
visibleWidthDays++;
|
|
91
|
+
}
|
|
92
|
+
const wrapStart = x !== rootX;
|
|
93
|
+
const wrapEnd = this.getAt(x + visibleWidthDays, y) && this.getAt(x + visibleWidthDays, y).value === event;
|
|
94
|
+
let extend = _types.EventExtend.None;
|
|
95
|
+
if (wrapStart && wrapEnd) {
|
|
96
|
+
extend = _types.EventExtend.Both;
|
|
97
|
+
} else if (wrapStart) {
|
|
98
|
+
extend = _types.EventExtend.Past;
|
|
99
|
+
} else if (wrapEnd) {
|
|
100
|
+
extend = _types.EventExtend.Future;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
event,
|
|
104
|
+
visibleWidthDays,
|
|
105
|
+
isPrimaryRendered,
|
|
106
|
+
extend
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.CalendarLayout = CalendarLayout;
|
|
113
|
+
//# sourceMappingURL=calendar-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_lodash","require","_types","CalendarLayout","constructor","visibleX","enableWeekBreaks","startOfWeekXOffset","array2d","Set","getAt","x","y","setAt","value","column","setRange","duration","increment","meta","fit","findFit","rowIndex","findFitAndInsert","eventStartIndex","eventDurationDays","event","height","length","max","map","col","getViewAt","record","rootX","previousRecord","has","isPrimaryRendered","Math","floor","visibleWidthDays","wrapStart","wrapEnd","extend","EventExtend","None","Both","Past","Future","exports"],"sourceRoot":"../../../src","sources":["utils/calendar-layout.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,cAAc,CAAC;EAC1B;EACA;EACA;;EAMAC,WAAWA,CAAC;IACVC,QAAQ;IACRC,gBAAgB;IAChBC;EAKF,CAAC,EAAE;IACD,IAAI,CAACC,OAAO,GAAG,EAAE;IACjB,IAAI,CAACH,QAAQ,GAAG,IAAII,GAAG,CAACJ,QAAQ,CAAC;IACjC,IAAI,CAACC,gBAAgB,GAAGA,gBAAgB;IACxC,IAAI,CAACC,kBAAkB,GAAGA,kBAAkB;EAC9C;EAEAG,KAAKA,CAACC,CAAS,EAAEC,CAAS,EAAE;IAC1B,OAAO,IAAI,CAACJ,OAAO,CAACG,CAAC,CAAC,IAAI,IAAI,CAACH,OAAO,CAACG,CAAC,CAAC,CAACC,CAAC,CAAC;EAC9C;EAEAC,KAAKA,CAACF,CAAS,EAAEC,CAAS,EAAEE,KAAuC,EAAE;IACnE,IAAIC,MAAM,GAAG,IAAI,CAACP,OAAO,CAACG,CAAC,CAAC;IAC5B,IAAI,CAACI,MAAM,EAAE;MACXA,MAAM,GAAG,EAAE;MACX,IAAI,CAACP,OAAO,CAACG,CAAC,CAAC,GAAGI,MAAM;IAC1B;IACAA,MAAM,CAACH,CAAC,CAAC,GAAGE,KAAK;EACnB;EACA;EACAE,QAAQA,CAACL,CAAS,EAAEC,CAAS,EAAEK,QAAgB,EAAEH,KAAU,EAAE;IAC3D,KAAK,IAAII,SAAS,GAAG,CAAC,EAAEA,SAAS,GAAGD,QAAQ,EAAE,EAAEC,SAAS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B,gBAAgB,EAAE5B,CAAC,CAAC,CAACE,KAAK,KAAKY,KAAK,EACnD;QACAc,gBAAgB,EAAE;MACpB;MAEA,MAAMC,SAAS,GAAG9B,CAAC,KAAKuB,KAAK;MAC7B,MAAMQ,OAAO,GACX,IAAI,CAAChC,KAAK,CAACC,CAAC,GAAG6B,gBAAgB,EAAE5B,CAAC,CAAC,IACnC,IAAI,CAACF,KAAK,CAACC,CAAC,GAAG6B,gBAAgB,EAAE5B,CAAC,CAAC,CAACE,KAAK,KAAKY,KAAK;MAErD,IAAIiB,MAAM,GAAGC,kBAAW,CAACC,IAAI;MAE7B,IAAIJ,SAAS,IAAIC,OAAO,EAAE;QACxBC,MAAM,GAAGC,kBAAW,CAACE,IAAI;MAC3B,CAAC,MAAM,IAAIL,SAAS,EAAE;QACpBE,MAAM,GAAGC,kBAAW,CAACG,IAAI;MAC3B,CAAC,MAAM,IAAIL,OAAO,EAAE;QAClBC,MAAM,GAAGC,kBAAW,CAACI,MAAM;MAC7B;MAEA,OAAO;QACLtB,KAAK;QACLc,gBAAgB;QAChBH,iBAAiB;QACjBM;MACF,CAAC;IACH;IAEA,OAAO,CAAC,CAAC;EACX;AACF;AAACM,OAAA,CAAA9C,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const computePositioning = ({
|
|
10
|
+
collisionObject,
|
|
11
|
+
startOfDayMoment,
|
|
12
|
+
timezone
|
|
13
|
+
}) => {
|
|
14
|
+
const startDateMoment = _momentTimezone.default.tz(collisionObject.event.start, timezone);
|
|
15
|
+
const durationMinutes = _momentTimezone.default.tz(collisionObject.event.end, timezone).diff(startDateMoment, "minutes");
|
|
16
|
+
let width = 100;
|
|
17
|
+
let margin = 0;
|
|
18
|
+
const top = startDateMoment.diff(startOfDayMoment, "minutes");
|
|
19
|
+
const height = Math.max(30, durationMinutes);
|
|
20
|
+
const collisions = collisionObject.collisions;
|
|
21
|
+
if (collisions) {
|
|
22
|
+
margin = 100 / collisions.total * collisions.order;
|
|
23
|
+
width = collisions.order + 1 < collisions.total ? Math.max(100 - 12 * collisions.total, 20) : 100 / collisions.total;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
top,
|
|
27
|
+
height,
|
|
28
|
+
width: `${width}%`,
|
|
29
|
+
marginLeft: `${margin}%`
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
var _default = exports.default = computePositioning;
|
|
33
|
+
//# sourceMappingURL=compute-positioning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_momentTimezone","_interopRequireDefault","require","e","__esModule","default","computePositioning","collisionObject","startOfDayMoment","timezone","startDateMoment","moment","tz","event","start","durationMinutes","end","diff","width","margin","top","height","Math","max","collisions","total","order","marginLeft","_default","exports"],"sourceRoot":"../../../src","sources":["utils/compute-positioning.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAiD,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAUjD,MAAMG,kBAAkB,GAAGA,CAAC;EAC1BC,eAAe;EACfC,gBAAgB;EAChBC;AACkB,CAAC,KAAoB;EACvC,MAAMC,eAAe,GAAGC,uBAAM,CAACC,EAAE,CAACL,eAAe,CAACM,KAAK,CAACC,KAAK,EAAEL,QAAQ,CAAC;EACxE,MAAMM,eAAe,GAAGJ,uBAAM,CAC3BC,EAAE,CAACL,eAAe,CAACM,KAAK,CAACG,GAAG,EAAEP,QAAQ,CAAC,CACvCQ,IAAI,CAACP,eAAe,EAAE,SAAS,CAAC;EAEnC,IAAIQ,KAAK,GAAG,GAAG;EACf,IAAIC,MAAM,GAAG,CAAC;EAEd,MAAMC,GAAG,GAAGV,eAAe,CAACO,IAAI,CAACT,gBAAgB,EAAE,SAAS,CAAC;EAC7D,MAAMa,MAAM,GAAGC,IAAI,CAACC,GAAG,CAAC,EAAE,EAAER,eAAe,CAAC;EAC5C,MAAMS,UAAU,GAAGjB,eAAe,CAACiB,UAAU;EAE7C,IAAIA,UAAU,EAAE;IACdL,MAAM,GAAI,GAAG,GAAGK,UAAU,CAACC,KAAK,GAAID,UAAU,CAACE,KAAK;IACpDR,KAAK,GACHM,UAAU,CAACE,KAAK,GAAG,CAAC,GAAGF,UAAU,CAACC,KAAK,GACnCH,IAAI,CAACC,GAAG,CAAC,GAAG,GAAG,EAAE,GAAGC,UAAU,CAACC,KAAK,EAAE,EAAE,CAAC,GACzC,GAAG,GAAGD,UAAU,CAACC,KAAK;EAC9B;EAEA,OAAO;IACLL,GAAG;IACHC,MAAM;IACNH,KAAK,EAAE,GAAGA,KAAK,GAAG;IAClBS,UAAU,EAAE,GAAGR,MAAM;EACvB,CAAC;AACH,CAAC;AAAC,IAAAS,QAAA,GAAAC,OAAA,CAAAxB,OAAA,GAEaC,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.startOfUserWeek = exports.isAllDayOrSpansMidnight = exports.getDurationInDays = exports.getDuration = exports.generatePrefabHours = exports.daysInRange = exports.dateRangeIntersect = exports.computeCalendarDateRange = void 0;
|
|
7
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
8
|
+
var _lodash = require("lodash");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const generatePrefabHours = (timeFormat = "HH:mm") => {
|
|
11
|
+
const startOfDayMoment = (0, _momentTimezone.default)().startOf("day");
|
|
12
|
+
return [...Array(24).keys()].reduce((accum, increment) => {
|
|
13
|
+
const hourMoment = startOfDayMoment.clone().hour(increment);
|
|
14
|
+
accum.push({
|
|
15
|
+
increment,
|
|
16
|
+
hourFormatted: hourMoment.format(timeFormat),
|
|
17
|
+
hourMoment
|
|
18
|
+
});
|
|
19
|
+
return accum;
|
|
20
|
+
}, []);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Returns a new moment instance at the start of the week in the user's
|
|
24
|
+
// timezone, with the user's start of week preference applied.
|
|
25
|
+
exports.generatePrefabHours = generatePrefabHours;
|
|
26
|
+
const startOfUserWeek = (startDayOfWeekOffset, dateOrMoment, timezone) => {
|
|
27
|
+
// If the day is Sunday, and the user's start of week preference is Sunday, return the day
|
|
28
|
+
// otherwise, the start of the 'isoWeek' will be for the previous week
|
|
29
|
+
if (startDayOfWeekOffset === 0 && _momentTimezone.default.tz(dateOrMoment, timezone).isoWeekday() === 7) {
|
|
30
|
+
return _momentTimezone.default.tz(dateOrMoment, timezone).startOf("day");
|
|
31
|
+
}
|
|
32
|
+
return _momentTimezone.default.tz(dateOrMoment, timezone).startOf("isoWeek").isoWeekday(startDayOfWeekOffset);
|
|
33
|
+
};
|
|
34
|
+
exports.startOfUserWeek = startOfUserWeek;
|
|
35
|
+
const isAllDayOrSpansMidnight = (calendarEvent, timezone) => {
|
|
36
|
+
const {
|
|
37
|
+
start,
|
|
38
|
+
end,
|
|
39
|
+
isAllDay
|
|
40
|
+
} = calendarEvent;
|
|
41
|
+
if (isAllDay) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Does the range start/end span midnight in the given timezone?
|
|
46
|
+
const startMoment = _momentTimezone.default.tz(start, timezone);
|
|
47
|
+
const endMoment = _momentTimezone.default.tz(end, timezone);
|
|
48
|
+
|
|
49
|
+
// Handle special case where range ends at midnight exactly, in which case spansMidnight should return false
|
|
50
|
+
return !startMoment.isSame(endMoment.hour() === 0 ? endMoment.subtract(1, "minute") : endMoment, "day");
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Returns the count of unique dates in the provided timezone
|
|
54
|
+
exports.isAllDayOrSpansMidnight = isAllDayOrSpansMidnight;
|
|
55
|
+
const getDurationInDays = (calendarEvent, timezone) => {
|
|
56
|
+
// the event duration in days calculation depends on if the event is all day
|
|
57
|
+
return calendarEvent.isAllDay ? _momentTimezone.default.tz(calendarEvent.end, timezone).diff(_momentTimezone.default.tz(calendarEvent.start, timezone), "days") + 1 : (0, _lodash.size)(daysInRange({
|
|
58
|
+
startDate: calendarEvent.start,
|
|
59
|
+
endDate: calendarEvent.end,
|
|
60
|
+
timezone
|
|
61
|
+
}));
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Returns an array of days (e.g. ['2022-01-02']) in a given date range.
|
|
65
|
+
exports.getDurationInDays = getDurationInDays;
|
|
66
|
+
const daysInRange = ({
|
|
67
|
+
startDate,
|
|
68
|
+
endDate,
|
|
69
|
+
timezone
|
|
70
|
+
}) => {
|
|
71
|
+
const countOfDaysInRange = _momentTimezone.default.tz(endDate, timezone).diff(_momentTimezone.default.tz(startDate, timezone), "days");
|
|
72
|
+
const startDay = _momentTimezone.default.tz(startDate, timezone).format("YYYY-MM-DD");
|
|
73
|
+
const days = [];
|
|
74
|
+
// Make sure we loop at a max of 30 times here as we had events that were scheduled for all day long for
|
|
75
|
+
// 1000 years in the future and this was causing the app to crash
|
|
76
|
+
for (let countOfDaysAfterStart = 0; countOfDaysAfterStart <= Math.min(30, Math.abs(countOfDaysInRange)); countOfDaysAfterStart++) {
|
|
77
|
+
days.push(_momentTimezone.default.tz(startDay, timezone).add(countOfDaysAfterStart, "day").format("YYYY-MM-DD"));
|
|
78
|
+
}
|
|
79
|
+
return days;
|
|
80
|
+
};
|
|
81
|
+
exports.daysInRange = daysInRange;
|
|
82
|
+
const getDuration = (calendarEvent, trueDuration) => {
|
|
83
|
+
const minDiff = (new Date(calendarEvent.end).valueOf() - new Date(calendarEvent.start).valueOf()) / (1000 * 60);
|
|
84
|
+
|
|
85
|
+
// If all-day, we want to throw in an extra 24 hours since we represent them a bit oddly.
|
|
86
|
+
return calendarEvent.isAllDay && !trueDuration ? minDiff + 24 * 60 * 60 : minDiff;
|
|
87
|
+
};
|
|
88
|
+
exports.getDuration = getDuration;
|
|
89
|
+
const computeCalendarDateRange = (date, tz, viewType, startDayOfWeekOffset) => {
|
|
90
|
+
const momentDate = _momentTimezone.default.tz(date, tz).startOf("day").toDate();
|
|
91
|
+
let basis;
|
|
92
|
+
let dayIndexes;
|
|
93
|
+
if (viewType === "month") {
|
|
94
|
+
const startOfMonth = _momentTimezone.default.tz(momentDate, tz).startOf("month");
|
|
95
|
+
const numberOfDaysInViewBeforeStartOfMonth = startOfMonth.isoWeekday() - startDayOfWeekOffset;
|
|
96
|
+
basis = startOfMonth.subtract(numberOfDaysInViewBeforeStartOfMonth, "days");
|
|
97
|
+
const startOfRange = 0;
|
|
98
|
+
const numberOfDaysInViewAfterEndOfMonth = (numberOfDaysInViewBeforeStartOfMonth + _momentTimezone.default.tz(date, tz).daysInMonth()) % 7 ? 7 - (numberOfDaysInViewBeforeStartOfMonth + _momentTimezone.default.tz(date, tz).daysInMonth()) % 7 : 0;
|
|
99
|
+
const endOfRange = numberOfDaysInViewBeforeStartOfMonth + _momentTimezone.default.tz(date, tz).daysInMonth() + numberOfDaysInViewAfterEndOfMonth;
|
|
100
|
+
dayIndexes = (0, _lodash.range)(startOfRange, endOfRange);
|
|
101
|
+
} else if (viewType === "workweek") {
|
|
102
|
+
basis = startOfUserWeek(startDayOfWeekOffset, momentDate, tz);
|
|
103
|
+
dayIndexes = (0, _lodash.range)(0, 7).filter(dayIndex => [0, 6].indexOf(basis.clone().add(dayIndex, "day").day()) === -1);
|
|
104
|
+
} else if (viewType === "3day") {
|
|
105
|
+
// On PYD, we need to see more than just today, as potentially we'll see yesterday and tomorrow
|
|
106
|
+
basis = _momentTimezone.default.tz(momentDate, tz);
|
|
107
|
+
dayIndexes = [0, 1, 2];
|
|
108
|
+
} else if (viewType === "1day") {
|
|
109
|
+
basis = _momentTimezone.default.tz(momentDate, tz);
|
|
110
|
+
dayIndexes = [0];
|
|
111
|
+
} else {
|
|
112
|
+
basis = startOfUserWeek(startDayOfWeekOffset, momentDate, tz);
|
|
113
|
+
dayIndexes = (0, _lodash.range)(0, 7);
|
|
114
|
+
}
|
|
115
|
+
const days = dayIndexes.map(dayIndex => _momentTimezone.default.tz(basis, tz).add(dayIndex, "day").toDate());
|
|
116
|
+
const calendarDates = dayIndexes.map(dayIndex => _momentTimezone.default.tz(basis, tz).add(dayIndex, "day").format("YYYY-MM-DD"));
|
|
117
|
+
return {
|
|
118
|
+
basisDate: (0, _momentTimezone.default)(basis, tz).toDate(),
|
|
119
|
+
dayIndexes,
|
|
120
|
+
days,
|
|
121
|
+
startDate: days[0],
|
|
122
|
+
endDate: _momentTimezone.default.tz(days[days.length - 1], tz).add(1, "day").toDate(),
|
|
123
|
+
calendarDates,
|
|
124
|
+
startCalendarDate: calendarDates[0],
|
|
125
|
+
endCalendarDate: calendarDates[calendarDates.length - 1]
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// tests if the date ranges intersect
|
|
130
|
+
exports.computeCalendarDateRange = computeCalendarDateRange;
|
|
131
|
+
const dateRangeIntersect = ({
|
|
132
|
+
startDate: start0,
|
|
133
|
+
endDate: end0
|
|
134
|
+
}, {
|
|
135
|
+
startDate: start1,
|
|
136
|
+
endDate: end1
|
|
137
|
+
}) => {
|
|
138
|
+
if (!(0, _lodash.isDate)(start0) || !(0, _lodash.isDate)(end0) || !(0, _lodash.isDate)(start1) || !(0, _lodash.isDate)(end1)) {
|
|
139
|
+
throw `invalid parameter ${start0} ${end0}; must pass dates`;
|
|
140
|
+
}
|
|
141
|
+
const s0 = start0.getTime();
|
|
142
|
+
const e0 = end0.getTime();
|
|
143
|
+
const s1 = start1.getTime();
|
|
144
|
+
const e1 = end1.getTime();
|
|
145
|
+
if (s0 > e0 || s1 > e1) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
return isBetween(s0, s1, e1) || isBetween(s1, s0, e0);
|
|
149
|
+
};
|
|
150
|
+
exports.dateRangeIntersect = dateRangeIntersect;
|
|
151
|
+
const isBetween = (value, startInclusive, endExclusive) => value >= startInclusive && value < endExclusive;
|
|
152
|
+
//# sourceMappingURL=date-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_momentTimezone","_interopRequireDefault","require","_lodash","e","__esModule","default","generatePrefabHours","timeFormat","startOfDayMoment","moment","startOf","Array","keys","reduce","accum","increment","hourMoment","clone","hour","push","hourFormatted","format","exports","startOfUserWeek","startDayOfWeekOffset","dateOrMoment","timezone","tz","isoWeekday","isAllDayOrSpansMidnight","calendarEvent","start","end","isAllDay","startMoment","endMoment","isSame","subtract","getDurationInDays","diff","size","daysInRange","startDate","endDate","countOfDaysInRange","startDay","days","countOfDaysAfterStart","Math","min","abs","add","getDuration","trueDuration","minDiff","Date","valueOf","computeCalendarDateRange","date","viewType","momentDate","toDate","basis","dayIndexes","startOfMonth","numberOfDaysInViewBeforeStartOfMonth","startOfRange","numberOfDaysInViewAfterEndOfMonth","daysInMonth","endOfRange","range","filter","dayIndex","indexOf","day","map","calendarDates","basisDate","length","startCalendarDate","endCalendarDate","dateRangeIntersect","start0","end0","start1","end1","isDate","s0","getTime","e0","s1","e1","isBetween","value","startInclusive","endExclusive"],"sourceRoot":"../../../src","sources":["utils/date-utils.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAA6C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CA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AA2D,kBAAA,GAAAA,kBAAA;AAEF,MAAMW,SAAS,GAAGA,CAChBC,KAAa,EACbC,cAAsB,EACtBC,YAAoB,KACjBF,KAAK,IAAIC,cAAc,IAAID,KAAK,GAAGE,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
8
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
+
const doubleTapGesture = (zoomLevel, initialZoomLevel, onZoomChange) => _reactNativeGestureHandler.Gesture.Tap().numberOfTaps(2).onEnd((_event, success) => {
|
|
10
|
+
if (success) {
|
|
11
|
+
// Reset the zoom level to the default
|
|
12
|
+
zoomLevel.value = initialZoomLevel;
|
|
13
|
+
if (onZoomChange) {
|
|
14
|
+
(0, _reactNativeReanimated.runOnJS)(onZoomChange)(initialZoomLevel);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _default = exports.default = doubleTapGesture;
|
|
19
|
+
//# sourceMappingURL=double-tap-reset-zoom-gesture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeGestureHandler","require","_reactNativeReanimated","doubleTapGesture","zoomLevel","initialZoomLevel","onZoomChange","Gesture","Tap","numberOfTaps","onEnd","_event","success","value","runOnJS","_default","exports","default"],"sourceRoot":"../../../src","sources":["utils/double-tap-reset-zoom-gesture.ts"],"mappings":";;;;;;AAAA,IAAAA,0BAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AAGA,MAAME,gBAAgB,GAAGA,CACvBC,SAA8B,EAC9BC,gBAAwB,EACxBC,YAAqC,KAErCC,kCAAO,CAACC,GAAG,CAAC,CAAC,CACVC,YAAY,CAAC,CAAC,CAAC,CACfC,KAAK,CAAC,CAACC,MAAM,EAAEC,OAAO,KAAK;EAC1B,IAAIA,OAAO,EAAE;IACX;IACAR,SAAS,CAACS,KAAK,GAAGR,gBAAgB;IAElC,IAAIC,YAAY,EAAE;MAChB,IAAAQ,8BAAO,EAACR,YAAY,CAAC,CAACD,gBAAgB,CAAC;IACzC;EACF;AACF,CAAC,CAAC;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEQd,gBAAgB","ignoreList":[]}
|