react-native-resource-calendar 1.1.12 → 1.1.14

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.mjs CHANGED
@@ -1384,10 +1384,6 @@ var CalendarInner = (props) => {
1384
1384
  const internalOnLongPress = useRef(null);
1385
1385
  const onDisabledBlockPressRef = React19__default.useRef(onDisabledBlockPress);
1386
1386
  onDisabledBlockPressRef.current = onDisabledBlockPress;
1387
- const selectedRef = useRef(props.isEventSelected);
1388
- selectedRef.current = props.isEventSelected;
1389
- const disabledRef = useRef(props.isEventDisabled);
1390
- disabledRef.current = props.isEventDisabled;
1391
1387
  const effectiveRenderer = useMemo(() => {
1392
1388
  return (p) => /* @__PURE__ */ React19__default.createElement(
1393
1389
  EventBlock_default,
@@ -1399,16 +1395,13 @@ var CalendarInner = (props) => {
1399
1395
  );
1400
1396
  }, [eventSlots, eventStyleOverrides]);
1401
1397
  const isEventSelectedStable = useCallback(
1402
- (ev) => selectedRef.current ? selectedRef.current(ev) : false,
1403
- []
1398
+ (ev) => props.isEventSelected?.(ev) ?? false,
1399
+ [props.isEventSelected]
1404
1400
  );
1405
1401
  const isEventDisabledStable = useCallback(
1406
- (ev) => disabledRef.current ? disabledRef.current(ev) : false,
1407
- []
1402
+ (ev) => props.isEventDisabled?.(ev) ?? false,
1403
+ [props.isEventDisabled]
1408
1404
  );
1409
- const rendererRef = useRef(effectiveRenderer);
1410
- rendererRef.current = effectiveRenderer;
1411
- const stableRenderer = useCallback((p) => rendererRef.current(p), []);
1412
1405
  const stableOnPress = React19__default.useCallback((e) => onPressRef.current?.(e), []);
1413
1406
  const stableOnDisabledBlockPress = React19__default.useCallback((b) => onDisabledBlockPressRef.current?.(b), []);
1414
1407
  const { useGetSelectedEvent: useGetSelectedEvent2, useSetSelectedEvent: useSetSelectedEvent2, useSetDraggedEventDraft: useSetDraggedEventDraft2, useGetDraggedEventDraft: useGetDraggedEventDraft2 } = useCalendarBinding();
@@ -1476,6 +1469,8 @@ var CalendarInner = (props) => {
1476
1469
  },
1477
1470
  [enableHapticFeedback]
1478
1471
  );
1472
+ const triggerHapticRef = useRef(triggerHaptic);
1473
+ triggerHapticRef.current = triggerHaptic;
1479
1474
  const resourceIds = useMemo(() => {
1480
1475
  const ids = resources?.map((item) => item?.id) || [];
1481
1476
  if (JSON.stringify(prevResourceIdsRef.current) !== JSON.stringify(ids)) {
@@ -1709,7 +1704,7 @@ var CalendarInner = (props) => {
1709
1704
  date: event.date
1710
1705
  });
1711
1706
  requestAnimationFrame(() => setDragReady(true));
1712
- triggerHaptic("Medium");
1707
+ triggerHapticRef.current("Medium");
1713
1708
  };
1714
1709
  }, []);
