react-native-resource-calendar 1.0.22 → 1.0.23
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 +17 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React19 from 'react';
|
|
2
|
-
import React19__default, { createContext, useState, useEffect,
|
|
2
|
+
import React19__default, { createContext, useState, useEffect, useMemo, useContext, useRef, useCallback } from 'react';
|
|
3
3
|
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
4
|
-
import Animated2, { useSharedValue, useAnimatedRef, runOnJS, withSpring, useFrameCallback, scrollTo, useAnimatedScrollHandler, useAnimatedStyle, useAnimatedProps } from 'react-native-reanimated';
|
|
5
|
-
import {
|
|
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';
|
|
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,7 +337,6 @@ 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;
|
|
341
340
|
const updateCurrentTimeYPosition = () => {
|
|
342
341
|
setCurrentTimeYPosition(timeToYPosition(getCurrentTimeInMinutes(timezone), hourHeight));
|
|
343
342
|
};
|
|
@@ -354,22 +353,6 @@ var TimeLabels = React19.forwardRef(({
|
|
|
354
353
|
const intervalId = setInterval(update, 300);
|
|
355
354
|
return () => clearInterval(intervalId);
|
|
356
355
|
}, [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]);
|
|
373
356
|
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(
|
|
374
357
|
Text,
|
|
375
358
|
{
|
|
@@ -1342,7 +1325,7 @@ var CalendarInner = (props) => {
|
|
|
1342
1325
|
const {
|
|
1343
1326
|
date,
|
|
1344
1327
|
numberOfColumns: numberOfColumnsProp = 3,
|
|
1345
|
-
startMinutes,
|
|
1328
|
+
startMinutes = 0,
|
|
1346
1329
|
hourHeight = 120,
|
|
1347
1330
|
snapIntervalInMinutes = 5,
|
|
1348
1331
|
timezone = Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone,
|
|
@@ -1761,6 +1744,22 @@ var CalendarInner = (props) => {
|
|
|
1761
1744
|
useEffect(() => {
|
|
1762
1745
|
dateRef.current = date;
|
|
1763
1746
|
}, [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]);
|
|
1764
1763
|
const renderItem = useCallback(({ item, index }) => {
|
|
1765
1764
|
const rid = !isMultiDay ? item : activeResourceId ?? resourceIds[0];
|
|
1766
1765
|
const dayDate = !isMultiDay ? void 0 : item.dayDate;
|