react-native-resource-calendar 1.0.23 → 1.0.24

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
@@ -1,8 +1,8 @@
1
1
  import * as React19 from 'react';
2
- import React19__default, { createContext, useState, useEffect, useMemo, useContext, useRef, useCallback } from 'react';
2
+ import React19__default, { createContext, useState, useEffect, useRef, useMemo, useContext, useCallback } from 'react';
3
3
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
4
- import Animated2, { useSharedValue, useAnimatedRef, runOnJS, withSpring, useFrameCallback, scrollTo, useAnimatedScrollHandler, runOnUI, useAnimatedStyle, useAnimatedProps } from 'react-native-reanimated';
5
- import { View, StyleSheet, Text, TouchableOpacity, TextInput, useWindowDimensions, Platform, Dimensions, Image } from 'react-native';
4
+ import Animated2, { useSharedValue, useAnimatedRef, runOnJS, withSpring, useFrameCallback, scrollTo, useAnimatedScrollHandler, useAnimatedStyle, useAnimatedProps } from 'react-native-reanimated';
5
+ import { InteractionManager, View, StyleSheet, Text, TouchableOpacity, TextInput, useWindowDimensions, Platform, Dimensions, Image } from 'react-native';
6
6
  import { FlashList } from '@shopify/flash-list';
7
7
  import { toZonedTime } from 'date-fns-tz';
8
8
  import { isSameDay, format, getHours, getMinutes, set, addDays, setSeconds, setMinutes, setHours } from 'date-fns';
@@ -337,6 +337,7 @@ var TimeLabels = React19.forwardRef(({
337
337
  const isToday = isSameDay(/* @__PURE__ */ new Date(), date);
338
338
  const [currentTimeYPosition, setCurrentTimeYPosition] = useState(timeToYPosition(getCurrentTimeInMinutes(timezone), hourHeight));
339
339
  const [currentTime, setCurrentTime] = useState(format(toZonedTime(/* @__PURE__ */ new Date(), timezone), "h:mm"));
340
+ const APPOINTMENT_BLOCK_HEIGHT = hourHeight / 4;
340
341
  const updateCurrentTimeYPosition = () => {
341
342
  setCurrentTimeYPosition(timeToYPosition(getCurrentTimeInMinutes(timezone), hourHeight));
342
343
  };
@@ -353,6 +354,22 @@ var TimeLabels = React19.forwardRef(({
353
354
  const intervalId = setInterval(update, 300);
354
355
  return () => clearInterval(intervalId);
355
356
  }, [timezone]);
357
+ const lastScrolledDateRef = useRef(null);
358
+ useEffect(() => {
359
+ if (!layout) return;
360
+ const dateKey = date.getTime();
361
+ if (lastScrolledDateRef.current === dateKey) return;
362
+ InteractionManager.runAfterInteractions(() => {
363
+ let pos = isToday ? currentTimeYPosition - 240 : timeToYPosition(startMinutes, hourHeight);
364
+ if (ref.current) {
365
+ ref.current.scrollTo({
366
+ y: Math.round(pos / APPOINTMENT_BLOCK_HEIGHT) * APPOINTMENT_BLOCK_HEIGHT,
367
+ animated: true
368
+ });
369
+ lastScrolledDateRef.current = dateKey;
370
+ }
371
+ });
372
+ }, [layout, date, isToday, APPOINTMENT_BLOCK_HEIGHT, startMinutes, hourHeight, currentTimeYPosition]);
356
373
  return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(Col_default, null, Array.from({ length: 24 }).map((_, index) => /* @__PURE__ */ React19.createElement(View, { key: index, style: [styles.timeLabel, { height: hourHeight }] }, /* @__PURE__ */ React19.createElement(
357
374
  Text,
358
375
  {
@@ -1325,7 +1342,7 @@ var CalendarInner = (props) => {
1325
1342
  const {
1326
1343
  date,
1327
1344
  numberOfColumns: numberOfColumnsProp = 3,
1328
- startMinutes = 0,
1345
+ startMinutes,
1329
1346
  hourHeight = 120,
1330
1347
  snapIntervalInMinutes = 5,
1331
1348
  timezone = Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone,
@@ -1744,22 +1761,6 @@ var CalendarInner = (props) => {
1744
1761
  useEffect(() => {
1745
1762
  dateRef.current = date;
1746
1763
  }, [date]);
1747
- const lastScrolledDateRef = useRef(null);
1748
- useEffect(() => {
1749
- if (!layout) return;
1750
- const isToday = isSameDay(/* @__PURE__ */ new Date(), date);
1751
- const APPOINTMENT_BLOCK_HEIGHT = hourHeight / 4;
1752
- const dateKey = date.getTime();
1753
- const currentTimeYPosition = timeToYPosition(getCurrentTimeInMinutes(timezone), hourHeight);
1754
- if (lastScrolledDateRef.current === dateKey) return;
1755
- let pos = isToday ? currentTimeYPosition - 240 : timeToYPosition(startMinutes, hourHeight);
1756
- const y = Math.round(pos / APPOINTMENT_BLOCK_HEIGHT) * APPOINTMENT_BLOCK_HEIGHT;
1757
- runOnUI((yVal) => {
1758
- "worklet";
1759
- scrollTo(verticalScrollViewRef, 0, yVal, true);
1760
- })(y);
1761
- lastScrolledDateRef.current = dateKey;
1762
- }, [layout, date, startMinutes, hourHeight]);
1763
1764
  const renderItem = useCallback(({ item, index }) => {
1764
1765
  const rid = !isMultiDay ? item : activeResourceId ?? resourceIds[0];
1765
1766
  const dayDate = !isMultiDay ? void 0 : item.dayDate;