react-native-resource-calendar 1.0.19 → 1.0.21
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/README.md +39 -30
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +61 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
|
4
4
|
import Animated2, { useSharedValue, useAnimatedRef, runOnJS, withSpring, useFrameCallback, scrollTo, useAnimatedScrollHandler, useAnimatedStyle, useAnimatedProps } from 'react-native-reanimated';
|
|
5
5
|
import { InteractionManager, View, StyleSheet, Text, TouchableOpacity, TextInput, useWindowDimensions, Platform, Dimensions, Image } from 'react-native';
|
|
6
6
|
import { FlashList } from '@shopify/flash-list';
|
|
7
|
-
import * as Haptics from 'expo-haptics';
|
|
8
7
|
import { toZonedTime } from 'date-fns-tz';
|
|
9
8
|
import { isSameDay, format, getHours, getMinutes, set, addDays, setSeconds, setMinutes, setHours } from 'date-fns';
|
|
10
9
|
import { isUndefined } from 'lodash';
|
|
@@ -721,6 +720,7 @@ function StaffAvatar({
|
|
|
721
720
|
}
|
|
722
721
|
var EventGridBlocksSkia = ({
|
|
723
722
|
handleBlockPress,
|
|
723
|
+
handleBlockLongPress,
|
|
724
724
|
hourHeight,
|
|
725
725
|
APPOINTMENT_BLOCK_WIDTH
|
|
726
726
|
}) => {
|
|
@@ -762,6 +762,16 @@ var EventGridBlocksSkia = ({
|
|
|
762
762
|
},
|
|
763
763
|
[handleBlockPress, timeLabels]
|
|
764
764
|
);
|
|
765
|
+
const onSlotLongPress = React19.useCallback(
|
|
766
|
+
(row) => {
|
|
767
|
+
setPressedRow(null);
|
|
768
|
+
const slot = timeLabels[row];
|
|
769
|
+
if (slot) {
|
|
770
|
+
handleBlockLongPress(slot);
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
[timeLabels, handleBlockLongPress]
|
|
774
|
+
);
|
|
765
775
|
const onPressBegin = React19.useCallback((row) => {
|
|
766
776
|
setPressedRow(row);
|
|
767
777
|
}, []);
|
|
@@ -771,14 +781,31 @@ var EventGridBlocksSkia = ({
|
|
|
771
781
|
const longPressGesture = Gesture.LongPress().onBegin((e) => {
|
|
772
782
|
"worklet";
|
|
773
783
|
runOnJS(onPressBegin)(Math.floor(e.y / rowHeight));
|
|
784
|
+
}).onTouchesUp(() => {
|
|
785
|
+
"worklet";
|
|
786
|
+
runOnJS(onTouchesUp)();
|
|
787
|
+
}).onEnd((e) => {
|
|
788
|
+
"worklet";
|
|
789
|
+
runOnJS(onSlotLongPress)(Math.floor(e.y / rowHeight));
|
|
790
|
+
}).onFinalize(() => {
|
|
791
|
+
"worklet";
|
|
792
|
+
runOnJS(onTouchesUp)();
|
|
793
|
+
});
|
|
794
|
+
const tapGesture = Gesture.Tap().onBegin((e) => {
|
|
795
|
+
"worklet";
|
|
796
|
+
runOnJS(onPressBegin)(Math.floor(e.y / rowHeight));
|
|
774
797
|
}).onEnd((e) => {
|
|
775
798
|
"worklet";
|
|
776
799
|
runOnJS(onSlotPress)(Math.floor(e.y / rowHeight));
|
|
800
|
+
}).onTouchesUp(() => {
|
|
801
|
+
"worklet";
|
|
802
|
+
runOnJS(onTouchesUp)();
|
|
777
803
|
}).onFinalize(() => {
|
|
778
804
|
"worklet";
|
|
779
805
|
runOnJS(onTouchesUp)();
|
|
780
806
|
});
|
|
781
|
-
|
|
807
|
+
const composedGesture = Gesture.Race(longPressGesture, tapGesture);
|
|
808
|
+
return /* @__PURE__ */ React19.createElement(GestureDetector, { gesture: composedGesture }, /* @__PURE__ */ React19.createElement(View, null, /* @__PURE__ */ React19.createElement(Canvas, { style: { width: APPOINTMENT_BLOCK_WIDTH, height: segmentHeight } }, firstRects.map(({ x, y, width: w, height: h, row }, idx) => /* @__PURE__ */ React19.createElement(React19.Fragment, { key: idx }, /* @__PURE__ */ React19.createElement(
|
|
782
809
|
Rect$1,
|
|
783
810
|
{
|
|
784
811
|
x,
|
|
@@ -1027,7 +1054,8 @@ var EventBlock = React19__default.memo(({
|
|
|
1027
1054
|
fontSize: getTextSize(hourHeight),
|
|
1028
1055
|
pointerEvents: "none",
|
|
1029
1056
|
padding: 0,
|
|
1030
|
-
margin: 0
|
|
1057
|
+
margin: 0,
|
|
1058
|
+
color: "black"
|
|
1031
1059
|
}, resolved?.time],
|
|
1032
1060
|
defaultValue: `${start} - ${end}`
|
|
1033
1061
|
}
|
|
@@ -1146,7 +1174,8 @@ var DraggableEvent = ({
|
|
|
1146
1174
|
fontSize: getTextSize(hourHeight),
|
|
1147
1175
|
pointerEvents: "none",
|
|
1148
1176
|
padding: 0,
|
|
1149
|
-
margin: 0
|
|
1177
|
+
margin: 0,
|
|
1178
|
+
color: "black"
|
|
1150
1179
|
}, resolved?.time],
|
|
1151
1180
|
defaultValue: initialDisplayTime,
|
|
1152
1181
|
animatedProps: animatedTimeProps
|
|
@@ -1320,9 +1349,11 @@ var CalendarInner = (props) => {
|
|
|
1320
1349
|
resources,
|
|
1321
1350
|
onResourcePress,
|
|
1322
1351
|
onBlockLongPress,
|
|
1352
|
+
onBlockTap,
|
|
1323
1353
|
onEventPress,
|
|
1324
1354
|
onEventLongPress,
|
|
1325
1355
|
onDisabledBlockPress,
|
|
1356
|
+
enableHapticFeedback = false,
|
|
1326
1357
|
eventSlots,
|
|
1327
1358
|
eventStyleOverrides,
|
|
1328
1359
|
overLappingLayoutMode = "stacked",
|
|
@@ -1439,9 +1470,19 @@ var CalendarInner = (props) => {
|
|
|
1439
1470
|
const startedX = useSharedValue(0);
|
|
1440
1471
|
const startedY = useSharedValue(0);
|
|
1441
1472
|
const touchY = useSharedValue(0);
|
|
1442
|
-
const triggerHaptic = useCallback(
|
|
1443
|
-
|
|
1444
|
-
|
|
1473
|
+
const triggerHaptic = useCallback(
|
|
1474
|
+
async (style = "Light") => {
|
|
1475
|
+
try {
|
|
1476
|
+
const Haptics = await import('expo-haptics');
|
|
1477
|
+
const feedbackStyle = Haptics.ImpactFeedbackStyle[style];
|
|
1478
|
+
if (enableHapticFeedback)
|
|
1479
|
+
await Haptics.impactAsync(feedbackStyle);
|
|
1480
|
+
} catch (e) {
|
|
1481
|
+
console.log("Haptics not available, skipping...");
|
|
1482
|
+
}
|
|
1483
|
+
},
|
|
1484
|
+
[enableHapticFeedback]
|
|
1485
|
+
);
|
|
1445
1486
|
const resourceIds = useMemo(() => {
|
|
1446
1487
|
const ids = resources?.map((item) => item?.id) || [];
|
|
1447
1488
|
if (JSON.stringify(prevResourceIdsRef.current) !== JSON.stringify(ids)) {
|
|
@@ -1602,7 +1643,7 @@ var CalendarInner = (props) => {
|
|
|
1602
1643
|
const increment = APPOINTMENT_BLOCK_WIDTH * Math.sign(autoScrollXSpeed.value);
|
|
1603
1644
|
const newScrollX = scrollX.value + increment;
|
|
1604
1645
|
runOnJS(scrollListTo)(newScrollX);
|
|
1605
|
-
runOnJS(
|
|
1646
|
+
runOnJS(triggerHaptic)("Medium");
|
|
1606
1647
|
}
|
|
1607
1648
|
});
|
|
1608
1649
|
useFrameCallback(() => {
|
|
@@ -1636,7 +1677,7 @@ var CalendarInner = (props) => {
|
|
|
1636
1677
|
const scrollDiff = Math.abs(newScrollY - lastHapticScrollY.value);
|
|
1637
1678
|
if (scrollDiff >= snapInterval) {
|
|
1638
1679
|
lastHapticScrollY.value = newScrollY;
|
|
1639
|
-
runOnJS(
|
|
1680
|
+
runOnJS(triggerHaptic)("Medium");
|
|
1640
1681
|
}
|
|
1641
1682
|
});
|
|
1642
1683
|
useEffect(() => {
|
|
@@ -1670,7 +1711,7 @@ var CalendarInner = (props) => {
|
|
|
1670
1711
|
eventHeight.value = initialHeight;
|
|
1671
1712
|
setSelectedEvent(event);
|
|
1672
1713
|
requestAnimationFrame(() => setDragReady(true));
|
|
1673
|
-
|
|
1714
|
+
runOnJS(triggerHaptic)("Medium");
|
|
1674
1715
|
};
|
|
1675
1716
|
}, []);
|
|
1676
1717
|
const internalStableOnLongPress = useCallback((e) => {
|
|
@@ -1693,12 +1734,18 @@ var CalendarInner = (props) => {
|
|
|
1693
1734
|
}
|
|
1694
1735
|
}
|
|
1695
1736
|
});
|
|
1696
|
-
const
|
|
1697
|
-
|
|
1737
|
+
const handleBlockLongPress = useCallback((resourceId, time) => {
|
|
1738
|
+
runOnJS(triggerHaptic)("Medium");
|
|
1698
1739
|
const resource = resources.find((r) => r.id === resourceId);
|
|
1699
1740
|
if (onBlockLongPress)
|
|
1700
1741
|
onBlockLongPress(resource, new Date(time));
|
|
1701
1742
|
}, [resources, onBlockLongPress]);
|
|
1743
|
+
const handleBlockPress = useCallback((resourceId, time) => {
|
|
1744
|
+
runOnJS(triggerHaptic)("Medium");
|
|
1745
|
+
const resource = resources.find((r) => r.id === resourceId);
|
|
1746
|
+
if (onBlockTap)
|
|
1747
|
+
onBlockTap(resource, new Date(time));
|
|
1748
|
+
}, [resources, onBlockTap]);
|
|
1702
1749
|
useEffect(() => {
|
|
1703
1750
|
const handleOrientationChange = () => {
|
|
1704
1751
|
if (selectedEvent) {
|
|
@@ -1722,7 +1769,8 @@ var CalendarInner = (props) => {
|
|
|
1722
1769
|
{
|
|
1723
1770
|
hourHeight,
|
|
1724
1771
|
APPOINTMENT_BLOCK_WIDTH,
|
|
1725
|
-
handleBlockPress: (time) => handleBlockPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time))
|
|
1772
|
+
handleBlockPress: (time) => handleBlockPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time)),
|
|
1773
|
+
handleBlockLongPress: (time) => handleBlockLongPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time))
|
|
1726
1774
|
}
|
|
1727
1775
|
), /* @__PURE__ */ React19__default.createElement(
|
|
1728
1776
|
DisabledIntervals_default,
|