react-native-resource-calendar 1.1.13 → 1.1.15

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 CHANGED
@@ -1052,7 +1052,10 @@ var EventBlock = React19__namespace.default.memo(({
1052
1052
  zIndex: frame.zIndex,
1053
1053
  opacity: anyEventSelected || disabled ? 0.5 : 1,
1054
1054
  borderWidth: selected ? 2 : 1,
1055
- borderColor: selected ? "#4d959c" : "rgba(0,0,0,0.12)"
1055
+ borderColor: selected ? "#4d959c" : "rgba(0,0,0,0.12)",
1056
+ // When disabled, let touches fall through to the grid blocks beneath
1057
+ // (e.g. "select a time" mode) instead of swallowing them.
1058
+ pointerEvents: disabled ? "none" : "auto"
1056
1059
  };
1057
1060
  const resolved = typeof styleOverrides === "function" ? styleOverrides(event) ?? {} : styleOverrides ?? {};
1058
1061
  const handlePress = React19.useCallback(() => onPress?.(event), [onPress, event]);
@@ -1409,10 +1412,6 @@ var CalendarInner = (props) => {
1409
1412
  const internalOnLongPress = React19.useRef(null);
1410
1413
  const onDisabledBlockPressRef = React19__namespace.default.useRef(onDisabledBlockPress);
1411
1414
  onDisabledBlockPressRef.current = onDisabledBlockPress;
1412
- const selectedRef = React19.useRef(props.isEventSelected);
1413
- selectedRef.current = props.isEventSelected;
1414
- const disabledRef = React19.useRef(props.isEventDisabled);
1415
- disabledRef.current = props.isEventDisabled;
1416
1415
  const effectiveRenderer = React19.useMemo(() => {
1417
1416
  return (p) => /* @__PURE__ */ React19__namespace.default.createElement(
1418
1417
  EventBlock_default,
@@ -1424,16 +1423,13 @@ var CalendarInner = (props) => {
1424
1423
  );
1425
1424
  }, [eventSlots, eventStyleOverrides]);
1426
1425
  const isEventSelectedStable = React19.useCallback(
1427
- (ev) => selectedRef.current ? selectedRef.current(ev) : false,
1428
- []
1426
+ (ev) => props.isEventSelected?.(ev) ?? false,
1427
+ [props.isEventSelected]
1429
1428
  );
1430
1429
  const isEventDisabledStable = React19.useCallback(
1431
- (ev) => disabledRef.current ? disabledRef.current(ev) : false,
1432
- []
1430
+ (ev) => props.isEventDisabled?.(ev) ?? false,
1431
+ [props.isEventDisabled]
1433
1432
  );
1434
- const rendererRef = React19.useRef(effectiveRenderer);
1435
- rendererRef.current = effectiveRenderer;
1436
- const stableRenderer = React19.useCallback((p) => rendererRef.current(p), []);
1437
1433
  const stableOnPress = React19__namespace.default.useCallback((e) => onPressRef.current?.(e), []);
1438
1434
  const stableOnDisabledBlockPress = React19__namespace.default.useCallback((b) => onDisabledBlockPressRef.current?.(b), []);
1439
1435
  const { useGetSelectedEvent: useGetSelectedEvent2, useSetSelectedEvent: useSetSelectedEvent2, useSetDraggedEventDraft: useSetDraggedEventDraft2, useGetDraggedEventDraft: useGetDraggedEventDraft2 } = useCalendarBinding();
@@ -1501,6 +1497,8 @@ var CalendarInner = (props) => {
1501
1497
  },
1502
1498
  [enableHapticFeedback]
1503
1499
  );
1500
+ const triggerHapticRef = React19.useRef(triggerHaptic);
1501
+ triggerHapticRef.current = triggerHaptic;
1504
1502
  const resourceIds = React19.useMemo(() => {
1505
1503
  const ids = resources?.map((item) => item?.id) || [];
1506
1504
  if (JSON.stringify(prevResourceIdsRef.current) !== JSON.stringify(ids)) {
@@ -1734,7 +1732,7 @@ var CalendarInner = (props) => {
1734
1732
  date: event.date
1735
1733
  });
1736
1734
  requestAnimationFrame(() => setDragReady(true));
1737
- triggerHaptic("Medium");
1735
+ triggerHapticRef.current("Medium");
1738
1736
  };
1739
1737
  }, []);
1740
1738
  const internalStableOnLongPress = React19.useCallback((e) => {
@@ -1769,6 +1767,18 @@ var CalendarInner = (props) => {
1769
1767
  if (onBlockTap)
1770
1768
  onBlockTap(resource, new Date(time));
1771
1769
  }, [resources, onBlockTap]);
1770
+ const handleBlockPressRef = React19.useRef(handleBlockPress);
1771
+ handleBlockPressRef.current = handleBlockPress;
1772
+ const stableHandleBlockPress = React19.useCallback(
1773
+ (resourceId, time) => handleBlockPressRef.current(resourceId, time),
1774
+ []
1775
+ );
1776
+ const handleBlockLongPressRef = React19.useRef(handleBlockLongPress);
1777
+ handleBlockLongPressRef.current = handleBlockLongPress;
1778
+ const stableHandleBlockLongPress = React19.useCallback(
1779
+ (resourceId, time) => handleBlockLongPressRef.current(resourceId, time),
1780
+ []
1781
+ );
1772
1782
  React19.useEffect(() => {
1773
1783
  const handleOrientationChange = () => {
1774
1784
  if (selectedEvent) {
@@ -1789,8 +1799,8 @@ var CalendarInner = (props) => {
1789
1799
  {
1790
1800
  hourHeight,
1791
1801
  APPOINTMENT_BLOCK_WIDTH,
1792
- handleBlockPress: (time) => handleBlockPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time)),
1793
- handleBlockLongPress: (time) => handleBlockLongPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time))
1802
+ handleBlockPress: (time) => stableHandleBlockPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time)),
1803
+ handleBlockLongPress: (time) => stableHandleBlockLongPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time))
1794
1804
  }