1715
1710
  const internalStableOnLongPress = useCallback((e) => {
@@ -1744,17 +1739,30 @@ var CalendarInner = (props) => {
1744
1739
  if (onBlockTap)
1745
1740
  onBlockTap(resource, new Date(time));
1746
1741
  }, [resources, onBlockTap]);
1742
+ const handleBlockPressRef = useRef(handleBlockPress);
1743
+ handleBlockPressRef.current = handleBlockPress;
1744
+ const stableHandleBlockPress = useCallback(
1745
+ (resourceId, time) => handleBlockPressRef.current(resourceId, time),
1746
+ []
1747
+ );
1748
+ const handleBlockLongPressRef = useRef(handleBlockLongPress);
1749
+ handleBlockLongPressRef.current = handleBlockLongPress;
1750
+ const stableHandleBlockLongPress = useCallback(
1751
+ (resourceId, time) => handleBlockLongPressRef.current(resourceId, time),
1752
+ []
1753
+ );
1747
1754
  useEffect(() => {
1748
1755
  const handleOrientationChange = () => {
1749
- setSelectedEvent(null);
1750
- setDragReady(false);
1751
- setLayout(null);
1756
+ if (selectedEvent) {
1757
+ setSelectedEvent(null);
1758
+ setDragReady(false);
1759
+ }
1752
1760
  };
1753
1761
  const subscription = Dimensions.addEventListener("change", handleOrientationChange);
1754
1762
  return () => {
1755
1763
  subscription.remove();
1756
1764
  };
1757
- }, [setSelectedEvent, setDragReady]);
1765
+ }, [setSelectedEvent, selectedEvent, setDragReady]);
1758
1766
  const renderItem = useCallback(({ item, index }) => {
1759
1767
  const rid = !isMultiDay ? item : activeResourceId ?? resourceIds[0];
1760
1768
  const dayDate = !isMultiDay ? void 0 : item.dayDate;
@@ -1763,8 +1771,8 @@ var CalendarInner = (props) => {
1763
1771
  {
1764
1772
  hourHeight,
1765
1773
  APPOINTMENT_BLOCK_WIDTH,
1766
- handleBlockPress: (time) => handleBlockPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time)),
1767
- handleBlockLongPress: (time) => handleBlockLongPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time))
1774
+ handleBlockPress: (time) => stableHandleBlockPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time)),
1775
+ handleBlockLongPress: (time) => stableHandleBlockLongPress(rid, combineDateAndTime(dayDate ?? dateRef.current, time))
1768
1776
  }
1769
1777
  ), /* @__PURE__ */ React19__default.createElement(
1770
1778
  DisabledIntervals_default,
@@ -1794,7 +1802,7 @@ var CalendarInner = (props) => {
1794
1802
  onLongPress: internalStableOnLongPress,
1795
1803
  isEventSelected: isEventSelectedStable,
1796
1804
  isEventDisabled: isEventDisabledStable,
1797
- eventRenderer: stableRenderer,
1805
+ eventRenderer: effectiveRenderer,
1798
1806
  mode: overLappingLayoutMode
1799
1807
  }
1800
1808
  )));
@@ -1804,14 +1812,36 @@ var CalendarInner = (props) => {
1804
1812
  resourceIds,
1805
1813
  APPOINTMENT_BLOCK_WIDTH,
1806
1814
  hourHeight,
1807
- stableRenderer,
1815
+ effectiveRenderer,
1808
1816
  isEventSelectedStable,
1809
1817
  isEventDisabledStable,
1810
1818
  overLappingLayoutMode,
1811
1819
  stableOnPress,
1812
1820
  internalStableOnLongPress,
1813
- stableOnDisabledBlockPress
1821
+ stableOnDisabledBlockPress,
1822
+ stableHandleBlockPress,
1823
+ stableHandleBlockLongPress
1814
1824
  ]);
1825
+ const listExtraData = useMemo(
1826
+ () => ({
1827
+ numberOfColumns,
1828
+ width,
1829
+ hourHeight,
1830
+ stacked: overLappingLayoutMode === "stacked",
1831
+ isEventSelectedStable,
1832
+ isEventDisabledStable,
1833
+ effectiveRenderer
1834
+ }),
1835
+ [
1836
+ numberOfColumns,
1837
+ width,
1838
+ hourHeight,
1839
+ overLappingLayoutMode,
1840
+ isEventSelectedStable,
1841
+ isEventDisabledStable,
1842
+ effectiveRenderer
1843
+ ]
1844
+ );
1815
1845
  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(
1816
1846
  Animated2.ScrollView,
1817
1847
  {
@@ -1895,7 +1925,7 @@ var CalendarInner = (props) => {
1895
1925
  /* @__PURE__ */ React19__default.createElement(
1896
1926
  AnimatedFlashList,
1897
1927
  {
1898
- extraData: numberOfColumns + width + hourHeight + (overLappingLayoutMode === "stacked" ? 1 : 0),
1928
+ extraData: listExtraData,
1899
1929
  scrollEnabled: !selectedEvent,
1900
1930
  ref: flashListRef,
1901
1931
  onScroll: flashListScrollHandler,