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.js
CHANGED
|
@@ -362,7 +362,6 @@ var TimeLabels = React19__namespace.forwardRef(({
|
|
|
362
362
|
const isToday = dateFns.isSameDay(/* @__PURE__ */ new Date(), date);
|
|
363
363
|
const [currentTimeYPosition, setCurrentTimeYPosition] = React19.useState(timeToYPosition(getCurrentTimeInMinutes(timezone), hourHeight));
|
|
364
364
|
const [currentTime, setCurrentTime] = React19.useState(dateFns.format(dateFnsTz.toZonedTime(/* @__PURE__ */ new Date(), timezone), "h:mm"));
|
|
365
|
-
const APPOINTMENT_BLOCK_HEIGHT = hourHeight / 4;
|
|
366
365
|
const updateCurrentTimeYPosition = () => {
|
|
367
366
|
setCurrentTimeYPosition(timeToYPosition(getCurrentTimeInMinutes(timezone), hourHeight));
|
|
368
367
|
};
|
|
@@ -379,22 +378,6 @@ var TimeLabels = React19__namespace.forwardRef(({
|
|
|
379
378
|
const intervalId = setInterval(update, 300);
|
|
380
379
|
return () => clearInterval(intervalId);
|
|
381
380
|
}, [timezone]);
|
|
382
|
-
const lastScrolledDateRef = React19.useRef(null);
|
|
383
|
-
React19.useEffect(() => {
|
|
384
|
-
if (!layout) return;
|
|
385
|
-
const dateKey = date.getTime();
|
|
386
|
-
if (lastScrolledDateRef.current === dateKey) return;
|
|
387
|
-
reactNative.InteractionManager.runAfterInteractions(() => {
|
|
388
|
-
let pos = isToday ? currentTimeYPosition - 240 : timeToYPosition(startMinutes, hourHeight);
|
|
389
|
-
if (ref.current) {
|
|
390
|
-
ref.current.scrollTo({
|
|
391
|
-
y: Math.round(pos / APPOINTMENT_BLOCK_HEIGHT) * APPOINTMENT_BLOCK_HEIGHT,
|
|
392
|
-
animated: true
|
|
393
|
-
});
|
|
394
|
-
lastScrolledDateRef.current = dateKey;
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
}, [layout, date, isToday, APPOINTMENT_BLOCK_HEIGHT, startMinutes, hourHeight, currentTimeYPosition]);
|
|
398
381
|
return /* @__PURE__ */ React19__namespace.createElement(React19__namespace.Fragment, null, /* @__PURE__ */ React19__namespace.createElement(Col_default, null, Array.from({ length: 24 }).map((_, index) => /* @__PURE__ */ React19__namespace.createElement(reactNative.View, { key: index, style: [styles.timeLabel, { height: hourHeight }] }, /* @__PURE__ */ React19__namespace.createElement(
|
|
399
382
|
reactNative.Text,
|
|
400
383
|
{
|
|
@@ -1367,7 +1350,7 @@ var CalendarInner = (props) => {
|
|
|
1367
1350
|
const {
|
|
1368
1351
|
date,
|
|
1369
1352
|
numberOfColumns: numberOfColumnsProp = 3,
|
|
1370
|
-
startMinutes,
|
|
1353
|
+
startMinutes = 0,
|
|
1371
1354
|
hourHeight = 120,
|
|
1372
1355
|
snapIntervalInMinutes = 5,
|
|
1373
1356
|
timezone = Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone,
|
|
@@ -1786,6 +1769,22 @@ var CalendarInner = (props) => {
|
|
|
1786
1769
|
React19.useEffect(() => {
|
|
1787
1770
|
dateRef.current = date;
|
|
1788
1771
|
}, [date]);
|
|
1772
|
+
const lastScrolledDateRef = React19.useRef(null);
|
|
1773
|
+
React19.useEffect(() => {
|
|
1774
|
+
if (!layout) return;
|
|
1775
|
+
const isToday = dateFns.isSameDay(/* @__PURE__ */ new Date(), date);
|
|
1776
|
+
const APPOINTMENT_BLOCK_HEIGHT = hourHeight / 4;
|
|
1777
|
+
const dateKey = date.getTime();
|
|
1778
|
+
const currentTimeYPosition = timeToYPosition(getCurrentTimeInMinutes(timezone), hourHeight);
|
|
1779
|
+
if (lastScrolledDateRef.current === dateKey) return;
|
|
1780
|
+
let pos = isToday ? currentTimeYPosition - 240 : timeToYPosition(startMinutes, hourHeight);
|
|
1781
|
+
const y = Math.round(pos / APPOINTMENT_BLOCK_HEIGHT) * APPOINTMENT_BLOCK_HEIGHT;
|
|
1782
|
+
Animated2.runOnUI((yVal) => {
|
|
1783
|
+
"worklet";
|
|
1784
|
+
Animated2.scrollTo(verticalScrollViewRef, 0, yVal, true);
|
|
1785
|
+
})(y);
|
|
1786
|
+
lastScrolledDateRef.current = dateKey;
|
|
1787
|
+
}, [layout, date, startMinutes, hourHeight]);
|
|
1789
1788
|
const renderItem = React19.useCallback(({ item, index }) => {
|
|
1790
1789
|
const rid = !isMultiDay ? item : activeResourceId ?? resourceIds[0];
|
|
1791
1790
|
const dayDate = !isMultiDay ? void 0 : item.dayDate;
|