1795
1805
  ), /* @__PURE__ */ React19__namespace.default.createElement(
1796
1806
  DisabledIntervals_default,
@@ -1820,7 +1830,7 @@ var CalendarInner = (props) => {
1820
1830
  onLongPress: internalStableOnLongPress,
1821
1831
  isEventSelected: isEventSelectedStable,
1822
1832
  isEventDisabled: isEventDisabledStable,
1823
- eventRenderer: stableRenderer,
1833
+ eventRenderer: effectiveRenderer,
1824
1834
  mode: overLappingLayoutMode
1825
1835
  }
1826
1836
  )));
@@ -1830,14 +1840,36 @@ var CalendarInner = (props) => {
1830
1840
  resourceIds,
1831
1841
  APPOINTMENT_BLOCK_WIDTH,
1832
1842
  hourHeight,
1833
- stableRenderer,
1843
+ effectiveRenderer,
1834
1844
  isEventSelectedStable,
1835
1845
  isEventDisabledStable,
1836
1846
  overLappingLayoutMode,
1837
1847
  stableOnPress,
1838
1848
  internalStableOnLongPress,
1839
- stableOnDisabledBlockPress
1849
+ stableOnDisabledBlockPress,
1850
+ stableHandleBlockPress,
1851
+ stableHandleBlockLongPress
1840
1852
  ]);
1853
+ const listExtraData = React19.useMemo(
1854
+ () => ({
1855
+ numberOfColumns,
1856
+ width,
1857
+ hourHeight,
1858
+ stacked: overLappingLayoutMode === "stacked",
1859
+ isEventSelectedStable,
1860
+ isEventDisabledStable,
1861
+ effectiveRenderer
1862
+ }),
1863
+ [
1864
+ numberOfColumns,
1865
+ width,
1866
+ hourHeight,
1867
+ overLappingLayoutMode,
1868
+ isEventSelectedStable,
1869
+ isEventDisabledStable,
1870
+ effectiveRenderer
1871
+ ]
1872
+ );
1841
1873
  return /* @__PURE__ */ React19__namespace.default.createElement(React19__namespace.default.Fragment, null, /* @__PURE__ */ React19__namespace.default.createElement(StoreFeeder, { resources, store: binding, baseDate: date }), /* @__PURE__ */ React19__namespace.default.createElement(reactNative.View, { style: { flex: 1 } }, !isMultiDay ? /* @__PURE__ */ React19__namespace.default.createElement(reactNative.View, { key: `header-${numberOfColumns}-${width}` }, /* @__PURE__ */ React19__namespace.default.createElement(
1842
1874
  Animated2__default.default.ScrollView,
1843
1875
  {
@@ -1921,7 +1953,7 @@ var CalendarInner = (props) => {
1921
1953
  /* @__PURE__ */ React19__namespace.default.createElement(
1922
1954
  AnimatedFlashList,
1923
1955
  {
1924
- extraData: numberOfColumns + width + hourHeight + (overLappingLayoutMode === "stacked" ? 1 : 0),
1956
+ extraData: listExtraData,
1925
1957
  scrollEnabled: !selectedEvent,
1926
1958
  ref: flashListRef,
1927
1959
  onScroll: flashListScrollHandler,