react-native-resource-calendar 1.1.4 → 1.1.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.
- package/dist/index.js +34 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React19 from 'react';
|
|
2
|
-
import React19__default, { createContext, useState, useEffect, useRef, useMemo,
|
|
2
|
+
import React19__default, { createContext, useState, useEffect, useRef, useMemo, useCallback, useContext } from 'react';
|
|
3
3
|
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
4
4
|
import { scheduleOnRN } from 'react-native-worklets';
|
|
5
5
|
import Animated2, { useAnimatedRef, useSharedValue, withSpring, useFrameCallback, scrollTo, useAnimatedScrollHandler, useAnimatedStyle, useAnimatedProps } from 'react-native-reanimated';
|
|
@@ -1009,13 +1009,12 @@ var EventBlock = React19__default.memo(({
|
|
|
1009
1009
|
onPress,
|
|
1010
1010
|
disabled,
|
|
1011
1011
|
selected,
|
|
1012
|
+
anyEventSelected,
|
|
1012
1013
|
hourHeight,
|
|
1013
1014
|
slots,
|
|
1014
1015
|
frame,
|
|
1015
1016
|
styleOverrides
|
|
1016
1017
|
}) => {
|
|
1017
|
-
const { useGetSelectedEvent: useGetSelectedEvent2 } = useCalendarBinding();
|
|
1018
|
-
const selectedAppointment = useGetSelectedEvent2();
|
|
1019
1018
|
const eventTop = scalePosition(event.from, hourHeight);
|
|
1020
1019
|
const eventHeight = scalePosition(event.to - event.from, hourHeight);
|
|
1021
1020
|
const start = minutesToTime(event.from);
|
|
@@ -1026,11 +1025,13 @@ var EventBlock = React19__default.memo(({
|
|
|
1026
1025
|
left: frame.leftPx + 1,
|
|
1027
1026
|
width: frame.widthPx - 3,
|
|
1028
1027
|
zIndex: frame.zIndex,
|
|
1029
|
-
opacity:
|
|
1028
|
+
opacity: anyEventSelected || disabled ? 0.5 : 1,
|
|
1030
1029
|
borderWidth: selected ? 2 : 1,
|
|
1031
1030
|
borderColor: selected ? "#4d959c" : "rgba(0,0,0,0.12)"
|
|
1032
1031
|
};
|
|
1033
1032
|
const resolved = typeof styleOverrides === "function" ? styleOverrides(event) ?? {} : styleOverrides ?? {};
|
|
1033
|
+
const handlePress = useCallback(() => onPress?.(event), [onPress, event]);
|
|
1034
|
+
const handleLongPress = useCallback(() => onLongPress?.(event), [onLongPress, event]);
|
|
1034
1035
|
if (eventHeight == 0)
|
|
1035
1036
|
return null;
|
|
1036
1037
|
const TopRight = slots?.TopRight;
|
|
@@ -1042,12 +1043,8 @@ var EventBlock = React19__default.memo(({
|
|
|
1042
1043
|
{
|
|
1043
1044
|
style: [styles5.event, resolved?.container, dynamicStyle],
|
|
1044
1045
|
disabled,
|
|
1045
|
-
onPress:
|
|
1046
|
-
|
|
1047
|
-
},
|
|
1048
|
-
onLongPress: () => {
|
|
1049
|
-
onLongPress && onLongPress(event);
|
|
1050
|
-
}
|
|
1046
|
+
onPress: handlePress,
|
|
1047
|
+
onLongPress: handleLongPress
|
|
1051
1048
|
},
|
|
1052
1049
|
/* @__PURE__ */ React19__default.createElement(Col_default, { style: [{ position: "relative" }, resolved?.content] }, /* @__PURE__ */ React19__default.createElement(
|
|
1053
1050
|
TextInput,
|
|
@@ -1241,29 +1238,32 @@ var EventBlocks = React19__default.memo(({
|
|
|
1241
1238
|
mode,
|
|
1242
1239
|
date: dateProp
|
|
1243
1240
|
}) => {
|
|
1244
|
-
const { useEventsFor: useEventsFor2, useGetDate: useGetDate2 } = useCalendarBinding();
|
|
1241
|
+
const { useEventsFor: useEventsFor2, useGetDate: useGetDate2, useGetSelectedEvent: useGetSelectedEvent2 } = useCalendarBinding();
|
|
1245
1242
|
const date = useGetDate2();
|
|
1243
|
+
const selectedEvent = useGetSelectedEvent2();
|
|
1246
1244
|
const events = useEventsFor2(id, dateProp ?? date);
|
|
1245
|
+
const anyEventSelected = !!selectedEvent;
|
|
1247
1246
|
const frameMap = useMemo(
|
|
1248
1247
|
() => computeEventFrames(events, EVENT_BLOCK_WIDTH, mode),
|
|
1249
1248
|
[events, mode, EVENT_BLOCK_WIDTH]
|
|
1250
1249
|
);
|
|
1251
1250
|
const Renderer = eventRenderer;
|
|
1252
1251
|
return events?.map(
|
|
1253
|
-
(evt
|
|
1252
|
+
(evt) => {
|
|
1254
1253
|
const selected = isEventSelected?.(evt) ?? false;
|
|
1255
1254
|
const disabled = isEventDisabled?.(evt) ?? false;
|
|
1256
1255
|
return /* @__PURE__ */ React19__default.createElement(
|
|
1257
1256
|
Renderer,
|
|
1258
1257
|
{
|
|
1259
|
-
key: `${evt.
|
|
1258
|
+
key: `${evt.id}`,
|
|
1260
1259
|
event: evt,
|
|
1261
|
-
onLongPress
|
|
1262
|
-
onPress
|
|
1260
|
+
onLongPress,
|
|
1261
|
+
onPress,
|
|
1263
1262
|
hourHeight,
|
|
1264
1263
|
frame: frameMap.get(evt.id),
|
|
1265
1264
|
selected,
|
|
1266
|
-
disabled
|
|
1265
|
+
disabled,
|
|
1266
|
+
anyEventSelected
|
|
1267
1267
|
}
|
|
1268
1268
|
);
|
|
1269
1269
|
}
|
|
@@ -1342,6 +1342,7 @@ var DaysComponent = ({ onResourcePress, activeResourceId, mode, date, APPOINTMEN
|
|
|
1342
1342
|
})));
|
|
1343
1343
|
};
|
|
1344
1344
|
var AnimatedFlashList = Animated2.createAnimatedComponent(FlashList);
|
|
1345
|
+
var DEFAULT_TIMEZONE = Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone;
|
|
1345
1346
|
var CalendarInner = (props) => {
|
|
1346
1347
|
const { width } = useWindowDimensions();
|
|
1347
1348
|
const isIOS = Platform.OS === "ios";
|
|
@@ -1352,7 +1353,7 @@ var CalendarInner = (props) => {
|
|
|
1352
1353
|
startMinutes,
|
|
1353
1354
|
hourHeight = 120,
|
|
1354
1355
|
snapIntervalInMinutes = 5,
|
|
1355
|
-
timezone =
|
|
1356
|
+
timezone = DEFAULT_TIMEZONE,
|
|
1356
1357
|
resources,
|
|
1357
1358
|
onResourcePress,
|
|
1358
1359
|
onBlockLongPress,
|
|
@@ -1376,11 +1377,16 @@ var CalendarInner = (props) => {
|
|
|
1376
1377
|
);
|
|
1377
1378
|
const snapInterval = hourHeight / 60 * snapIntervalInMinutes;
|
|
1378
1379
|
const onPressRef = React19__default.useRef(onEventPress);
|
|
1380
|
+
onPressRef.current = onEventPress;
|
|
1379
1381
|
const onLongPressRef = React19__default.useRef(onEventLongPress);
|
|
1382
|
+
onLongPressRef.current = onEventLongPress;
|
|
1380
1383
|
const internalOnLongPress = useRef(null);
|
|
1381
1384
|
const onDisabledBlockPressRef = React19__default.useRef(onDisabledBlockPress);
|
|
1385
|
+
onDisabledBlockPressRef.current = onDisabledBlockPress;
|
|
1382
1386
|
const selectedRef = useRef(props.isEventSelected);
|
|
1387
|
+
selectedRef.current = props.isEventSelected;
|
|
1383
1388
|
const disabledRef = useRef(props.isEventDisabled);
|
|
1389
|
+
disabledRef.current = props.isEventDisabled;
|
|
1384
1390
|
const effectiveRenderer = useMemo(() => {
|
|
1385
1391
|
return (p) => /* @__PURE__ */ React19__default.createElement(
|
|
1386
1392
|
EventBlock_default,
|
|
@@ -1399,25 +1405,8 @@ var CalendarInner = (props) => {
|
|
|
1399
1405
|
(ev) => disabledRef.current ? disabledRef.current(ev) : false,
|
|
1400
1406
|
[]
|
|
1401
1407
|
);
|
|
1402
|
-
useEffect(() => {
|
|
1403
|
-
onPressRef.current = onEventPress;
|
|
1404
|
-
}, [onEventPress]);
|
|
1405
|
-
useEffect(() => {
|
|
1406
|
-
onLongPressRef.current = onEventLongPress;
|
|
1407
|
-
}, [onEventLongPress]);
|
|
1408
|
-
useEffect(() => {
|
|
1409
|
-
onDisabledBlockPressRef.current = onDisabledBlockPress;
|
|
1410
|
-
}, [onDisabledBlockPress]);
|
|
1411
|
-
useEffect(() => {
|
|
1412
|
-
rendererRef.current = effectiveRenderer;
|
|
1413
|
-
}, [effectiveRenderer]);
|
|
1414
|
-
useEffect(() => {
|
|
1415
|
-
selectedRef.current = props.isEventSelected;
|
|
1416
|
-
}, [props.isEventSelected]);
|
|
1417
|
-
useEffect(() => {
|
|
1418
|
-
disabledRef.current = props.isEventDisabled;
|
|
1419
|
-
}, [props.isEventDisabled]);
|
|
1420
1408
|
const rendererRef = useRef(effectiveRenderer);
|
|
1409
|
+
rendererRef.current = effectiveRenderer;
|
|
1421
1410
|
const stableRenderer = useCallback((p) => rendererRef.current(p), []);
|
|
1422
1411
|
const stableOnPress = React19__default.useCallback((e) => onPressRef.current?.(e), []);
|
|
1423
1412
|
const stableOnDisabledBlockPress = React19__default.useCallback((b) => onDisabledBlockPressRef.current?.(b), []);
|
|
@@ -1425,27 +1414,20 @@ var CalendarInner = (props) => {
|
|
|
1425
1414
|
const selectedEvent = useGetSelectedEvent2();
|
|
1426
1415
|
const setSelectedEvent = useSetSelectedEvent2();
|
|
1427
1416
|
const setDraggedEventDraft = useSetDraggedEventDraft2();
|
|
1428
|
-
const APPOINTMENT_BLOCK_WIDTH = (
|
|
1417
|
+
const APPOINTMENT_BLOCK_WIDTH = useMemo(
|
|
1418
|
+
() => (width - TIME_LABEL_WIDTH) / numberOfColumns,
|
|
1419
|
+
[width, numberOfColumns]
|
|
1420
|
+
);
|
|
1429
1421
|
const hourHeightRef = useRef(hourHeight);
|
|
1422
|
+
hourHeightRef.current = hourHeight;
|
|
1430
1423
|
const resourcesRef = useRef(resources);
|
|
1424
|
+
resourcesRef.current = resources;
|
|
1431
1425
|
const apptWidthRef = useRef(APPOINTMENT_BLOCK_WIDTH);
|
|
1426
|
+
apptWidthRef.current = APPOINTMENT_BLOCK_WIDTH;
|
|
1432
1427
|
const isMultiDayRef = useRef(isMultiDay);
|
|
1428
|
+
isMultiDayRef.current = isMultiDay;
|
|
1433
1429
|
const daysRef = useRef(days);
|
|
1434
|
-
|
|
1435
|
-
hourHeightRef.current = hourHeight;
|
|
1436
|
-
}, [hourHeight]);
|
|
1437
|
-
useEffect(() => {
|
|
1438
|
-
resourcesRef.current = resources;
|
|
1439
|
-
}, [resources]);
|
|
1440
|
-
useEffect(() => {
|
|
1441
|
-
apptWidthRef.current = APPOINTMENT_BLOCK_WIDTH;
|
|
1442
|
-
}, [APPOINTMENT_BLOCK_WIDTH]);
|
|
1443
|
-
useEffect(() => {
|
|
1444
|
-
isMultiDayRef.current = isMultiDay;
|
|
1445
|
-
}, [isMultiDay]);
|
|
1446
|
-
useEffect(() => {
|
|
1447
|
-
daysRef.current = days;
|
|
1448
|
-
}, [days]);
|
|
1430
|
+
daysRef.current = days;
|
|
1449
1431
|
useEffect(() => {
|
|
1450
1432
|
if (!selectedEvent) {
|
|
1451
1433
|
setDraggedEventDraft(null);
|
|
@@ -1462,6 +1444,7 @@ var CalendarInner = (props) => {
|
|
|
1462
1444
|
const [layout, setLayout] = useState(null);
|
|
1463
1445
|
const [dragReady, setDragReady] = useState(false);
|
|
1464
1446
|
const dateRef = useRef(date);
|
|
1447
|
+
dateRef.current = date;
|
|
1465
1448
|
const eventStartedTop = useSharedValue(0);
|
|
1466
1449
|
const eventHeight = useSharedValue(0);
|
|
1467
1450
|
const panXAbs = useSharedValue(0);
|
|
@@ -1765,9 +1748,6 @@ var CalendarInner = (props) => {
|
|
|
1765
1748
|
subscription.remove();
|
|
1766
1749
|
};
|
|
1767
1750
|
}, [setSelectedEvent, selectedEvent, setDragReady]);
|
|
1768
|
-
useEffect(() => {
|
|
1769
|
-
dateRef.current = date;
|
|
1770
|
-
}, [date]);
|
|
1771
1751
|
const renderItem = useCallback(({ item, index }) => {
|
|
1772
1752
|
const rid = !isMultiDay ? item : activeResourceId ?? resourceIds[0];
|
|
1773
1753
|
const dayDate = !isMultiDay ? void 0 : item.dayDate;
|
|
@@ -1823,8 +1803,7 @@ var CalendarInner = (props) => {
|
|
|
1823
1803
|
overLappingLayoutMode,
|
|
1824
1804
|
stableOnPress,
|
|
1825
1805
|
internalStableOnLongPress,
|
|
1826
|
-
stableOnDisabledBlockPress
|
|
1827
|
-
dateRef
|
|
1806
|
+
stableOnDisabledBlockPress
|
|
1828
1807
|
]);
|
|
1829
1808
|
return /* @__PURE__ */ React19__default.createElement(React19__default.Fragment, null, /* @__PURE__ */ React19__default.createElement(StoreFeeder, { resources, store: binding, baseDate: date }), /* @__PURE__ */ React19__default.createElement(View, { style: { flex: 1 } }, !isMultiDay ? /* @__PURE__ */ React19__default.createElement(View, { key: `header-${numberOfColumns}-${width}` }, /* @__PURE__ */ React19__default.createElement(
|
|
1830
1809
|
Animated2.ScrollView,
|